forked from rho_n/hpr_generator
Add baseurl feature
Allow an optional base url to be included in generation of html files.
This commit is contained in:
parent
cf554571c8
commit
536f7cce03
@ -116,6 +116,10 @@ sub main {
|
|||||||
if (exists($config{$parsed_arg{'page'}})) {
|
if (exists($config{$parsed_arg{'page'}})) {
|
||||||
my $page_config = $config{$parsed_arg{'page'}};
|
my $page_config = $config{$parsed_arg{'page'}};
|
||||||
$page_config->{'page'} = $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 ($page_config->{'multipage'} && $page_config->{'multipage'} eq 'true') {
|
||||||
if (scalar @{$parsed_arg{'ids'}} == 1) {
|
if (scalar @{$parsed_arg{'ids'}} == 1) {
|
||||||
@ -124,13 +128,12 @@ sub main {
|
|||||||
foreach my $id (@{$parsed_arg{'ids'}}) {
|
foreach my $id (@{$parsed_arg{'ids'}}) {
|
||||||
$page_config->{'id'} = $id;
|
$page_config->{'id'} = $id;
|
||||||
verbose ($verbose, "Generating page: $page_config->{'page'} with id: $id");
|
verbose ($verbose, "Generating page: $page_config->{'page'} with id: $id");
|
||||||
generate_page($tt, $config{root_template}{content}, \$page_config, $preview);
|
generate_page($tt, \$page_config, $preview);
|
||||||
print "$page_config->{'page'} $page_config->{'id'}\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
verbose ($verbose, "Generating page: $page_config->{'page'}");
|
verbose ($verbose, "Generating page: $page_config->{'page'}");
|
||||||
generate_page($tt, $config{root_template}{content}, \$page_config, $preview);
|
generate_page($tt, \$page_config, $preview);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -164,12 +167,12 @@ sub get_template_html (\%@) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub generate_page {
|
sub generate_page {
|
||||||
my ($tt, $root_template, $config, $preview) = @_;
|
my ($tt, $config, $preview) = @_;
|
||||||
my $html;
|
my $html;
|
||||||
if (!$preview) {
|
if (!$preview) {
|
||||||
$html = get_filename($$config);
|
$html = get_filename($$config);
|
||||||
}
|
}
|
||||||
$tt->process($root_template, $$config, $html)
|
$tt->process($$config->{root_template}, $$config, $html)
|
||||||
|| die $tt->error(), "\n";
|
|| die $tt->error(), "\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
5
site.cfg
5
site.cfg
@ -7,9 +7,12 @@ user:
|
|||||||
password:
|
password:
|
||||||
|
|
||||||
# Configure the root template page which pulls in the navigation and
|
# 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]
|
[root_template]
|
||||||
content: page.tpl.html
|
content: page.tpl.html
|
||||||
|
#baseurl: OPTIONAL [i.e. file://<full path to local website directory>]
|
||||||
|
|
||||||
# Configure the navigation menu and the content templates for each page
|
# Configure the navigation menu and the content templates for each page
|
||||||
# of the site:
|
# of the site:
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>Hacker Public Radio ~ The Technology Community Podcast</title>
|
<title>Hacker Public Radio ~ The Technology Community Podcast</title>
|
||||||
|
<!--% IF baseurl %-->
|
||||||
|
<base href="<!--% baseurl %-->">
|
||||||
|
<!--% END %-->
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta http-equiv="X-Clacks-Overhead" content="GNU Terry Pratchett" />
|
<meta http-equiv="X-Clacks-Overhead" content="GNU Terry Pratchett" />
|
||||||
<meta name="keywords" content="Technology, Tech News, Education, Training" />
|
<meta name="keywords" content="Technology, Tech News, Education, Training" />
|
||||||
|
Loading…
Reference in New Issue
Block a user