# Webroot & base dir
$conf->{'basePath'} = "/usr/local/www/cmstest";
# Template::Toolkit settings
$conf->{'tt_include_path'} = "$conf->{'basePath'}/Templates";
$conf->{'tt_compile_dir'} = "$conf->{'basePath'}/ttwork";
$conf->{'tt_cache_size'} = "20";
$conf->{'tt_output_path'} = "$conf->{'basePath'}/website/";
# Default Template::Toolkit spec
$conf->{'defTemplateSpec'} = {
INCLUDE_PATH => $conf->{'tt_include_path'},
COMPILE_DIR => $conf->{'tt_compile_dir'},
CACHE_SIZE => $conf->{'tt_cache_size'},
POST_CHOMP => 2,
PRE_CHOMP => 2,
TRIM => true
};
####
my $templateSpec = $conf->{'defTemplateSpec'};
$templateSpec->{'OUTPUT_PATH'} = $conf->{'tt_output_path'};
####
my $nodeTemplate = Template->new($templateSpec);
$nodeTemplate->process( "node/" .$node->{$nodeId}->{'template'},
$vars, "$nodeId.html" )
|| push @errors, $nodeTemplate->error();
####
[% nodes.$node.data.textwidth = nodes.$node.data.width %]
[% USE gd = GD.Image(nodes.$node.data.width,nodes.$node.data.height); %]
[% gd.trueColor(1); %]
[% USE wrapbox = GD.Text.Wrap(gd,
line_space => 4,
text=> nodes.$node.data.text,
); %]
[% wrapbox.font_path(basePath _ "/Templates/fonts"); %]
[% wrapbox.set_font(nodes.$node.data.font,nodes.$node.data.tsize); %]
[% bounds = wrapbox.get_bounds(0,0) %]
[% nodes.$node.data.height = bounds.3 %]
[% xpos = (nodes.$node.data.width - nodes.$node.data.textwidth) %]
[% IF xpos >0 %]
[% xpos = xpos / 2; %]
[% END %]
[% USE gd2 = GD.Image(nodes.$node.data.width,nodes.$node.data.height); %]
[% gd2.trueColor(1); %]
[% bgcol = gd2.colorAllocate(nodes.$node.data.bgcol.r, nodes.$node.data.bgcol.g, nodes.$node.data.bgcol.b); %]
[% gd2.fill(1,1,bgcol); %]
[% IF nodes.$node.data.trans == "1" %]
[% gd2.transparent(bgcol); %]
[% END %]
[% fgcol = gd2.colorAllocate(nodes.$node.data.fgcol.r,nodes.$node.data.fgcol.g,nodes.$node.data.fgcol.b); %]
[% USE wrapbox2 = GD.Text.Wrap(gd2,
line_space => 4,
color => fgcol,
text=> nodes.$node.data.text,
); %]
[% wrapbox2.font_path(basePath _ "/Templates/fonts"); %]
[% wrapbox2.set_font(nodes.$node.data.font,nodes.$node.data.tsize); %]
[% wrapbox2.set(align => 'left', width => nodes.$node.data.textwidth); %]
[% wrapbox2.draw(xpos, 0); %]
[% gd2.png | stdout(1); %]