diff --git a/site-generator b/site-generator index 143e2de..6b1f8e2 100755 --- a/site-generator +++ b/site-generator @@ -116,7 +116,11 @@ sub main { if (exists($config{$parsed_arg{'page'}})) { my $page_config = $config{$parsed_arg{'page'}}; $page_config->{'page'} = $parsed_arg{'page'}; - + $page_config->{'root_template'} = $config{root_template}{content}; + if (exists $config{root_template}{baseurl}) { + $page_config->{'baseurl'} = $config{root_template}{baseurl}; + } + if ($page_config->{'multipage'} && $page_config->{'multipage'} eq 'true') { if (scalar @{$parsed_arg{'ids'}} == 1) { @{$parsed_arg{'ids'}} = get_ids_from_db($tt, \$page_config); @@ -124,13 +128,12 @@ sub main { foreach my $id (@{$parsed_arg{'ids'}}) { $page_config->{'id'} = $id; verbose ($verbose, "Generating page: $page_config->{'page'} with id: $id"); - generate_page($tt, $config{root_template}{content}, \$page_config, $preview); - print "$page_config->{'page'} $page_config->{'id'}\n"; + generate_page($tt, \$page_config, $preview); } } else { verbose ($verbose, "Generating page: $page_config->{'page'}"); - generate_page($tt, $config{root_template}{content}, \$page_config, $preview); + generate_page($tt, \$page_config, $preview); } } else { @@ -164,12 +167,12 @@ sub get_template_html (\%@) { } sub generate_page { - my ($tt, $root_template, $config, $preview) = @_; + my ($tt, $config, $preview) = @_; my $html; if (!$preview) { $html = get_filename($$config); } - $tt->process($root_template, $$config, $html) + $tt->process($$config->{root_template}, $$config, $html) || die $tt->error(), "\n"; } diff --git a/site.cfg b/site.cfg index 942825b..5518985 100644 --- a/site.cfg +++ b/site.cfg @@ -7,9 +7,12 @@ user: password: # Configure the root template page which pulls in the navigation and -# content templates used by each page. +# content templates used by each page. An optional baseurl property may +# be defined. This is useful when opening files directly from local +# filesystem to allow relative paths to work. [root_template] content: page.tpl.html +#baseurl: OPTIONAL [i.e. file://] # Configure the navigation menu and the content templates for each page # of the site: diff --git a/templates/page.tpl.html b/templates/page.tpl.html index 3de32a2..eb412d0 100644 --- a/templates/page.tpl.html +++ b/templates/page.tpl.html @@ -2,6 +2,9 @@ Hacker Public Radio ~ The Technology Community Podcast + + +