Merge pull request 'I145 Various bug fixes' (#146) from I145_Various_bug_fixes into main

Reviewed-on: rho_n/hpr_generator#146
This commit is contained in:
Ken Fallon 2023-07-23 18:45:38 +00:00
commit d7d94b1ba7
16 changed files with 86 additions and 54 deletions

View File

@ -9,7 +9,7 @@
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
-c, --configure path to configuration file -c, --configuration path to configuration file
-l, --list print list of configured pages -l, --list print list of configured pages
-p, --preview print generated pages to standard out -p, --preview print generated pages to standard out
-q, --quiet suppress progress information while generating pages -q, --quiet suppress progress information while generating pages
@ -30,6 +30,10 @@
Generate pages based on the same template: Generate pages based on the same template:
site-generator correspondent=1,3,5..10 site-generator correspondent=1,3,5..10
Generate two specific pages with a different configuration:
site-generator --configuration=site_sqlite.cfg index about
=head1 DESCRIPTION =head1 DESCRIPTION
This is a site generator for the Hacker Public Radio website based upon the Perl Templates Toolkit. This is a site generator for the Hacker Public Radio website based upon the Perl Templates Toolkit.
@ -179,7 +183,9 @@ sub main {
} }
if ($page_config->{'multipage'} && $page_config->{'multipage'} eq 'true') { if ($page_config->{'multipage'} && $page_config->{'multipage'} eq 'true') {
if (scalar @{$parsed_arg{'ids'}} == 1) { # Empty arrayref bug fixed, so count is reduced by 1
# if (scalar @{$parsed_arg{'ids'}} == 1) {
if (scalar @{$parsed_arg{'ids'}} == 0) {
@{$parsed_arg{'ids'}} = get_ids_from_db($tt, \$page_config); @{$parsed_arg{'ids'}} = get_ids_from_db($tt, \$page_config);
} }
foreach my $id (@{$parsed_arg{'ids'}}) { foreach my $id (@{$parsed_arg{'ids'}}) {
@ -252,7 +258,8 @@ sub parse_page_arg {
my ($page_arg) = @_; my ($page_arg) = @_;
# Split page name from page ids if available. # Split page name from page ids if available.
my ($page, $ids) = split(/=/, $page_arg); my ($page, $ids) = split(/=/, $page_arg);
my @ids = []; #my @ids = [];
my @ids;
if(!$ids) { if(!$ids) {
$ids = ""; $ids = "";
@ -288,7 +295,8 @@ sub get_ids_from_db {
$tt->process($id_template, $$config, \$selected_ids) $tt->process($id_template, $$config, \$selected_ids)
|| die $tt->error(), "\n"; || die $tt->error(), "\n";
return split(/,/, substr($selected_ids, 1)); # Starts with a newline and comma
return split(/,/, substr($selected_ids, 2));
} }
sub get_filename { sub get_filename {

View File

@ -8,14 +8,15 @@
<table class="hosts"> <table class="hosts">
<th >Avatar</th> <th >Avatar</th>
<th >Name &amp; Host ID</th> <th >Name &amp; Host ID</th>
<th >license</th> <th >License</th>
<th >Last Show</th> <th >Last Show</th>
<!--% FOREACH host IN DBI.query( <!--% FOREACH host IN DBI.query(
'select h.hostid, h.host, h.license, e.date, 'select h.hostid, h.host, h.license, e.date,
h.local_image h.local_image
from hosts as h from hosts as h
inner join (select hostid, max(date) as date from eps group by hostid) as e inner join (select hostid, max(date) as date from eps group by hostid) as e
on h.hostid = e.hostid ' on h.hostid = e.hostid
order by h.host'
) %--> ) %-->
<tr height="80"> <tr height="80">
<td><!--% get_avatar(host.hostid, host.host, host_cnt > 8) %--></td> <td><!--% get_avatar(host.hostid, host.host, host_cnt > 8) %--></td>

View File

@ -5,14 +5,14 @@
<!--% PROCESS 'shared-show-transcript.tpl.html' %--> <!--% PROCESS 'shared-show-transcript.tpl.html' %-->
<!--% PROCESS "queries-episode-${constants.database}.tpl.html" %--> <!--% PROCESS "queries-episode-${constants.database}.tpl.html" %-->
<!--% USE DBI(constants.driver, constants.user, constants.password) %--> <!--% USE DBI(constants.driver, constants.user, constants.password) %-->
<!--% query_episodes = DBI.prepare(query_episode_maxmin) <!--% query_episodes = DBI.prepare(query_episode_maxmin) %-->
%-->
<!--% episode_result = query_episodes.execute(id, id, id, id, id) %--> <!--% episode_result = query_episodes.execute(id, id, id, id, id) %-->
<!--% FOREACH episode IN episode_result %--> <!--% FOREACH episode IN episode_result %-->
<!--% in_window = ( episode.id > episode.latest || episode.id < ( episode.latest - 20 ) ? 0 : 1 ) %-->
<!--% episode_navigation = step_navigation(baseurl,episode) %--> <!--% episode_navigation = step_navigation(baseurl,episode) %-->
<article> <article>
<header> <header>
<h1>hpr<!--% episode.id %--> :: <!--% episode.title %--></h1> <h1>hpr<!--% zero_pad_left(episode.id) %--> :: <!--% episode.title %--></h1>
<h3><!--% episode.summary %--></h3> <h3><!--% episode.summary %--></h3>
<p class="meta"><!--% episode_navigation %--> <p class="meta"><!--% episode_navigation %-->
</p> </p>
@ -55,7 +55,7 @@ Subscribe to the comments <a href="<!--% absolute_path(baseurl) %-->comments.rss
<!--% FOREACH comment IN comments_result %--> <!--% FOREACH comment IN comments_result %-->
<h5 id="comment_<!--% comment.id %-->">Comment #<!--% comment_index %--> posted on <!--% comment.comment_timestamp %--> by <!--% comment.comment_author_name %--></h5> <h5 id="comment_<!--% comment.id %-->">Comment #<!--% comment_index %--> posted on <!--% comment.comment_timestamp %--> by <!--% comment.comment_author_name %--></h5>
<h4><!--% comment.comment_title %--></h4> <h4><!--% comment.comment_title %--></h4>
<!--% comment.comment_text %--> <!--% comment.comment_text FILTER html_para %-->
<!--% comment_index = comment_index + 1 %--> <!--% comment_index = comment_index + 1 %-->
<!--% END %--> <!--% END %-->
@ -87,13 +87,41 @@ Subscribe to the comments <a href="<!--% absolute_path(baseurl) %-->comments.rss
<tr> <tr>
<td>Anti Spam Question:</td> <td>Anti Spam Question:</td>
<td> <td>
What does the <strong>P</strong> in <em>HPR</em> stand for ? <br /> What does the letter<strong>P</strong> in <em>HPR</em> stand for? <br />
<input required type="text" name="anti_spam_question" size="50" maxlength="100" placeholder="Type out what the P in HPR stands for."></td> <input required type="text" name="anti_spam_question" size="50" maxlength="100" placeholder="Type out what the P in HPR stands for."></td>
</tr> </tr>
<!--% IF in_window %-->
<tr><td>
<input type="hidden" name="spammer" value="No"> <input type="hidden" name="spammer" value="No">
<input type="hidden" name="hostid" value="<!--% episode.hostid %-->"> <input type="hidden" name="hostid" value="<!--% episode.hostid %-->">
<input type="hidden" name="justification" value="No justification is asked for or required."> <input type="hidden" name="justification" value="No justification is asked for or required.">
</td></tr>
<!--% ELSE %-->
<!-- . -->
<tr>
<td>Are you a spammer?</td>
<td>
<input required checked="checked" type="radio" name="spammer" id="spammer_yes" value="Yes">
<label for="spammer_yes">Yes</label>
<input required type="radio" name="spammer" id="spammer_no" value="No">
<label for="spammer_no">No</label>
</td>
</tr>
<!-- . -->
<tr>
<td>Who hosted this show?</td>
<td>
<input required type="text" name="hostid" size="20" maxlength="5" placeholder="Type the host number"></td>
<td>
<!-- . -->
<tr>
<td>What does HPR mean to you?</td>
<td><textarea required name="justification" maxlength="200" rows="4" cols="50" placeholder="Convince us you are part of the community."></textarea></td>
</tr>
<!--% END %-->
<tr><td>
<input type="hidden" name="eps_id" value="<!--% episode.id %-->"> <input type="hidden" name="eps_id" value="<!--% episode.id %-->">
</td></tr>
</table> </table>
<input type="submit" value="Next"> <input type="submit" value="Next">
</fieldset> </fieldset>

View File

@ -27,7 +27,7 @@
<li><a href="<!--% absolute_path(baseurl) %-->correspondents/index.html">Hosts</a> ← A list of all our Hosts.</li> <li><a href="<!--% absolute_path(baseurl) %-->correspondents/index.html">Hosts</a> ← A list of all our Hosts.</li>
<li><a href="<!--% absolute_path(baseurl) %-->contact.html">Contact</a> ← How to get in touch with us.</li> <li><a href="<!--% absolute_path(baseurl) %-->contact.html">Contact</a> ← How to get in touch with us.</li>
<li><a href="<!--% absolute_path(baseurl) %-->promote.html">Promote HPR</a> ← Ways you can spread the word.</li> <li><a href="<!--% absolute_path(baseurl) %-->promote.html">Promote HPR</a> ← Ways you can spread the word.</li>
<li><a href="https://www.hackerpublicradio.org/comments_viewer.php">Show Comments</a> ← Read the latest comments left on shows.</li> <li><a href="<!--% absolute_path(baseurl) %-->comments_viewer.html">Show Comments</a> ← Read the latest comments left on shows.</li>
</ul> </ul>
<li><a href="<!--% absolute_path(baseurl) %-->search.html">Search</a> ← Search HPR</li> <li><a href="<!--% absolute_path(baseurl) %-->search.html">Search</a> ← Search HPR</li>
</ul> </ul>

View File

@ -11,7 +11,7 @@
<meta http-equiv="X-Clacks-Overhead" content="GNU Terry Pratchett" /> <meta http-equiv="X-Clacks-Overhead" content="GNU Terry Pratchett" />
<meta http-equiv="last-modified" content="<!--% format_feed_date(date.now) %-->"> <meta http-equiv="last-modified" content="<!--% format_feed_date(date.now) %-->">
<meta name="keywords" content="Technology, Tech News, Education, Training" /> <meta name="keywords" content="Technology, Tech News, Education, Training" />
<meta name="description" content="Hacker Public Radio is an podcast that releases shows every weekday Monday through Friday. Our shows are produced by the community (you) and can be on any topic that are of interest to hackers and hobbyists." /> <meta name="description" content="Hacker Public Radio is a podcast that releases shows every weekday Monday through Friday. Our shows are produced by the community (you) and can be on any topic that is of interest to hackers and hobbyists." />
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Internal CSS --> <!-- Internal CSS -->
<style type="text/css"> <style type="text/css">

View File

@ -2,7 +2,7 @@
WITH episode_maxmin AS ( WITH episode_maxmin AS (
SELECT MAX(id) AS \'latest\', MIN(id) AS \'earliest\', ? AS \'id\' SELECT MAX(id) AS \'latest\', MIN(id) AS \'earliest\', ? AS \'id\'
FROM eps FROM eps
WHERE eps.date < DATE_ADD(NOW(), INTERVAL 1 DAY) WHERE eps.date <= UTC_DATE()
), ),
episode_date AS ( episode_date AS (
SELECT eps.date SELECT eps.date
@ -21,7 +21,7 @@
FROM eps FROM eps
INNER JOIN episode_date INNER JOIN episode_date
ON eps.date > episode_date.date ON eps.date > episode_date.date
WHERE eps.date < NOW() WHERE eps.date <= NOW()
), ),
comment_tallies AS ( comment_tallies AS (
SELECT SELECT

View File

@ -2,7 +2,7 @@
WITH episode_maxmin AS ( WITH episode_maxmin AS (
SELECT MAX(id) AS \'latest\', MIN(id) AS \'earliest\', ? AS \'id\' SELECT MAX(id) AS \'latest\', MIN(id) AS \'earliest\', ? AS \'id\'
FROM eps FROM eps
WHERE eps.date < date(\'now\', \'+1 days\') WHERE eps.date <= date(\'now\')
), ),
episode_date AS ( episode_date AS (
SELECT eps.date SELECT eps.date

View File

@ -9,7 +9,7 @@
FROM eps FROM eps
INNER JOIN hosts ON eps.hostid = hosts.hostid INNER JOIN hosts ON eps.hostid = hosts.hostid
INNER JOIN miniseries ON eps.series = miniseries.id INNER JOIN miniseries ON eps.series = miniseries.id
WHERE eps.date < DATE_ADD(NOW(), INTERVAL 1 DAY) WHERE eps.date <= UTC_DATE()
ORDER BY eps.id DESC' ORDER BY eps.id DESC'
%--> %-->

View File

@ -9,7 +9,7 @@
FROM eps FROM eps
INNER JOIN hosts ON eps.hostid = hosts.hostid INNER JOIN hosts ON eps.hostid = hosts.hostid
INNER JOIN miniseries ON eps.series = miniseries.id INNER JOIN miniseries ON eps.series = miniseries.id
WHERE eps.date < date(\'now\', \'+1 days\') WHERE eps.date <= date(\'now\')
ORDER BY eps.id + 0 DESC' ORDER BY eps.id + 0 DESC'
%--> %-->

View File

@ -1,4 +1,2 @@
<!--% query_ids_episode = 'select eps.id from eps <!--% query_ids_episode = 'select eps.id from eps order by eps.id' %-->
where eps.date < DATE_ADD(NOW(), INTERVAL 1 DAY) '
%-->

View File

@ -1,4 +1,2 @@
<!--% query_ids_episode = 'select eps.id from eps <!--% query_ids_episode = 'select eps.id from eps order by eps.id' %-->
where eps.date < date(\'now\', \'+1 days\')'
%-->

View File

@ -37,7 +37,7 @@
INNER JOIN hosts ON eps.hostid = hosts.hostid INNER JOIN hosts ON eps.hostid = hosts.hostid
INNER JOIN miniseries ON eps.series = miniseries.id INNER JOIN miniseries ON eps.series = miniseries.id
LEFT JOIN comment_tallies ON eps.id = comment_tallies.eps_id LEFT JOIN comment_tallies ON eps.id = comment_tallies.eps_id
WHERE eps.date < DATE_ADD(NOW(), INTERVAL 1 DAY) WHERE eps.date <= UTC_DATE()
ORDER BY eps.id DESC ORDER BY eps.id DESC
LIMIT 10 LIMIT 10
' '
@ -54,7 +54,7 @@
FROM eps FROM eps
INNER JOIN hosts ON eps.hostid = hosts.hostid INNER JOIN hosts ON eps.hostid = hosts.hostid
INNER JOIN miniseries ON eps.series = miniseries.id INNER JOIN miniseries ON eps.series = miniseries.id
WHERE eps.date < DATE_ADD(NOW(), INTERVAL 1 DAY) WHERE eps.date <= UTC_DATE()
ORDER BY eps.id DESC ORDER BY eps.id DESC
LIMIT 30 OFFSET 10 LIMIT 30 OFFSET 10
' '

View File

@ -37,7 +37,7 @@
INNER JOIN hosts ON eps.hostid = hosts.hostid INNER JOIN hosts ON eps.hostid = hosts.hostid
INNER JOIN miniseries ON eps.series = miniseries.id INNER JOIN miniseries ON eps.series = miniseries.id
LEFT JOIN comment_tallies ON eps.id = comment_tallies.eps_id LEFT JOIN comment_tallies ON eps.id = comment_tallies.eps_id
WHERE eps.date < date(\'now\', \'+1 days\') WHERE eps.date <= date(\'now\')
ORDER BY eps.id + 0 DESC ORDER BY eps.id + 0 DESC
LIMIT 10 LIMIT 10
' '
@ -54,7 +54,7 @@
FROM eps FROM eps
INNER JOIN hosts ON eps.hostid = hosts.hostid INNER JOIN hosts ON eps.hostid = hosts.hostid
INNER JOIN miniseries ON eps.series = miniseries.id INNER JOIN miniseries ON eps.series = miniseries.id
WHERE eps.date < date(\'now\', \'+1 days\') WHERE eps.date <= date(\'now\')
ORDER BY eps.id + 0 DESC ORDER BY eps.id + 0 DESC
LIMIT 30 OFFSET 10 LIMIT 30 OFFSET 10
' '

View File

@ -6,7 +6,7 @@
<channel> <channel>
<title>Hacker Public Radio ~ Comment Feed</title> <title>Hacker Public Radio ~ Comment Feed</title>
<link><!--% baseurl %-->about.html</link> <link><!--% baseurl %-->about.html</link>
<description>Comments Feed: Hacker Public Radio is an podcast that releases shows every weekday Monday through Friday. Our shows are produced by the community (you) and can be on any topic that are of interest to hackers and hobbyists.</description> <description>Comments Feed: Hacker Public Radio is a podcast that releases shows every weekday Monday through Friday. Our shows are produced by the community (you) and can be on any topic that is of interest to hackers and hobbyists.</description>
<language>en-us</language> <language>en-us</language>
<copyright>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) License</copyright> <copyright>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) License</copyright>
<managingEditor>feedback.nospam@nospam.hackerpublicradio.org (HPR Feedback)</managingEditor> <managingEditor>feedback.nospam@nospam.hackerpublicradio.org (HPR Feedback)</managingEditor>

View File

@ -8,8 +8,8 @@
<channel> <channel>
<title>Hacker Public Radio</title> <title>Hacker Public Radio</title>
<link>https://www.hackerpublicradio.org/about.html</link> <link>https://www.hackerpublicradio.org/about.html</link>
<itunes:subtitle>A daily show hosted the community on topics that are of interest to hackers and hobbyists.</itunes:subtitle> <itunes:subtitle>A daily show hosted by the community on topics that are of interest to hackers and hobbyists.</itunes:subtitle>
<description>Hacker Public Radio is an podcast that releases shows every weekday Monday through Friday. Our shows are produced by the community (you) and can be on any topic that are of interest to hackers and hobbyists.</description> <description>Hacker Public Radio is a podcast that releases shows every weekday Monday through Friday. Our shows are produced by the community (you) and can be on any topic that is of interest to hackers and hobbyists.</description>
<language>en-us</language> <language>en-us</language>
<itunes:category text="Technology"> <itunes:category text="Technology">
<itunes:category text="Tech News"/> <itunes:category text="Tech News"/>
@ -45,7 +45,7 @@
<width>144</width> <width>144</width>
</image> </image>
<googleplay:author>HPR Volunteer</googleplay:author> <googleplay:author>HPR Volunteer</googleplay:author>
<googleplay:description>Hacker Public Radio is an podcast that releases shows every weekday Monday through Friday. Our shows are produced by the community (you) and can be on any topic that are of interest to hackers and hobbyists.</googleplay:description> <googleplay:description>Hacker Public Radio is a podcast that releases shows every weekday Monday through Friday. Our shows are produced by the community (you) and can be on any topic that is of interest to hackers and hobbyists.</googleplay:description>
<googleplay:email>admin@hackerpublicradio.org</googleplay:email> <googleplay:email>admin@hackerpublicradio.org</googleplay:email>
<googleplay:image href="https://www.hackerpublicradio.org/images/hpr_feed_itunes.png"/> <googleplay:image href="https://www.hackerpublicradio.org/images/hpr_feed_itunes.png"/>
<googleplay:category text="Technology"/> <googleplay:category text="Technology"/>

View File

@ -12,7 +12,6 @@
</header> </header>
<p><strong><em>We are running very low on shows</em></strong> at the moment. Have a look at the <a href="<!--% absolute_path(baseurl) %-->correspondents/index.html">hosts</a> page and if you don't see "<!--% date.format(date.now, '%Y') %-->-??-??" next to your name, or if your name is not listed, you might consider sending us in something.</p> <p><strong><em>We are running very low on shows</em></strong> at the moment. Have a look at the <a href="<!--% absolute_path(baseurl) %-->correspondents/index.html">hosts</a> page and if you don't see "<!--% date.format(date.now, '%Y') %-->-??-??" next to your name, or if your name is not listed, you might consider sending us in something.</p>
<!-- <img src="/images/hprstats.png" alt="hpr queue showing an graph showing how few shows we have" /> --> <!-- <img src="/images/hprstats.png" alt="hpr queue showing an graph showing how few shows we have" /> -->
<p>There are no files to process on the FTP server.</p>
</article> </article>
<!--% END %--> <!--% END %-->
<!--% END %--> <!--% END %-->