At 10:15 12.06.2002, Per Einar Ellefsen wrote:
At 10:03 12.06.2002, Stas Bekman wrote:
> so just to make sure that we are on the same line, currently we will handle only <meta> and <base> tags, right? These should be deparsed into key/value pairs which will be then reconsructed by the templates.
meta:
metaname => metavalue

It can't be exactly like that, because there is meta http-equiv too. I'll construct it like:
meta => [
{ name => '...',
content => '...',
},
{ 'http-equiv' => 'Content-type',
content => 'text/html',
} ]


But the idea is the same.

Ok, finally it became: head => { meta => { name => { author => '...', classification => '...', }, http-equiv => { 'Content-type' => 'text/html', }, Makes the template simpler, and still gets all the info.

I didn't store the description, I did as before with doc.meta.abstract, but passed it through the "|html" filter.

Anyway, we're along the same lines...I'll make it work soon :)

Ok, now it works!

Index: lib/DocSet/Doc/HTML2HTML.pm
===================================================================
RCS file: /home/cvs/modperl-docs/lib/DocSet/Doc/HTML2HTML.pm,v
retrieving revision 1.2
diff -u -r1.2 HTML2HTML.pm
--- lib/DocSet/Doc/HTML2HTML.pm 5 Feb 2002 10:27:19 -0000       1.2
+++ lib/DocSet/Doc/HTML2HTML.pm 15 Jun 2002 12:46:40 -0000
@@ -20,6 +20,7 @@
     my $vars = {
                 meta => $self->{meta},
                 body => [EMAIL PROTECTED],
+                headers => $self->{parsed_tree}{head},
                 dir  => $self->{dir},
                 nav  => $self->{nav},
                 last_modified => $self->{timestamp},
Index: lib/DocSet/Doc/POD2HTML.pm
===================================================================
RCS file: /home/cvs/modperl-docs/lib/DocSet/Doc/POD2HTML.pm,v
retrieving revision 1.6
diff -u -r1.6 POD2HTML.pm
--- lib/DocSet/Doc/POD2HTML.pm  13 Jun 2002 09:20:16 -0000      1.6
+++ lib/DocSet/Doc/POD2HTML.pm  15 Jun 2002 12:46:40 -0000
@@ -48,6 +48,7 @@
                 meta => $self->{meta},
                 toc  => $self->{toc},
                 body => [EMAIL PROTECTED],
+                headers => {},
                 dir  => $self->{dir},
                 nav  => $self->{nav},
                 last_modified => $self->{timestamp},
Index: lib/DocSet/Source/HTML.pm
===================================================================
RCS file: /home/cvs/modperl-docs/lib/DocSet/Source/HTML.pm,v
retrieving revision 1.6
diff -u -r1.6 HTML.pm
--- lib/DocSet/Source/HTML.pm   14 Apr 2002 06:17:48 -0000      1.6
+++ lib/DocSet/Source/HTML.pm   15 Jun 2002 12:46:41 -0000
@@ -55,7 +55,9 @@

# currently retrieves these parts from the source HTML
# head.title
-# head.meta.description
+# head.meta.* (description -> abstract)
+# base
+# link
# body
sub parse {
my($self) = @_;
@@ -127,26 +129,57 @@
# this one retrieves and stashes away the description (As 'abstract')
# and the body and the title of the given html
my $start_h = sub {
- my($self, $tagname, $attr) = @_;
+ my($self, $tagname, $attr, $text) = @_;
+
+ # special treatment
if ($tagname eq 'meta' && lc $attr->{name} eq 'description') {
$self->{parsed_tree}->{abstract} = $attr->{content};
}
+ elsif ($tagname eq 'meta') {
+ # note: doesn't take into account the 'scheme' attr,
+ # but that one isn't used much
+ if ($attr->{name}) {
+ $self->{parsed_tree}{head}{meta}{name}{$attr->{name}} = $attr->{content};
+ }
+ elsif ($attr->{'http-equiv'}) {
+ $self->{parsed_tree}{head}{meta}{'http-equiv'}{$attr->{'http-equiv'}}
+ = $attr->{content};
+ }
+ }
+ elsif ($tagname eq 'base') {
+ # there is usually only one <base>
+ $self->{parsed_tree}{head}{base} = $attr->{href};
+ }
+ elsif ($tagname eq 'link') {
+ # link elements won't overlap, because each is
+ # additive -> easier to store text
+ $self->{parsed_tree}{head}{link} .= $text;
+ }
+ # note: if adding other elements that also appear outside <head>,
+ # you will need to check that you are inside <head> by setting
+ # a flag when entering it and unsetting it when exiting
};


my $end_h = sub {
my($self, $tagname, $skipped_text) = @_;
# use $p itself as a tmp storage (ok according to the docs)
+ if ($tagname eq 'title' or $tagname eq 'body') { # get special treatment
$self->{parsed_tree}->{$tagname} = $skipped_text;
+ }
};


my $p = HTML::Parser->new(api_version => 3,
- report_tags => [qw(title meta body)],
- start_h => [$start_h, "self, tagname, attr"],
- end_h => [$end_h, "self, tagname, skipped_text"],
+ report_tags => [
+ qw(title meta body base link)
+ ],
+ start_h => [$start_h, "self, tagname, attr, text"],
+ end_h => [$end_h, "self, tagname, skipped_text"],
);
# Parse document text chunk by chunk
$p->parse(${ $self->{content} });
$p->eof;
+
+


# store the tree away
$self->{parsed_tree} = $p->{parsed_tree};
Index: tmpl/custom/html/headers
===================================================================
RCS file: /home/cvs/modperl-docs/tmpl/custom/html/headers,v
retrieving revision 1.4
diff -u -r1.4 headers
--- tmpl/custom/html/headers 3 Apr 2002 05:18:27 -0000 1.4
+++ tmpl/custom/html/headers 15 Jun 2002 12:46:41 -0000
@@ -1,6 +1,38 @@
- <meta name="Author" content="docs-dev (at) perl.apache.org">
- <meta name="Description" content="mod_perl documentation: Manuals, Hints, Guidelines, Scenarios, Troubleshooting and Help">
- <meta name="keywords" content="mod_perl modperl perl cgi apache webserver speed fast guide mod_perl asf parent apache guide help info faq mod_perl installation cgi troubleshooting help no sex speedup child rules free open source OSS mod_perl speed suck apache guide manual troubleshoot cgi fast apache sexy ">
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Classification" content="information">
- <link href="[% doc.dir.abs_doc_root %]/style.css" rel="stylesheet" type="text/css" title="refstyle">
\ No newline at end of file
+
+[%- default_headers = {
+ meta => {
+ name => {
+ author => 'docs-dev (at) perl.apache.org',
+ keywords => 'mod_perl modperl perl cgi apache webserver speed fast guide mod_perl asf parent apache guide help info faq mod_perl installation cgi troubleshooting help no sex speedup child rules free open source OSS mod_perl speed suck apache guide manual troubleshoot cgi fast apache sexy',
+ classification => 'information',
+ },
+ 'http-equiv' => {
+ 'Content-Type' => 'text/html; charset=iso-8859-1',
+ },
+ },
+ link => "<link href=\"${doc.dir.abs_doc_root}/style.css\" rel=\"stylesheet\" type=\"text/css\" title=\"refstyle\">",
+
+};
+
+abstract = doc.meta.abstract or "Manuals, Hints, Guidelines, Scenarios, Troubleshooting and Help";
+
+-%]
+
+ <meta name="description" content="mod_perl documentation: [% abstract | html %]">
+
+[%- IF doc.headers.base %]
+ <base href="[% doc.headers.base | html %]">
+[% END -%]
+
+[% " $l\n" FOREACH l = [ doc.headers.link, default_headers.link ] -%]
+
+[%- FOREACH m = ["name", "http-equiv"];
+ FOREACH n = [ doc.headers.meta.$m.keys, default_headers.meta.$m.keys ];
+ FOREACH name = n; # bug fix, otherwise n is an array ref (flattening fails)
+ UNLESS printed.$m.lc($name) %]
+ <meta [% m %]="[% name %]" content="[% (doc.headers.meta.$m.$name or default_headers.meta.$m.$name) | html %]">
+ [%- printed.$m.lc($name) = 1;
+ END;
+ END;
+ END;
+END -%]



Please test it. You can try this patch to 404.html which will utilize those features:


Index: src/404.html
===================================================================
RCS file: /home/cvs/modperl-docs/src/404.html,v
retrieving revision 1.1
diff -u -r1.1 404.html
--- src/404.html        5 Jan 2002 19:21:48 -0000       1.1
+++ src/404.html        15 Jun 2002 12:48:41 -0000
@@ -1,6 +1,11 @@
 <html>
 <head>
 <title>File not found!</title>
+<base href="http://perl.apache.org/release/";>
+<meta name="description" content="foo">
+<meta http-equiv="Content-type" content="text/html">
+<meta name="author" content="me">
+<link rel="stylesheet" href="style.css">
 </head>
 <body>

That's about it.

The only problem is that with the <base> tag of perl.apache.org/release/, all links in the menu will then point to perl.apache.org/release/, and not to the mirror. Might it be an idea to add something to config.cfg specifying the Base URL (optional)?

By the way, is the template-docset list supposed to be the place to discuss DocSet? I checked the archive and apart from your announces it seems a little empty :)


-- Per Einar Ellefsen [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to