Files
hpr-tools/Community_News/hosts_list.tpl

54 lines
2.0 KiB
Smarty
Raw Normal View History

[%# ==========================================================================
This is the TT2 file for making a list of hosts contributing to HPR in the
current year which is run in conjunction with 'query2tt2'. It's invoked
by using the Bash script 'thanks_to_hosts'.
[We can't use the planned pure TT2 version since Template::Plugin::DBI
can't run over the SSH tunnel.]
The 'query2tt2' script needs a configuration file '.hpr_sqlite.cfg,' though this
is the default.
The file 'hosts_in_year.sqlite.sql' is used to generate the 'result' hash
which is used by this template. The query needs to be given the first and last
dates of the year.
This template uses the variable 'year' which can be provided to 'query2tt2'
using the option '-def year="$year"' or similar. If not provided the default
value is the current year.
The 'result' hash is sorted by host name. The loop which writes the output
generates links to the HPR website, with 8 per list element
Changes:
-------
2023-10-30: The correspondent URL has changed with the static site, and needs
the hostid to be zero-padded.
2025-01-01: We now use a copy of the live database, built from the HPR server
and available as https://www.hackerpublicradio.org/hpr.sql. This is
a MySQL/MariaDB dump which can be used to create a MariaDB or a SQLite copy.
See the script collect_HPR_database for how the SQLite version is created.
========================================================================== -%]
[%- USE date -%]
[%- DEFAULT
year = date.format(date.now,'%Y','UTC')
-%]
<h3>Thanks to all [% result.size %] HPR contributors in [% year %]!</h3>
[% limit = 8 -%]
[% count = 0 -%]
<p><ul><li>
[% FOREACH h = result -%]
<a href="https://hackerpublicradio.org/correspondents/[% h.hostid %].html">[% h.hostname %]</a>
[%- IF loop.count mod limit == 0 || loop.count == result.size -%].[% ELSE %],[% END %]
[% count = count + 1 -%]
[% IF count == limit -%]
[% count = 0 -%]
</li><li>
[% END -%]
[% END -%]
</li></ul></p>
[%#
# vim: syntax=tt2:ts=8:sw=4:ai:et:tw=78:fo=tcrqn21:fdm=marker
-%]