From af810c88bc05f29620832e057573a34152b78154 Mon Sep 17 00:00:00 2001 From: Roan Horning Date: Sat, 7 Sep 2024 16:51:55 -0400 Subject: [PATCH 1/7] Add bash script to check Perl module dependencies --- utils/check-dependencies.sh | 73 +++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100755 utils/check-dependencies.sh diff --git a/utils/check-dependencies.sh b/utils/check-dependencies.sh new file mode 100755 index 0000000..970db90 --- /dev/null +++ b/utils/check-dependencies.sh @@ -0,0 +1,73 @@ +#!/bin/bash - +#=============================================================================== +# +# FILE: check-dependencies.sh +# +# USAGE: ./check-dependencies.sh +# +# DESCRIPTION: Check that Perl module dependencies for the hpr_generator +# are installed. +# +# OPTIONS: --- +# REQUIREMENTS: --- +# BUGS: --- +# NOTES: --- +# AUTHOR: Roan "Rho`n" Horning (roan.horning@gmail.com) +# ORGANIZATION: +# CREATED: 09/05/2024 09:55:00 PM +# REVISION: --- +#=============================================================================== + +set -o nounset # Treat unset variables as an error + +#--- FUNCTION ---------------------------------------------------------------- +# NAME: is_module_installed +# DESCRIPTION: Tests if the supplied module is found on the system +# PARAMETERS: Name of the denpendent Perl module +# RETURNS: 0 if not found, 1 if found +#------------------------------------------------------------------------------- +function is_module_installed { + HR="----------------------" + perl -e "use ${1} " + if [ $? -ne 0 ] + then + echo ${HR} + else + echo "Found module ${1}" + echo ${HR} + fi +} + +MODULES=( \ + "Getopt::Long" \ + "Pod::Usage" \ + "Config::Std" \ + "Template" \ + "Template::Plugin::File" \ + "Template::Plugin::DBI" \ + "Template::Plugin::HTML::Strip" \ + "DBI" \ + "Tie::DBI" \ + "DBD::SQLite" \ + "DBD::mysql" \ + "Date::Calc" \ + "Text::CSV_XS" \ +) + +echo "The following modules must be installed for the site-generator to function: " +for module in "${MODULES[@]}" +do + echo "* ${module}" +done +echo "When MySQL is used, the DBD:mysql module is required (otherwise it is optional)" +echo "When SQLite is used, then the DBD:SQLite module is required (otherwise it is optional)" + +echo "Scanning for modules ..." +echo "----------------------" + +for module in "${MODULES[@]}" +do + is_module_installed "${module}" +done + +echo "Finished scanning." From 4ae854f5e11674ae7b482450dd17afc515328bbf Mon Sep 17 00:00:00 2001 From: Roan Horning Date: Sun, 8 Sep 2024 09:01:17 -0400 Subject: [PATCH 2/7] Remove unused module import The dbi sqlite module is not directly used in the site-generator code. The module is called by template files. Removing it allows the main code to be database independent. --- site-generator | 1 - 1 file changed, 1 deletion(-) diff --git a/site-generator b/site-generator index 80fce08..e1ff3cb 100755 --- a/site-generator +++ b/site-generator @@ -122,7 +122,6 @@ use Text::CSV_XS; use HTML::Entities qw(encode_entities); use Date::Calc; use DBI; -use DBD::SQLite; use Tie::DBI; use Template; use Template::Plugin::Date; From 4e9f1457d5947ee13721821148fbefaebeef70e1 Mon Sep 17 00:00:00 2001 From: Roan Horning Date: Sun, 8 Sep 2024 09:05:34 -0400 Subject: [PATCH 3/7] Fix typos in module names --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 71bbf83..00fb5dd 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Static web page generator for the Hacker Public Radio website. - ``GRANT SELECT ON hpr_hpr.* TO 'hpr-generator'@'localhost';`` - ``GRANT EXECUTE ON `hpr_hpr`.* TO 'hpr-generator'@'localhost';`` * Install the needed Perl modules using preferred method (distribution packages, CPAN, etc.) - * GetOpt + * Getopt::Long * Pod::Usage * Config::Std * Template @@ -35,7 +35,7 @@ Static web page generator for the Hacker Public Radio website. * Template::Plugin::HTML::Strip * DBI * Tie::DBI - * DBD::SQLite or DBD:mysql + * DBD::SQLite or DBD::mysql * Date::Calc * Text::CSV_XS * HTML::Entities From 48b3c51bb3b5ea0271a9296535dc3856932e2759 Mon Sep 17 00:00:00 2001 From: Roan Horning Date: Sun, 8 Sep 2024 09:08:23 -0400 Subject: [PATCH 4/7] Update instructions for installing modules via CPAN --- GETTING_STARTED.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md index cb37d09..5a83297 100644 --- a/GETTING_STARTED.md +++ b/GETTING_STARTED.md @@ -41,8 +41,9 @@ apt install libconfig-std-perl \ ## Using CPAN to install the modules A cross platform method to install the needed modules is the Perl CPAN application. -Make sure both the [make](https://www.gnu.org/software/make/manual/make.html) -command and the [cpan](https://perldoc.perl.org/CPAN) command are available. +Make sure that the [gcc](https://www.gnu.org/software/gcc/), +[make](https://www.gnu.org/software/make/manual/make.html), +and [cpan](https://perldoc.perl.org/CPAN) commands are available. Install them using the operating system's package manager, or from source. Run commands: @@ -51,9 +52,11 @@ Run commands: cpan Config::Std cpan Template cpan Template::Plugin::DBI +cpan Template::Plugin::HTML::Strip cpan DBD::SQLite cpan Date::Calc cpan Tie::DBI +cpan Text:CSV_XS ``` # Create the HPR database From 0f57b99fbee06a78fc7b778465780b3727f25b48 Mon Sep 17 00:00:00 2001 From: Roan Horning Date: Sun, 8 Sep 2024 09:30:40 -0400 Subject: [PATCH 5/7] Add instructions for the dependency check script --- GETTING_STARTED.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md index 5a83297..de7614e 100644 --- a/GETTING_STARTED.md +++ b/GETTING_STARTED.md @@ -59,6 +59,16 @@ cpan Tie::DBI cpan Text:CSV_XS ``` +## Testing for Perl module dependencies + +A bash script is included in the utils directory that will list the Perl modules used by the site-generator and report whether the modules are installed on the current OS. + +It can be run from any directory. To run from the utils directory: + +``` +./check-dependencies.sh +``` + # Create the HPR database The hpr_generator relies on information from a database to generate many of the From c64ad492c8b5f81c64f0e2fa070a3622906429d6 Mon Sep 17 00:00:00 2001 From: Roan Horning Date: Sun, 8 Sep 2024 12:00:23 -0400 Subject: [PATCH 6/7] Limit correspondent page episode count to released episodes Fix for https://repo.anhonesthost.net/rho_n/hpr_generator/issues/188 --- templates/content-correspondent.tpl.html | 9 ++------- templates/queries-correspondent-mysql.tpl.html | 6 ++++++ templates/queries-correspondent-sqlite.tpl.html | 6 ++++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/templates/content-correspondent.tpl.html b/templates/content-correspondent.tpl.html index fc3d4d6..537fab4 100644 --- a/templates/content-correspondent.tpl.html +++ b/templates/content-correspondent.tpl.html @@ -3,15 +3,10 @@ - - + + diff --git a/templates/queries-correspondent-mysql.tpl.html b/templates/queries-correspondent-mysql.tpl.html index b676977..bdd7d4e 100644 --- a/templates/queries-correspondent-mysql.tpl.html +++ b/templates/queries-correspondent-mysql.tpl.html @@ -16,3 +16,9 @@ ORDER BY eps.id DESC ' %--> + diff --git a/templates/queries-correspondent-sqlite.tpl.html b/templates/queries-correspondent-sqlite.tpl.html index d2e1d41..3363afe 100644 --- a/templates/queries-correspondent-sqlite.tpl.html +++ b/templates/queries-correspondent-sqlite.tpl.html @@ -16,3 +16,9 @@ ORDER BY eps.id + 0 DESC ' %--> + From 3662ebd0aa6d5317bfb725904e62b52f0e41156a Mon Sep 17 00:00:00 2001 From: Roan Horning Date: Mon, 9 Sep 2024 21:36:36 -0400 Subject: [PATCH 7/7] Code formatting --- templates/queries-correspondent-mysql.tpl.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/templates/queries-correspondent-mysql.tpl.html b/templates/queries-correspondent-mysql.tpl.html index bdd7d4e..6f3de33 100644 --- a/templates/queries-correspondent-mysql.tpl.html +++ b/templates/queries-correspondent-mysql.tpl.html @@ -1,5 +1,5 @@