hpr-tools/Database/hosts_list.tpl
Dave Morriss fdd0823f93 Finishing off 'query2*' scripts
Database/hosts_list.tpl, Database/hosts_showcount.sqlite.sql: examples
    of using 'query2tt2'

Database/query2csv, Database/query2json, Database/query2tt2: minor bug
    fix relating to '-dbarg=ARG' option
2025-05-09 14:15:41 +01:00

40 lines
1.5 KiB
Smarty

[%# ==========================================================================
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
thus:
year="2022" # or whatever
./query2tt2 -query=$HOME/HPR/Community_News/hosts_showcount.sql \
-conf=$HOME/HPR/.hpr_livedb.cfg \
-dbargs "${year}-01-01" -dbargs "${year}-12-31" -def year=${year} \
-template=$HOME/HPR/Community_News/hosts_list.tpl \
> $HOME/HPR/Community_News/hosts_showcount_${year}.html
[We can't use the planned pure TT2 version since Template::Plugin::DBI
can't run over the SSH tunnel.]
2023-10-30 The correspondent URL has changed with the static site, and needs
the hostid to be zero-padded.
========================================================================== -%]
[%- 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
-%]