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

jshirley at dev.catalyst.perl.org jshirley at dev.catalyst.perl.org
Thu Sep 27 01:43:31 GMT 2007


Author: jshirley
Date: 2007-09-27 01:43:31 +0100 (Thu, 27 Sep 2007)
New Revision: 6947

Added:
   branches/site-notrac/podbuilder/
   branches/site-notrac/podbuilder/buildtree.pl
   branches/site-notrac/podbuilder/cat_toc.yml
   branches/site-notrac/podbuilder/root/
   branches/site-notrac/podbuilder/root/docs/
   branches/site-notrac/podbuilder/root/docs/page_nav.tt
   branches/site-notrac/podbuilder/root/docs/toc.tt
   branches/site-notrac/podbuilder/root/docs/toc_r.tt
   branches/site-notrac/podbuilder/root/docs/wrapper.tt
   branches/site-notrac/podbuilder/root/sample.tt
Log:
First go of the podbuilder for the cat site docs

Added: branches/site-notrac/podbuilder/buildtree.pl
===================================================================
--- branches/site-notrac/podbuilder/buildtree.pl	                        (rev 0)
+++ branches/site-notrac/podbuilder/buildtree.pl	2007-09-27 00:43:31 UTC (rev 6947)
@@ -0,0 +1,165 @@
+#!/usr/bin/perl
+
+use Config::Any;
+use Path::Class;
+use Pod::Simple::Search;
+use Pod::POM::View::HTML;
+use Template;
+use Data::Visitor::Callback;
+
+my $toc = $ARGV[0];
+
+die "$0: toc.yml <output>\n"
+    unless $toc and -f $toc;
+
+my $output = $ARGV[1];
+die "$0: toc.yml <output>\n"
+    unless $output;
+
+my $dir = dir($output);
+unless ( $dir->stat ) {
+    $dir->mkpath or die "Unable to make $output, check permissions\n";;
+}
+
+my $cfg = Config::Any->load_files({ files => [ $toc ], use_ext => 1 });
+
+die "$0: Invalid configuration" unless $cfg and $cfg->[0];
+
+my ( $cfg_file, $config ) = each %{ $cfg->[0] };
+
+my $tree = $config->{tree};
+
+die "$toc doesn't have a valid tree node\n"
+    unless $tree and ref $tree eq 'ARRAY';
+
+my %pod_list = ();
+my %name2path = %{ Pod::Simple::Search->new->limit_glob('Catalyst::*')->survey(
+    @{ $config->{search_paths} || [] }
+) };
+
+my $default_bucket = [];
+
+#
+# We molest the data structure to do all sorts of circular references and stupid
+# shit now.  We need this to make the TT table of content and navigation
+# structure sane.  Oh yeah, and to verify that we have all the pod files we
+# need before we even start.
+#
+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";
+            }
+            print "Got $data->{source}\n";
+
+            $pod_list{$data->{source}} = $name2path{$data->{source}};
+
+            $filename = $data->{source};
+                $filename =~ s/\s/-/g;
+                $filename =~ s/::/-/g;
+            $data->{filename} = "$filename.html";
+        }
+
+        if ( $data->{children} ) {
+            for my $i ( 0 .. @{$data->{children}} ) {
+                $data->{children}->[$i]->{parent} = $data;
+
+                $data->{children}->[$i]->{prev} = $data->{children}->[$i-1]
+                    if $i > 0;
+
+                $data->{children}->[$i]->{next} = $data->{children}->[$i+1]
+                    if $data->{children}->[$i + 1];
+            }
+        }
+
+        if ( $data->{default_children} ) {
+            print "Got default_children on $data->{title}, adding children\n";
+            $data->{children} ||= $default_bucket;
+        }
+        return $data;
+    }
+);
+
+push @{$default_bucket},
+    map { { source => $_ } }
+    grep { !exists $pod_list{$_} }
+    keys %name2path;
+%pod_list = %pod_list, %name2path;
+
+$tree = $visitor->visit( $tree );
+
+my $template = Template->new({
+    INCLUDE_PATH => 'root',
+    WRAPPER      => 'docs/wrapper.tt',
+    RECURSION    => 1,
+    %{ $config->{'View::TT'} || {} }
+});
+
+foreach my $node ( @$tree ) {
+    walk_node($node);
+}
+
+sub walk_node {
+    my ( $node, $depth ) = @_;
+        $depth ||= 1;
+
+    if ( $node->{children} and ref $node->{children} eq 'ARRAY' ) {
+        foreach my $child ( @{ $node->{children} } ) {
+            walk_node($child, $depth + 1);
+        }
+    }
+
+    # Generate the template for this
+    if ( $node->{source} ) {
+        my $filename = $node->{filename};
+        unless ( $filename ) {
+            $filename = $node->{source};
+                $filename =~ s/\s/-/g;
+                $filename =~ s/::/-/g;
+            $node->{filename} = $filename;
+        }
+
+        my $path = $pod_list{$node->{source}};
+
+warn "Generating $dir/$filename.html from $path\n";
+
+        my $stash = {
+            pod_path    => $path,
+            tree        => $tree,
+            render_link => \&render_link,
+            %{ $node }
+        };
+
+        my $fh = file("$dir/$filename")->open('w');
+        $template->process(
+            "sample.tt",
+            $stash,
+            $fh
+        ) or die
+            "Unable to generate manual page for $node->{source}: " .
+            $template->error;
+        $fh->close;
+    }
+}
+
+sub render_link {
+    my ( $link ) = @_;
+    return Pod::POM::View::HTML->view_seq_link($link);
+}
+
+package Pod::POM::View::HTML;
+
+sub view_seq_link_transform_path {
+    my ( $self, $page ) = @_;
+    if ( $page =~ /^Catalyst/ ) {
+        my $page = "$page.html";
+        $page =~ s/::/-/g;
+        return $page;
+    } else {
+        return "CPAN LINK TO $page";
+    }
+}
+
+1;

Added: branches/site-notrac/podbuilder/cat_toc.yml
===================================================================
--- branches/site-notrac/podbuilder/cat_toc.yml	                        (rev 0)
+++ branches/site-notrac/podbuilder/cat_toc.yml	2007-09-27 00:43:31 UTC (rev 6947)
@@ -0,0 +1,29 @@
+---
+name: Catalyst Documentation Repository
+output: 
+    - html
+search_paths:
+    - /home/jshirley/workarea/perl/Catalyst/Catalyst-Manual/lib
+
+tree:
+    - title: Catalyst Manual
+      source:  Catalyst::Manual::Intro
+      children:
+        - title: Catalyst Tutorial
+          source: Catalyst::Manual::Tutorial
+          children:
+            - title:  "Part 1: Introduction"
+              source: Catalyst::Manual::Tutorial::Intro
+            - source: Catalyst::Manual::Tutorial::CatalystBasics
+            - source: Catalyst::Manual::Tutorial::BasicCRUD
+        - title: Catalyst Cookbook
+          source:  Catalyst::Manual::Cookbook
+        - title: Catalyst Philosophy
+          source:  Catalyst::Manual::About
+    - title: Catalyst Internals
+      source:  Catalyst::Devel
+      children:
+        - source: Catalyst::Base
+    - title: Other Catalyst Modules
+      #default_children: 1
+

Added: branches/site-notrac/podbuilder/root/docs/page_nav.tt
===================================================================
--- branches/site-notrac/podbuilder/root/docs/page_nav.tt	                        (rev 0)
+++ branches/site-notrac/podbuilder/root/docs/page_nav.tt	2007-09-27 00:43:31 UTC (rev 6947)
@@ -0,0 +1,18 @@
+[% IF prev %]
+<a class="previous_topic" href="[% prev.filename %]">&ldquo; Previous ([% prev.title || prev.source %])</a>
+[% ELSE %]
+<span class="previous_topic">&nbsp;</span>
+[% END %]
+
+[% IF parent %]
+Up to <a class="topic_tree" href="[% parent.filename %]">[% parent.title || parent.source %]</a>
+[% ELSE %]
+<span class="topic_tree">&nbsp;</span>
+[% END %]
+
+[% IF next %]
+<a class="next_topic" href="[% next.filename %]">[% next.title || next.source %] &rsaquo;</a>
+[% ELSE %]
+<span class="next_topic">&nbsp;</a>
+[% END %]
+

Added: branches/site-notrac/podbuilder/root/docs/toc.tt
===================================================================
--- branches/site-notrac/podbuilder/root/docs/toc.tt	                        (rev 0)
+++ branches/site-notrac/podbuilder/root/docs/toc.tt	2007-09-27 00:43:31 UTC (rev 6947)
@@ -0,0 +1,9 @@
+<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;
+    END %]
+    [% END %]
+</ul>
+

Added: branches/site-notrac/podbuilder/root/docs/toc_r.tt
===================================================================
--- branches/site-notrac/podbuilder/root/docs/toc_r.tt	                        (rev 0)
+++ branches/site-notrac/podbuilder/root/docs/toc_r.tt	2007-09-27 00:43:31 UTC (rev 6947)
@@ -0,0 +1,9 @@
+<ul>
+    [% FOREACH branch IN tree %] 
+    <li>[% branch.title || branch.source %]</li>
+    [% IF branch.children;
+        PROCESS "docs/toc.tt", tree = branch.children;
+    END %]
+    [% END %]
+</ul>
+

Added: branches/site-notrac/podbuilder/root/docs/wrapper.tt
===================================================================
--- branches/site-notrac/podbuilder/root/docs/wrapper.tt	                        (rev 0)
+++ branches/site-notrac/podbuilder/root/docs/wrapper.tt	2007-09-27 00:43:31 UTC (rev 6947)
@@ -0,0 +1,53 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+	<head>
+		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+		<title>[% title %] - Catalyst Docs</title>
+		<link rel="stylesheet" type="text/css" href="/css/global/generic.css" media="screen" />
+		<link rel="stylesheet" type="text/css" href="/css/global/layout.css" media="screen" />
+		<link rel="stylesheet" type="text/css" href="/css/docs/manual.css" media="screen" />
+		<!--[if lt IE 7]>
+		<link rel="stylesheet" type="text/css" href="/css/global/ie.css" media="screen" />
+		<![endif]-->
+		<link rel="shortcut icon" href="/catalyst.ico" />
+	</head>
+	<body class="documentation">
+        <div id="wrapper">
+            <div id="header">
+		        <h1>
+		          <a href="/"><img src="/images/layout/catalyst_130pix.gif" alt="Catalyst - Web Framework" /></a>
+		        </h1>
+                <form id="searchbox_001489226992342776861:khgrvdklfes" action="http://google.com/cse">
+                    <input type="hidden" name="cx" value="001489226992342776861:khgrvdklfes" />
+                    <input type="hidden" name="cof" value="FORID:0" />
+                    <input name="q" type="text" size="30" />
+                    <input type="submit" name="sa" value="Search" />
+                </form>
+		        <ul id="menu_global">
+		            <li id="home"><span><a href="/">Home</a></span></li>
+		            <li id="community"><span><a href="http://dev.catalystframework.org/">Community</a></span></li>
+		            <li id="documentation"><span><a href="http://search.cpan.org/dist/Catalyst-Runtime/lib/Catalyst/Manual.pm">Documentation</a></span></li>
+		            <li id="developer"><span><a href="http://dev.catalystframework.org/timeline">Developer</a></span></li>
+		            <li id="download"><span><a href="http://search.cpan.org/dist/Catalyst-Runtime/">Download</a></span></li>
+		            <li id="support"><span><a href="http://dev.catalystframework.org/wiki/Support">Support</a></span></li>
+		            <li id="planet"><span><a href="http://planet.catalystframework.org/">Planet</a></span></li>
+		            <li id="advent"><span><a href="http://www.catalystframework.org/calendar">Calendar</a></span></li>
+		        </ul>
+		    </div>
+		    <div id="main">
+		        <div id="crumbtrail">
+                    [% PROCESS "docs/page_nav.tt" %]
+		        </div>
+				<div class="content fullwidth">
+					<h1>[% title %]</h1>
+                    <div class="manual_navigator">
+                      [% PROCESS "docs/toc.tt" %]
+                    </div>
+                    <p>[% content %]</p>
+                </div>
+            </div>
+        </div>
+    </body>
+</html>
+

Added: branches/site-notrac/podbuilder/root/sample.tt
===================================================================
--- branches/site-notrac/podbuilder/root/sample.tt	                        (rev 0)
+++ branches/site-notrac/podbuilder/root/sample.tt	2007-09-27 00:43:31 UTC (rev 6947)
@@ -0,0 +1,121 @@
+[% 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;
+
+myview.print(pom);
+
+%]
+
+<p class="source">Sourced from: <a href="#">[% pod_path %]</a></p>
+




More information about the Catalyst-commits mailing list