Changeset 793


Ignore:
Timestamp:
12/16/15 17:44:30 (9 years ago)
Author:
Kris Deugau
Message:

/trunk

Refine the template loading process to allow completely reskinning the
UI by replacing templates as convenient, to match the CSS override allowed
by referencing not-provided local.css. See #17, sort of.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/main.cgi

    r789 r793  
    7070
    7171# Set up some globals
    72 $ENV{HTML_TEMPLATE_ROOT} = $thingroot."templates";
    73 
    74 my $header = HTML::Template->new(filename => "header.tmpl");
    75 my $footer = HTML::Template->new(filename => "footer.tmpl");
    76 my $utilbar = HTML::Template->new(filename => "utilbar.tmpl", loop_context_vars => 1, global_vars => 1);
     72$ENV{HTML_TEMPLATE_ROOT} = $thingroot;
     73my @templatepath = [ "localtemplates", "templates" ];
     74
     75my $header = HTML::Template->new(filename => "header.tmpl", path => @templatepath);
     76my $footer = HTML::Template->new(filename => "footer.tmpl", path => @templatepath);
     77my $utilbar = HTML::Template->new(filename => "utilbar.tmpl", loop_context_vars => 1, global_vars => 1,
     78        path => @templatepath);
    7779
    7880print "Content-type: text/html\n\n";
     
    9698
    9799my $page;
    98 if (-e "$ENV{HTML_TEMPLATE_ROOT}/$webvar{action}.tmpl") {
    99   $page = HTML::Template->new(filename => "$webvar{action}.tmpl", loop_context_vars => 1, global_vars => 1);
     100if (-e "$ENV{HTML_TEMPLATE_ROOT}/templates/$webvar{action}.tmpl") {
     101  $page = HTML::Template->new(filename => "$webvar{action}.tmpl", loop_context_vars => 1, global_vars => 1,
     102        path => @templatepath);
    100103} else {
    101   $page = HTML::Template->new(filename => "dunno.tmpl");
     104  $page = HTML::Template->new(filename => "dunno.tmpl", die_on_bad_params => 0,
     105        path => @templatepath);
    102106}
    103107
     
    230234# remove the links a user is not allowed to click on.
    231235if ($aclerr) {
    232   $page = HTML::Template->new(filename => "aclerror.tmpl");
     236  $page = HTML::Template->new(filename => "aclerror.tmpl", path => @templatepath);
    233237  $page->param(ipdbfunc => $aclmsg{$aclerr});
    234238}
     
    272276    # Containers have a second line for the subblock metadata.
    273277    # We need to load an alternate template for this case.
    274     $page = HTML::Template->new(filename => "showsubs2.tmpl", loop_context_vars => 1, global_vars => 1);
     278    $page = HTML::Template->new(filename => "showsubs2.tmpl", loop_context_vars => 1, global_vars => 1,
     279        path => @templatepath);
    275280
    276281    $page->param(maydel => ($IPDBacl{$authuser} =~ /d/));
Note: See TracChangeset for help on using the changeset viewer.