[%# report_missing_tags.tpl 2022-08-03 -%]
[%# version: 0.1.1 -%]
[%# Page summarising data from the database, generates PHP -%]
[%# USE dumper -%]
[%- USE date -%]
[%- DEFAULT title = 'Test' -%]
[%- DEFAULT htmltags = 'tags.html' -%]
[%- table_size = 37 count = 0 anchors = [] -%]
<?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>
<h3 class="date">Page generated on [% date.format(date.now,'%Y-%m-%d at %H:%M:%S UTC','en_GB',1) %]</h3>
<h4>Sort order: [%- order_by.join(', ') %]</h4>
<h4>Current counts</h4>
<ul>
<li><b>[% s_count %]</b> shows without summaries</li>
<li><b>[% t_count %]</b> shows without tags</li>
<li><b>[% st_count %]</b> shows with neither summaries nor tags</li>
<li><b>[% needwork = s_count+t_count-st_count; needwork %]</b> shows which need work</li>
</ul>
<h4>Instructions</h4>
<ol>
<li>Find a show in the list below</li>
<li>Check in the list which attributes are missing: summary and/or tags</li>
<li>Click the show number or title to visit the show page</li>
<li>Read the show notes and listen to the show to determine the missing information</li>
<li>Submit your updates by email to <em>tags at hackerpublicradio.org</em></li>
</ol>
<p>Please send simple ASCII email. No HTML please, and no multipart, encrypted
or signed messages; the script can't handle them at the moment! (We are
working on a solution to some of this though). Remember, the internals of an
email are <em>complex</em> and the script isn't clever enough to deal with all
the many possible formats. <strong>Please be gentle with it!</strong></p>
<p>Format the message as follows:</p>
<pre>
show:12345
summary:Using Linux at Christmas to make tomato soup in a sporran
tags:linux,christmas,sporran,tomato soup

show: 12346
tags: sausage,clothing,hairpiece
</pre>
<ul>
<li>Start with the <code>show:XXXX</code> line (just the show number, no
<code>'hpr'</code>)</li>
<li>If either the summary or the tags are already present on the show you can omit them from the group</li>
<li>It's not possible to change existing summaries or tags by this route, only to add missing ones</li>
<li>Ensure the summary text isn't longer than 100 characters</li>
<li>The tags need to be separated by commas</li>
<li>If you need to add a tag with a comma in it enclose the tag in double quotes</li>
<li>The length of the tag list can't exceed 200 characters</li>
<li>You can update more than one show per email if you want</li>
<li>Blank lines between the groups of <em>show</em>/<em>summary</em>/<em>tags</em> lines are fine (as shown), as are comment lines beginning with '#'</li>
</ul>
<p>Updates will be processed with a script, which is run manually, and this page
will be refreshed once the changes have been made. The timestamp above shows
when it was last refreshed.</p>
<hr/>
</article>

[% IF needwork > 0 -%]

[%- BLOCK table_head -%]
<p>
<a href="#END">Go to END of section</a>
</p>
<table id="t01" style="width:100%">
    <tr>
    <th style="width:5%">Id</th>
    <th style="width:12%">Date</th>
    <th style="width:50%">Title</th>
    <th style="width:17%">Host</th>
    <th style="width:8%">Summary</th>
    <th style="width:8%">Tags</th>
    </tr>
[%- END -%]

[%- BLOCK table_foot -%]
</table>
<p>
<a href="#TOP">Go to TOP of page</a>
</p>
[%- END -%]

<article>
<h3>Section Index</h3>
<ul>
<li><a href="#Shows_by_host">Shows by host</a></li>
<li><a href="#Tag_summary">Tag summary</a></li>
</ul>
<hr/>
</article>

[%# Make the index. Point to the first show and every $table_size shows -%]
[%# thereafter. Keep the id numbers in a list for use later.            -%]
<article>
<h3>Tables of shows requiring attention</h3>
<p>The following index is to help you find shows in need of attention.</p>

<h4>Index of tables</h4>
<ul>
[%- count = 0 %]
[%- FOREACH row IN shows %]
    [%- IF count % table_size == 0 && count < shows.size %]
    <li><a href="#show[% row.id %]">Go to show number [% row.id %]</a></li>
    [%- anchors.push(row.id) %]
    [%- END %]
    [%- count = count + 1 %]
[%- END %]
</ul>
<hr/>
</article>

<article>
[% count = 0 -%]
<small>
<a id="show[% anchors.shift %]"></a>
[%- PROCESS table_head %]
    [%- FOREACH row IN shows %]
    <tr valign="top">
    <td align="left"><strong><a href="http://hackerpublicradio.org/eps.php?id=[% row.id FILTER format("%04i") %]" target="_blank">[% row.id %]</a></strong></td>
    <td align="left">[% date.format(row.date,'%Y-%m-%d') %]</td>
    <td align="left"><a href="http://hackerpublicradio.org/eps.php?id=[% row.id FILTER format("%04i") %]" target="_blank">[% row.title %]</a></td>
    <td align="left">[% row.host FILTER html_entity %]</a></td>
    <td align="left">[% row.summary == 0 ? 'No' : 'Yes' %]</a></td>
    <td align="left">[% row.tags == 0 ? 'No' : 'Yes' %]</a></td>
    </tr>
    [%- count = count + 1 -%]
    [%- IF count % table_size == 0 && count < shows.size -%]
    [%- PROCESS table_foot %]
    <a id="show[% anchors.shift %]"></a>
    [%- PROCESS table_head %]
    [%- END -%]
    [%- END %]
[%- PROCESS table_foot %]
</small>
<a id="END"></a>
<p>Total shows = [% count %]</p>
<hr/>
</article>

<article>
<a id="Shows_by_host"><h3>Shows by host</h3></a>
<p>This section lists all HPR hosts who have shows without summaries and/or tags. The show numbers in question are listed against each host and can be clicked to open the show. </p>
<p> If you are one of the hosts below it would be very much appreciated if you could help out by adding the summary and or tags to all of your shows that do not have them. You are the person who is best able to add these missing items to your shows!</p>
<ul>
[%- FOREACH row IN byhost %]
<li><strong><a href="http://hackerpublicradio.org/correspondents.php?hostid=[% row.hostid %]" target="_blank">[% row.host %]</a></strong>:
    [%- showlist = row.shows.split(',') %]
    [%- count = 0 %]
    [%- FOREACH show IN showlist %]
        [%- count = count + 1 %]
        <a href="http://hackerpublicradio.org/eps.php?id=[% show FILTER format("%04i") %]" target="_blank">[% show %]</a>
        [%- count < showlist.size ? ', ' : '' %]
    [%- END %]
</li>
[%- END %]
</ul>
<p>
<a href="#TOP">Go to TOP of page</a>
</p>
<hr/>
</article>

[% ELSE -%]
<article>
<h3>The project is finished!</h3>
<p>All shows have been processed! Thanks to everyone who has helped!</p>
<hr/>
</article>
[% END -%]

<article>
[% BLOCK tags -%]
<a id="Tag_summary"><h3>Tag summary</h3></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="#Tag_summary">&#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="http://hackerpublicradio.org/eps.php?id=[% id FILTER format("%04i") %]"
            target="_blank" aria-label="Tag [% pair.key FILTER html_entity %]: show [% id %]">[% id %]</a>
        [%- count < pair.value.size ? ', ' : '' %]
    [%- END %]
</li>
[%- END %]
</ul>
[% END -%]
[% INCLUDE tags FILTER redirect("$htmltags") -%]
[% INSERT $htmltags -%]
<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
-%]
