Add baseurl feature
Allow an optional base url to be included in generation of html files.
This commit is contained in:
@@ -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";
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user