Archived
4
2

Compare commits

...

3 Commits

Author SHA1 Message Date
Roan Horning
8783ca5099 Merge pull request '[I92] paramertize paths for configuration, templates, and HTML files' (#93) from I92-templates_and_output_directory_options into main
Reviewed-on: #93
2023-03-10 01:34:21 +00:00
f65e892182
Add template and HTML folder configuration options
Allow user to set the path for the website templates and
output folders in the site.cfg file.
2023-03-09 20:25:25 -05:00
14bafbc3ab
Add command line option for path to configuration file
Allow user to pass the path to the configuration file into the
site-generator.
2023-03-08 22:23:56 -05:00
2 changed files with 36 additions and 17 deletions

View File

@ -9,6 +9,7 @@
site-generator [OPTION]... PAGE|PAGE=<comma separated list of ids>...
-a, --all generate all pages defined in configuration file
-c, --configure path to configuration file
-l, --list print list of configured pages
-p, --preview print generated pages to standard out
-q, --quiet suppress progress information while generating pages
@ -109,11 +110,13 @@ sub main {
# Argument parsing
my $all;
my $configuration_path;
my $preview;
my $verbose;
my $quiet;
GetOptions(
'all' => \$all,
'configuration=s' => \$configuration_path,
'list' => \&print_available_pages,
'preview' => \$preview,
'verbose' => \$verbose,
@ -126,10 +129,21 @@ sub main {
$verbose = 'quiet';
};
# Load config file
read_config "site.cfg" => my %config;
if (!$configuration_path) {
$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
# for all pages
@ -140,7 +154,7 @@ sub main {
# from the generated list of pages.
@page_args= grep { $_ ne 'DBI' } @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) {
@ -193,8 +207,8 @@ sub get_template_html (\%@) {
# HTML comments to make the template file valid HTML.
#
return Template->new({
INCLUDE_PATH => './templates',
OUTPUT_PATH => './public_html',
INCLUDE_PATH => $_[1]{templates_path},
OUTPUT_PATH => $_[1]{output_path},
EVAL_PERL => 1,
START_TAG => '<!--%',
END_TAG => '%-->',

View File

@ -13,6 +13,11 @@
#user: hpr-generator (Suggested user with read-only privileges)
#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
# content templates used by each page. An optional baseurl property may
# be defined. This is useful when opening files directly from local