I145 Various bug fixes

site-generator: fixed an error in the POD documentation and added an
    example. Reformatted 'GetOptions' arguments. Fixed 'parse_page_arg'
    which started its returned array with an empty arrayref. Fixed code
    using this array which skipped this unwanted extra value. Fixed
    'get_ids_from_db' which turns a CSV list of shows into an array, but
    includes a blank element. Removed a few trailing spaces.

templates/content-correspondents.tpl.html: Capitalised "License". Added
    'order by h.host' to the internal query to get hosts sorted
    alphabetically.

templates/content-episode.tpl.html: Added a call to macro
    'zero_pad_left' to add leading zeroes to show number in the title.
    Added a call to 'FILTER html_para' when displaying comments (which
    are plain text). Added a test for whether the show being displayed
    is in the 20-show window before the current one to determine whether
    the short or long comment form is required. Added the code to
    generate the two form types depending on the earlier test.

templates/content-sitemap.tpl.html: Corrected the entry for "Show
    Comments" which contained an invalid URL.

templates/page.tpl.html: Grammar corrections in the '<head>' section.

templates/queries-episode-mysql.tpl.html: Adjusted the date tests in the
    CTE's which compare the episode date with today's date plus one day.
    Why add a day when the test is whether the episode date is less than
    or equal to the current one? Also, it seemed that MySQL/MariaDB
    might need to work with the UTC date rather than the local dat
    implied by 'NOW()'.

templates/queries-episode-sqlite.tpl.html: Similar adjustment to date
    tests in CTE's to the MySQL version. SQLite defaults to UTC however.

templates/queries-episodes-mysql.tpl.html: See above for notes about
    date tests and MySQL UTC dates. Same arguments here.

templates/queries-episodes-sqlite.tpl.html: Date test adjustment
    described above.

templates/queries-ids-episode-mysql.tpl.html: Removed the date test from
    the query so all episode numbers are returned. Added an 'order by'
    since the table can (could in the past) return numbers out of
    numerical sequence.

templates/queries-ids-episode-sqlite.tpl.html: Same change as for the
    MySQL version.

templates/queries-index-mysql.tpl.html: There are three queries here,
    returned as TT² variables. The one called 'query_latest_episodes'
    has been adjusted to use UTC and to avoid adding a day to the
    current date. The query called 'query_last_5_weeks_episodes' has
    been similarly adjusted.

templates/queries-index-sqlite.tpl.html: Changes for the same two
    queries, but just for the tests requiring today's date plus one day.

templates/rss-comments.tpl.xml: Grammar corrections in the
    '<channel><description>' section.

templates/rss.tpl.xml: Grammar corrections in various subsections of the
    '<channel>' section.

templates/shared-call_for_shows.tpl.html: Removed the "FTP server"
    message. Slight tidying.
This commit is contained in:
Dave Morriss 2023-07-23 17:03:27 +01:00
parent fb2b3ec6db
commit 3f766544ac
16 changed files with 86 additions and 54 deletions

View File

@ -8,13 +8,13 @@
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
-v, --verbose print extended progress information while generating pages
--help print this help message
-a, --all generate all pages defined in configuration file
-c, --configuration 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
-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
or the special I<ALL> (to generate all pages).
@ -30,6 +30,10 @@
Generate pages based on the same template:
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
This is a site generator for the Hacker Public Radio website based upon the Perl Templates Toolkit.
@ -115,12 +119,12 @@ sub main {
my $verbose;
my $quiet;
GetOptions(
'all' => \$all,
'all' => \$all,
'configuration=s' => \$configuration_path,
'list' => \&print_available_pages,
'preview' => \$preview,
'verbose' => \$verbose,
'quiet' => \$quiet,
'list' => \&print_available_pages,
'preview' => \$preview,
'verbose' => \$verbose,
'quiet' => \$quiet,
) or pod2usage(1);
pod2usage(1) unless @ARGV || $all;
my (@page_args) = @ARGV;
@ -179,8 +183,10 @@ sub main {
}
if ($page_config->{'multipage'} && $page_config->{'multipage'} eq 'true') {
if (scalar @{$parsed_arg{'ids'}} == 1) {
@{$parsed_arg{'ids'}} = get_ids_from_db($tt, \$page_config);
# 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);
}
foreach my $id (@{$parsed_arg{'ids'}}) {
$page_config->{'id'} = $id;
@ -252,7 +258,8 @@ sub parse_page_arg {
my ($page_arg) = @_;
# Split page name from page ids if available.
my ($page, $ids) = split(/=/, $page_arg);
my @ids = [];
#my @ids = [];
my @ids;
if(!$ids) {
$ids = "";
@ -287,8 +294,9 @@ sub get_ids_from_db {
$tt->process($id_template, $$config, \$selected_ids)
|| 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 {
@ -313,7 +321,7 @@ sub get_filename {
# Default naming if full filename configuration is not supplied.
if ($$config{'multipage'} && $$config{'multipage'} eq 'true') {
my $padded_index = sprintf("%04d", $$config{'id'});
$filename = "$base_path$$config{'page'}${padded_index}.html";
$filename = "$base_path$$config{'page'}${padded_index}.html";
}
else {
$filename = "$base_path$$config{'page'}.html";

View File

@ -8,14 +8,15 @@
<table class="hosts">
<th >Avatar</th>
<th >Name &amp; Host ID</th>
<th >license</th>
<th >License</th>
<th >Last Show</th>
<!--% FOREACH host IN DBI.query(
'select h.hostid, h.host, h.license, e.date,
h.local_image
from hosts as h
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">
<td><!--% get_avatar(host.hostid, host.host, host_cnt > 8) %--></td>

View File

@ -5,14 +5,14 @@
<!--% PROCESS 'shared-show-transcript.tpl.html' %-->
<!--% PROCESS "queries-episode-${constants.database}.tpl.html" %-->
<!--% 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) %-->
<!--% FOREACH episode IN episode_result %-->
<!--% in_window = ( episode.id > episode.latest || episode.id < ( episode.latest - 20 ) ? 0 : 1 ) %-->
<!--% episode_navigation = step_navigation(baseurl,episode) %-->
<article>
<header>
<h1>hpr<!--% episode.id %--> :: <!--% episode.title %--></h1>
<h1>hpr<!--% zero_pad_left(episode.id) %--> :: <!--% episode.title %--></h1>
<h3><!--% episode.summary %--></h3>
<p class="meta"><!--% episode_navigation %-->
</p>
@ -55,7 +55,7 @@ Subscribe to the comments <a href="<!--% absolute_path(baseurl) %-->comments.rss
<!--% FOREACH comment IN comments_result %-->
<h5 id="comment_<!--% comment.id %-->">Comment #<!--% comment_index %--> posted on <!--% comment.comment_timestamp %--> by <!--% comment.comment_author_name %--></h5>
<h4><!--% comment.comment_title %--></h4>
<!--% comment.comment_text %-->
<!--% comment.comment_text FILTER html_para %-->
<!--% comment_index = comment_index + 1 %-->
<!--% END %-->
@ -78,7 +78,7 @@ Subscribe to the comments <a href="<!--% absolute_path(baseurl) %-->comments.rss
</tr>
<tr>
<td>Title:</td>
<td><input required type="text" name="comment_title" size="50" maxlength="100" placeholder="What is your comment about ?"></td>
<td><input required type="text" name="comment_title" size="50" maxlength="100" placeholder="What is your comment about?"></td>
</tr>
<tr>
<td>Comment:</td>
@ -87,13 +87,41 @@ Subscribe to the comments <a href="<!--% absolute_path(baseurl) %-->comments.rss
<tr>
<td>Anti Spam Question:</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>
</tr>
</tr>
<!--% IF in_window %-->
<tr><td>
<input type="hidden" name="spammer" value="No">
<input type="hidden" name="hostid" value="<!--% episode.hostid %-->">
<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 %-->">
</td></tr>
</table>
<input type="submit" value="Next">
</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) %-->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="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>
<li><a href="<!--% absolute_path(baseurl) %-->search.html">Search</a> ← Search HPR</li>
</ul>

View File

@ -11,7 +11,7 @@
<meta http-equiv="X-Clacks-Overhead" content="GNU Terry Pratchett" />
<meta http-equiv="last-modified" content="<!--% format_feed_date(date.now) %-->">
<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">
<!-- Internal CSS -->
<style type="text/css">

View File

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

View File

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

View File

@ -9,7 +9,7 @@
FROM eps
INNER JOIN hosts ON eps.hostid = hosts.hostid
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'
%-->

View File

@ -9,7 +9,7 @@
FROM eps
INNER JOIN hosts ON eps.hostid = hosts.hostid
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'
%-->

View File

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

View File

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

View File

@ -37,7 +37,7 @@
INNER JOIN hosts ON eps.hostid = hosts.hostid
INNER JOIN miniseries ON eps.series = miniseries.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
LIMIT 10
'
@ -54,7 +54,7 @@
FROM eps
INNER JOIN hosts ON eps.hostid = hosts.hostid
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
LIMIT 30 OFFSET 10
'

View File

@ -37,7 +37,7 @@
INNER JOIN hosts ON eps.hostid = hosts.hostid
INNER JOIN miniseries ON eps.series = miniseries.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
LIMIT 10
'
@ -54,7 +54,7 @@
FROM eps
INNER JOIN hosts ON eps.hostid = hosts.hostid
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
LIMIT 30 OFFSET 10
'

View File

@ -6,7 +6,7 @@
<channel>
<title>Hacker Public Radio ~ Comment Feed</title>
<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>
<copyright>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) License</copyright>
<managingEditor>feedback.nospam@nospam.hackerpublicradio.org (HPR Feedback)</managingEditor>

View File

@ -8,8 +8,8 @@
<channel>
<title>Hacker Public Radio</title>
<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>
<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>
<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 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>
<itunes:category text="Technology">
<itunes:category text="Tech News"/>
@ -45,7 +45,7 @@
<width>144</width>
</image>
<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:image href="https://www.hackerpublicradio.org/images/hpr_feed_itunes.png"/>
<googleplay:category text="Technology"/>

View File

@ -4,7 +4,7 @@
<!--% result_call_for_shows = DBI.prepare(query_call_for_shows)
%-->
<!--% results_call_for_shows = result_call_for_shows.execute().get_all() %-->
<!--% IF results_call_for_shows.0.request_for_shows == 1 %-->
<!--% IF results_call_for_shows.0.request_for_shows == 1 %-->
<!--% USE date %-->
<article>
<header>
@ -12,7 +12,6 @@
</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>
<!-- <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>
<!--% END %-->
<!--% END %-->