Archived
4
2

Setting up static RSS feeds

site-generator: Changed the routine used to generate entities in
    'HTML::Entities'; see filter function 'xml_entity'

site.cfg: Added root variable 'http_baseurl' which defines the base URL
    using 'http'

templates/rss.tpl.xml: RSS template defining the channel and inserting
    the 'item' definitions; adjusted to be in step with the PHP version.

templates/shared-item.tpl.xml: RSS template used for each 'item' in an
    RSS feed; contains a call to 'HTML::Strip' which turns off the
    addition of spaces when removing tags; adjusted to be in step with
    the PHP version.

templates/shared-utils.tpl.html: Macro collection used by other
    templates; addition of temporay macro 'display_explicit_feed_2'
    which generates 'Yes/No' strings to be in step with the PHP version.
This commit is contained in:
Dave Morriss 2024-05-23 20:14:42 +01:00
parent a2c69ec898
commit ccba560ee3
5 changed files with 34 additions and 23 deletions

View File

@ -67,18 +67,21 @@ Perl Template Toolkit.
- GRANT EXECUTE 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.) Install the needed Perl modules using preferred method (distribution packages, CPAN, etc.)
* GetOpt
* Pod::Usage
* Config::Std * Config::Std
* Template
* Template::Plugin::File
* Template::Plugin::DBI
* Template::Plugin::HTML::Strip
* DBI
* Tie::DBI
* DBD::SQLite or DBD:mysql * DBD::SQLite or DBD:mysql
* DBI
* Data::Dumper
* Date::Calc * Date::Calc
* GetOpt::Long
* HTML::Entities
* Pod::Usage
* Template
* Template::Plugin::DBI
* Template::Plugin::Date
* Template::Plugin::File
* Template::Plugin::HTML::Strip
* Text::CSV_XS * Text::CSV_XS
* Tie::DBI
=head1 AUTHOR =head1 AUTHOR
@ -115,7 +118,8 @@ use Getopt::Long qw(:config auto_help);
use Pod::Usage; use Pod::Usage;
use Config::Std; use Config::Std;
use Text::CSV_XS; use Text::CSV_XS;
use HTML::Entities qw(encode_entities_numeric); #use HTML::Entities qw(encode_entities_numeric);
use HTML::Entities qw(encode_entities);
use Date::Calc; use Date::Calc;
use DBI; use DBI;
use DBD::SQLite; use DBD::SQLite;
@ -425,7 +429,8 @@ sub parse_csv {
sub xml_entity { sub xml_entity {
my ($text) = @_; my ($text) = @_;
encode_entities_numeric( $text ); # encode_entities_numeric( $text );
encode_entities( $text );
return $text; return $text;
} }

View File

@ -29,6 +29,7 @@ content: page.tpl.html
#baseurl: OPTIONAL [i.e. file://<full path to local website directory>] #baseurl: OPTIONAL [i.e. file://<full path to local website directory>]
#baseurl: file:///home/roan/Development/hpr/website/hpr_generator/public_html/ #baseurl: file:///home/roan/Development/hpr/website/hpr_generator/public_html/
baseurl: https://hackerpublicradio.org/ baseurl: https://hackerpublicradio.org/
http_baseurl: http://hackerpublicradio.org/
hub_baseurl: https://hub.hackerpublicradio.org/ hub_baseurl: https://hub.hackerpublicradio.org/
media_baseurl: https://archive.org/download/hpr$eps_id/ media_baseurl: https://archive.org/download/hpr$eps_id/
generator_name: The HPR Robot generator_name: The HPR Robot

View File

@ -2,8 +2,8 @@
<!--% PROCESS 'shared-utils.tpl.html' %--> <!--% PROCESS 'shared-utils.tpl.html' %-->
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" <rss version="2.0"
xmlns:googleplay="https://www.google.com/schemas/play-podcasts/1.0" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"
xmlns:atom="https://www.w3.org/2005/Atom" xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" > xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" >
<channel> <channel>
<title>Hacker Public Radio</title> <title>Hacker Public Radio</title>
@ -17,7 +17,7 @@
<itunes:category text="Education"> <itunes:category text="Education">
<itunes:category text="Training"/> <itunes:category text="Training"/>
</itunes:category> </itunes:category>
<itunes:image href="<!--% absolute_url(baseurl) %-->images/hpr_feed_itunes.png"/> <itunes:image href="<!--% absolute_url(http_baseurl) %-->images/hpr_feed_itunes.png"/>
<itunes:explicit>yes</itunes:explicit> <itunes:explicit>yes</itunes:explicit>
<itunes:author>Hacker Public Radio</itunes:author> <itunes:author>Hacker Public Radio</itunes:author>
<itunes:keywords>Community Radio, Tech Interviews, Linux, Open, Hobby, Software Freedom</itunes:keywords> <itunes:keywords>Community Radio, Tech Interviews, Linux, Open, Hobby, Software Freedom</itunes:keywords>
@ -30,7 +30,7 @@
</itunes:owner> </itunes:owner>
<webMaster>admin@hackerpublicradio.org (HPR Volunteer)</webMaster> <webMaster>admin@hackerpublicradio.org (HPR Volunteer)</webMaster>
<generator>site-generator</generator> <generator>site-generator</generator>
<docs>https://www.rssboard.org/rss-specification</docs> <docs>http://www.rssboard.org/rss-specification</docs>
<ttl>43200</ttl> <ttl>43200</ttl>
<skipDays> <skipDays>
<day>Saturday</day> <day>Saturday</day>
@ -47,9 +47,9 @@
<googleplay:author>HPR Volunteer</googleplay:author> <googleplay:author>HPR Volunteer</googleplay:author>
<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: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="<!--% absolute_url(baseurl) %-->images/hpr_feed_itunes.png"/> <googleplay:image href="<!--% absolute_url(http_baseurl) %-->images/hpr_feed_itunes.png"/>
<googleplay:category text="Technology"/> <googleplay:category text="Technology"/>
<atom:link href="<!--% absolute_url(baseurl) %--><!--% filename %-->" rel="self" type="application/rss+xml" /> <atom:link href="<!--% absolute_url(http_baseurl) %--><!--% filename %-->" rel="self" type="application/rss+xml" />
<pubDate><!--% format_feed_date(date.now) %--></pubDate> <pubDate><!--% format_feed_date(date.now) %--></pubDate>
<!--% INCLUDE $content %--> <!--% INCLUDE $content %-->

View File

@ -1,24 +1,25 @@
<!--% PROCESS 'shared-utils.tpl.html' %--> <!--% PROCESS 'shared-utils.tpl.html' %-->
<!--% MACRO display_item(episode, file_extension, audio_mime_type) BLOCK %--> <!--% MACRO display_item(episode, file_extension, audio_mime_type) BLOCK %-->
<!--% USE HTML.Strip %--> <!--% USE HTML.Strip emit_spaces = 0 %-->
<!--% IF audio_mime_type == "" %--> <!--% IF audio_mime_type == "" %-->
<!--% audio_mime_type = 'ogg' %--> <!--% audio_mime_type = 'ogg' %-->
<!--% END %--> <!--% END %-->
<item> <item>
<itunes:explicit><!--% display_explicit_feed(episode.explicit) %--></itunes:explicit> <itunes:explicit><!--% display_explicit_feed(episode.explicit) %--></itunes:explicit>
<googleplay:explicit><!--% display_explicit_feed(episode.explicit) %--></googleplay:explicit> <googleplay:explicit><!--% display_explicit_feed_2(episode.explicit) %--></googleplay:explicit>
<title>HPR<!--% zero_pad_left(episode.id) %-->: <!--% episode.title %--></title> <title>HPR<!--% zero_pad_left(episode.id) %-->: <!--% episode.title | html_strip | xml_entity %--></title>
<author><!--% episode.email %--> (<!--% episode.host %-->)</author> <author><!--% episode.email %--> (<!--% episode.host %-->)</author>
<googleplay:author><!--% episode.email %--> (<!--% episode.host %-->)</googleplay:author> <googleplay:author><!--% episode.email %--> (<!--% episode.host %-->)</googleplay:author>
<itunes:author><!--% episode.email %--> (<!--% episode.host %-->)</itunes:author> <itunes:author><!--% episode.email %--> (<!--% episode.host %-->)</itunes:author>
<googleplay:image href="<!--% absolute_url(baseurl) %-->images/hpr_feed_itunes.png"/> <googleplay:image href="<!--% absolute_url(http_baseurl) %-->images/hpr_feed_itunes.png"/>
<link><!--% absolute_url(baseurl) %-->eps/hpr<!--% zero_pad_left(episode.id) %-->/index.html</link> <link><!--% absolute_url(baseurl) %-->eps/hpr<!--% zero_pad_left(episode.id) %-->/index.html</link>
<description><![CDATA[<!--% episode.notes %-->]]> <description><![CDATA[<!--% episode.notes %-->]]>
</description> </description>
<itunes:summary><![CDATA[<!--% episode.notes.substr(0, 4000) | html_strip | xml_entity %-->]]> <itunes:summary><![CDATA[<!--% episode.notes.substr(0, 4000) | html_strip | xml_entity %-->]]>
</itunes:summary> </itunes:summary>
<pubDate><!--% format_feed_date(episode.date) %--></pubDate> <pubDate><!--% format_feed_date(episode.date) %--></pubDate>
<enclosure url="<!--% baseurl %-->eps/hpr<!--% zero_pad_left(episode.id) %-->.<!--% file_extension %-->" length="<!--% episode.length %-->" type="audio/<!--% audio_mime_type %-->"/> <enclosure url="<!--% http_baseurl %-->eps/hpr<!--% zero_pad_left(episode.id) %-->.<!--% file_extension %-->" length="<!--% episode.length %-->" type="audio/<!--% audio_mime_type %-->"/>
<guid><!--% baseurl %-->eps/hpr<!--% zero_pad_left(episode.id) %-->.<!--% file_extension %--></guid> <guid><!--% http_baseurl %-->eps/hpr<!--% zero_pad_left(episode.id) %-->.<!--% file_extension %--></guid>
</item> </item>
<!--% END %--> <!--% END %-->

View File

@ -35,6 +35,10 @@
<!--% display_choice(is_explicit, 'yes', 'no') %--> <!--% display_choice(is_explicit, 'yes', 'no') %-->
<!--% END %--> <!--% END %-->
<!--% MACRO display_explicit_feed_2(is_explicit) BLOCK %-->
<!--% display_choice(is_explicit, 'Yes', 'No') %-->
<!--% END %-->
<!--% MACRO format_feed_date(date_to_format) BLOCK %--> <!--% MACRO format_feed_date(date_to_format) BLOCK %-->
<!--% USE feed_date = date(format = '%a, %d %b %Y %H:%M:%S +0000', gmt=1) %--> <!--% USE feed_date = date(format = '%a, %d %b %Y %H:%M:%S +0000', gmt=1) %-->
<!--% feed_date.format(date_to_format) %--> <!--% feed_date.format(date_to_format) %-->