[Catalyst-commits] r6861 - in trunk/Catalyst-View-TT-Bootstrap: . lib lib/Catalyst lib/Catalyst/Helper lib/Catalyst/Helper/View lib/Catalyst/Helper/View/TT lib/Catalyst/Helper/View/TT/Bootstrap

lsmith at dev.catalyst.perl.org lsmith at dev.catalyst.perl.org
Sat Sep 8 01:54:07 GMT 2007


Author: lsmith
Date: 2007-09-08 01:54:07 +0100 (Sat, 08 Sep 2007)
New Revision: 6861

Added:
   trunk/Catalyst-View-TT-Bootstrap/Makefile.PL
   trunk/Catalyst-View-TT-Bootstrap/lib/
   trunk/Catalyst-View-TT-Bootstrap/lib/Catalyst/
   trunk/Catalyst-View-TT-Bootstrap/lib/Catalyst/Helper/
   trunk/Catalyst-View-TT-Bootstrap/lib/Catalyst/Helper/View/
   trunk/Catalyst-View-TT-Bootstrap/lib/Catalyst/Helper/View/TT/
   trunk/Catalyst-View-TT-Bootstrap/lib/Catalyst/Helper/View/TT/Bootstrap.pm
   trunk/Catalyst-View-TT-Bootstrap/lib/Catalyst/Helper/View/TT/Bootstrap/
   trunk/Catalyst-View-TT-Bootstrap/lib/Catalyst/Helper/View/TT/Bootstrap/Manual.pm
Log:
Initial drop of Catalyst::Helper::View::TT::Bootstrap

Added: trunk/Catalyst-View-TT-Bootstrap/Makefile.PL
===================================================================
--- trunk/Catalyst-View-TT-Bootstrap/Makefile.PL	                        (rev 0)
+++ trunk/Catalyst-View-TT-Bootstrap/Makefile.PL	2007-09-08 00:54:07 UTC (rev 6861)
@@ -0,0 +1,11 @@
+use inc::Module::Install;
+
+name 'Catalyst-Helper-View-TT-Bootstrap';
+all_from 'lib/Catalyst/Helper/View/TT/Bootstrap.pm';
+
+# Standard Modules 
+requires 'Catalyst::Devel';
+requires 'Catalyst::View::TT';
+
+auto_install;
+WriteAll;

Added: trunk/Catalyst-View-TT-Bootstrap/lib/Catalyst/Helper/View/TT/Bootstrap/Manual.pm
===================================================================
--- trunk/Catalyst-View-TT-Bootstrap/lib/Catalyst/Helper/View/TT/Bootstrap/Manual.pm	                        (rev 0)
+++ trunk/Catalyst-View-TT-Bootstrap/lib/Catalyst/Helper/View/TT/Bootstrap/Manual.pm	2007-09-08 00:54:07 UTC (rev 6861)
@@ -0,0 +1,368 @@
+package Catalyst::Helper::View::TT::Bootstrap::Manual; 1;
+
+=head1 NAME
+
+Catalyst::Helper::View::TT::Bootstrap::Manual - User guide and reference for
+files generated by Catalyst::Helper::View::TT::Bootstrap.
+
+=head1 DESCRIPTION
+
+=head2 Files and Directory Structure
+
+The files and directories generated under your application root (e.g. MyApp/) are:
+
+    lib/MyApp/View/TT.pm # The TT View module with a couple extras
+
+    root/
+        site/
+            wrapper.tt         # routes all pages to their appropriate layout
+            html.tt            # renders the html wrapper.  See below
+
+            header/            # directory for header templates
+                default.tt     # placeholder masthead for you to override
+
+            footer/            # directory for footer templates
+                default.tt     # placeholder footer for you to override
+
+            nav/               # directory for navigation templates. See below
+                default.tt     # placeholder nav for you to override
+
+            layout/            # directory for various content layouts
+                default.tt     # basic layout, renders content only
+                2columns.tt    # 2 column layout. See below
+                2col_top.tt    # 2 columns above full width content.  See below
+                2col_bottom.tt # 2 columns below full width content.  See below
+
+            shared/            # directory for templates shared by several pages
+                base.tt        # core macros and stash framework.  See below
+
+        static/                # directory root of static resources
+            
+            images/            # content images go here or in a subdir
+
+            scripts/           # javascript files go here or in a subdir
+
+            css/               # stylesheets go here or in a subdir
+                screen.css     # global stylesheet supporting the provided
+                               # layouts and resetting default browser styles
+                nav_default.css # stylesheet for nav/default.tt
+
+                images/        # css images go here on in a subdir
+                
+=head2 View Module Configuration
+
+The generated View/TT.pm sets the following configuration key/values:
+
+ PRE_PROCESS        => 'site/shared/base.tt',
+ WRAPPER            => 'site/wrapper.tt',
+ TEMPLATE_EXTENSION => '.tt',
+ TIMER              => 0,
+ static_root        => '/static',
+ static_build       => 0
+
+The last two config options are added to the template stash for each rendering.
+
+ <p>The current static root is [% static_root %]</p>
+ <p>And the current static build is [% static_build %]</p>
+
+=over 4
+
+=item static_root
+
+Used by the macro 'static' (see below) to locate static resources such as images, stylesheets, and javascript files.  The default value is '/static' (effectively MyApp/root/static).
+
+=item static_build
+
+(Optional) Used by the macro 'static' to append the returned URIs with a query
+string 'ver' with the value assigned to static_build.  This is particularly
+useful to ensure returning site visitors get the latest version of static
+resources. By default, this is set to 0 (versioning off).
+
+Two strategies for use are
+
+=over 4
+
+=item 1
+
+Manually update it when a static file is modifed, using the a datestamp value.
+Using a YAML config makes this more convenient.
+
+    ...
+    View::TT:
+        static_build: 20070907
+    ...
+
+=item 2
+
+Assign it the result of a call to localtime,  so every time the server restarts,
+static requests will avoid the browser cache (first request only).
+
+=back
+
+=back
+
+=head2 Template variable framework
+
+=head3 base.tt and the page variable
+
+site/shared/base.tt is PRE_PROCESSed before any page template rendering.  It
+adds the following variables and macros:
+
+=over 4
+
+=item MACRO ref(variable)
+
+Works essentially like the native perl ref.  Since TT auto-converts variables,
+it's often difficult to incorporate type checking into any template
+conditionals.  This makes that functionality available again.
+
+    [%
+    IF colors && ref(colors) == 'HASH';
+        ...do something...
+    END
+    %]
+
+=item MACRO static(resource, versioned, query)
+
+Wraps c.uri_for for static resources.  The full URI is returned with any query
+params appended.  If a non-false value is passed for the versioned param, the
+query param ver => [% static_build %] will be added to the query string if
+static_build is set.
+
+    <img alt="Sample image" src="[% static('images/sample.png') %]">
+    BECOMES (e.g.)
+    <img alt="Sample image" src="http://mydomain.com/static/images/sample.png">
+
+    <script type="text/javascript" src="[% static('scripts/changes_often.js',1) %]"></script>
+    BECOMES
+    <script type="text/javascript" src="http://mydomain.com/static/scripts/changes_often.js?ver=20070907"></script>
+    
+For flexibility, if a full URI is passed as the resource param, it will be
+returned unaltered.  No query params nor the static_build versioning will be
+appended to the URI.
+
+=item page
+
+This hash struct contains key/value pairs used by the template structure to
+describe how the page should be rendered.  Don't create or clobber a template
+stash variable named 'page', as this will cause havok.  Work with the page
+variable structure provided.
+
+The stuff you can and should play with are ...
+
+=item page.layout
+
+    [% page.layout = '2columns'; %]
+
+Assign the short name of the template found in /root/site/layout.
+Will cause the page to be wrapped in the appropriate layout.  Add any new
+layouts (say 3column.tt) to this directory and the page.layout will do the right
+thing.  The default value is 'default'.
+
+Other magic values are:
+
+=over 4
+
+=item 'none'
+
+Don't use a layout.  Just place the content in the html.tt wrapper.  Out of the
+box, this is equivalent to the default.
+
+=item 'partial'
+
+Don't even wrap in html.tt.  This is useful for Ajax calls returning only bits
+of a page dynamically.
+
+=back
+
+=item page.title
+
+Assigned to the title element in the html head.  The default value is the name
+of your app (e.g. MyApp).
+
+Note, unless you refer to page.title in the content area, this is NOT displayed in your page content.
+
+=item page.header
+
+    [% page.header = 'small_screen' %]
+
+Similar to page.layout, this accepts a string short name for templates in
+/root/site/header.  The default value is 'default'.
+
+This also accepts the value 'none' to omit the inclusion of a header.
+
+Note that page.header and page.footer are still rendered when page.layout is set
+to 'none' unless they too are set to 'none'.
+
+=item page.footer
+
+    [% page.footer = 'no_contact_us' %]
+
+Works like page.header.
+
+=item page.nav
+
+    [% page.nav = 'green' %]
+
+Similar to page.layout, this accepts a string short name for templates in
+/root/site/nav.  The default value is 'default';
+
+The out of the box default header happens to PROCESS page.nav, but in a real
+world application, you should add the PROCESS call in either your header or
+a layout template according to where you want the nav located.
+
+Additionally, a stylesheet reference is automatically added to the head element
+named nav_[% page.nav %].css.  In the example above, 'nav_green.css'.  Be sure
+to place style rules for your navigation template(s) in appropriately named
+files.
+
+=item page.head.stylesheets
+
+    [%
+    page.head.stylesheets.push('widgets.css', 'widgets.css', page_name _ '.css',
+                               'http://somedomain.com/hosted/stylesheet.css');
+    %]
+
+Holds an array of css file names/URIs.  Each entry will be added to the head
+element after locating the resource URI using the static macro.  Duplicates will
+be ignored.  Filenames will be prepended with /css and absolute URIs will be
+left alone.  Local files will also be versioned according to the configuration
+of static_build (see above).
+
+The above example will produce the following links:
+
+    <link rel="stylesheet" type="text/css" href="http://mydomain.com/static/css/widgets.css?ver=20070907" media="screen">
+    <link rel="stylesheet" type="text/css" href="http://mydomain.com/static/css/foo.css?ver=20070907" media="screen">
+    <link rel="stylesheet" type="text/css" href="http://somedomain.com/hosted/stylesheet.css" media="screen">
+
+Note that screen.css and nav_[% page.nav %].css are added to the head separately
+and before any page.head.stylesheets.
+
+=item page.head.scripts
+
+    [%
+    page.head.scripts.push('widgets.js', 'widgets.js', page_name _ '.js',
+                               'http://somedomain.com/hosted/script.js');
+    %]
+
+Holds an array of javascript file names/URIs.  Works in the same fashion as
+page.head.stylesheets.
+
+Note that it is generally preferable from a performance standpoint to place
+script tags at the bottom of the body tag.  For this reason, it is advisable to
+use page.body.scripts rather than this.
+
+=item page.body.classes
+
+    [%
+    page.body.classes.push('foo','foo','bar');
+    %]
+
+Holds an array of class names to add to the body tag.  Duplicates are ignored.
+
+Note that html.tt automatically adds classes 'IE' and 'IE(5|6|7)' to the body
+tag using conditional comments.  These will only be added  when the requesting
+browser is Internet Explorer.  This is useful for adding style rules to target
+IE without resorting to css hacks.
+
+=item page.body.scripts
+
+Works exactly as page.head.scripts, except it adds script tags to the very end of the body content.
+
+=item page.content_class
+
+    [% page.content_class = 'wide_content' %]
+
+Used by html.tt, assigned to the class of the div containing the page content.
+Also used by layouts as a default container class.  See the info on the layouts
+below.  Default value is 'content'.
+
+=back
+
+=head2 html.tt points of interest
+
+html.tt creates the html, head and body elements of each page.  As noted above,
+it references many of the page.* variables to populate these sections.
+
+=over 4
+
+=item HTML 4.01 strict DOCTYPE
+
+Per the recommendation of the w3c, the broadcasted DOCTYPE is HTML 4.01 strict.
+It was either this or XHTML 1.0 strict, but since you're likely delivering your
+pages with Content-Type header set to 'text/html', this is more correct.  There
+are arguments for and against using HTML 4.01 instead of XHTML 1.0, but it's
+probably not worth the reading, since you really just want to get stuff done.
+
+That said, please use HTML style closed tags or change the DOCTYPE in html.tt
+
+    <p>This is<br>GOOD</p>
+    <p>This is<br/>a waste of a character</p>
+
+=item debug_init
+
+    [% # in some PRE_PROCESS template
+    MACRO devel_env BLOCK;
+        ...etc...
+    END;
+
+    debug_init = 'devel_env';
+    %]
+    
+If your server is running in debug mode, before anything, it checks if a
+variable named debug_init is populated.  If it is, it attempts to execute a
+macro by the name assigned to the variable.  This allows you to set up logging,
+add scripts or stylesheets etc for use in development.
+
+=item IE detection
+
+html.tt uses IE conditional comments to decorate the body tag with a class 'IE'
+and another class 'IE5', 'IE6', or 'IE7' depending on the version of the browser
+requesting the page.  Non-IE browsers will no have these classes added.
+
+This allows you to use the cascade in your css to target IE to correct display
+issues that may*cough*WILL*cough* arise.
+
+    /* Container dimensions */
+    .container {
+        width: 276px;
+        padding: 10px:
+        border: 2px solid #eee;
+    }
+
+    /* correction for IE's box model */
+    .IE .container {
+        width: 300px;
+    }
+
+=item Header, content, and footer separation
+
+The header, content, and footer are rendered separately under the body element,
+not wrapped in a global wrapping div.  This was done to allow layouts to use
+the full content width for header/footer if their design mandates, but keep a
+narrower content area centered.  If your design mandates consistent width, it's
+probably easiest to move the open and close div tags surrounding [% content %]
+to encompass the header and footer includes.
+
+=back
+
+=head2 Using layouts
+
+TODO: talk about the template vars and nesting
+
+=head1 AUTHOR
+
+Lucas Smith E<lt>lsmith at lucassmith.nameE<gt>
+
+=head1 VERSION
+
+TT Bootstrap version 0.1, released Sept 7, 2007
+
+=head1 COPYRIGHT
+
+Copyright (C) Lucas Smith. All Rights Reserved.
+
+This module is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
+=cut

Added: trunk/Catalyst-View-TT-Bootstrap/lib/Catalyst/Helper/View/TT/Bootstrap.pm
===================================================================
--- trunk/Catalyst-View-TT-Bootstrap/lib/Catalyst/Helper/View/TT/Bootstrap.pm	                        (rev 0)
+++ trunk/Catalyst-View-TT-Bootstrap/lib/Catalyst/Helper/View/TT/Bootstrap.pm	2007-09-08 00:54:07 UTC (rev 6861)
@@ -0,0 +1,574 @@
+package Catalyst::Helper::View::TT::Bootstrap;
+
+use strict;
+use Path::Class;
+
+sub mk_compclass {
+    my ( $self, $helper, @args ) = @_;
+    my $file = $helper->{file};
+    $helper->render_file( 'compclass', $file );
+    $self->mk_templates( $helper, @args );
+}
+
+sub mk_templates {
+    my ( $self, $helper ) = @_;
+
+    # Build directory structure
+    # /{base}/root
+    my $root = dir( $helper->{base}, 'root' );
+    $helper->mk_dir($root);
+
+    # /{base}/root/static ./css ./css/images ./scripts ./images
+    my $static = dir( $root, 'static' );
+    $helper->mk_dir($static);
+    my $css = dir( $static, 'css' );
+    $helper->mk_dir($css);
+    $helper->mk_dir( dir( $css, 'images' ) );
+    $helper->mk_dir( dir( $static, 'images') );
+    $helper->mk_dir( dir( $static, 'scripts') );
+
+    # /{base}/root/site
+    my $site = dir( $root, 'site' );
+    $helper->mk_dir($site);
+
+    # /{base}/root/site/shared
+    my $shared = dir( $site, 'shared' );
+    $helper->mk_dir($shared);
+
+    # /{base}/root/site/layout
+    my $layout = dir( $site, 'layout' );
+    $helper->mk_dir($layout);
+
+    # /{base}/root/site/header, navigation, and footer
+    my $header = dir( $site, 'header' );
+    $helper->mk_dir($header);
+    my $nav = dir( $site, 'nav' );
+    $helper->mk_dir($nav);
+    my $footer = dir( $site, 'footer' );
+    $helper->mk_dir($footer);
+
+    # Render files
+    # /{base}/root/static/css files
+    $helper->render_file( "screen_css",      file( $css, 'screen.css' ) );
+    $helper->render_file( "nav_default_css", file( $css, 'nav_default.css' ) );
+
+    # /{base}/root/site files
+    $helper->render_file( "site_wrapper", file( $site, 'wrapper.tt' ) );
+    $helper->render_file( "site_html",    file( $site, 'html.tt' ) );
+
+    # /{base}/root/site/shared files
+    $helper->render_file( "shared_base",   file( $shared, 'base.tt' ) );
+
+    # /{base}/root/site/layout files
+    $helper->render_file( "layout_default",     file( $layout, 'default.tt' ) );
+    $helper->render_file( "layout_2columns",    file( $layout, '2columns.tt' ) );
+    $helper->render_file( "layout_2col_top",    file( $layout, '2col_top.tt' ) );
+    $helper->render_file( "layout_2col_bottom", file( $layout, '2col_bottom.tt' ) );
+
+    # /{base}/root/site/header, navigation, and footer files
+    $helper->render_file( "header_default", file( $header, 'default.tt' ) );
+    $helper->render_file( "nav_default",    file( $nav,    'default.tt' ) );
+    $helper->render_file( "footer_default", file( $footer, 'default.tt' ) );
+}
+
+=head1 NAME
+
+Catalyst::Helper::View::TT::Bootstrap - Helper for TT view. Creates the View/TT.pm and a template directory structure under MyApp/root containing templates, macros, and a base stylesheet to facilitate getting to the meat of building your app's pages sooner than later.
+
+=head1 SYNOPSIS
+
+# use the helper to create the view module and templates
+
+    $ script/myapp_create.pl view TT TT::Bootstrap
+
+# add something like the following to the page templates for your application
+ [%
+ page.layout = '2columns';  # use a 2 column layout
+ page.header = 'my_custom'; # will load root/site/header/my_custom.tt
+ page.footer = 'none';      # don't display a footer
+
+ # adds these <link rel="stylsheet"...> tags to the <head>
+ page.head.stylesheets.push('foo.css','bar.css');
+
+ # adds these <script> tags to the <head>
+ page.head.scripts.push('foo.js','bar.js');
+
+ # adds these <script> tags to the bottom of the <body> -- usually preferable
+ page.body.scripts.push('baz.js','poop.js');
+
+ # adds these classes to the <body> tag
+ page.body.classes.push('foo','bar');
+ %]
+ ...your content here...
+
+=head1 DESCRIPTION
+
+This helper module creates a TT View module.  It also creates a set of
+templates, macros, and a stylesheet to let you focus on the content of
+your apps pages sooner.
+
+The View/TT.pm module created is configured to work within the generated
+template structure.
+
+See L<Catalyst::Helper::View::TT::Bootstrap::Manual> for more details on
+available variables and macros, and how to work with the layouts.
+
+=head2 METHODS
+
+=head3 mk_compclass
+
+Generates the component class.
+
+=head3 mk_templates
+
+Generates the templates.
+
+=cut
+
+=head1 SEE ALSO
+
+L<Catalyst>, L<Catalyst::View::TT>, L<Catalyst::Helper>,
+L<Catalyst::Helper::View::TT>
+
+=head1 AUTHOR
+
+Lucas Smith <lsmith at lucas.e.smith@gmail.com>
+
+=head1 LICENSE
+
+This library is free software . You can redistribute it and/or modify
+it under the same terms as perl itself.
+
+=cut
+
+1;
+
+__DATA__
+
+__compclass__
+package [% class %];
+
+use strict;
+use base 'Catalyst::View::TT';
+
+__PACKAGE__->config({
+    PRE_PROCESS        => 'site/shared/base.tt',
+    WRAPPER            => 'site/wrapper.tt',
+    TEMPLATE_EXTENSION => '.tt',
+    TIMER              => 0,
+    static_root        => '/static',
+    static_build       => 0
+});
+
+sub template_vars {
+    my $self = shift;
+    return (
+        $self->NEXT::template_vars(@_),
+        static_root  => $self->{static_root},
+        static_build => $self->{static_build}
+    );
+}
+
+=head1 NAME
+
+[% class %] - Catalyst TT::Bootstrap View
+
+=head1 SYNOPSIS
+
+See L<[% app %]>
+
+=head1 DESCRIPTION
+
+Catalyst TT::Bootstrap View.
+
+=head1 AUTHOR
+
+[% author %]
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
+__shared_base__
+[%~ TAGS star %]
+[%~
+
+MACRO ref(var) BLOCK;
+    var_ref = "$var";
+    var_ref.match('^([A-Z]+)\\(0x[0-9a-f]+\\)$').0;
+END;
+
+# Wraps c.uri_for to point to static resources either inside the
+# /root/static structure or explicit URIs.  Assumes 
+MACRO static(res, versioned, query) BLOCK;
+    uri_params = query || {};
+    IF res.match('^https?://');
+        res;
+    ELSIF versioned && static_build;
+        uri_params.ver = uri_params.ver || static_build;
+        c.uri_for( static_root, res, uri_params );
+    ELSE;
+        c.uri_for( static_root, res );
+    END;
+END;
+
+# Set up the default stash structure for the page
+IF !page || !ref(page) == 'HASH';
+    page = {};
+END;
+DEFAULT page.title  = '[* app *]';
+DEFAULT page.layout = 'default';
+DEFAULT page.header = 'default';
+DEFAULT page.nav    = 'default';
+DEFAULT page.footer = 'default';
+DEFAULT page.head             = {};
+DEFAULT page.head.stylesheets = [];
+DEFAULT page.head.scripts     = [];
+DEFAULT page.body             = {};
+DEFAULT page.body.classes     = [];
+DEFAULT page.body.scripts     = [];
+DEFAULT page.content_class    = 'content';
+
+# Include global macros/vars/set up per implementation
+TRY; PROCESS site/global.tt; CATCH file; END;
+
+~%]
+__screen_css__
+/* Reset styles */
+body {
+    color: #000;
+    background:#FFF;
+}
+body,
+h1, h2, h3, h4, h5, h6,
+div, p, blockquote, code, pre, th, td,
+ol, ul, li, dl, dt, dd,
+form, fieldset, legend, input, textarea {
+    margin: 0;
+    padding: 0;
+}
+table {
+    border-collapse: collapse;
+    border-spacing: 0;
+}
+fieldset, img {
+    border:0;
+}
+strong, em, code, th, td {
+    font-style: normal;
+    font-weight: normal;
+}
+li {
+    list-style: none;
+}
+h1, h2, h3, h4, h5, h6 {
+    font-size: 100%;
+    font-weight: normal;
+}
+
+/* Layout style */
+.content {
+    width: 750px;
+    overflow: hidden;
+    margin-left: auto;
+    margin-right: auto;
+}
+.float_container {
+    overflow: hidden;
+}
+.main_column {
+    width: 425px;
+}
+.support_column {
+    width: 300px;
+}
+.column {
+    width: 365px;
+}
+
+/* Miscellaneous useful styles */
+.hide  { display: none !important }
+.left  { display: inline; float: left }
+.right { display: inline; float: right }
+.clear { clear: both }
+
+/* cursor styles */
+.clickable   { cursor: pointer; cursor: hand; }
+.unclickable { cursor: default !important; }
+.movable     { cursor: move; }
+__nav_default_css__
+/* Define the style for the default site navigation here */
+#nav {
+    width: 750px;
+    margin: 0 auto 1.2em;
+    border-bottom: 1px solid #4d3c4b;
+    overflow: hidden;
+}   
+#nav li {
+    float: left;
+    margin-right: -10px;
+}   
+#nav li a {
+    display: block;
+    background: url(../images/catalyst_logo.png) no-repeat right top;
+    padding-right: 25px;
+    color: #900;
+    font: bold small-caps 120% Trebuchet MS, Arial Black, Arial, sans-serif;
+}
+#nav li a span {
+    display: block;
+    background: url(../images/catalyst_logo.png) no-repeat -10px 0;
+    padding: 25px 0 .2em 15px;
+}
+#nav li.active a {
+    background-position: -10px 0;
+    padding: 0 0 0 15px;
+    color: #555;
+    text-decoration: none;
+}
+#nav li.active a span {
+    background-position: right top;
+    padding: 25px 25px .2em 0;
+}
+__site_wrapper__
+[%~ TAGS star ~%]
+[%~
+# Process the appropriate layout
+IF page.layout == 'partial';
+    content;
+ELSE;
+    IF page.layout == 'none';
+        content WRAPPER site/html.tt;
+    ELSE;
+        content WRAPPER site/html.tt + "site/layout/${page.layout}.tt";
+    END;
+END;
+~%]
+__site_html__
+[%~ TAGS star ~%]
+[% IF c.debug && debug_init.defined; $debug_init; END %]
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="[% page.language %]">
+ <head>
+  <title>[% page.title %]</title>
+  <meta http-equiv="Content-Language" content="[% page.language %]">
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+  <link rel="stylesheet" href="[% static( 'css/screen.css', 1 ) %]" media="screen"/>
+  <link rel="stylesheet" href="[% static( 'css/nav_' _ page.nav _ '.css' ) %]" media="screen"/>
+[%
+# Add all javascript refs in page.head.scripts (see page.body.scripts)
+page.head.scripts = page.head.scripts.unique;
+FOREACH script IN page.head.scripts;
+    NEXT UNLESS script;
+    script = script.match('^https?://') ?
+                    script :
+                    static('scripts/' _ script, 1); -%]
+    <script type="text/javascript" src="[% script %]"></script>
+[%
+END;
+
+# Add all stylesheet refs in page.head.stylesheets
+page.head.stylesheets = page.head.stylesheets.unique;
+FOREACH stylesheet IN page.head.stylesheets;
+    NEXT UNLESS stylesheet;
+    stylesheet = stylesheet.match('^https?://') ?
+                    stylesheet :
+                    static('css/' _ stylesheet, 1); -%]
+   <link rel="stylesheet" href="[% stylesheet %]" media="screen">
+[%
+END;
+%]
+ </head>
+ <!--[if !IE]> <-->
+ <body[% page.body.classes.size ?
+            ' class="' _ page.body.classes.unique.join(' ') _ '"' : '' %]>
+ <!--><![endif]-->
+ <!--[if IE 5]>
+ <body class="[% page.body.classes.join(' ') %] IE IE5">
+ <![endif]-->
+ <!--[if IE 6]>
+ <body class="[% page.body.classes.join(' ') %] IE IE6">
+ <![endif]-->
+ <!--[if IE 7]>
+ <body class="[% page.body.classes.join(' ') %] IE IE7">
+ <![endif]-->
+    [% # Drop in the header if appropriate
+    IF page.header && page.header != 'none';
+        PROCESS "site/header/${page.header}.tt";
+    END; %]
+    <div class="[% page.content_class %]">[% content %]</div>
+    [% # Drop in the footer if appropriate
+    IF page.footer && page.footer != 'none';
+        PROCESS "site/footer/${page.footer}.tt";
+    END;
+
+    # Add footer scripts
+    page.body.scripts = page.body.scripts.unique;
+    FOREACH script IN page.body.scripts;
+        NEXT UNLESS script;
+        script = script.match('^https?://') ?
+                        script :
+                        static('scripts/' _ script, undef, 1); -%]
+        <script type="text/javascript" src="[% script %]"></script>
+    [%
+    END;
+    %]
+ </body>
+</html>
+__layout_default__
+[%~ TAGS star ~%]
+[%~ 
+# Nothing fancy here.  Just dump the content
+content
+~%]
+__layout_2columns__
+[%~ TAGS star ~%]
+[%
+DEFAULT left_column_template  = 'left_column';
+DEFAULT left_column_class     = 'main_column';
+
+DEFAULT right_column_template = 'right_column';
+DEFAULT right_column_class    = 'support_column';
+
+DEFAULT content_column = 'left';
+
+DEFAULT column_wrapper_class  = page.content_class;
+column_wrapper_class = '' IF column_wrapper_class == 'none';
+~%]
+<div class="[% page.content_class %]">
+IF content_column == 'left' %]
+    <div class="left [% left_column_class %]">[% content %]</div>
+    <div class="right [% right_column_class %]">
+    [%~
+    TRY;
+        PROCESS $right_column_template;
+    CATCH file;
+        '<p>Error rendering right column</p>';
+        IF c.debug;
+            '<p>' _ file.info _ '</p>';
+        END;
+    END;
+    ~%]
+    </div>
+[%
+ELSE;
+~%]
+    <div class="left [% left_column_class %]">
+    [%~
+    TRY;
+        PROCESS $left_column_template;
+    CATCH file;
+        '<p>Error rendering left column</p>';
+        IF c.debug;
+            '<p>' _ file.info _ '</p>';
+        END;
+    END ~%]
+    </div>
+    <div class="right [% right_column_class %]">[% content %]</div>
+[%
+END
+%]
+__layout_2col_top__
+[%~ TAGS star ~%]
+[%
+DEFAULT left_column_template  = 'left_column';
+DEFAULT left_column_class     = 'column';
+DEFAULT right_column_template = 'right_column';
+DEFAULT right_column_class    = 'column';
+
+DEFAULT bottom_content_class  = page.content_class;
+bottom_content_class = '' IF bottom_content_class == 'none';
+
+DEFAULT column_wrapper_class  = bottom_content_class;
+column_wrapper_class = '' IF column_wrapper_class == 'none';
+~%]
+<div class="float_container [% column_wrapper_class %]">
+    <div class="left [% left_column_class %]">
+    [%~
+    TRY;
+        PROCESS $left_column_template;
+    CATCH file;
+        '<p>Error rendering left column</p>';
+        IF c.debug;
+            '<p>' _ file.info _ '</p>';
+        END;
+    END;
+    %]</div>
+    <div class="right [% right_column_class %]">
+    [%~
+    TRY;
+        PROCESS $right_column_template;
+    CATCH file;
+        '<p>Error rendering right column</p>';
+        IF c.debug;
+            '<p>' _ file.info _ '</p>';
+        END;
+    END;
+    %]</div>
+</div>
+<div class="[% bottom_content_class %]">[% content %]</div>
+__layout_2col_bottom__
+[%~ TAGS star ~%]
+[%
+DEFAULT left_column_template  = 'left_column';
+DEFAULT left_column_class     = 'column';
+
+DEFAULT right_column_template = 'right_column';
+DEFAULT right_column_class    = 'column';
+
+DEFAULT top_content_class     = page.content_class;
+top_content_class = '' IF top_content_class == 'none';
+
+DEFAULT column_wrapper_class  = top_content_class;
+column_wrapper_class = '' IF column_wrapper_class == 'none';
+~%]
+<div class="[% top_content_class %]">[% content %]</div>
+<div class="float_container [% column_wrapper_class %]">
+    <div class="left [% left_column_class %]">
+    [%~
+    TRY;
+        PROCESS $left_column_template;
+    CATCH file;
+        '<p>Error rendering left column</p>';
+        IF c.debug;
+            '<p>' _ file.info _ '</p>';
+        END;
+    END;
+    %]</div>
+    <div class="right [% right_column_class %]">
+    [%~
+    TRY;
+        PROCESS $right_column_template;
+    CATCH file;
+        '<p>Error rendering right column</p>';
+        IF c.debug;
+            '<p>' _ file.info _ '</p>';
+        END;
+    END;
+    %]</div>
+</div>
+__header_default__
+[%~ TAGS star ~%]
+<p>Your masthead here</p>
+
+[% # Include the navigation
+IF page.nav && page.nav != 'none';
+    PROCESS "site/nav/${page.nav}.tt";
+END;
+~%]
+__nav_default__
+[%~ TAGS star ~%]
+<ul id="nav">
+    <li class="active"><a href="#"><span>Nav 1</span></a></li>
+    <li><a href="#"><span>Nav 2</span></a></li>
+    <li><a href="#"><span>Nav 3</span></a></li>
+    <li><a href="#"><span>Nav 4</span></a></li>
+    <li><a href="#"><span>Nav 5</span></a></li>
+</ul>
+__footer_default__
+[%~ TAGS star ~%]
+<p>Your footer here</p>




More information about the Catalyst-commits mailing list