[Templates] Replacing ttree with make
Jonas Liljegren
jonas@liljegren.org
15 Nov 2002 15:37:00 +0100
Simon Wilcox <essuu@ourshack.com> writes:
> Does anyone have a sample makefile I could examine, or any advice
> for alternative approaches ?
This is a rather elaborate example that may spark id=E9as about a better
way to do it. :-)
Makefile :
---------------------------------------------------
quick:
chmod -R u+w public_html
ttree -r -f etc/ttree_html.rc
ttree -r -f etc/ttree_plain.rc
chmod -R a-w public_html
all:
chmod -R u+w public_html
ttree -r -a -f etc/ttree_html.rc
ttree -r -a -f etc/ttree_plain.rc
chmod -R a-w public_html
init:
tools/build_page.pl ttree_html.rc.tt > etc/ttree_html.rc
tools/build_page.pl ttree_plain.rc.tt > etc/ttree_plain.rc
chmod -R u+w public_html
rm -rf public_html
mkdir public_html
---------------------------------------------------
etc/ttree_html.rc.tt
---------------------------------------------------
[% PROCESS localconfig.tt %]
src =3D [% approot %]/dev
dest =3D [% approot %]/public_html
lib =3D [% approot %]/inc/html/sv
lib =3D [% approot %]/etc
perl5lib =3D [% ritframe %]/lib
perl5lib =3D [% approot %]/lib
ignore =3D \b(CVS|RCS)\b
copy =3D \.(gif|png|jpg)$
copy =3D \.(txt|cgi|pm|tt|ppt|pdf)$
copy =3D .htpasswd
accept =3D \.html$
plugin_base =3D Rit::Frame::Template::Plugin
pre_process =3D siteconfig.tt
pre_process =3D top_static.html
post_process=3D footer_static.html
eval_perl =3D 1
interpolate
post_chomp
pre_chomp
---------------------------------------------------
etc/ttree_plain.rc.tt
---------------------------------------------------
[% PROCESS localconfig.tt %]
src =3D [% approot %]/dev
dest =3D [% approot %]/public_html
lib =3D [% approot %]/etc
perl5lib =3D [% ritframe %]/lib
perl5lib =3D [% approot %]/lib
ignore =3D \b(CVS|RCS)\b
accept =3D \.css$
accept =3D ^\.htaccess$
plugin_base =3D Rit::Frame::Template::Plugin
pre_process =3D siteconfig.tt
eval_perl =3D 1
interpolate
trim
---------------------------------------------------
tools/build_page.pl
---------------------------------------------------
#!/usr/bin/perl -w
use strict;
use Template;
#use Cwd;
my $file =3D $ARGV[0] or die;
my $template =3D Template->
new({
INCLUDE_PATH =3D> [ "etc" ],
});
$template->process($file) or die $template->error();
---------------------------------------------------
etc/localconfig.tt
---------------------------------------------------
[%
approot =3D "/home/jonas/project/kores";
apphome =3D "/project/kores/public_html";
ritframe =3D "/home/jonas/project/ritframe";
%]
---------------------------------------------------
In a current project I have taken another step and replaced ttree with
somthing more suitable with the layout. One thing to think about is
how to build up a tree of components that will work with a combination
of precompiled pages, dynaic pages under mod_perl, pages for HTML or
text/plain and all this for multipple languages and website sections.
In part, I uses this tree layout:
inc/
|-- html
| |-- c
| | |-- admin
| | | `-- updated.tt
| | |-- clean
| | | `-- footer.tt
| | |-- footer.tt
| | |-- menu.tt
| | |-- title.tt
| | `-- top_menu.tt
| |-- en
| | |-- index.tt
| | |-- login.tt
| | |-- page_not_found.tt
| | |-- search_help.tt
| `-- sv
| |-- index.tt
| |-- login.tt
| |-- page_not_found.tt
| `-- search_help.tt
`-- plain
`-- sv
|-- visitor2info.tt
`-- visitor2lodging.tt
The thing above about rendering the configuration for ttree was about
the inability of ttree to handle relative directories. We are using
CVS and don't want to change the paths each time we update the file
from CVS.
--=20
/ Jonas - http://jonas.liljegren.org/myself/en/index.html