Changeset 142


Ignore:
Timestamp:
May 12, 2003, 1:17:02 AM (19 years ago)
Author:
kake
Message:

Made a start at pulling the Template Toolkit stuff out into a module

Location:
trunk
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Changes

    r141 r142  
     10.10   
     2        Added OpenGuides::Diff to provide nice diff output between
     3        node versions.
     4
     5        Added OpenGuides::Template to handle Template Toolkit stuff in a
     6        more testable and reusable way than just bunging it in wiki.cgi
     7
    180.09    10 May 2003
    29        Added OpenGuides::UK::PubCrawl and pubcrawl.cgi as a start at a
  • trunk/MANIFEST

    r141 r142  
    1010lib/OpenGuides/Diff.pm
    1111lib/OpenGuides/RDF.pm
     12lib/OpenGuides/Template.pm
    1213lib/OpenGuides/UK/PubCrawl.pm
    1314lib/OpenGuides/Utils.pm
     
    3839t/01_add_test_data.t
    3940t/11_utils.t
     41t/15_template.t
    4042t/21_rdf.t
    4143t/21_wiki.conf
    4244t/22_rss_modwiki.t
    4345t/41_pubcrawl.t
     46t/templates/15_test.tt
    4447wiki.cgi
  • trunk/lib/OpenGuides.pm

    r141 r142  
    44use vars qw( $VERSION );
    55
    6 $VERSION = '0.09';
     6$VERSION = '0.10';
    77
    88=head1 NAME
  • trunk/t/21_wiki.conf

    r141 r142  
    44default_country = United Kingdom
    55default_city = London
    6 
     6contact_email = wiki@example.com
     7stylesheet_url = http://wiki.example.com/styles.css
     8home_name = Home Page
  • trunk/wiki.cgi

    r141 r142  
    66
    77use vars qw( $VERSION );
    8 $VERSION = '0.09';
     8$VERSION = '0.10';
    99
    1010use CGI qw/:standard/;
     
    2222use OpenGuides::Utils;
    2323use OpenGuides::Diff qw(display_node_diff);
    24 use Template;
     24use OpenGuides::Template;
    2525use Time::Piece;
    2626use URI::Escape;
     
    550550    my ($template, $node, $vars, $conf, $omit_header) = @_;
    551551
    552     $vars ||= {};
    553     $conf ||= {};
    554 
    555     my %tt_vars = ( %$vars,
    556                     site_name     => $config->{_}->{site_name},
    557                     cgi_url       => $script_name,
    558                     full_cgi_url  => $script_url . $script_name,
    559                     contact_email => $contact_email,
    560                     description   => "",
    561                     keywords      => "",
    562                     stylesheet    => $config->{_}->{stylesheet_url},
    563                     home_link     => $script_name,
    564                     home_name     => $config->{_}->{home_name} );
    565 
     552    my %tt_vars = %{ $vars || {} };
    566553    if ($node) {
    567554        $tt_vars{node_name} = $q->escapeHTML($node);
     
    569556    }
    570557
    571     my %tt_conf = ( %$conf,
    572                 INCLUDE_PATH => $config->{_}->{template_path} );
    573 
    574     # Create Template object, print CGI header, process template.
    575     my $tt = Template->new(\%tt_conf);
    576     print $q->header unless $omit_header;
    577     unless ($tt->process($template, \%tt_vars)) {
    578         print qq(<html><head><title>ERROR</title></head><body><p>
    579                  Failed to process template: )
    580           . $tt->error
    581           . qq(</p></body></html>);
    582     }
     558    my %output_conf = ( wiki   => $wiki,
     559                        config => $config,
     560                        template => $template,
     561                        vars   => \%tt_vars
     562    );
     563    $output_conf{content_type} = "" if $omit_header; # defaults otherwise
     564    print OpenGuides::Template->output( %output_conf );
    583565}
    584566
Note: See TracChangeset for help on using the changeset viewer.