Archived
4
2

Compare commits

..

No commits in common. "c4b036110410975ae412d803fd46262babfed109" and "74b806f7125ae17a412bec109ce0b61a29846366" have entirely different histories.

9 changed files with 34 additions and 100 deletions

View File

@ -116,11 +116,7 @@ sub main {
if (exists($config{$parsed_arg{'page'}})) {
my $page_config = $config{$parsed_arg{'page'}};
$page_config->{'page'} = $parsed_arg{'page'};
$page_config->{'root_template'} = $config{root_template}{content};
if (exists $config{root_template}{baseurl}) {
$page_config->{'baseurl'} = $config{root_template}{baseurl};
}
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);
@ -128,12 +124,13 @@ sub main {
foreach my $id (@{$parsed_arg{'ids'}}) {
$page_config->{'id'} = $id;
verbose ($verbose, "Generating page: $page_config->{'page'} with id: $id");
generate_page($tt, \$page_config, $preview);
generate_page($tt, $config{root_template}{content}, \$page_config, $preview);
print "$page_config->{'page'} $page_config->{'id'}\n";
}
}
else {
verbose ($verbose, "Generating page: $page_config->{'page'}");
generate_page($tt, \$page_config, $preview);
generate_page($tt, $config{root_template}{content}, \$page_config, $preview);
}
}
else {
@ -167,12 +164,12 @@ sub get_template_html (\%@) {
}
sub generate_page {
my ($tt, $config, $preview) = @_;
my ($tt, $root_template, $config, $preview) = @_;
my $html;
if (!$preview) {
$html = get_filename($$config);
}
$tt->process($$config->{root_template}, $$config, $html)
$tt->process($root_template, $$config, $html)
|| die $tt->error(), "\n";
}
@ -180,11 +177,10 @@ sub generate_page {
sub verbose {
my ($verbose, $message) = @_;
if ($verbose) {
print STDOUT "$message\n";
print "$message\n";
}
else {
STDOUT->autoflush(1);
print STDOUT ".";
print ".";
};
}
@ -242,10 +238,7 @@ sub get_filename {
}
else {
$filename = $$config{'filename'};
my $padded_index = "";
if ($$config{'id'}) {
$padded_index = sprintf("%04d", $$config{'id'});
}
my $padded_index = sprintf("%04d", $$config{'id'});
$filename =~ s/\[id\]/$padded_index/;
return $filename;
}

View File

@ -7,12 +7,9 @@ user:
password:
# 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
# filesystem to allow relative paths to work.
# content templates used by each page.
[root_template]
content: page.tpl.html
#baseurl: OPTIONAL [i.e. file://<full path to local website directory>]
# Configure the navigation menu and the content templates for each page
# of the site:

View File

@ -1,46 +1,14 @@
<!--% PROCESS 'shared-episode-summary.tpl.html' %-->
<!--% PROCESS 'shared-avatar.tpl.html' %-->
<!--% USE DBI(constants.driver, constants.user, constants.password) %-->
<!--% query_show_count = DBI.prepare('
SELECT id
FROM eps
WHERE eps.hostid = ? ')
%-->
<!--% query_shows = DBI.prepare('
SELECT
substr(\'0000\' || eps.id, -4, 4) AS [id],
CASE eps.explicit WHEN 1 THEN \'Explicit\' ELSE \'Clean\' END AS explicit ,
eps.date, eps.license, eps.duration,
eps.title, eps.summary, eps.tags,
eps.series, eps.notes,
hosts.local_image,
substr(\'0000\' || hosts.hostid, -4, 4) AS [host_id],
hosts.host, hosts.email
FROM eps INNER JOIN hosts ON eps.hostid = hosts.hostid
WHERE hosts.hostid = ?
ORDER BY date DESC ')
%-->
<!--% shows_to_count = query_show_count.execute(id); %-->
<!--% shows = query_shows.execute(id); %-->
<!--% show_count = 0 %-->
<!--% FOREACH show IN shows_to_count %-->
<!--% show_count = show_count +1; %-->
<!--% END %-->
<!--% hosts = DBI.tie('hosts', 'hostid') %-->
<article>
<!--% this_host = hosts.$id %-->
<h2 class="title">Correspondent</h2>
<h2><!--% this_host.host %--></h2>
<p><img src="./images/<!--% get_avatar(this_host.local_image, this_host.hostid) %-->"
height="80" alt="Host Image" /><br>
<label>Host ID</label>: <!--% this_host.hostid %--><br><br>
<label>email:</label> <u><!--% this_host.email %--></u><br>
<label>episodes:</label> <strong><!--% show_count %--></strong>
<h2>Rho`n</h2>
<p><img src="./images/hosts/293.png" height="80" alt="Host Image" /><br>
<label>Host ID</label>:<!--% id %--><br><br>
<label>email:</label> <u>roan.horning.nospam@nospam.gmail.com</u><br>
<label>episodes:</label> <strong>12</strong>
</p>
<!--% FOREACH show IN shows; %-->
<!--% show_summary(show, 'hide_host') %-->
<!--% END %-->
<h3><a href="eps.php?id=3647">hpr3647 :: Weekend projects</a></h3>
<p class="meta"><strong>Released:</strong> 2022-07-26. <strong>Duration:</strong> 00:16:44. <strong>Flag:</strong> Clean. <strong>Series:</strong> <a href="series.php?id=0">general</a>. <br>
<strong>Tags:</strong> <em>diy, repairs, umbrella, basketball</em>.<br>
Rho`n rambles about some weekend projects</p>
<p><a href="contribute.php">Become a Correspondent</a></p>
</article>
<p><a href="contribute.html">Become a Correspondent</a></p>

View File

@ -1,9 +1,7 @@
<!--% PROCESS 'shared-utils.tpl.html' %-->
<article>
<p>
<h2 class="title">Correspondents</h2><p>For more information on how to become a Correspondent see our <a href="contribute.php">contribute</a></center> page. To add a logo here, either email one to admin at hpr or setup your email on <a href="https://en.gravatar.com/">Gravatar</a>. To protect your browsing privacy we gather the images every hour and serve them directly from HPR.<p />
<!--% USE DBI(constants.driver, constants.user, constants.password) %-->
<!--% PROCESS 'shared-avatar.tpl.html' %-->
<table>
<th >Avatar</th>
<th >Name &amp; Host ID</th>
@ -11,17 +9,17 @@
<th >Last Show</th>
<!--% FOREACH host IN DBI.query(
'select h.hostid, h.host, h.license, e.date,
h.local_image
CASE WHEN h.local_image = 0 THEN \'hpr_logo\' ELSE h.hostid END AS avatar
from hosts as h
inner join (select hostid, max(date) as date from eps group by hostid) as e
on h.hostid = e.hostid '
) %-->
<tr height="80" bgcolor="#CCCCCC">
<td><img src="./images/<!--% get_avatar(host.local_image, host.hostid) %-->" height="80" width="80" alt="avatar" /></td>
<td><img src="./images/<!--% host.avatar%-->.png" height="80" width="80" alt="avatar" /></td>
<td><strong><!--% host.host %--></strong><br />
Host ID: <a href="correspondents/<!--% zero_pad_left(host.hostid) %-->/index.html"><!--% host.hostid %--></a></td>
Host ID: <a href="correspondents/<!--% host.hostid %-->.html"><!--% host.hostid %--></a></td>
<td><!--% host.license %--></td>
<td><!--% host.date %--></td>
</tr>

View File

@ -1,4 +1,3 @@
<!--% PROCESS 'shared-avatar.tpl.html' %-->
<hr>
<article>
<header>
@ -19,7 +18,8 @@
</p>
</article>
<hr>
<!--% PROCESS 'shared-episode-summary.tpl.html' %-->
<!--% MACRO show_series(series) IF series != "" %--><label>Series:</label> <a href="series.php?id=11"><!--% series %--></a>.
<!--% END %-->
<h1>latest shows</h1>
<!--% USE DBI(constants.driver, constants.user, constants.password) %-->
<!--% FOREACH latest_episodes IN DBI.query('
@ -29,8 +29,8 @@
eps.date, eps.license, eps.duration,
eps.title, eps.summary, eps.tags,
eps.series, eps.notes,
hosts.local_image,
hosts.hostid,
CASE hosts.local_image WHEN 1 THEN hosts.hostid ELSE \'hpr_logo\' END AS avatar,
substr(\'0000\' || hosts.hostid, -4, 4) AS [host_id],
hosts.host, hosts.email
FROM eps INNER JOIN hosts ON eps.hostid = hosts.hostid
WHERE eps.date BETWEEN date(\'now\', \'-7 days\') AND date(\'now\')
@ -41,7 +41,7 @@ ORDER BY date DESC ')
<header>
<h1><a href="episodes/hpr<!--% latest_episodes.id %-->.html">hpr<!--% latest_episodes.id %--> :: <!--% latest_episodes.title %--></a></h1>
<h3><!--% latest_episodes.summary%--></h3>
<p class="meta"$><img src="./images/<!--% get_avatar(latest_episodes.local_image, latest_episodes.hostid) %-->" height="80" width="80" alt="" /></a><br>Hosted by <a href="correspondents/host<!--% latest_episodes.host_id %-->.html"><!--% latest_episodes.host %--></a> on <!--% latest_episodes.date %--> is flagged as <!--% latest_episodes.explicit %--> and released under a <!--% latest_episodes.license %--> license. <br>
<p class="meta"$><img src="./images/hosts/<!--% latest_episodes.avatar %-->.png" height="80" width="80" alt="" /></a><br>Hosted by <a href="correspondents/host<!--% latest_episodes.host_id %-->.html"><!--% latest_episodes.host %--></a> on <!--% latest_episodes.date %--> is flagged as <!--% latest_episodes.explicit %--> and released under a <!--% latest_episodes.license %--> license. <br>
<strong>Tags:</strong> <!--% latest_episodes.tags %--><em></em>.<br>
<small>listen in <a href="local/hpr<!--% latest_episodes.id %-->.ogg">ogg</a>, <a href="local/hpr<!--% latest_episodes.id %-->.spx">spx</a>, or <a href="local/hpr<!--% latest_episodes.id %-->.mp3">mp3</a> format. <!--% show_series(latest_episodes.series) %-->
<a href="eps.php?id=3628#comments">comments (0)</a></small>
@ -81,7 +81,12 @@ ORDER BY date DESC ')
ORDER BY date DESC
')
%-->
<!--% show_summary(last_5_weeks_episodes) %-->
<h3 class="title"><a href="episodes/hpr<!--% last_5_weeks_episodes.id %-->.html">hpr<!--% last_5_weeks_episodes.id %--> :: <!--% last_5_weeks_episodes.title %--></a> hosted by <a href="correspondents/host<!--% last_5_weeks_episodes.id %-->.html"><!--% last_5_weeks_episodes.host %--></a>
</h3>
<p class="meta"><span><label>Released:</label> <!--% last_5_weeks_episodes.date %-->.</span> <span><label>Duration:</label> <!--% last_5_weeks_episodes.duration %-->.</span> <span><label>Flag:</label> <!--% last_5_weeks_episodes.explicit %-->.</span> <span><!--% show_series(last_5_weeks_episodes.series) %--></span> <br>
<span><label>Tags:</label> <em><!--% last_5_weeks_episodes.tags %--></em>.</span><br>
<!--% last_5_weeks_episodes.summary %-->
</p>
<!--% END %-->
</article>
<h1>Older Shows</h1>

View File

@ -2,9 +2,6 @@
<html lang="en">
<head>
<title>Hacker Public Radio ~ The Technology Community Podcast</title>
<!--% IF baseurl %-->
<base href="<!--% baseurl %-->">
<!--% END %-->
<meta charset="utf-8" />
<meta http-equiv="X-Clacks-Overhead" content="GNU Terry Pratchett" />
<meta name="keywords" content="Technology, Tech News, Education, Training" />

View File

@ -1,3 +0,0 @@
<!--% MACRO get_avatar(has_avatar, host_id) BLOCK %-->
<!--% IF has_avatar == 0 %-->hpr_logo.png<!--% ELSE %-->hosts/<!--% host_id %-->.png<!--% END %-->
<!--% END %-->

View File

@ -1,17 +0,0 @@
<!--% MACRO show_series(series) IF series != "" %-->
<label>Series:</label> <a href="series.php?id=11"><!--% series %--></a>.
<!--% END %-->
<!--% MACRO show_summary(show, hide_host) BLOCK %-->
<h3 class="title"><a href="episodes/hpr<!--% show.id %-->.html">hpr<!--% show.id %--> :: <!--% show.title %--></a> <!--% IF hide_host == "" %-->
hosted by <a href="correspondents/host<!--% show.id %-->.html"><!--% show.host %--></a>
<!--% END %-->
</h3>
<p class="meta"><span><label>Released:</label> <!--% show.date %-->.</span> <span><label>Duration:</label> <!--% show.duration %-->.</span> <span><label>Flag:</label> <!--% show.explicit %-->.</span> <span><!--% show_series(show.series) %--></span> <br>
<span><label>Tags:</label> <em><!--% show.tags %--></em>.</span><br>
<!--% show.summary %-->
</p>
<!--% END %-->

View File

@ -1,4 +0,0 @@
<!--% MACRO zero_pad_left(word) BLOCK %-->
<!--% USE String(word) %-->
<!--% String.format("%04s") %-->
<!--% END %-->