[%# make_tag_index.tpl 2022-09-14 -%]
[%# version: 0.0.3 -%]
[%# Default page summarising tag data from the database, generates PHP -%]
[%- USE date -%]
[%- DEFAULT title = 'Tag summary' -%]
<?php
# released under a Creative Commons Attribution-ShareAlike 3.0 Unported license. http://creativecommons.org/licenses/by-sa/3.0/
$body="help_out";
require "/home/hpr/php/hpr.php";
include '/home/hpr/www/header.php';
?>

<main id="maincontent">
<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">[% title %]</h1></a>
<h4 class="date">Page generated on [% date.format(date.now,'%Y-%m-%d at %H:%M:%S UTC','en_GB',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 [% tag_ids.size %] 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">
[%# tagindex contains the first tag in an alphabetic list that has a different
first letter from the previous one. We use it to build an alphabetic table of
anchors linking to the blocks of tags starting with that character. -%]
[%- FOREACH index IN tagindex %]
<li><a href="#[% index.replace('\s','_') %]"><strong>[% index.substr(0,1) %]</strong></a></li>
[%- END %]
</ul>
<hr/>
[%# BLOCK tags -%]
<ul>
[%# tag_ids is a hash keyed by tags, each containing an array of episode
numbers. If a tag matches the one in 'index' place an anchor to it for the
alphabetic index above. %]
[%- index = tagindex.shift %]
[%- FOREACH pair IN tag_ids.pairs %]
[%- IF pair.key == index %]
</ul>
<p class="ralign"><a href="#TOP">&#129137; Go to index</a></p>
<h3>Tags beginning with '[% index.substr(0,1) %]'</h3>
<ul>
<li>
[%- index = tagindex.shift %]
[%- ELSE %]
<li>
[%- END %]
<a id="[% pair.key.replace('\s','_') %]"><strong>[% pair.key FILTER html_entity %]</strong></a>: 
    [%- count = 0 %]
    [%- FOREACH id IN pair.value.nsort %]
        [%- count = count + 1 %]
        <a href="https://hackerpublicradio.org/eps.php?id=[% id FILTER format("%04i") %]"
            target="_blank" aria-label="[% pair.key FILTER html_entity %] - show [% id %]">[% id %]</a>
        [%- count < pair.value.size ? ', ' : '' %]
    [%- END %]
</li>
[%- END %]
</ul>
[%# END -%]

<p>
<a href="#TOP">Go to TOP of page</a>
</p>
</article>

</main>

<?php
include 'footer.html';
?>

[%#
  vim: syntax=tt2:ts=8:sw=4:ai:et:tw=78:fo=tcrqn21
-%]
