diff --git a/Community_News/Thanking_hosts_at_end_of_year.md b/Community_News/Thanking_hosts_at_end_of_year.md new file mode 100644 index 0000000..521e183 --- /dev/null +++ b/Community_News/Thanking_hosts_at_end_of_year.md @@ -0,0 +1,51 @@ +# Thanking hosts at the end of the year + +## Introduction + +Every year, in the last Community News recording (for December) it has been the +norm to list all of the hosts who have contributed. A list of host names is +assembled for this purpose, included in the notes and read out by the +volunteers. + +## Method + +A Bash script exists, called `thanks_to_hosts`, which manages the generation of +the list of hosts. The end product is a piece of HTML for insertion into the +notes. + +The script is invoked simply by typing: +``` +thanks_to_hosts +``` +By default, the script uses the current year when generating the list of hosts. +If, as may happen, the list is being generated in the next year, then a 4-digit +year can be given in as an argument. + +### Items required to run + +The `thanks_to_hosts` script requires a number of tools and files to run: + +- `query2tt2` - this is a Perl script which performs a database query and hands + the results to Template Toolkit template. + +- `hpr.db` - a SQLite database which contains a copy of the live HPR database. + This needs to have been refreshed in the recent past. + +- `.hpr_sqlite.cfg` - the configuration file for `query2tt2` to indicate what + type of database is being used and where to find it. + +- `hosts_in_year.sqlite.sql` - a file containing the query used (using SQLite + syntax) + +- `hosts_list.tpl` - the template which will be used to generate HTML + +### Output file + +Running the script `thanks_to_hosts`, if successful, will result in the +generation of a file called `hosts_in_year_${YEAR}.html`, where `${YEAR}` is +replaced by the default or explicit year. The script will report the name of +this file for convenience. + + diff --git a/Community_News/hosts_in_year.sqlite.sql b/Community_News/hosts_in_year.sqlite.sql new file mode 100644 index 0000000..4e0b7ff --- /dev/null +++ b/Community_News/hosts_in_year.sqlite.sql @@ -0,0 +1,17 @@ +-- +-- hosts_in_year.sqlite.sql 2025-10-06 +-- +-- Query for use with 'query2tt2' to generate a list of hosts who contributed +-- shows in a particular year. Designed to be used with the 'hosts_list.tpl' +-- template. +-- The two '?' placeholders in the query are to be filled with 'YYYY-01-01' +-- for the start of the year and 'YYYY-12-31'. The values can be passed using +-- the '-dbargs' option to 'query2tt2'. +-- +SELECT DISTINCT + printf('%04d',h.hostid) AS hostid, h.host AS hostname +FROM eps e +JOIN hosts h ON e.hostid = h.hostid +WHERE e.date BETWEEN ? AND ? +AND title != 'Reserved' +ORDER BY lower(h.host) diff --git a/Community_News/hosts_list.tpl b/Community_News/hosts_list.tpl new file mode 100644 index 0000000..948528a --- /dev/null +++ b/Community_News/hosts_list.tpl @@ -0,0 +1,53 @@ +[%# ========================================================================== +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') +-%] +