forked from rho_n/hpr_generator
Merge pull request '[I92] paramertize paths for configuration, templates, and HTML files' (#93) from I92-templates_and_output_directory_options into main
Reviewed-on: rho_n/hpr_generator#93
This commit is contained in:
commit
8783ca5099
@ -8,12 +8,13 @@
|
|||||||
|
|
||||||
site-generator [OPTION]... PAGE|PAGE=<comma separated list of ids>...
|
site-generator [OPTION]... PAGE|PAGE=<comma separated list of ids>...
|
||||||
|
|
||||||
-a, --all generate all pages defined in configuration file
|
-a, --all generate all pages defined in configuration file
|
||||||
-l, --list print list of configured pages
|
-c, --configure path to configuration file
|
||||||
-p, --preview print generated pages to standard out
|
-l, --list print list of configured pages
|
||||||
-q, --quiet suppress progress information while generating pages
|
-p, --preview print generated pages to standard out
|
||||||
-v, --verbose print extended progress information while generating pages
|
-q, --quiet suppress progress information while generating pages
|
||||||
--help print this help message
|
-v, --verbose print extended progress information while generating pages
|
||||||
|
--help print this help message
|
||||||
|
|
||||||
Where I<PAGE> is a file name of a web page
|
Where I<PAGE> is a file name of a web page
|
||||||
or the special I<ALL> (to generate all pages).
|
or the special I<ALL> (to generate all pages).
|
||||||
@ -109,15 +110,17 @@ sub main {
|
|||||||
|
|
||||||
# Argument parsing
|
# Argument parsing
|
||||||
my $all;
|
my $all;
|
||||||
|
my $configuration_path;
|
||||||
my $preview;
|
my $preview;
|
||||||
my $verbose;
|
my $verbose;
|
||||||
my $quiet;
|
my $quiet;
|
||||||
GetOptions(
|
GetOptions(
|
||||||
'all' => \$all,
|
'all' => \$all,
|
||||||
'list' => \&print_available_pages,
|
'configuration=s' => \$configuration_path,
|
||||||
'preview' => \$preview,
|
'list' => \&print_available_pages,
|
||||||
'verbose' => \$verbose,
|
'preview' => \$preview,
|
||||||
'quiet' => \$quiet,
|
'verbose' => \$verbose,
|
||||||
|
'quiet' => \$quiet,
|
||||||
) or pod2usage(1);
|
) or pod2usage(1);
|
||||||
pod2usage(1) unless @ARGV || $all;
|
pod2usage(1) unless @ARGV || $all;
|
||||||
my (@page_args) = @ARGV;
|
my (@page_args) = @ARGV;
|
||||||
@ -126,10 +129,21 @@ sub main {
|
|||||||
$verbose = 'quiet';
|
$verbose = 'quiet';
|
||||||
};
|
};
|
||||||
|
|
||||||
# Load config file
|
if (!$configuration_path) {
|
||||||
read_config "site.cfg" => my %config;
|
$configuration_path = "site.cfg";
|
||||||
|
}
|
||||||
|
|
||||||
my $tt = get_template_html($config{DBI});
|
my %config;
|
||||||
|
if ( -f $configuration_path ) {
|
||||||
|
# Load config file
|
||||||
|
read_config $configuration_path => %config;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print STDOUT "Could not read configuration file: $configuration_path\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $tt = get_template_html($config{DBI}, $config{app_paths});
|
||||||
|
|
||||||
# If command line option all is set, parse configuration file
|
# If command line option all is set, parse configuration file
|
||||||
# for all pages
|
# for all pages
|
||||||
@ -140,7 +154,7 @@ sub main {
|
|||||||
# from the generated list of pages.
|
# from the generated list of pages.
|
||||||
@page_args= grep { $_ ne 'DBI' } @page_args;
|
@page_args= grep { $_ ne 'DBI' } @page_args;
|
||||||
@page_args= grep { $_ ne 'root_template' } @page_args;
|
@page_args= grep { $_ ne 'root_template' } @page_args;
|
||||||
@page_args= grep { $_ ne 'media_hostname' } @page_args;
|
@page_args= grep { $_ ne 'app_paths' } @page_args;
|
||||||
|
|
||||||
};
|
};
|
||||||
foreach my $page_arg (@page_args) {
|
foreach my $page_arg (@page_args) {
|
||||||
@ -193,8 +207,8 @@ sub get_template_html (\%@) {
|
|||||||
# HTML comments to make the template file valid HTML.
|
# HTML comments to make the template file valid HTML.
|
||||||
#
|
#
|
||||||
return Template->new({
|
return Template->new({
|
||||||
INCLUDE_PATH => './templates',
|
INCLUDE_PATH => $_[1]{templates_path},
|
||||||
OUTPUT_PATH => './public_html',
|
OUTPUT_PATH => $_[1]{output_path},
|
||||||
EVAL_PERL => 1,
|
EVAL_PERL => 1,
|
||||||
START_TAG => '<!--%',
|
START_TAG => '<!--%',
|
||||||
END_TAG => '%-->',
|
END_TAG => '%-->',
|
||||||
|
5
site.cfg
5
site.cfg
@ -13,6 +13,11 @@
|
|||||||
#user: hpr-generator (Suggested user with read-only privileges)
|
#user: hpr-generator (Suggested user with read-only privileges)
|
||||||
#password: ********* (Password for user)
|
#password: ********* (Password for user)
|
||||||
|
|
||||||
|
# Configure the location of the templates and the generated HTML
|
||||||
|
[app_paths]
|
||||||
|
templates_path: ./templates
|
||||||
|
output_path: ./public_html
|
||||||
|
|
||||||
# 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. An optional baseurl property may
|
# content templates used by each page. An optional baseurl property may
|
||||||
# be defined. This is useful when opening files directly from local
|
# be defined. This is useful when opening files directly from local
|
||||||
|
Loading…
Reference in New Issue
Block a user