Fixed link to Tags.

Get episode ID and episode tags from eps.
Generate the Tags page by looping through the tags, order by their first character.
Added tags page to the config.
This commit is contained in:
Gordon Stanton 2023-05-01 00:50:01 +10:00
parent f3de654284
commit afc6b7518f
5 changed files with 91 additions and 1 deletions

View File

@ -146,6 +146,10 @@ content: content-promote.tpl.html
navigation: navigation-about.tpl.html navigation: navigation-about.tpl.html
content: content-sitemap.tpl.html content: content-sitemap.tpl.html
[tags]
navigation: navigation-main.tpl.html
content: content-tags.tpl.html
[twat_episode] [twat_episode]
navigation: navigation-get-shows.tpl.html navigation: navigation-get-shows.tpl.html
content: content-twat_episode.tpl.html content: content-twat_episode.tpl.html

View File

@ -0,0 +1,84 @@
<!--% PROCESS "queries-tags-${constants.database}.tpl.html" %-->
<!--% USE DBI(constants.driver, constants.user, constants.password) %-->
<!--% PERL %-->
$Template::Stash::PRIVATE = undef; # Allow . in tag
<!--% END %-->
<!--% uniq_tag_count = 0 %-->
<!--% comma_re = '(?x)(?:^|,\s*)(?:"((?>[^"]*)(?:""[^"]*)*)"|([^",]*))'; %-->
<!--# 'Moka5,interview, "computer science"' -->
<!--% FOREACH episode IN DBI.query(query_tags);
ep_id = episode.id;
ep_tags = episode.tags;
FOREACH tag_str IN ep_tags.split(comma_re);
NEXT UNLESS tag_str;
NEXT IF tag_str == '';
tag = tag_str.lower;
first_char = tag.substr(0,1);
IF first_char == '.';
first_char = '&#x0002E;'; # Unicode .
END;
IF all_tags.${first_char}.exists(tag);
all_tags.${first_char}.${tag}.count = all_tags.${first_char}.${tag}.count + 1;
all_tags.${first_char}.${tag}.urls.push(ep_id);
ELSE;
all_tags.${first_char}.${tag}.count = 1;
uniq_tag_count = uniq_tag_count + 1;
all_tags.${first_char}.${tag}.urls = [ep_id];
END;
END;
END %-->
<!--% USE date %-->
<!--% all_first = ['#','&#x0002E;','/','0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] %-->
<style>
.columns3 { columns: 3 auto; list-style-type: none }
hr.thin {
border: 0;
height: 0;
border-top: 1px solid rgba(0, 0, 0, 0.1);
border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}
p.ralign { text-align: right }
</style>
<article>
<a id="TOP"><h1 class="title">Tag summary</h1></a>
<h4 class="date">Page generated on <!--% date.format(date.now, format => '%Y-%m-%d at %H:%M:%S UTC', gmt => 1) %--></h4>
<p>This section summarises all of the tags currently used throughout the
database. The tags are in alphabetical order and each is followed by links to
the show numbers where it is used so you can see the context the author used
it in. There are currently <!--% uniq_tag_count %--> unique tags in the system.</p>
<h4>Alphabetical index</h4>
<p>This is an index to the initial letters of the tags below.</p>
<ul class="columns3">
<!--% FOREACH first_char IN all_first %-->
<!--% IF all_tags.${first_char} %-->
<li><a href="#<!--% all_tags.${first_char}.keys.sort.first %-->"><strong><!--% first_char %--></strong></a></li>
<!--% END %-->
<!--% END %-->
</ul>
<hr>
<!--% FOREACH first_char IN all_first %-->
<!--% IF all_tags.${first_char} %-->
<p class="ralign"><a href="#TOP">&UpArrow; Go to index</a></p>
<h3>Tags beginning with '<!--% first_char %-->'</h3>
<ul>
<!--% FOREACH tag IN all_tags.${first_char}.keys.sort %-->
<li>
<a id="<!--% tag %-->"><strong><!--% tag %--></strong></a>:
<!--% ep_links = [] %-->
<!--% FOREACH ep_id IN all_tags.${first_char}.${tag}.urls.nsort;
ep_links.push('<a href="./hpr' _ ep_id _ '/index.html"'
' target="_blank" aria-label="' _ tag _
' - show ' _ ep_id _ '">' _ ep_id _ '</a>');
END %-->
<!--% ep_links.join(', ') %-->
</li>
<!--% END %-->
</ul>
<!--% END %-->
<!--% END %-->
<p><a href="#TOP">Go to TOP of page</a></p>
</article>
<!--% PERL %-->
$Template::Stash::PRIVATE = 1;
<!--% END %-->

View File

@ -5,7 +5,7 @@
<li><a href="<!--% absolute_path(baseurl) %-->syndication.html">Get Shows</a></li> <li><a href="<!--% absolute_path(baseurl) %-->syndication.html">Get Shows</a></li>
<li><a href="<!--% absolute_path(baseurl) %-->contribute.html">Give Shows</a></li> <li><a href="<!--% absolute_path(baseurl) %-->contribute.html">Give Shows</a></li>
<li><a href="<!--% absolute_path(baseurl) %-->help_out.html">Contribute</a></li> <li><a href="<!--% absolute_path(baseurl) %-->help_out.html">Contribute</a></li>
<li><a href="http://www.hackerpublicradio.org/tags.php">Tags</a></li> <li><a href="<!--% absolute_path(baseurl) %-->tags.html">Tags</a></li>
<li><a href="<!--% absolute_path(baseurl) %-->about.html">About</a></li> <li><a href="<!--% absolute_path(baseurl) %-->about.html">About</a></li>
<li><a href="<!--% absolute_path(baseurl) %-->search.html">Search</a></li> <li><a href="<!--% absolute_path(baseurl) %-->search.html">Search</a></li>
</ul> </ul>

View File

@ -0,0 +1 @@
<!--% query_tags = 'SELECT id, tags FROM eps' %-->

View File

@ -0,0 +1 @@
<!--% query_tags = 'SELECT id, tags FROM eps' %-->