[Catalyst-commits] r6950 - in branches/site-notrac/podbuilder: . root root/docs

jshirley at dev.catalyst.perl.org jshirley at dev.catalyst.perl.org
Sun Sep 30 23:26:06 GMT 2007


Author: jshirley
Date: 2007-09-30 23:26:05 +0100 (Sun, 30 Sep 2007)
New Revision: 6950

Added:
   branches/site-notrac/podbuilder/root/docs/view.tt
Modified:
   branches/site-notrac/podbuilder/buildtree.pl
   branches/site-notrac/podbuilder/cat_toc.yml
   branches/site-notrac/podbuilder/root/docs/toc.tt
   branches/site-notrac/podbuilder/root/docs/wrapper.tt
   branches/site-notrac/podbuilder/root/sample.tt
Log:
More updates, can pull in straight .pod files in the tree, better nav structure and expansion based by topic.

Modified: branches/site-notrac/podbuilder/buildtree.pl
===================================================================
--- branches/site-notrac/podbuilder/buildtree.pl	2007-09-28 00:27:58 UTC (rev 6949)
+++ branches/site-notrac/podbuilder/buildtree.pl	2007-09-30 22:26:05 UTC (rev 6950)
@@ -1,12 +1,19 @@
 #!/usr/bin/perl
 
 use Config::Any;
+
+use Data::Visitor::Callback;
+use File::Spec;
 use Path::Class;
+
 use Pod::Simple::Search;
 use Pod::POM::View::HTML;
+
 use Template;
-use Data::Visitor::Callback;
 
+use warnings;
+use strict;
+
 my $toc = $ARGV[0];
 
 die "$0: toc.yml <output>\n"
@@ -48,18 +55,55 @@
 my $visitor = Data::Visitor::Callback->new(
     hash => sub {
         my ( $visitor, $data ) = @_;
+
         if ( exists $data->{source} ) {
-            unless ( exists $name2path{$data->{source}} ) {
-                die "Unable to find $data->{source} in the search_paths, check config\n";
+            
+            if ( exists $name2path{$data->{source}} ) {
+
+                unless ( exists $name2path{$data->{source}} ) {
+                }
+                print "Got $data->{source}\n";
+                $pod_list{$data->{source}} = $name2path{$data->{source}};
+
+                my $filename = $data->{source};
+                    $filename =~ s/\s/-/g;
+                    $filename =~ s/::/-/g;
+                $data->{filename} = "$filename.html";
             }
-            print "Got $data->{source}\n";
+            # A path name, and then we have to do substitutions for path parts
+            elsif ( $data->{source} =~ /\.(pm|pod)$/i ) {
+                my $source;
+                if ( -f $data->{source} ) {
+                    $source = $data->{source};
+                } else {
+                    my @search_paths =
+                        (
+                            ref $config->{search_paths} ?
+                            ( @{$config->{search_paths} } ) :
+                            ( $config->{search_paths} )
+                        ); 
+                    my @found_files =
+                        grep { -f $_ }
+                        map  { File::Spec->catfile($_, $data->{source}) }
+                        @search_paths;
+                    # Just pick the first?
+                    $source = $found_files[0];
+warn "File path: $data->{source} <=> $source \n";
+                    $pod_list{$data->{source}} = $source;
 
-            $pod_list{$data->{source}} = $name2path{$data->{source}};
+                    my $filename = $data->{source};
+                        $filename =~ s/\s/-/g;
+                        $filename =~ s/::/-/g;
+                        $filename =~ s#/#_#g;
 
-            $filename = $data->{source};
-                $filename =~ s/\s/-/g;
-                $filename =~ s/::/-/g;
-            $data->{filename} = "$filename.html";
+                    $data->{filename} = "$filename.html";
+                }
+                unless ( $source ) {
+                    die "Unable to find $data->{source} in the search_paths, check config\n";
+                }
+            } else {
+                die "Unable to find $data->{source} in the search_paths, check config\n";
+            }
         }
 
         if ( $data->{children} ) {
@@ -92,6 +136,7 @@
 
 my $template = Template->new({
     INCLUDE_PATH => 'root',
+    PRE_PROCESS  => 'docs/view.tt',
     WRAPPER      => 'docs/wrapper.tt',
     RECURSION    => 1,
     %{ $config->{'View::TT'} || {} }
@@ -102,12 +147,11 @@
 }
 
 sub walk_node {
-    my ( $node, $depth ) = @_;
-        $depth ||= 1;
+    my ( $node, @parents ) = @_;
 
     if ( $node->{children} and ref $node->{children} eq 'ARRAY' ) {
         foreach my $child ( @{ $node->{children} } ) {
-            walk_node($child, $depth + 1);
+            walk_node($child, @parents, $node);
         }
     }
 
@@ -123,12 +167,14 @@
 
         my $path = $pod_list{$node->{source}};
 
-warn "Generating $dir/$filename.html from $path\n";
+warn "Generating $dir/$filename from $path\n";
 
+#use YAML::Syck; warn Dump([ map { $_->{title} } @parents ]);
         my $stash = {
-            pod_path    => $path,
-            tree        => $tree,
-            render_link => \&render_link,
+            parent_stack => [ map { $_->{title} } @parents ],
+            pod_path     => $path,
+            tree         => $tree,
+            render_link  => \&render_link,
             %{ $node }
         };
 

Modified: branches/site-notrac/podbuilder/cat_toc.yml
===================================================================
--- branches/site-notrac/podbuilder/cat_toc.yml	2007-09-28 00:27:58 UTC (rev 6949)
+++ branches/site-notrac/podbuilder/cat_toc.yml	2007-09-30 22:26:05 UTC (rev 6950)
@@ -4,6 +4,7 @@
     - html
 search_paths:
     - /home/jshirley/workarea/perl/Catalyst/Catalyst-Manual/lib
+    - /home/jshirley/workarea/perl/Catalyst/examples
 
 tree:
     - title: Catalyst Manual
@@ -34,6 +35,58 @@
           source:  Catalyst::Manual::About
         - title: Catalyst Cookbook
           source:  Catalyst::Manual::Cookbook
+    - title: Catalyst Advent Calendar
+      children:
+            - title: Catalyst and Subversion
+              source: "CatalystAdvent/root/2006/1.pod"
+            - title: Handel
+              source: "CatalystAdvent/root/2006/2.pod"
+            - title: Layout of a Catalyst Application
+              source: "CatalystAdvent/root/2006/3.pod"
+            - title: Catalyst and FastCGI Deployment
+              source: "CatalystAdvent/root/2006/4.pod"
+            - title: Taming Legacy Websites with Catalyst and wget
+              source: "CatalystAdvent/root/2006/5.pod"
+# BindLex entry throws a TT processing error, FIXME/TODO
+            #- title: "Catalyst::Controller::BindLex"
+            #  source: "CatalystAdvent/root/2006/6.pod"
+            - title: Testing with an External Webserver
+              source: "CatalystAdvent/root/2006/7.pod"
+            - title: YouTube Catalyst Application
+              source: "CatalystAdvent/root/2006/8.pod"
+            - title: "Web Services with Catalyst::Action::REST"
+              source: "CatalystAdvent/root/2006/9.pod"
+            - title: "The Chained Dispatch Type"
+              source: "CatalystAdvent/root/2006/10.pod"
+            - title: "Using Catalyst with Log4perl"
+              source: "CatalystAdvent/root/2006/11.pod"
+            - title: "Producing PDFs with Template::Latex"
+              source: "CatalystAdvent/root/2006/12.pod"
+            - title: "Adding Custom Headers"
+              source: "CatalystAdvent/root/2006/13.pod"
+            - title: "Catalyst JobQueue"
+              source: "CatalystAdvent/root/2006/14.pod"
+            - title: "Streaming MP3s with Catalyst"
+              source: "CatalystAdvent/root/2006/15.pod"
+            - title: "FastCGI, Second Visit"
+              source: "CatalystAdvent/root/2006/16.pod"
+            - title: "Testing Catalyst Controllers"
+              source: "CatalystAdvent/root/2006/17.pod"
+            - title: "Catalyst and I18N"
+              source: "CatalystAdvent/root/2006/18.pod"
+            - title: "HTML::Widget Tricks"
+              source: "CatalystAdvent/root/2006/19.pod"
+            - title: "Catalyst::Plugin::Flavour"
+              source: "CatalystAdvent/root/2006/20.pod"
+# Same issue - TODO/FIXME later
+#            - title: "Catalyst and Unicode"
+#              source: "CatalystAdvent/root/2006/21.pod"
+            - title: "LDAP Autocomplete"
+              source: "CatalystAdvent/root/2006/22.pod"
+            - title: "Creating a Google Maps Mashup"
+              source: "CatalystAdvent/root/2006/23.pod"
+            - title: "The Catalyst Community"
+              source: "CatalystAdvent/root/2006/24.pod"
     - title: Advanced Catalyst Topics
       children:
         - title: Catalyst Internals/Request Lifecycle

Modified: branches/site-notrac/podbuilder/root/docs/toc.tt
===================================================================
--- branches/site-notrac/podbuilder/root/docs/toc.tt	2007-09-28 00:27:58 UTC (rev 6949)
+++ branches/site-notrac/podbuilder/root/docs/toc.tt	2007-09-30 22:26:05 UTC (rev 6950)
@@ -1,9 +1,16 @@
 <ul>
-    [% FOREACH branch IN tree %] 
-    <li><a href="[% branch.filename %]">[% branch.title || branch.source %]</a></li>
-    [% IF branch.children;
-        PROCESS "docs/toc.tt", tree = branch.children;
+[% FOREACH branch IN tree %] 
+    <li>
+        <a href="[% branch.filename %]">
+            [% branch.title || branch.source %]
+        </a>
+    [%
+    IF
+      ( parent_stack.$depth == branch.title && branch.children ) ||
+      ( branch.title == title );
+        PROCESS "docs/toc.tt", tree = branch.children, depth = depth + 1;
     END %]
-    [% END %]
+    </li>
+[% END %]
 </ul>
 

Added: branches/site-notrac/podbuilder/root/docs/view.tt
===================================================================
--- branches/site-notrac/podbuilder/root/docs/view.tt	                        (rev 0)
+++ branches/site-notrac/podbuilder/root/docs/view.tt	2007-09-30 22:26:05 UTC (rev 6950)
@@ -0,0 +1,110 @@
+[% VIEW myview;
+
+    BLOCK pod;
+        FOREACH i IN item.content;
+            view.print(i);
+        END;
+    END;
+
+
+    BLOCK head1;
+        SWITCH item.title;
+            CASE 'NAME';
+                # If we have a title, disregard name and just keep the override
+                IF !title; title = view.print(item.content); END;
+            CASE;
+                %]<h1>[% item.title %]</h1>
+                <p>[% view.print(item.content) %]</p>[%
+        END;
+    END;
+                                       
+    BLOCK head2;
+        %]<a name="[% item.title %]"></a>
+        <h2>[% view.print(item.title) %]</h2>
+        [% view.print(item.content) %]
+    [% END %]
+
+    [% BLOCK head3 %]
+        <a name="[% item.title %]"></a>
+        <h3>[% view.print(item.title) %]</h3>
+        [% view.print(item.content) %]
+    [% END %]
+
+    [% BLOCK head4 %]
+        <a name="[% item.title %]"></a>
+        <h4>[% view.print(item.title) %]</h4>
+        [% view.print(item.content) %]
+    [% END %]
+
+    [% BLOCK seq_text; item; END; %]
+
+    [% BLOCK seq_code %]
+        <span class="code">[% item %]</span>
+    [% END %]
+
+    [% BLOCK seq_bold %]
+        <span class="strong">[% item %]</span>
+    [% END %]
+
+    [% BLOCK seq_italic %]
+        <em>[% item.content %]</em>
+    [% END %]
+
+    [% BLOCK seq_entity %]&[% item %];[% END %]
+
+    [% BLOCK seq_link;
+        render_link(item);
+    END %]
+
+    [% BLOCK seq_file %]
+        F&lt;[% item %]&gt;
+    [% END %]
+
+    [% BLOCK seq_space %]
+        <span class="code">[% item %]</span>
+    [% END %]
+
+    [% BLOCK seq_zero; END; %]
+
+    [% BLOCK textblock %]
+        <p>[% item %]</p>
+    [% END %]
+
+    [% BLOCK over %]
+        [% IF item.title; view.print(item.title); END %]
+        <ul>
+        [% FOREACH i IN item.content %]
+            <li>[% view.print(i) %]</li>
+        [% END %]
+        </ul>
+    [% END %]
+
+    [% BLOCK item %]
+        [% view.print(item.content) %]
+    [% END %]
+
+    [% BLOCK verbatim %]
+        <p class="verbatim">[% item %]</p>
+    [% END %]
+
+    [% BLOCK list;
+        view.print(i) FOREACH i = item;
+    END;
+    
+    BLOCK useless; %]
+        <dl>
+         [% FOREACH i IN item %]
+         [% IF i.title %]<dt>[% view.print(i.title) %]</dt>[% END %]
+         [% IF i.content %]<dd>[% view.print(i.content) %]</dd>[% END %]
+         [% END; %]
+        </dl>
+    [% END %]
+
+    [% BLOCK begin; END %]
+    [% BLOCK for; END %]
+
+    [% BLOCK text %]
+        [%# item %]
+    [% END %]
+[% END %]
+

Modified: branches/site-notrac/podbuilder/root/docs/wrapper.tt
===================================================================
--- branches/site-notrac/podbuilder/root/docs/wrapper.tt	2007-09-28 00:27:58 UTC (rev 6949)
+++ branches/site-notrac/podbuilder/root/docs/wrapper.tt	2007-09-30 22:26:05 UTC (rev 6950)
@@ -42,7 +42,7 @@
 				<div class="content fullwidth">
 					<h1>[% title %]</h1>
                     <div class="manual_navigator">
-                      [% PROCESS "docs/toc.tt" %]
+                      [% PROCESS "docs/toc.tt", depth = 0 %]
                     </div>
                     <p>[% content %]</p>
                 </div>

Modified: branches/site-notrac/podbuilder/root/sample.tt
===================================================================
--- branches/site-notrac/podbuilder/root/sample.tt	2007-09-28 00:27:58 UTC (rev 6949)
+++ branches/site-notrac/podbuilder/root/sample.tt	2007-09-30 22:26:05 UTC (rev 6950)
@@ -1,118 +1,8 @@
-[% USE Pod;
-
-pom = Pod.parse(pod_path) %]
-
-[% VIEW myview %]
-
-    [% BLOCK pod;
-        FOREACH i IN item.content;
-            view.print(i);
-        END;
-    END %]
-
-
-    [% BLOCK head1;
-        SWITCH item.title;
-            CASE 'NAME';
-                # If we have a title, disregard name and just keep the override
-                IF !title; title = view.print(item.content); END;
-            CASE;
-                %]<h1>[% item.title %]</h1>
-                <p>[% view.print(item.content) %]</p>[%
-        END;
-    END %]
-                                       
-    [% BLOCK head2 %]
-        <a name="[% item.title %]"></a>
-        <h2>[% view.print(item.title) %]</h2>
-        [% view.print(item.content) %]
-    [% END %]
-
-    [% BLOCK head3 %]
-        <a name="[% item.title %]"></a>
-        <h3>[% view.print(item.title) %]</h3>
-        [% view.print(item.content) %]
-    [% END %]
-
-    [% BLOCK head4 %]
-        <a name="[% item.title %]"></a>
-        <h4>[% view.print(item.title) %]</h4>
-        [% view.print(item.content) %]
-    [% END %]
-
-    [% BLOCK seq_text; item; END; %]
-
-    [% BLOCK seq_code %]
-        <span class="code">[% item %]</span>
-    [% END %]
-
-    [% BLOCK seq_bold %]
-        <span class="strong">[% item %]</span>
-    [% END %]
-
-    [% BLOCK seq_italic %]
-        <em>[% item.content %]</em>
-    [% END %]
-
-    [% BLOCK seq_entity %]&[% item %];[% END %]
-
-    [% BLOCK seq_link;
-        render_link(item);
-    END %]
-
-    [% BLOCK seq_file %]
-        F&lt;[% item %]&gt;
-    [% END %]
-
-    [% BLOCK seq_space %]
-        <span class="code">[% item %]</span>
-    [% END %]
-
-    [% BLOCK seq_zero; END; %]
-
-    [% BLOCK textblock %]
-        <p>[% item %]</p>
-    [% END %]
-
-    [% BLOCK over %]
-        [% IF item.title; view.print(item.title); END %]
-        <ul>
-        [% FOREACH i IN item.content %]
-            <li>[% view.print(i) %]</li>
-        [% END %]
-        </ul>
-    [% END %]
-
-    [% BLOCK item %]
-        [% view.print(item.content) %]
-    [% END %]
-
-    [% BLOCK verbatim %]
-        <p class="verbatim">[% item %]</p>
-    [% END %]
-
-    [% BLOCK list;
-        view.print(i) FOREACH i = item;
-    END;
-    
-    BLOCK useless; %]
-        <dl>
-         [% FOREACH i IN item %]
-         [% IF i.title %]<dt>[% view.print(i.title) %]</dt>[% END %]
-         [% IF i.content %]<dd>[% view.print(i.content) %]</dd>[% END %]
-         [% END; %]
-        </dl>
-    [% END %]
-
-    [% BLOCK begin; END %]
-    [% BLOCK for; END %]
-
-    [% BLOCK text %]
-        [%# item %]
-    [% END %]
 [%
-END;
 
+USE Pod;
+
+pom = Pod.parse(pod_path);
 myview.print(pom);
 
 %]




More information about the Catalyst-commits mailing list