stas 02/02/05 02:27:20 Modified: lib DocSet.pm lib/DocSet Cache.pm Config.pm DocSet.pm NavigateCache.pm Util.pm lib/DocSet/Doc HTML2HTML.pm POD2HTML.pm POD2HTMLPS.pm lib/DocSet/Source POD.pm Added: lib/DocSet/Doc Common.pm HTML2HTMLPS.pm Log: - sync with DocSet distro Revision Changes Path 1.3 +1 -1 modperl-docs/lib/DocSet.pm Index: DocSet.pm =================================================================== RCS file: /home/cvs/modperl-docs/lib/DocSet.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DocSet.pm 24 Jan 2002 18:11:24 -0000 1.2 +++ DocSet.pm 5 Feb 2002 10:27:19 -0000 1.3 @@ -1,6 +1,6 @@ package DocSet; -$VERSION = '0.10'; +$VERSION = '0.11'; =head1 NAME 1.3 +2 -4 modperl-docs/lib/DocSet/Cache.pm Index: Cache.pm =================================================================== RCS file: /home/cvs/modperl-docs/lib/DocSet/Cache.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Cache.pm 24 Jan 2002 18:11:24 -0000 1.2 +++ Cache.pm 5 Feb 2002 10:27:19 -0000 1.3 @@ -134,8 +134,7 @@ } else { # this shouldn't happen! - die "Cannot find $id in $self->{path} cache", - dumper $self; + Carp::croak("Cannot find '$id' in $self->{path} cache"); } } @@ -149,8 +148,7 @@ return $self->{cache}{_ordered_ids}->[$seq]; } else { - die "Cannot find $seq in $self->{path} cache", - dumper $self; + Carp::croak("Cannot find '$seq' in $self->{path} cache"); } } 1.4 +1 -1 modperl-docs/lib/DocSet/Config.pm Index: Config.pm =================================================================== RCS file: /home/cvs/modperl-docs/lib/DocSet/Config.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Config.pm 30 Jan 2002 16:55:04 -0000 1.3 +++ Config.pm 5 Feb 2002 10:27:19 -0000 1.4 @@ -28,7 +28,7 @@ }, 'text/html' => { 'text/html' => 'DocSet::Doc::HTML2HTML', - 'text/htmlps' => 'DocSet::Doc::HTML2HTML', + 'text/htmlps' => 'DocSet::Doc::HTML2HTMLPS', 'text/ps' => 'DocSet::Doc::HTML2PS', }, 'text/plain' => { 1.4 +4 -3 modperl-docs/lib/DocSet/DocSet.pm Index: DocSet.pm =================================================================== RCS file: /home/cvs/modperl-docs/lib/DocSet/DocSet.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- DocSet.pm 30 Jan 2002 16:55:04 -0000 1.3 +++ DocSet.pm 5 Feb 2002 10:27:19 -0000 1.4 @@ -249,8 +249,9 @@ $chapter->scan(); # cache the chapter's meta and toc data - $self->cache->set($src_file, 'meta', $chapter->meta, $hidden); - $self->cache->set($src_file, 'toc', $chapter->toc, $hidden); + my $id = $src_file; + $self->cache->set($id, 'meta', $chapter->meta, $hidden); + $self->cache->set($id, 'toc', $chapter->toc, $hidden); return $chapter; @@ -333,7 +334,7 @@ } -# abstract classes +# an abstract method sub complete {} 1; 1.2 +13 -12 modperl-docs/lib/DocSet/NavigateCache.pm Index: NavigateCache.pm =================================================================== RCS file: /home/cvs/modperl-docs/lib/DocSet/NavigateCache.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- NavigateCache.pm 5 Jan 2002 18:51:58 -0000 1.1 +++ NavigateCache.pm 5 Feb 2002 10:27:19 -0000 1.2 @@ -67,23 +67,24 @@ } -# get prev item's object or undef if there are no more +# get prev node's object or undef if there are no more sub prev { my($self) = @_; - my $cache = $self->[OBJ]; + my $cache = $self->[OBJ]; my $seq = $cache->id2seq($self->[ID]); - - # since the hidden objects, if any, are always coming last - # we need to go to the last of the non-hidden objects. + + # if the current node is hidden, it's like there is no prev + # node, because we don't want hidden node to be linked to the + # exposed or hidden sibling nodes if any + if ($cache->is_hidden($self->[ID])) { + return undef; + } + if ($seq) { my $id = $cache->seq2id($seq - 1); - if ($cache->is_hidden($id)) { - return $self->new($self->[CUR_PATH], $id)->prev(); - } - else { - return $self->new($self->[CUR_PATH], $id); - } - } else { + return $self->new($self->[CUR_PATH], $id); + } + else { return undef; } } 1.3 +6 -1 modperl-docs/lib/DocSet/Util.pm Index: Util.pm =================================================================== RCS file: /home/cvs/modperl-docs/lib/DocSet/Util.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Util.pm 24 Jan 2002 18:11:24 -0000 1.2 +++ Util.pm 5 Feb 2002 10:27:19 -0000 1.3 @@ -29,11 +29,16 @@ sub copy_file { my($src, $dst) = @_; + die "$src doesn't exist" unless -e $src; + my $mode = (stat _)[2]; + # make sure that the directory exist or create one my $base_dir = File::Basename::dirname $dst; create_dir($base_dir) unless (-d $base_dir); - File::Copy::copy($src, $dst); + # File::Copy::syscopy doesn't preserve the mode :( + File::Copy::syscopy($src, $dst); + chmod $mode, $dst; } # gzip_file($src_path); 1.2 +6 -0 modperl-docs/lib/DocSet/Doc/HTML2HTML.pm Index: HTML2HTML.pm =================================================================== RCS file: /home/cvs/modperl-docs/lib/DocSet/Doc/HTML2HTML.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- HTML2HTML.pm 5 Jan 2002 18:51:59 -0000 1.1 +++ HTML2HTML.pm 5 Feb 2002 10:27:19 -0000 1.2 @@ -9,6 +9,10 @@ require DocSet::Source::HTML; @ISA = qw(DocSet::Source::HTML); +use DocSet::Doc::Common (); +*fetch_pdf_doc_ver = \&DocSet::Doc::Common::fetch_pdf_doc_ver; +*fetch_src_doc_ver = \&DocSet::Doc::Common::fetch_src_doc_ver; + sub convert { my($self) = @_; @@ -19,6 +23,8 @@ dir => $self->{dir}, nav => $self->{nav}, last_modified => $self->{timestamp}, + pdf_doc => $self->fetch_pdf_doc_ver, + src_doc => $self->fetch_src_doc_ver, }; my $tmpl_file = 'page'; my $mode = $self->{tmpl_mode}; 1.3 +10 -127 modperl-docs/lib/DocSet/Doc/POD2HTML.pm Index: POD2HTML.pm =================================================================== RCS file: /home/cvs/modperl-docs/lib/DocSet/Doc/POD2HTML.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- POD2HTML.pm 24 Jan 2002 18:11:24 -0000 1.2 +++ POD2HTML.pm 5 Feb 2002 10:27:19 -0000 1.3 @@ -6,11 +6,16 @@ use File::Spec::Functions; use DocSet::Util; + require Pod::POM; #require Pod::POM::View::HTML; #my $view_mode = 'Pod::POM::View::HTML'; my $view_mode = 'DocSet::Doc::POD2HTML::View::HTML'; +use DocSet::Doc::Common (); +*fetch_pdf_doc_ver = \&DocSet::Doc::Common::fetch_pdf_doc_ver; +*fetch_src_doc_ver = \&DocSet::Doc::Common::fetch_src_doc_ver; + use vars qw(@ISA); require DocSet::Source::POD; @ISA = qw(DocSet::Source::POD); @@ -44,8 +49,8 @@ dir => $self->{dir}, nav => $self->{nav}, last_modified => $self->{timestamp}, - pdf_doc => $self->pdf_doc, - src_doc => $self->src_doc, + pdf_doc => $self->fetch_pdf_doc_ver, + src_doc => $self->fetch_src_doc_ver, }; my $tmpl_file = 'page'; @@ -55,69 +60,6 @@ } -# search for a pdf version in the parallel tree and copy/gzip it to -# the same dir as the html version (we link to it from the html) -sub pdf_doc { - my $self = shift; - - my $dst_path = $self->{dst_path}; - $dst_path =~ s/html$/pdf/; - - my $pdf_path = $dst_path; - - my $docset = $self->{docset}; - my $ps_root = $docset->get_dir('dst_ps'); - my $html_root = $docset->get_dir('dst_html'); - - $pdf_path =~ s/^$html_root/$ps_root/; - -#print "TRYING $dst_path $pdf_path \n"; - - my %pdf = (); - if (-e $pdf_path) { - copy_file($pdf_path, $dst_path); - gzip_file($dst_path); - my $gzip_path = "$dst_path.gz"; - %pdf = ( - size => format_bytes(-s $gzip_path), - link => filename($gzip_path), - ); - } -#dumper \%pdf; - - return \%pdf; - -} - -# search for the source version in the source tree and copy/gzip it to -# the same dir as the html version (we link to it from the html) -sub src_doc { - my $self = shift; - #$self->src_uri - - my $dst_path = catfile $self->{dst_root}, $self->{src_uri}; - my $src_path = catfile $self->{src_root}, $self->{src_uri}; - -#print "TRYING $dst_path $src_path \n"; - - my %src = (); - if (-e $src_path) { - # it's ok if the source file has the same name as the dest, - # because the final dest file wasn't created yet. - copy_file($src_path, $dst_path); - gzip_file($dst_path); - my $gzip_path = "$dst_path.gz"; - %src = ( - size => format_bytes(-s $gzip_path), - link => filename($gzip_path), - ); - } -#dumper \%src; - - return \%src; -die; -} - sub slice_by_head { my @sections = @_; @@ -173,68 +115,9 @@ $head4->content->present($self); } -sub anchor { - my($self, $title) = @_; - my $anchor = "$title"; - $anchor =~ s/\W/_/g; - my $link = $title->present($self); - return qq{<a name="$anchor">$link</a>}; -} - - -sub view_seq_link { - my ($self, $link) = @_; - - # full-blown URL's are emitted as-is - if ($link =~ m{^\w+://}s ){ - return make_href($link); - } - - $link =~ s/\n/ /g; # undo word-wrapped tags - - my $orig_link = $link; - my $linktext; - # strip the sub-title and the following '|' char - if ( $link =~ s/^ ([^|]+) \| //x ) { - $linktext = $1; - } - - # make sure sections start with a / - $link =~ s|^"|/"|; - - my $page; - my $section; - if ($link =~ m|^ (.*?) / "? (.*?) "? $|x) { # [name]/"section" - ($page, $section) = ($1, $2); - } - elsif ($link =~ /\s/) { # this must be a section with missing quotes - ($page, $section) = ('', $link); - } - else { - ($page, $section) = ($link, ''); - } - - # warning; show some text. - $linktext = $orig_link unless defined $linktext; - - my $url = ''; - if (defined $page && length $page) { - $url = $page; - $url =~ s|::|/|g; - } - - # append the #section if exists - $url .= "#$section" if defined $section and length $section; - - return make_href($url, $linktext); -} - -sub make_href { - my($url, $title) = @_; - $title = $url unless defined $title; - return qq{<a href="$url">$title</a>}; -} - +*anchor = \&DocSet::Doc::Common::pod_pom_html_anchor; +*view_seq_link = \&DocSet::Doc::Common::pod_pom_html_view_seq_link; +*view_verbatim = \&DocSet::Doc::Common::pod_pom_html_view_verbatim; 1; 1.2 +11 -90 modperl-docs/lib/DocSet/Doc/POD2HTMLPS.pm Index: POD2HTMLPS.pm =================================================================== RCS file: /home/cvs/modperl-docs/lib/DocSet/Doc/POD2HTMLPS.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- POD2HTMLPS.pm 24 Jan 2002 18:11:24 -0000 1.1 +++ POD2HTMLPS.pm 5 Feb 2002 10:27:19 -0000 1.2 @@ -4,15 +4,19 @@ use warnings; use DocSet::Util; -require Pod::POM; -#require Pod::POM::View::HTML; -#my $view_mode = 'Pod::POM::View::HTML'; -my $view_mode = 'DocSet::Doc::POD2HTML::View::HTMLPS'; use vars qw(@ISA); require DocSet::Source::POD; @ISA = qw(DocSet::Source::POD); +use DocSet::Doc::Common (); +*postprocess = \&DocSet::Doc::Common::postprocess_ps_pdf; + +require Pod::POM; +#require Pod::POM::View::HTML; +#my $view_mode = 'Pod::POM::View::HTML'; +my $view_mode = 'DocSet::Doc::POD2HTML::View::HTMLPS'; + my %split_by = map {"head".$_ => 1} 1..4; sub convert { @@ -47,30 +51,6 @@ } -sub postprocess { - my $self = shift; - - # convert to ps - my $html2ps_exec = DocSet::RunTime::can_create_ps(); - my $html2ps_conf = $self->{docset}->get_file('html2ps_conf'); - my $dst_path = $self->{dst_path}; - - (my $dst_base = $dst_path) =~ s/\.html//; - - my $dst_root = $self->{dst_root}; - my $command = "$html2ps_exec -f $html2ps_conf -o ${dst_base}.ps ${dst_base}.html"; - note "% $command"; - system $command; - - # convert to pdf - $command = "ps2pdf ${dst_base}.ps ${dst_base}.pdf"; - note "% $command"; - system $command; - - # META: can delete the .ps now - -} - sub slice_by_head { my @sections = @_; @@ -128,68 +108,9 @@ $head4->content->present($self); } -sub anchor { - my($self, $title) = @_; - my $anchor = "$title"; - $anchor =~ s/\W/_/g; - my $link = $title->present($self); - return qq{<a name="$anchor">$link</a>}; -} - - -sub view_seq_link { - my ($self, $link) = @_; - - # full-blown URL's are emitted as-is - if ($link =~ m{^\w+://}s ){ - return make_href($link); - } - - $link =~ s/\n/ /g; # undo word-wrapped tags - - my $orig_link = $link; - my $linktext; - # strip the sub-title and the following '|' char - if ( $link =~ s/^ ([^|]+) \| //x ) { - $linktext = $1; - } - - # make sure sections start with a / - $link =~ s|^"|/"|; - - my $page; - my $section; - if ($link =~ m|^ (.*?) / "? (.*?) "? $|x) { # [name]/"section" - ($page, $section) = ($1, $2); - } - elsif ($link =~ /\s/) { # this must be a section with missing quotes - ($page, $section) = ('', $link); - } - else { - ($page, $section) = ($link, ''); - } - - # warning; show some text. - $linktext = $orig_link unless defined $linktext; - - my $url = ''; - if (defined $page && length $page) { - $url = $page; - $url =~ s|::|/|g; - } - - # append the #section if exists - $url .= "#$section" if defined $section and length $section; - - return make_href($url, $linktext); -} - -sub make_href { - my($url, $title) = @_; - $title = $url unless defined $title; - return qq{<a href="$url">$title</a>}; -} - +*anchor = \&DocSet::Doc::Common::pod_pom_html_anchor; +*view_seq_link = \&DocSet::Doc::Common::pod_pom_html_view_seq_link; +*view_verbatim = \&DocSet::Doc::Common::pod_pom_html_view_verbatim; 1; 1.1 modperl-docs/lib/DocSet/Doc/Common.pm Index: Common.pm =================================================================== package DocSet::Doc::Common; use File::Spec::Functions; use DocSet::Util; use DocSet::RunTime; # See HTML2HTMLPS.pm or POD2HTMLPS.pm sub postprocess_ps_pdf { my $self = shift; # convert to ps my $html2ps_exec = DocSet::RunTime::can_create_ps(); my $html2ps_conf = $self->{docset}->get_file('html2ps_conf'); my $dst_path = $self->{dst_path}; (my $dst_base = $dst_path) =~ s/\.html//; my $dst_root = $self->{dst_root}; my $command = "$html2ps_exec -f $html2ps_conf -o ${dst_base}.ps ${dst_base}.html"; note "% $command"; system $command; # convert to pdf $command = "ps2pdf ${dst_base}.ps ${dst_base}.pdf"; note "% $command"; system $command; # META: can delete the .ps now } # search for a pdf version in the parallel tree and copy/gzip it to # the same dir as the html version (we link to it from the html) sub fetch_pdf_doc_ver { my $self = shift; my $dst_path = $self->{dst_path}; $dst_path =~ s/html$/pdf/; my $pdf_path = $dst_path; my $docset = $self->{docset}; my $ps_root = $docset->get_dir('dst_ps'); my $html_root = $docset->get_dir('dst_html'); $pdf_path =~ s/^$html_root/$ps_root/; #print "TRYING $dst_path $pdf_path \n"; my %pdf = (); if (-e $pdf_path) { copy_file($pdf_path, $dst_path); gzip_file($dst_path); my $gzip_path = "$dst_path.gz"; %pdf = ( size => format_bytes(-s $gzip_path), link => filename($gzip_path), ); } #dumper \%pdf; return \%pdf; } # search for the source version in the source tree and copy/gzip it to # the same dir as the html version (we link to it from the html) sub fetch_src_doc_ver { my $self = shift; #$self->src_uri my $dst_path = catfile $self->{dst_root}, $self->{src_uri}; my $src_path = catfile $self->{src_root}, $self->{src_uri}; #print "TRYING $dst_path $src_path \n"; my %src = (); if (-e $src_path) { # it's ok if the source file has the same name as the dest, # because the final dest file wasn't created yet. copy_file($src_path, $dst_path); gzip_file($dst_path); my $gzip_path = "$dst_path.gz"; %src = ( size => format_bytes(-s $gzip_path), link => filename($gzip_path), ); } #dumper \%src; return \%src; } # These are POD::POM functions sub pod_pom_html_view_seq_link { my ($self, $link) = @_; #dumper $link; #print "$link\n"; # full-blown URL's are emitted as-is if ($link =~ m{^\w+://}s ){ return make_href($link); } $link =~ s/\n/ /g; # undo word-wrapped tags my $orig_link = $link; my $linktext; # strip the sub-title and the following '|' char if ( $link =~ s/^ ([^|]+) \| //x ) { $linktext = $1; } # make sure sections start with a / $link =~ s|^"|/"|; my $page; my $section; if ($link =~ m|^ (.*?) / "? (.*?) "? $|x) { # [name]/"section" ($page, $section) = ($1, $2); } elsif ($link =~ /\s/) { # this must be a section with missing quotes ($page, $section) = ('', $link); } else { ($page, $section) = ($link, ''); } # warning; show some text. $linktext = $orig_link unless defined $linktext; my $url = ''; if (defined $page && length $page) { $url = "$page.html"; $url =~ s|::|/|g; } # append the #section if exists $url .= "#$section" if defined $section and length $section; return make_href($url, $linktext); } sub make_href { my($url, $title) = @_; #print "$url, $title\n"; # $title = $url unless defined $title; # return qq{<a href="$url">$title</a>}; } sub pod_pom_html_anchor { my($self, $title) = @_; my $anchor = "$title"; $anchor =~ s/^\s*|\s*$//g; # strip leading and closing spaces $anchor =~ s/\W/_/g; my $link = $title->present($self); return qq{<a name="$anchor">$link</a>}; } # we want the pre sections look different from normal text. So we use # the vertical bar on the left sub pod_pom_html_view_verbatim { my ($self, $text) = @_; for ($text) { s/&/&/g; s/</</g; s/>/>/g; } return <<PRE_SECTION; <table> <tr> <td bgcolor="#cccccc" width="1"> </td> <td> <pre>$text</pre> </td> </tr> </table> PRE_SECTION } 1; __END__ 1.1 modperl-docs/lib/DocSet/Doc/HTML2HTMLPS.pm Index: HTML2HTMLPS.pm =================================================================== package DocSet::Doc::HTML2HTMLPS; use strict; use warnings; use DocSet::Util; use vars qw(@ISA); require DocSet::Doc::HTML2HTML; @ISA = qw(DocSet::Doc::HTML2HTML); use DocSet::Doc::Common (); *postprocess = \&DocSet::Doc::Common::postprocess_ps_pdf; 1; __END__ =head1 NAME C<DocSet::Doc::HTML2HTMLPS> - HTML source to PS (intermediate HTML) target converter =head1 SYNOPSIS =head1 DESCRIPTION See C<DocSet::Doc::HTML2HTML>. This sub-class only extends the postprocess() method. =head1 METHODS For the rest of the super class methods see C<DocSet::Doc::HTML2HTML>. =over =item * postprocess() Convert the generated HTML doc to PS and PDF. =back =head1 AUTHORS Stas Bekman E<lt>stas (at) stason.orgE<gt> =cut 1.3 +4 -3 modperl-docs/lib/DocSet/Source/POD.pm Index: POD.pm =================================================================== RCS file: /home/cvs/modperl-docs/lib/DocSet/Source/POD.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- POD.pm 24 Jan 2002 18:11:24 -0000 1.2 +++ POD.pm 5 Feb 2002 10:27:20 -0000 1.3 @@ -93,9 +93,10 @@ sub render_toc_level { my($self, $node, $level) = @_; my $title = $node->title; - my $link = "$title"; # must stringify to get the raw string - $link =~ s/\W/_/g; # META: put into a sub? - $link = "#$link"; # prepand '#' for internal links + my $link = "$title"; # must stringify to get the raw string + $link =~ s/^\s*|\s*$//g; # strip leading and closing spaces + $link =~ s/\W/_/g; # META: put into a sub? see Doc::Common::pod_pom_html_anchor + $link = "#$link"; # prepand '#' for internal links my %toc_entry = ( title => $title->present($mode), # run the formatting if any
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]