1
0
forked from HPR/hpr-tools

Moved project directories and files to an empty local repo

This commit is contained in:
Dave Morriss
2024-06-04 16:35:44 +01:00
parent 2d2b937a9b
commit 38abbcdd39
271 changed files with 55348 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
<gmane>
url = http://download.gmane.org/gmane.network.syndication.podcast.hacker-public-radio
template1 = "$url/%d/%d"
lookahead = 100
thread = http://comments.gmane.org/gmane.network.syndication.podcast.hacker-public-radio
template2 = "$thread/%d"
</gmane>
<cache>
directory = /home/cendjm/HPR/Community_News/mail_cache
filename = gmane.mbox
regex = "<http://permalink\.gmane\.org/gmane\.network\.syndication\.podcast\.hacker-public-radio/(\d+)>"
</cache>

View File

@@ -0,0 +1,9 @@
### Example section
- Bulleted list item 1
- Bulleted list item 2
[%#
vim: syntax=markdown:ts=8:sw=4:ai:et:tw=78:fo=tcqn:fdm=marker:com-=b\:-
-%]

252
Community_News/build_AOB Executable file
View File

@@ -0,0 +1,252 @@
#!/bin/bash -
#===============================================================================
#
# FILE: build_AOB
#
# USAGE: ./build_AOB [date]
#
# DESCRIPTION: Build the AOB files for a particular month
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: Dave Morriss (djm), Dave.Morriss@gmail.com
# VERSION: 0.0.12
# CREATED: 2021-04-15 17:36:22
# REVISION: 2024-03-15 09:50:02
#
#===============================================================================
set -o nounset # Treat unset variables as an error
SCRIPT=${0##*/}
BASEDIR=${0%/*}
VERSION="0.0.12"
STDOUT="/dev/fd/2"
#
# Make sure we're in the working directory
#
cd "$BASEDIR" || exit 1
#
# Load library functions
#
LIB="$HOME/bin/function_lib.sh"
[ -e "$LIB" ] || { echo "$SCRIPT: Unable to source functions"; exit 1; }
# shellcheck disable=SC1090
source "$LIB"
# {{{ -- Functions usage and _DEBUG
#=== FUNCTION ================================================================
# NAME: _usage
# DESCRIPTION: Report usage
# PARAMETERS: None
# RETURNS: Nothing
#===============================================================================
_usage () {
cat >$STDOUT <<-endusage
Usage: ./${SCRIPT} [-h] [-D] [date]
Version: $VERSION
Converts the AOB in Markdown format for a particular month to HTML and to text
Options:
-h Print this help
-D Select debug mode (works the same; more output)
Arguments (optional):
date Specifies the month to build the AOB for. The default
is the current month. The format can be YYYY-MM (e.g.
2022-05) or any date format that the 'date' command
can parse, so 2022-04-01 or 01-Apr-2022 and so on. If
the date cannot be parsed an error will be reported.
Examples
./${SCRIPT} -h
./${SCRIPT} -D 01-February-2021
./${SCRIPT} 2021-02
endusage
exit
}
#=== FUNCTION ================================================================
# NAME: _DEBUG
# DESCRIPTION: Writes a message if in DEBUG mode
# PARAMETERS: List of messages
# RETURNS: Nothing
#===============================================================================
_DEBUG () {
[ "$DEBUG" == 0 ] && return
for msg in "$@"; do
printf 'D> %s\n' "$msg"
done
}
# }}}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Base and database directories
#
PARENT="$HOME/HPR"
BASEDIR="$PARENT/Community_News"
cd "$BASEDIR" || {
echo "Failed to cd to $BASEDIR";
exit 1;
}
# IADIR="$PARENT/InternetArchive"
#
# Option defaults
#
DEBUG=0
#
# Process options
#
while getopts :hdD opt
do
case "${opt}" in
h) _usage;;
D) DEBUG=1;;
?) echo "$SCRIPT: Invalid option; aborting"; exit 1;;
esac
done
shift $((OPTIND - 1))
#
# Handle the optional argument
#
if [[ $# -eq 1 ]]; then
startdate="$1"
# Normalise a YYYY-MM date so 'date' will not complain
if [[ $startdate =~ ^[0-9]{4}-[0-9]{2}$ ]]; then
startdate+='-01'
fi
# Validate the date and standardise it if it's OK
tmp="$(date -d "$startdate" +%Y-%m)" || {
echo "Use a date such as $(date +%Y-%m)"
exit 1
}
startdate="$tmp"
else
startdate="$(date +%Y-%m)"
fi
_DEBUG "Date used: $startdate"
#
# We added a new field in 2022, 'item_last_updated' which is taken from the IA
# (which we discovered was being maintained). It is a Unix date field, but the
# view 'episodes_view' converts it.
#
# TODO: Since query3 was added it has made query1 and query2 obsolete. We
# generate a per-month table with query3 which is turned into HTML using awk
# and used in the AOB report. The code below that uses these queries and their
# results could now be removed (or commented out).
#
#query1="select count(*) from episodes where id between 871 and 2429 and with_derived = 1"
##query1="select count(*) from episodes_view where id between 871 and 2429 and \
##item_last_updated between '${startdate}-01' and \
##date('${startdate}-01','+1 month') and with_derived = 1"
##
##query2='select count(*) from episodes where id between 871 and 2429 and with_derived = 0'
##
##query3=$(cat <<ENDOFQ3
##SELECT
## strftime('%Y-%m',item_last_updated) AS month,
## count(*) AS count
##FROM episodes_view
##WHERE id BETWEEN 871 AND 2429
##AND item_last_updated IS NOT NULL
##AND item_last_updated < date('${startdate}-01','+1 month')
##GROUP BY strftime('%Y-%m',item_last_updated);
##ENDOFQ3
##)
##
##_DEBUG "Query used (1): $query1"
##_DEBUG "Query used (2): $query2"
##_DEBUG "Query used (3): $query3"
##
#
# The database
#
##IADB="$IADIR/ia.db"
##
#
# Collect the values
#
##UPLOADS=$(echo "$query1" | sqlite3 -list "$IADB")
##REMAINING=$(echo "$query2" | sqlite3 -list "$IADB")
##TABLE=$(echo "$query3" | sqlite3 -list "$IADB")
##
##_DEBUG "Uploads=$UPLOADS (query 1)"
##_DEBUG "Remaining=$REMAINING (query 2)"
##_DEBUG "Table=$TABLE"
#
# Files we need to build the AOB
#
AOBMKD="$BASEDIR/aob_$startdate.mkd"
#
# Sanity check
#
[ -e "$AOBMKD" ] || { echo "Unable to find $AOBMKD"; exit 1; }
#
# Make temporary files and set traps to delete them
#
##TMP1=$(mktemp) || { echo "$SCRIPT: creation of temporary file failed!"; exit 1; }
##trap 'cleanup_temp $TMP1' SIGHUP SIGINT SIGPIPE SIGTERM EXIT
##
#
# Use Awk to process the table we failed to generate in SQL :-(
#
##awk -F '|' -f /dev/fd/7 <<<"$TABLE" >"$TMP1" 7<<'ENDAWK'
##BEGIN{
## total = 0
## remainder = (2429 - 871 + 1)
## print "<table>"
## print "<tr><th>Month</th><th>Month count</th>"\
## "<th>Running total</th><th>Remainder</th></tr>"
##}
##{
## total = total + $2
## remainder = remainder - $2
## printf "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n",
## $1,$2,total,remainder
##}
##END{
## print "</table>"
##}
##ENDAWK
##cat >>"$TMP1" <<ENDDATE
##<p><small><small>Table updated: $(date --utc +'%F %T')</small></small></p>
##ENDDATE
##_DEBUG "Table" "$(cat "$TMP1")"
#
# Build the output files
#
# if tpage --define "uploads=$UPLOADS" --define "remaining=$REMAINING" \
# --define "table=$TMP1" "$AOBMKD" |\
# pandoc -f markdown-smart -t html5 -o "${AOBMKD%mkd}html"; then
#
if pandoc -f markdown-smart -t html5 "$AOBMKD" -o "${AOBMKD%mkd}html"; then
echo "Converted $AOBMKD to HTML"
else
echo "Conversion of $AOBMKD to HTML failed"
fi
exit
# vim: syntax=sh:ts=8:sw=4:ai:et:tw=78:fo=tcrqn21:fdm=marker

View File

@@ -0,0 +1,121 @@
[%# comments_only.tpl 2018-11-05 -%]
[%# Textual comment summary for Community News. -%]
[%# This one partitions comments into past and current. -%]
[%# It requires make_shownotes > V0.0.28 -%]
[%- USE date -%]
[%- USE wrap -%]
[%- DEFAULT mark_comments = 0
aob = 0 -%]
[% TAGS outline -%]
%% IF mark_comments == 1 && missed_comments.size > 0
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Missed comments last month
--------------------------
Note to Volunteers: These are comments for shows last month that were not read
in the last show because they arrived after the recording.
%% FOREACH comment IN missed_comments
================================================================================
hpr[% comment.episode %] ([% comment.date %]) "[% comment.title %]" by [% comment.host %].
------------------------------------------------------------------------------
From: [% comment.comment_author_name -%] on [% date.format(comment.comment_timestamp_ut,'%Y-%m-%d','UTC') -%]:
[%- IF comment.comment_title.length > 0 -%]
"[% comment.comment_title %]"
[%- ELSE -%]
"[no title]"
[%- END %]
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
[% wrap(comment.comment_text, 80, ' ', ' ') FILTER decode_entities %]
%% END
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
%% END
Comments this month
-------------------
%% IF comment_count > 0
There [%- comment_count == 1 ? "is $comment_count comment" : "are $comment_count comments" -%] in total.
%% IF past_count > 0
Past shows
----------
There [% past_count == 1 ? "is $past_count comment" : "are $past_count comments" %] on [% past.size %] previous [% past.size == 1 ? "show" : "shows" %]:
%% FOREACH ep IN past.keys.sort
%% arr = past.$ep
================================================================================
hpr[% arr.0.episode %] ([% arr.0.date %]) "[% arr.0.title %]" by [% arr.0.host %].
%% FOREACH row IN arr
------------------------------------------------------------------------------
Comment [% row.index %]: [% row.comment_author_name -%] on [% date.format(row.comment_timestamp_ut,'%Y-%m-%d','UTC') -%]:
[%- IF row.comment_title.length > 0 -%]
"[% row.comment_title FILTER decode_entities %]"
[%- ELSE -%]
"[no title]"
[%- END %]
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
[% IF mark_comments == 1 && ((row.comment_timestamp_ut <= last_recording) && (arr.0.date.substr(0,7) == last_month)) -%]
[% wrap(row.comment_text, 80, '| ', '| ') FILTER decode_entities %]
[% ELSE -%]
[% wrap(row.comment_text, 80, ' ', ' ') FILTER decode_entities %]
[% END -%]
%% END
%% END
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
%% END
%% cc = (comment_count - past_count)
%% IF cc > 0
This month's shows
------------------
There [% cc == 1 ? "is $cc comment" : "are $cc comments" %] on [% current.size %] of this month's shows:
%% FOREACH ep IN current.keys.sort
%% arr = current.$ep
================================================================================
hpr[% arr.0.episode %] ([% arr.0.date %]) "[% arr.0.title %]" by [% arr.0.host %].
%% FOREACH row IN arr
------------------------------------------------------------------------------
Comment [% row.index %]: [% row.comment_author_name -%] on [% date.format(row.comment_timestamp_ut,'%Y-%m-%d','UTC') -%]:
[%- IF row.comment_title.length > 0 -%]
"[% row.comment_title FILTER decode_entities %]"
[%- ELSE -%]
"[no title]"
[%- END %]
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
[% wrap(row.comment_text, 80, ' ', ' ') FILTER decode_entities %]
%% END
%% END
%% END
%% ELSE
There were no comments this month.
%% END
[%# Any other business? -%]
[% IF aob == 1 -%]
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Any other business
------------------
[% INCLUDE $aobfile -%]
[%- END %]
[%#
# vim: syntax=tt2:ts=8:sw=4:ai:et:tw=78:fo=tcrqn21
-%]

View File

@@ -0,0 +1,21 @@
[%# mailnote_template.tpl 2015-06-12
# This is the main (and default) template used by the script
# 'summarise_mail'. It generates an HTML snippet which simply lists all of
# the message threads passed to it in the 'threads' hash and reports the
# total. This HTML is then inserted into the notes generated by
# the 'make_shownotes' script.
-%]
[%- aa = 'archived-at' -%]
<ol>
[%- FOREACH key IN threads.keys.sort %]
<li><em>From:</em> [% threads.$key.from.0 FILTER html_entity %]<br/>
<em>Date:</em> [% threads.$key.date %]<br/>
<em>Subject:</em> [% threads.$key.subject FILTER html_entity %]<br/>
<em>Link:</em> <a href="[% threads.$key.thread %]" target="_blank">[% threads.$key.thread %]</a><br/>
<em>Messages:</em> [% threads.$key.count %]<br/>[% key != threads.keys.sort.last ? '<br/>' : '' %]</li>
[%- END %]
</ol>
Total messages this month: [% total %]<br/>
[%#
# vim: syntax=tt2:ts=8:sw=4:ai:et:tw=78:fo=tcrqn21
-%]

View File

@@ -0,0 +1,22 @@
[%# mailnote_template2.tpl
# This is an alternative template for use with the 'summarise_mail' script.
# It generates a plain text version of the mail threads and is intended to
# be used by the Community News hosts when reading through the month's
# message threads.
-%]
[%- aa = 'archived-at' -%]
[%- FOREACH key IN threads.keys.sort -%]
From: [% threads.$key.from.0 %]
Date: [% threads.$key.date %]
Subject: [% threads.$key.subject %]
Link: [% threads.$key.thread %]
Messages: [% threads.$key.count %]
--------------------------------------------------------------------------------
[%- END -%]
Total messages this month: [% total %]
[%#
# vim: syntax=tt2:ts=8:sw=4:ai:et:tw=78:fo=tcrqn21
-%]

1578
Community_News/make_email Executable file

File diff suppressed because it is too large Load Diff

484
Community_News/make_meeting Executable file
View File

@@ -0,0 +1,484 @@
#!/usr/bin/env perl
#===============================================================================
#
# FILE: make_meeting
#
# USAGE: ./make_meeting
#
# DESCRIPTION: Makes a recurrent iCalendar meeting to be loaded into
# a calendar. This is apparently necessary when the 'RRULE'
# recurrence description is not adequate.
#
# OPTIONS: None
# REQUIREMENTS: Needs modules Getopt::Long, Data::ICal, Date::Parse and
# Date::Calc
# BUGS: ---
# NOTES: Based on a script distributed with the HPR episode "iCalendar
# Hacking"
# AUTHOR: Dave Morriss (djm), Dave.Morriss@gmail.com
# LICENCE: Copyright (c) year 2012-2024 Dave Morriss
# VERSION: 0.2.2
# CREATED: 2012-10-13 15:34:01
# REVISION: 2024-05-24 22:45:56
#
#===============================================================================
use 5.010;
use strict;
use warnings;
use Getopt::Long;
use Data::ICal;
use Data::ICal::Entry::Event;
use Data::ICal::Entry::Todo;
use Date::Parse;
use Date::Calc qw{:all};
use Date::ICal;
#use Data::Dumper;
#
# Version number (manually incremented)
#
our $VERSION = '0.2.2';
#
# Script name
#
( my $PROG = $0 ) =~ s|.*/||mx;
( my $DIR = $0 ) =~ s|/?[^/]*$||mx;
$DIR = '.' unless $DIR;
#
# Enable Unicode mode
#
binmode STDOUT, ":encoding(UTF-8)";
binmode STDERR, ":encoding(UTF-8)";
#-------------------------------------------------------------------------------
# Declarations
#-------------------------------------------------------------------------------
my ( @startdate, @rdate, @events );
#
# Attributes for the calendar message
#
#my $server = 'ch1.teamspeak.cc';
#my $port = 64747;
my $server = 'chatter.skyehaven.net';
my $port = 64738;
#-------------------------------------------------------------------------------
# Options and arguments
#-------------------------------------------------------------------------------
my $DEF_COUNT = 12;
#my $DEF_SUMMARY = 'Send out CNews email';
#
# Process options
#
my %options;
Options( \%options );
#
# Default help
#
usage() if ( $options{'help'} );
#
# Collect options
#
my $count = ( defined( $options{count} ) ? $options{count} : $DEF_COUNT );
my $reminder = ( defined( $options{reminder} ) ? $options{reminder} : 0 );
my $force = ( defined( $options{force} ) ? $options{force} : 0 );
#my $reminder_summary = ( defined( $options{summary} ) ? $options{summary} :
# $DEF_SUMMARY );
#
# Two reminders: 8 days ahead reminder to check with Ken, 5 days ahead
# reminder to send out the email.
#
my %reminders = (
email => [ -5, 'Send out CNews email' ],
check => [ -8, 'Check CNews date with Ken' ],
);
#
# Use the date provided or the default
#
if ( defined( $options{from} ) ) {
#
# Parse the date, convert to start of month and (optionally) validate it
#
@startdate = convert_date( $options{from}, $force );
}
else {
#
# Use the current date
#
@startdate = Today();
}
#
# Date and time values
#
# TODO: These should be in a configuration file, and should ideally be capable
# of having a time zone defined (default UTC, as now).
#
my $monday = 1; # Day of week number 1-7, Monday-Sunday
my @starttime = ( 13, 00, 00 ); # UTC
my @endtime = ( 15, 00, 00 );
my @todostart = ( 9, 00, 00 ); # UTC
my @todoend = ( 17, 00, 00 );
#
# Format of an ISO UTC datetime
#
my $fmt = "%02d%02d%02dT%02d%02d%02dZ";
#
# Constants for the event
#
my $calname = 'HPR Community News';
my $timezone = 'UTC';
my $location = "$server port: $port";
my $summary = 'HPR Community News Recording Dates';
my $description = <<ENDDESC;
Mumble settings
-------------------
Server Name: Anything you like
Server Address: $server
Port: $port
Name: Your name or alias is fine
Information about Mumble can be found here:
http://hackerpublicradio.org/recording.php
ENDDESC
#
# Compute the next recording date from the starting date (@startdate will be
# today's date or the start of the explicitly selected month provided via
# -from=DATE. We want day of the week to be Monday, the first in the month,
# then to go back 1 day from that to get to the Sunday! Simple)
#
@startdate = make_date( \@startdate, $monday, 1, -1 );
@rdate = @startdate;
#
# Create the calendar object
#
my $calendar = Data::ICal->new();
#
# Some calendar properties
#
$calendar->add_properties(
'X-WR-CALNAME' => $calname,
'X-WR-TIMEZONE' => $timezone,
);
#
# Create the event object
#
my $vevent = Data::ICal::Entry::Event->new();
#
# Add some event properties
#
$vevent->add_properties(
summary => $summary,
location => $location,
description => $description,
dtstart => sprintf( $fmt, @startdate, @starttime ),
dtend => sprintf( $fmt, @startdate, @endtime ),
);
#
# Add recurring dates. (Note that this generates RDATE entries rather than
# 1 entry with multiple dates; this is because this module doesn't seem to
# have the ability to generate the concatenated entry. The two modes of
# expressing the repeated dates seem to be equivalent.)
#
for my $i ( 1 .. $count ) {
#
# Recording date computation from the start of the month
#
@rdate = make_date( \@rdate, $monday, 1, -1 );
#
# Save the current recording date to make an array of arrayrefs
#
push( @events, [@rdate] );
#
# Add this date to the multi-date event
#
$vevent->add_property( rdate =>
[ sprintf( $fmt, @rdate, @starttime ), { value => 'DATE-TIME' } ],
);
#
# Increment the meeting date for the next one. If we're early in the month
# by one day otherwise to the beginning of the next month. This is
# necessary because otherwise make_date will skip months.
#
if ( $rdate[2] < 7 ) {
@rdate = Add_Delta_Days( @rdate, 1 );
}
else {
@rdate = ( ( Add_Delta_YM( @rdate, 0, 1 ) )[ 0 .. 1 ], 1 );
}
}
#
# Add the event into the calendar
#
$calendar->add_entry($vevent);
#
# Are we to add reminders?
#
if ($reminder) {
#
# Loop through the cache of recording dates
#
for my $i ( 0 .. $count - 1 ) {
#
# Loop through the reminders hash
#
for my $key (keys(%reminders)) {
#
# A new Todo entry each iteration
#
my $vtodo = Data::ICal::Entry::Todo->new();
#
# Get a recording date from the cache and subtract 5 days from it to
# get the preceding Monday
#
@rdate = @{ $events[$i] };
@rdate = Add_Delta_Days( @rdate, $reminders{$key}->[0] );
#
# Add the date as the date part of the Todo
#
$vtodo->add_properties(
summary => $reminders{$key}->[1],
status => 'INCOMPLETE',
dtstart => Date::ICal->new(
ical => sprintf( $fmt, @rdate, @todostart )
)->ical,
due => Date::ICal->new(
ical => sprintf( $fmt, @rdate, @todoend )
)->ical,
);
#
# Add to the calendar
#
$calendar->add_entry($vtodo);
}
}
}
#
# Print the result
#
print $calendar->as_string;
exit;
#=== FUNCTION ================================================================
# NAME: convert_date
# PURPOSE: Convert a textual date (ideally YYYY-MM-DD) to a Date::Calc
# date for the start of the given month.
# PARAMETERS: $textdate date in text form
# $force Boolean defining whether to skip validating
# the date
# RETURNS: The start of the month in the textual date in Date::Calc
# format
# DESCRIPTION: Parses the date string and makes a Date::Calc date from the
# result where the day part is 1. Optionally checks that the
# date isn't in the past, though $force = 1 ignores this check.
# THROWS: No exceptions
# COMMENTS: Requires Date::Calc and Date::Parse
# Note the validation 'die' has a non-generic message
# SEE ALSO: N/A
#===============================================================================
sub convert_date {
my ( $textdate, $force ) = @_;
my ( @today, @parsed, @startdate );
#
# Reference date
#
@today = Today();
#
# Parse and perform rudimentary validation on the $textdate date. Function
# 'strptime' returns "($ss,$mm,$hh,$day,$month,$year,$zone,$century)".
#
# The Date::Calc date $startdate[0] gets the returned year or the current
# year if no year was parsed, $startdate[1] gets the parsed month or the
# current month if no month was parsed, and $startdate[2] gets a day of 1.
#
@parsed = strptime($textdate);
die "Unable to parse date '$textdate'\n" unless @parsed;
@startdate = (
( defined( $parsed[5] ) ? $parsed[5] + 1900 : $today[0] ), # year
( defined( $parsed[4] ) ? $parsed[4] + 1 : $today[1] ), 1
);
#
# Unless we've overridden the check there should be a positive or zero
# difference in days between the target date and today's date to prevent
# going backwards in time.
#
unless ($force) {
unless ( Delta_Days( @today[ 0, 1 ], 1, @startdate ) ge 0 ) {
warn "Invalid date $textdate (in the past)\n";
die "Use -force to create a back-dated calendar\n";
}
}
return @startdate;
}
#=== FUNCTION ================================================================
# NAME: make_date
# PURPOSE: Make the event date for recurrence
# PARAMETERS: $refdate An arrayref to the reference date array
# (usually today's date)
# $dow Day of week for the event date (1-7, 1=Monday)
# $n The nth day of the week ($dow) in the given
# month required for the event date ($dow=1,
# $n=1 means first Monday)
# $offset Number of days to offset the computed date
# RETURNS: The resulting date as a list for Date::Calc
# DESCRIPTION: We want to compute a simple date with an offset, such as
# "the Sunday before the first Monday of the month". We do
# this by computing a pre-offset date (first Monday of month)
# then apply the offset (Sunday before).
# THROWS: No exceptions
# COMMENTS: TODO Needs more testing to be considered truly universal
# SEE ALSO:
#===============================================================================
sub make_date {
my ( $refdate, $dow, $n, $offset ) = @_;
#
# Compute the required date: the "$n"th day of week "$dow" in the year and
# month in @$refdate. This could be a date in the past.
#
my @date = Nth_Weekday_of_Month_Year( @$refdate[ 0, 1 ], $dow, $n );
#
# If the computed date plus the offset is before the base date advance
# a month
#
if ( Day_of_Year(@date) + $offset < Day_of_Year(@$refdate) ) {
#
# Add a month and recompute
#
@date = Add_Delta_YM( @date, 0, 1 );
@date = Nth_Weekday_of_Month_Year( @date[ 0, 1 ], $dow, $n );
}
#
# Apply the day offset
#
@date = Add_Delta_Days( @date, $offset ) if $offset;
#
# Return a list
#
return (@date);
}
#=== FUNCTION ================================================================
# NAME: ISO8601_Date
# PURPOSE: Format a Date::Calc date in ISO8601 format
# PARAMETERS: @date - a date in the Date::Calc format
# RETURNS: Text string containing a YYYY-MM-DD date
# DESCRIPTION: Just a convenience to allow a simple call like
# $str = ISO8601_Date(@date)
# THROWS: No exceptions
# COMMENTS: None
# SEE ALSO: N/A
#===============================================================================
sub ISO8601_Date {
my (@date) = (@_)[ 0, 1, 2 ];
if ( check_date(@date) ) {
return sprintf( "%04d-%02d-%02d", @date );
}
else {
return "*Invalid Date*";
}
}
#=== FUNCTION ================================================================
# NAME: usage
# PURPOSE: Display a usage message and exit
# PARAMETERS: None
# RETURNS: To command line level with exit value 1
# DESCRIPTION: Builds the usage message using global values
# THROWS: no exceptions
# COMMENTS: none
# SEE ALSO: n/a
#===============================================================================
sub usage {
print STDERR <<EOD;
Usage: $PROG [options] [FILE...]
$PROG v$VERSION
Makes a recurrent iCalendar meeting to be loaded into a calendar. Optionally
adds reminders in the form of TODO items in relation to each meeting.
-help Display this information
-from=DATE Start date for the calendar
-count=N Number of entries; default 12
-[no]force Allow a -from=DATE date before today; default not
-[no]reminder Add a reminder TODO item; default no
EOD
# -summary=TEXT Alternative text for the reminder (default 'Send out
# CNews email')
exit(1);
}
#=== FUNCTION ================================================================
# NAME: Options
# PURPOSE: Processes command-line options
# PARAMETERS: $optref Hash reference to hold the options
# RETURNS: Undef
# DESCRIPTION:
# THROWS: no exceptions
# COMMENTS: none
# SEE ALSO: n/a
#===============================================================================
sub Options {
my ($optref) = @_;
my @options = ( "help", "from=s", "count=i", "force!", "reminder!");
# "summary|rs=s" );
if ( !GetOptions( $optref, @options ) ) {
usage();
}
return;
}
# vim: syntax=perl:ts=8:sw=4:et:ai:tw=78:fo=tcrqn21:fdm=marker

2106
Community_News/make_shownotes Executable file

File diff suppressed because it is too large Load Diff

864
Community_News/reserve_cnews Executable file
View File

@@ -0,0 +1,864 @@
#!/usr/bin/env perl
#===============================================================================
#
# FILE: reserve_cnews
#
# USAGE: ./reserve_cnews [-from[=DATE]] [-count=COUNT] [-[no]dry-run]
# [-[no]silent] [-config=FILE] [-help] [-debug=N]
#
# DESCRIPTION: Reserve a series of slots from a given date for the Community
# News shows by computing the dates for the reservations and
# then working out the show numbers from there.
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: Dave Morriss (djm), Dave.Morriss@gmail.com
# VERSION: 0.0.14
# CREATED: 2014-04-29 22:16:00
# REVISION: 2023-04-10 16:05:36
#
#===============================================================================
use 5.010;
use strict;
use warnings;
use utf8;
use Getopt::Long;
use Pod::Usage;
use Config::General;
use Date::Parse;
use Date::Calc qw{:all};
use DBI;
use Data::Dumper;
#
# Version number (manually incremented)
#
our $VERSION = '0.0.14';
#
# Script name
#
( my $PROG = $0 ) =~ s|.*/||mx;
( my $DIR = $0 ) =~ s|/?[^/]*$||mx;
$DIR = '.' unless $DIR;
#-------------------------------------------------------------------------------
# Declarations
#-------------------------------------------------------------------------------
#
# Constants and other declarations
#
my $basedir = "$ENV{HOME}/HPR/Community_News";
my $configfile = "$basedir/.hpr_db.cfg";
my $hostname = 'HPR Volunteers';
my $seriesname = 'HPR Community News';
my $tags = 'Community News';
my $titlefmt = 'HPR Community News for %s %d';
my $summaryfmt = 'HPR Volunteers talk about shows released and comments '
. 'posted in %s %d';
my ( $dbh, $sth1, $sth2, $sth3, $h1, $h2, $rv );
my (@startdate, @rdate, @lastmonth, $show,
$hostid, $series, $title, $summary
);
#
# Enable Unicode mode
#
binmode STDOUT, ":encoding(UTF-8)";
binmode STDERR, ":encoding(UTF-8)";
#-------------------------------------------------------------------------------
# Options and arguments
#-------------------------------------------------------------------------------
my $DEFDEBUG = 0;
my $DEF_COUNT = 12;
#
# Process options
#
my %options;
Options( \%options );
#
# Default help
#
pod2usage( -msg => "$PROG version $VERSION\n", -exitval => 1 )
if ( $options{'help'} );
#
# Collect options
#
my $DEBUG = ( $options{'debug'} ? $options{'debug'} : $DEFDEBUG );
my $cfgfile
= ( defined( $options{config} ) ? $options{config} : $configfile );
my $dry_run = ( defined( $options{'dry-run'} ) ? $options{'dry-run'} : 0 );
my $silent = ( defined( $options{silent} ) ? $options{silent} : 0 );
my $count = ( defined( $options{count} ) ? $options{count} : $DEF_COUNT );
my $from = $options{from};
_debug( $DEBUG >= 1, 'Host name: ' . $hostname );
_debug( $DEBUG >= 1, 'Series name: ' . $seriesname );
_debug( $DEBUG >= 1, 'Tags: ' . $tags );
#-------------------------------------------------------------------------------
# Configuration file - load data
#-------------------------------------------------------------------------------
my $conf = new Config::General(
-ConfigFile => $cfgfile,
-InterPolateVars => 1,
-ExtendedAccess => 1
);
my %config = $conf->getall();
#-------------------------------------------------------------------------------
# Connect to the database
#-------------------------------------------------------------------------------
my $dbhost = $config{database}->{host} // '127.0.0.1';
my $dbport = $config{database}->{port} // 3306;
my $dbname = $config{database}->{name};
my $dbuser = $config{database}->{user};
my $dbpwd = $config{database}->{password};
$dbh = DBI->connect( "dbi:mysql:host=$dbhost;port=$dbport;database=$dbname",
$dbuser, $dbpwd, { AutoCommit => 1 } )
or die $DBI::errstr;
#
# Enable client-side UTF8
#
$dbh->{mysql_enable_utf8} = 1;
#-------------------------------------------------------------------------------
# Find the latest show for reference purposes
#-------------------------------------------------------------------------------
$sth1 = $dbh->prepare(
# q{SELECT id, date FROM eps
# WHERE DATEDIFF(date,CURDATE()) <= 0 AND DATEDIFF(date,CURDATE()) >= -2
# ORDER BY date DESC LIMIT 1}
q{SELECT id, date FROM eps
WHERE DATEDIFF(date,CURDATE()) BETWEEN -2 AND 0
ORDER BY date DESC LIMIT 1}
);
$sth1->execute;
if ( $dbh->err ) {
warn $dbh->errstr;
}
$h1 = $sth1->fetchrow_hashref;
my $ref_date = $h1->{date};
my $ref_show = $h1->{id};
#-------------------------------------------------------------------------------
# Find the required hostid
#-------------------------------------------------------------------------------
$sth1 = $dbh->prepare(q{SELECT hostid FROM hosts WHERE host = ?});
$sth1->execute($hostname);
if ( $dbh->err ) {
warn $dbh->errstr;
}
unless ( $h1 = $sth1->fetchrow_hashref ) {
warn "Unable to find host '$hostname' - cannot continue\n";
exit 1;
}
$hostid = $h1->{hostid};
#-------------------------------------------------------------------------------
# Find the required series
#-------------------------------------------------------------------------------
$sth1 = $dbh->prepare(q{SELECT id FROM miniseries WHERE name = ?});
$sth1->execute($seriesname);
if ( $dbh->err ) {
warn $dbh->errstr;
}
unless ( $h1 = $sth1->fetchrow_hashref ) {
warn "Unable to find series '$seriesname' - cannot continue\n";
exit 1;
}
$series = $h1->{id};
_debug( $DEBUG >= 2, 'Reference date: ' . $ref_date );
_debug( $DEBUG >= 2, 'Reference show: ' . $ref_show );
_debug( $DEBUG >= 2, 'Host id: ' . $hostid );
_debug( $DEBUG >= 2, 'Series id: ' . $series );
#-------------------------------------------------------------------------------
# The start date comes from the -from=DATE option, the database or is defaulted
#-------------------------------------------------------------------------------
#
# Use the date provided or the default
#
if ( ! defined( $from ) ) {
#
# Compute the first of the current month
#
_debug($DEBUG >= 3, "From date: Default");
@startdate = ( ( Today() )[ 0 .. 1 ], 1 );
}
elsif ( $from =~ /^$/ ) {
_debug($DEBUG >= 3, "From date: Database");
@startdate = get_next_date( $dbh, $series );
}
else {
#
# Parse the date, convert to start of month
#
_debug($DEBUG >= 3, "From date: Explicit");
@startdate = convert_date( $from, 0 );
}
_debug($DEBUG >= 3,"Start date: " . ISO8601_Date(@startdate));
#-------------------------------------------------------------------------------
# Set up for date manipulation
#-------------------------------------------------------------------------------
my @cdate = @startdate;
my $monday = 1; # Day of week number 1-7, Monday-Sunday
print "Start date: ", ISO8601_Date(@startdate), "\n" unless ($silent);
#
# The reference show, taken from the database
#
my @ref_date = split( /-/, $ref_date );
print "Reference show: hpr$ref_show on ", ISO8601_Date(@ref_date), "\n\n"
unless ($silent);
#
# Prepare some SQL (Note stopgap fix for the INSERT statement associated with $sth3)
#
$sth1 = $dbh->prepare(q{SELECT id FROM eps where id = ?});
$sth2 = $dbh->prepare(q{SELECT id, date FROM eps where title = ?});
$sth3 = $dbh->prepare(
q{
INSERT INTO eps (id,date,hostid,title,summary,series,tags,
duration,notes,downloads)
VALUES(?,?,?,?,?,?,?,0,'',0)
}
);
#
# Compute a series of dates from the start date
#
for my $i ( 1 .. $count ) {
#
# Determine the next first Monday of the month and the show number that
# goes with it
#
@rdate = make_date( \@cdate, $monday, 1, 0 );
$show = $ref_show + Delta_Business_Days( @ref_date, @rdate );
_debug($DEBUG >= 3,"Date: " . ISO8601_Date(@rdate) . " Show: $show");
#
# Make the text strings for this month
#
@lastmonth = Add_Delta_YM( @rdate, 0, -1 );
$title
= sprintf( $titlefmt, Month_to_Text( $lastmonth[1] ), $lastmonth[0] );
$summary
= sprintf( $summaryfmt, Month_to_Text( $lastmonth[1] ),
$lastmonth[0] );
_debug($DEBUG >= 3,"Title: $title");
_debug($DEBUG >= 3,"Summary: $summary");
#
# Do we already have a show with this title?
#
$rv = $sth2->execute($title);
if ( $dbh->err ) {
warn $dbh->errstr;
}
if ( $rv > 0 ) {
$h2 = $sth2->fetchrow_hashref;
unless ($silent) {
printf
"Skipping; an episode already exists with title '%s' (hpr%s, %s)\n",
$title, $h2->{id}, $h2->{date};
}
@cdate = Add_Delta_YM( @cdate, 0, 1 );
next;
}
#
# Is this show number taken?
#
$rv = $sth1->execute($show);
if ( $dbh->err ) {
warn $dbh->errstr;
}
if ( $rv > 0 ) {
#
# Find a free slot
#
print "Slot $show for '$title' is allocated. " unless ($silent);
until ( $rv == 0 && ( Day_of_Week(@rdate) < 6 ) ) {
$show++ if ( Day_of_Week(@rdate) < 6 );
@rdate = Add_Delta_Days( @rdate, 1 );
$rv = $sth1->execute($show);
if ( $dbh->err ) {
warn $dbh->errstr;
}
}
print "Next free slot is $show\n" unless ($silent);
}
#
# Reserve the slot or pretend to
#
unless ($dry_run) {
$rv = $sth3->execute( $show, ISO8601_Date(@rdate), $hostid,
$title, $summary, $series, $tags );
if ( $dbh->err ) {
warn $dbh->errstr;
}
if ( $rv > 0 ) {
printf "Reserved show hpr%d on %s for '%s'\n",
$show, ISO8601_Date(@rdate), $title
unless ($silent);
}
else {
print "Error reserving slot for '$title'\n" unless ($silent);
}
}
else {
printf "Show hpr%d on %s for '%s' not reserved - dry run\n",
$show, ISO8601_Date(@rdate), $title
unless ($silent);
}
@cdate = Add_Delta_YM( @cdate, 0, 1 );
}
for my $sth ( $sth1, $sth2, $sth3 ) {
$sth->finish;
}
$dbh->disconnect;
exit;
#=== FUNCTION ================================================================
# NAME: convert_date
# PURPOSE: Convert a textual date (ideally YYYY-MM-DD) to a Date::Calc
# date for the start of the given month.
# PARAMETERS: $textdate date in text form
# $force Boolean defining whether to skip validating
# the date
# RETURNS: The start of the month in the textual date in Date::Calc
# format
# DESCRIPTION: Parses the date string and makes a Date::Calc date from the
# result where the day part is 1. Optionally checks that the
# date isn't in the past, though $force = 1 ignores this check.
# THROWS: No exceptions
# COMMENTS: Requires Date::Calc and Date::Parse
# Note the validation 'die' has a non-generic message
# SEE ALSO: N/A
#===============================================================================
sub convert_date {
my ( $textdate, $force ) = @_;
my ( @today, @parsed, @startdate );
#
# Reference date
#
@today = Today();
#
# Parse and perform rudimentary validation on the $textdate date. Function
# 'strptime' returns "($ss,$mm,$hh,$day,$month,$year,$zone,$century)".
#
# The Date::Calc date $startdate[0] gets the returned year or the current
# year if no year was parsed, $startdate[1] gets the parsed month or the
# current month if no month was parsed, and $startdate[2] gets a day of 1.
#
@parsed = strptime($textdate);
die "Unable to parse date '$textdate'\n" unless @parsed;
@startdate = (
( defined( $parsed[5] ) ? $parsed[5] + 1900 : $today[0] ), # year
( defined( $parsed[4] ) ? $parsed[4] + 1 : $today[1] ), 1
);
#
# Unless we've overridden the check there should be a positive or zero
# difference in days between the target date and today's date to prevent
# going backwards in time.
#
unless ($force) {
unless ( Delta_Days( @today[ 0, 1 ], 1, @startdate ) ge 0 ) {
warn "Invalid date $textdate (in the past)\n";
die "Use -force to create a back-dated calendar\n";
}
}
return @startdate;
}
#=== FUNCTION ================================================================
# NAME: get_next_date
# PURPOSE: Find the next unused date from the database
# PARAMETERS: $dbh Database handle
# $series The id of the Community News series (from
# a previous query)
# RETURNS: The start of the month of the next free date in Date::Calc
# format
# DESCRIPTION: Finds the latest reservation in the database. Uses the date
# associated with this reservation, converts to Date::Calc
# format, adds a month to it and ensures it's the first Monday
# of that month (in case a non-standard reservation had been
# made)
# THROWS: No exceptions
# COMMENTS: TODO: do we need the show number of the latest reservation?
# SEE ALSO: N/A
#===============================================================================
sub get_next_date {
my ( $dbh, $series ) = @_;
my ( $sth, $h );
my ( $id, $lastdate, @startdate );
#
# Find the last reservation in the database
#
$sth = $dbh->prepare( q{
SELECT id, date
FROM eps WHERE series = ?
ORDER BY id DESC LIMIT 1;
}
);
$sth->execute($series);
if ( $dbh->err ) {
warn $dbh->errstr;
}
#
# Get the values returned
#
$h = $sth->fetchrow_hashref;
$id = $h->{id};
$lastdate = $h->{date};
#
# Convert the date to Date::Calc format, increment by a month and ensure
# it's the first Monday of the month (in case the last reservation is not
# on the right day for some reason - such as the day being reserved by
# some other mechanism)
#
@startdate = convert_date( $lastdate, 0 );
@startdate = Add_Delta_YM( @startdate, 0, 1 );
@startdate = make_date( \@startdate, 1, 1, 0 );
return @startdate;
}
#=== FUNCTION ================================================================
# NAME: make_date
# PURPOSE: Make the event date for recurrence
# PARAMETERS: $refdate
# An arrayref to the reference date array (usually
# today's date)
# $dow Day of week for the event date (1-7, 1=Monday)
# $n The nth day of the week in the given month required
# for the event date ($dow=1, $n=1 means first Monday)
# $offset Number of days to offset the computed date
# RETURNS: The resulting date as a list for Date::Calc
# DESCRIPTION: We want to compute a simple date with an offset, such as
# "the Saturday before the first Monday of the month". We do
# this by computing a pre-offset date (first Monday of month)
# then apply the offset (Saturday before).
# THROWS: No exceptions
# COMMENTS: TODO Needs more testing to be considered truly universal
# SEE ALSO:
#===============================================================================
sub make_date {
my ( $refdate, $dow, $n, $offset ) = @_;
#
# Compute the required date: the "$n"th day of week "$dow" in the year and
# month in @$refdate. This could be a date in the past.
#
my @date = Nth_Weekday_of_Month_Year( @$refdate[ 0, 1 ], $dow, $n );
#
# If the computed date plus the offset is before the base date advance
# a month
#
if ( Day_of_Year(@date) + $offset < Day_of_Year(@$refdate) ) {
#
# Add a month and recompute
#
@date = Add_Delta_YM( @date, 0, 1 );
@date = Nth_Weekday_of_Month_Year( @date[ 0, 1 ], $dow, $n );
}
#
# Apply the day offset
#
@date = Add_Delta_Days( @date, $offset ) if $offset;
#
# Return a list
#
return (@date);
}
#=== FUNCTION ================================================================
# NAME: Delta_Business_Days
# PURPOSE: Computes the number of weekdays between two dates
# PARAMETERS: @date1 - first date in Date::Calc format
# @date2 - second date in Date::Calc format
# RETURNS: The business day offset
# DESCRIPTION: This is a direct copy of the routine of the same name on the
# Date::Calc manpage.
# THROWS: No exceptions
# COMMENTS: Lifted from the manpage for Date::Calc
# SEE ALSO: N/A
#===============================================================================
sub Delta_Business_Days {
my (@date1) = (@_)[ 0, 1, 2 ];
my (@date2) = (@_)[ 3, 4, 5 ];
my ( $minus, $result, $dow1, $dow2, $diff, $temp );
$minus = 0;
$result = Delta_Days( @date1, @date2 );
if ( $result != 0 ) {
if ( $result < 0 ) {
$minus = 1;
$result = -$result;
$dow1 = Day_of_Week(@date2);
$dow2 = Day_of_Week(@date1);
}
else {
$dow1 = Day_of_Week(@date1);
$dow2 = Day_of_Week(@date2);
}
$diff = $dow2 - $dow1;
$temp = $result;
if ( $diff != 0 ) {
if ( $diff < 0 ) {
$diff += 7;
}
$temp -= $diff;
$dow1 += $diff;
if ( $dow1 > 6 ) {
$result--;
if ( $dow1 > 7 ) {
$result--;
}
}
}
if ( $temp != 0 ) {
$temp /= 7;
$result -= ( $temp << 1 );
}
}
if ($minus) { return -$result; }
else { return $result; }
}
#=== FUNCTION ================================================================
# NAME: ISO8601_Date
# PURPOSE: Format a Date::Calc date in ISO8601 format
# PARAMETERS: @date - a date in the Date::Calc format
# RETURNS: Text string containing a YYYY-MM-DD date
# DESCRIPTION: Just a convenience to allow a simple call like
# $str = ISO8601_Date(@date)
# THROWS: No exceptions
# COMMENTS: None
# SEE ALSO: N/A
#===============================================================================
sub ISO8601_Date {
my (@date) = (@_)[ 0, 1, 2 ];
if ( check_date(@date) ) {
return sprintf( "%04d-%02d-%02d", @date );
}
else {
return "*Invalid Date*";
}
}
#=== FUNCTION ================================================================
# NAME: _debug
# PURPOSE: Prints debug reports
# PARAMETERS: $active Boolean: 1 for print, 0 for no print
# $message Message to print
# RETURNS: Nothing
# DESCRIPTION: Outputs a message if $active is true. It removes any trailing
# newline and then adds one in the 'print' to the caller doesn't
# have to bother. Prepends the message with 'D> ' to show it's
# a debug message.
# THROWS: No exceptions
# COMMENTS: None
# SEE ALSO: N/A
#===============================================================================
sub _debug {
my ( $active, $message ) = @_;
chomp($message);
print "D> $message\n" if $active;
}
#=== FUNCTION ================================================================
# NAME: Options
# PURPOSE: Processes command-line options
# PARAMETERS: $optref Hash reference to hold the options
# RETURNS: Undef
# DESCRIPTION:
# THROWS: no exceptions
# COMMENTS: none
# SEE ALSO: n/a
#===============================================================================
sub Options {
my ($optref) = @_;
my @options = (
"help", "debug=i", "config=s", "from:s",
"count=i", "dry-run!", "silent!",
);
if ( !GetOptions( $optref, @options ) ) {
pod2usage( -msg => "$PROG version $VERSION\n", -exitval => 1 );
}
return;
}
__END__
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Application Documentation
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#{{{
=head1 NAME
reserve_cnews - reserve Community News shows in the HPR database
=head1 VERSION
This documentation refers to B<reserve_cnews> version 0.0.14
=head1 USAGE
./reserve_cnews [-help] [-from[=DATE]] [-count=COUNT]
[-[no]dry-run] [-[no]silent] [-config=FILE] [-debug=N]
Examples:
./reserve_cnews -help
./reserve_cnews
./reserve_cnews -from=1-June-2014 -dry-run
./reserve_cnews -from=15-Aug-2015 -count=6
./reserve_cnews -from=2015-12-06 -count=1 -silent
./reserve_cnews -from -count=1
./reserve_cnews -from -count=2 -debug=4
./reserve_cnews -config=.hpr_livedb.cfg -from=1-March-2019 -dry-run
=head1 OPTIONS
=over 8
=item B<-help>
Prints a brief help message describing the usage of the program, and then exits.
=item B<-from=DATE> or B<-from>
This option defines the starting date from which reservations are to be
created. The program ignores the day part, though it must be provided, and
replaces it with the first day of the month.
The date format should be B<DD-Mon-YYYY> (e.g. 12-Jun-2014), B<DD-MM-YYYY>
(e.g. 12-06-2014) or B<YYYY-MM-DD> (e.g. 2014-06-12).
If this option is omitted the current date is used.
If the B<DATE> part is omitted the script will search the database for the
reservation with the latest date and will use it as the starting point to
generate B<-count=COUNT> (or the default 12) reservations.
=item B<-count=COUNT>
This option defines the number of slots to reserve.
If this option is omitted then 12 slots are reserved.
=item B<-[no]dry-run>
This option in the form B<-dry-run> causes the program omit the step of adding
reservations to the database. In the form B<-nodry-run> or if omitted, the
program will perform the update(s).
=item B<-[no]silent>
This option in the form B<-silent> causes the program omit the reporting of
what it has done. In the form B<-nosilent> or if omitted, the program will
report what it is doing.
=item B<-config=FILE>
This option defines a configuration file other than the default
I<.hpr_db.cfg>. The file must be formatted as described below in the section
I<CONFIGURATION AND ENVIRONMENT>.
=item B<-debug=N>
Sets the level of debugging. The default is 0: no debugging.
Values are:
=over 4
=item 1
Produces details of some of the built-in values used.
=item 2
Produces any output defined for lower levels as well as details of the values
taken from the database for use when reserving the show(s).
=item 3
Produces any output defined for lower levels as well as:
=over 4
=item .
Details of how the `-from` date is being interpreted: default, computed from
the database or explicit. The actual date being used is reported.
=item .
Details of all dates chosen and their associated sho numbers using the
algorithm "first Monday of the month".
=item .
The show title chosen for each reservation is displayed as well as the summary.
=back
=back
=back
=head1 DESCRIPTION
Hacker Public Radio produces a Community News show every month. The show is
recorded on the Saturday before the first Monday of the month, and should be
released as soon as possible afterwards.
This program reserves future slots in the database for upcoming shows. It
computes the date of the first Monday of all of the months in the requested
sequence then determines which show number matches that date. It writes rows
into the I<reservations> table containing the episode number, the host
identifier ('HPR Admins') and the reason for the reservation.
It is possible that an HPR host has already requested the slot that this
program determines it should reserve. When this happens the program increments
the episode number and checks again, and repeats this process until a free
slot is discovered.
It is also possible that a reservation has previously been made in the
I<reservations> table. When this case occurs the program ignores this
particular reservation.
=head1 DIAGNOSTICS
=over 8
=item B<Invalid date ...>
The date element of the B<-from=DATE> option is not valid. See the description
of this option for details of what formats are acceptable.
=item B<Various database messages>
The program can generate warning messages from the database.
=item B<Unable to find host '...' - cannot continue>
The script needs to find the id number relating to the host that will be used
for Community News episodes. It does this by looking in the hosts table for
the name "HPR Volunteers". If this cannot be found, perhaps because it has
been changed, then the script cannot continue. The remedy is to change the
variable $hostname to match the new name.
=item B<Unable to find series '...' - cannot continue>
The script needs to find the id number relating to the series that will be
used for Community News episodes. It does this by looking in the miniseries
table for the name "HPR Community News". If this cannot be found, perhaps
because it has been changed, then the script cannot continue. The remedy is to
change the variable $seriesname to match the new name.
=back
=head1 CONFIGURATION AND ENVIRONMENT
The program obtains the credentials it requires for connecting to the HPR
database by loading them from a configuration file. The file is called
B<.hpr_db.cfg> and should contain the following data:
<database>
host = 127.0.0.1
port = PORT
name = DBNAME
user = USER
password = PASSWORD
</database>
=head1 DEPENDENCIES
Config::General
Data::Dumper
Date::Calc
Date::Parse
DBI
Getopt::Long
Pod::Usage
=head1 BUGS AND LIMITATIONS
There are no known bugs in this module.
Please report problems to Dave Morriss (Dave.Morriss@gmail.com)
Patches are welcome.
=head1 AUTHOR
Dave Morriss (Dave.Morriss@gmail.com)
=head1 LICENCE AND COPYRIGHT
Copyright (c) 2014 - 2023 Dave Morriss (Dave.Morriss@gmail.com). All
rights reserved.
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself. See perldoc perlartistic.
=cut
#}}}
# [zo to open fold, zc to close]
# vim: syntax=perl:ts=8:sw=4:et:ai:tw=78:fo=tcrqn21:fdm=marker

View File

@@ -0,0 +1 @@
shownote_template11.tpl

View File

@@ -0,0 +1,164 @@
[%# shownote_template10.tpl 2018-11-05 -%]
[%# HTML snippet for insertion into the database -%]
[%# This one uses the new format for the mailing list data, and partitions -%]
[%# comments into past and current. It also marks comments that don't need -%]
[%# to be read when -markcomments is selected. It requires make_shownotes > V0.0.28 -%]
[%- USE date -%]
[%- prefix = "http://hackerpublicradio.org"
correspondents = "$prefix/correspondents.php"
mailthreads = "$prefix/pipermail/hpr_hackerpublicradio.org/$review_year-$review_month/thread.html" -%]
[%- DEFAULT skip_comments = 0
mark_comments = 0 -%]
[%- IF mark_comments == 1 %]
<style>
p#ignore, li#ignore {
background-color: lightgreen;
color:maroon;
}
</style>
[%- END %]
[%# For the '-mailnotes' option without a file we generate our own inclusion. -%]
[%# We pretend 'default_mail' is a filename in the calling script. Messy. -%]
[% BLOCK default_mail -%]
<a href="[% mailthreads %]" target="_blank">[% mailthreads %]</a>
[% END -%]
<h2>New hosts</h2>
<p>
[% IF hosts.size > 0 -%]
Welcome to our new host[%- hosts.size > 1 ? 's' : '' -%]: <br />
[%- count = 0 %]
[%# List the new hosts. If a name contains a comma quote it. -%]
[%- FOREACH row IN hosts %]
[%- count = count + 1 %]
[%- hostname = (row.host.search(',') ? row.host.replace('^(.*)$','"$1"') : row.host) %]
<a href="[% correspondents %]?hostid=[% row.hostid %]" target="_blank">[% hostname %]</a>
[%- count < hosts.size ? ', ' : '.' %]
[%- END %]
[% ELSE -%]
There were no new hosts this month.
[% END -%]
</p>
<h2>Last Month's Shows</h2>
[%# The 'summary' attribute is deprecated in HTML5 but is included here to -%]
[%# prevent errors being reported in the note checker -%]
<table id="t01" summary="Last month's shows">
<tr>
<th>Id</th>
<th>Day</th>
<th>Date</th>
<th>Title</th>
<th>Host</th>
</tr>
[%- FOREACH row IN shows %]
<tr valign="top">
<td><strong><a href="http://hackerpublicradio.org/eps.php?id=[% row.eps_id %]" target="_blank">[% row.eps_id %]</a></strong></td>
<td>[% date.format(row.date,'%a') %]</td>
<td>[% date.format(row.date,'%Y-%m-%d') %]</td>
<td><a href="http://hackerpublicradio.org/eps.php?id=[% row.eps_id %]" target="_blank">[% row.title %]</a></td>
<td><a href="[% correspondents %]?hostid=[% row.ho_hostid %]" target="_blank">[% row.ho_host FILTER html_entity %]</a></td>
</tr>
[%- END %]
</table>
[%# ---------------------------------------------------------------------------------------- -%]
[%# Skip comments if told to by the caller -%]
[%- IF skip_comments == 0 -%]
<h2>Comments this month</h2>
[% IF comment_count > 0 -%]
[%- IF mark_comments == 1 -%]
<p id="ignore"><b>Note to Volunteers</b>: Comments marked in green were read in the last
Community News show and should be ignored in this one.</p>
[%- END -%]
<p>These are comments which have been made during the past month, either to shows
released during the month or to past shows.<br/>
There [%- comment_count == 1 ? "is $comment_count comment" : "are $comment_count comments" -%] in total.</p>
[% IF past_count > 0 -%]
<p>There [% past_count == 1 ? "is $past_count comment" : "are $past_count comments" %] on
[% past.size %] previous [% past.size == 1 ? "show" : "shows" %]:</p>
<ul>
[%- FOREACH ep IN past.keys.sort -%]
[%- arr = past.$ep -%]
<li><strong><a href="[% arr.0.identifier_url %]#comments" target="_blank">hpr[% arr.0.episode %]</a></strong>
([% arr.0.date %]) "<em>[% arr.0.title %]</em>"
by <a href="[% correspondents %]?hostid=[% arr.0.hostid %]" target="_blank">[% arr.0.host %]</a>.</li>
<li style="list-style: none; display: inline">
<ul>
[%- FOREACH row IN arr -%]
[%- IF mark_comments == 1 && ((row.comment_timestamp_ut <= last_recording) && (arr.0.date.substr(0,7) == last_month)) -%]
<li id="ignore">
[%- ELSE %]
<li>
[%- END %]
<a href="[% row.identifier_url %]#[% row.index %]" target="_blank">Comment [% row.index %]</a>:
[% row.comment_author_name FILTER html_entity -%] on [% date.format(row.comment_timestamp_ut,'%Y-%m-%d','UTC') -%]:
[%- IF row.comment_title.length > 0 %]
"[% row.comment_title %]"
[%- ELSE -%]
"[no title]"
[%- END -%]
</li>
[%- END -%]
</ul><br/>
</li>
[%- END -%]
</ul>
[%- END %]
[%# ---------------------------------------------------------------------------------------- -%]
[% cc = (comment_count - past_count) -%]
[% IF cc > 0 -%]
<p>There [% cc == 1 ? "is $cc comment" : "are $cc comments" %] on [% current.size %] of this month's shows:</p>
<ul>
[%- FOREACH ep IN current.keys.sort -%]
[%- arr = current.$ep -%]
<li><strong><a href="[% arr.0.identifier_url %]#comments" target="_blank">hpr[% arr.0.episode %]</a></strong>
([% arr.0.date %]) "<em>[% arr.0.title %]</em>"
by <a href="[% correspondents %]?hostid=[% arr.0.hostid %]" target="_blank">[% arr.0.host %]</a>.</li>
<li style="list-style: none; display: inline">
<ul>
[%- FOREACH row IN arr -%]
<li><a href="[% row.identifier_url %]#[% row.index %]" target="_blank">Comment [% row.index %]</a>:
[% row.comment_author_name FILTER html_entity -%] on [% date.format(row.comment_timestamp_ut,'%Y-%m-%d','UTC') -%]:
[%- IF row.comment_title.length > 0 %]
"[% row.comment_title %]"
[%- ELSE -%]
"[no title]"
[%- END -%]
</li>
[%- END -%]
</ul><br/>
</li>
[%- END -%]
</ul>
[%- END %]
[%- ELSE %]
There were no comments this month.
[%- END %]
[%- END %]
[%# ---------------------------------------------------------------------------------------- -%]
[%- IF includefile.defined -%]
<h2>Mailing List discussions</h2>
<p>
Policy decisions surrounding HPR are taken by the community as a whole. This
discussion takes place on the <a href="http://hackerpublicradio.org/maillist"
target="_blank">Mail List</a> which is open to all HPR listeners and
contributors. The discussions are open and available on the HPR server under
<a href="http://hackerpublicradio.org/pipermail/hpr_hackerpublicradio.org/">Mailman</a>.
</p>
<p>The threaded discussions this month can be found here:</p>
[% INCLUDE $includefile -%]
[%- END %]
[%# ---------------------------------------------------------------------------------------- -%]
[%# Any other business? -%]
[% IF aob == 1 -%]
<h2>Any other business</h2>
[% INCLUDE $aobfile -%]
[%- END %]
[%#
# vim: syntax=tt2:ts=8:sw=4:ai:et:tw=78:fo=tcrqn21
-%]

View File

@@ -0,0 +1,234 @@
[%# shownote_template11.tpl 2024-05-07 -%]
[%# HTML snippet for insertion into the database -%]
[%# This one uses the new format for the mailing list data, and partitions -%]
[%# comments into past and current. It also marks comments that don't need -%]
[%# to be read when -markcomments is selected. It requires make_shownotes >= V0.0.30 -%]
[%- USE date -%]
[%- USE pad4 = format('%04d') -%]
[%- correspondents = "https://hackerpublicradio.org/correspondents"
mailbase="https://lists.hackerpublicradio.com/pipermail/hpr"
mailthreads = "$mailbase/$review_year-$review_month/thread.html" -%]
[%- DEFAULT skip_comments = 0
mark_comments = 0
ctext = 0
ignore_count = 0
missed_count = 0
past_count = 0
-%]
[%# Embedded CSS. The 'table' and 'hr' settings are always there but the rest is only for if -%]
[%# we are marking comments -%]
<style>
table td.shrink {
white-space:nowrap
}
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);
}
[%- IF mark_comments == 1 %]
p#ignore, li#ignore {
background-color: lightgreen;
color:maroon;
}
div#highlight {
border-style: solid;
border-color: red;
padding-right: 20px;
padding-left: 20px;
}
[%- END %]
</style>
[%# For the '-mailnotes' option without a file we generate our own inclusion. -%]
[%# We pretend 'default_mail' is a filename in the calling script. Messy. -%]
[% BLOCK default_mail -%]
<a href="[% mailthreads %]" target="_blank">[% mailthreads %]</a>
[% END -%]
<h2>New hosts</h2>
<p>
[% IF hosts.size > 0 -%]
Welcome to our new host[%- hosts.size > 1 ? 's' : '' -%]: <br />
[%- count = 0 %]
[%# List the new hosts. If a name contains a comma quote it. -%]
[%- FOREACH row IN hosts %]
[%- count = count + 1 %]
[%- hostname = (row.host.search(',') ? row.host.replace('^(.*)$','"$1"') : row.host) %]
<a href="[% correspondents %]/[% pad4(row.hostid) %].html" target="_blank">[% hostname %]</a>
[%- count < hosts.size ? ', ' : '.' %]
[%- END %]
[% ELSE -%]
There were no new hosts this month.
[% END -%]
</p>
<h2>Last Month's Shows</h2>
[%# The id 't01' is in the HPR CSS but might give trouble on the IA -%]
<table id="t01">
<tr>
<th>Id</th>
<th>Day</th>
<th>Date</th>
<th>Title</th>
<th>Host</th>
</tr>
[%- FOREACH row IN shows %]
<tr>
<td><strong><a href="https://hackerpublicradio.org/eps/hpr[% pad4(row.eps_id) %]/index.html" target="_blank">[% row.eps_id %]</a></strong></td>
<td>[% date.format(row.date,'%a') %]</td>
<td class="shrink">[% date.format(row.date,'%Y-%m-%d') %]</td>
<td><a href="https://hackerpublicradio.org/eps/hpr[% pad4(row.eps_id) %]/index.html" target="_blank">[% row.title %]</a></td>
<td><a href="[% correspondents %]/[% pad4(row.ho_hostid) %].html" target="_blank">[% row.ho_host FILTER html_entity %]</a></td>
</tr>
[%- END %]
</table>
[%# ---------------------------------------------------------------------------------------- -%]
[%# Skip comments if told to by the caller -%]
[%- IF skip_comments == 0 -%]
[%# Handle any missed comments if mark_comments is true -%]
[%- IF mark_comments == 1 && missed_count > 0 -%]
<br/><div id="highlight">
<h2>Missed comment[%- missed_comments.size > 1 ? 's' : '' -%] last month</h2>
<p><b>Note to Volunteers</b>: These are comments for shows last month that were not read in the last show because they arrived on or after the recording day. This section will be removed before these notes are released.</p>
<ul>
[%- FOREACH comment IN missed_comments -%]
<li><strong><a href="[% comment.identifier_url %]#comments" target="_blank">hpr[% comment.episode %]</a></strong>
([% comment.date %]) "<em>[% comment.title %]</em>" by <a href="[% correspondents %]/[% pad4(comment.hostid) %].html" target="_blank">[% comment.host %]</a>.<br/>
<small>Summary: "<em>[% comment.summary %]</em>"</small><br/>
From: [% comment.comment_author_name FILTER html_entity -%] on [% date.format(comment.comment_timestamp_ut,'%Y-%m-%d','UTC') -%]:
[%- IF comment.comment_title.length > 0 %]
"[% comment.comment_title %]"
[%- ELSE -%]
"[no title]"
[%- END -%]
<br/><hr class="thin">[% comment.comment_text FILTER html_line_break %]
</li><br/>
[%- END -%]
</ul></div>
[%- END -%]
[%# ---------------------------------------------------------------------------------------- -%]
<h2>Comments this month</h2>
[% IF comment_count > 0 -%]
[%- IF mark_comments == 1 && ignore_count > 0 -%]
<p id="ignore"><b>Note to Volunteers</b>: Comments marked in green were read in the last
Community News show and should be ignored in this one.</p>
[%- END -%]
<p>These are comments which have been made during the past month, either to shows released during the month or to past shows.
There [%- comment_count == 1 ? "is $comment_count comment" : "are $comment_count comments" -%] in total.</p>
[% IF past_count > 0 -%]
<h3>Past shows</h3>
<p>There [% past_count == 1 ? "is $past_count comment" : "are $past_count comments" %] on
[% past.size %] previous [% past.size == 1 ? "show" : "shows" %]:</p>
<ul>
[%# Loop through by episode then by comment relating to that episode -%]
[%- FOREACH ep IN past.keys.sort -%]
[%- arr = past.$ep -%]
<li><strong><a href="[% arr.0.identifier_url %]#comments" target="_blank">hpr[% arr.0.episode %]</a></strong>
([% arr.0.date %]) "<em>[% arr.0.title %]</em>"
by <a href="[% correspondents %]/[% pad4(arr.0.hostid) %].html" target="_blank">[% arr.0.host %]</a>.<br/>
[%- IF mark_comments == 1 || ctext == 1 -%]
<small>Summary: "<em>[% arr.0.summary %]</em>"</small></li>
[%- END %]
<li style="list-style: none; display: inline">
<ul>
[%- FOREACH row IN arr -%]
[%# IF mark_comments == 1 && ((row.comment_timestamp_ut <= last_recording) && (arr.0.date.substr(0,7) == last_month)) -%]
[%# IF mark_comments == 1 && ((row.comment_released_ut <= last_recording) && (arr.0.date.substr(0,7) == last_month)) -%]
[%- IF mark_comments == 1 && row.ignore == 1 -%]
<li id="ignore">
[%- ELSE %]
<li>
[%- END %]
<a href="[% row.identifier_url %]#[% row.index %]" target="_blank">Comment [% row.index %]</a>:
[% row.comment_author_name FILTER html_entity -%] on [% date.format(row.comment_timestamp_ut,'%Y-%m-%d','UTC') -%]:
[%- IF row.comment_title.length > 0 %]
"[% row.comment_title %]"
[%- ELSE -%]
"[no title]"
[%- END -%]
[%# Add the comment body in too if ctext is true -%]
[%- IF ctext == 1 %]
<br/><hr class="thin">[% row.comment_text FILTER html_line_break %]
</li><br/>
[%- ELSE -%]
</li>
[%- END -%]
[%- END -%]
</ul><br/>
</limage>
[%- END -%]
</ul>
[%- IF mark_comments == 1 || ctext == 1 -%]
<p><small><small><em>Updated on [% date.format(date.now,'%Y-%m-%d %H:%M:%S') %]</em></small></small></p>
[%- END -%]
[%- END %]
[%# ---------------------------------------------------------------------------------------- -%]
[% cc = (comment_count - past_count) -%]
[% IF cc > 0 -%]
<h3>This month's shows</h3>
<p>There [% cc == 1 ? "is $cc comment" : "are $cc comments" %] on [% current.size %] of this month's shows:</p>
<ul>
[%- FOREACH ep IN current.keys.sort -%]
[%- arr = current.$ep -%]
<li><strong><a href="[% arr.0.identifier_url %]#comments" target="_blank">hpr[% arr.0.episode %]</a></strong>
([% arr.0.date %]) "<em>[% arr.0.title %]</em>"
by <a href="[% correspondents %]/[% pad4(arr.0.hostid) %].html" target="_blank">[% arr.0.host %]</a>.</li>
<li style="list-style: none; display: inline">
<ul>
[%- FOREACH row IN arr -%]
<li><a href="[% row.identifier_url %]#[% row.index %]" target="_blank">Comment [% row.index %]</a>:
[% row.comment_author_name FILTER html_entity -%] on [% date.format(row.comment_timestamp_ut,'%Y-%m-%d','UTC') -%]:
[%- IF row.comment_title.length > 0 %]
"[% row.comment_title %]"
[%- ELSE -%]
"[no title]"
[%- END -%]
</li>
[%- END -%]
</ul><br/>
</li>
[%- END -%]
</ul>
[%- END %]
[%- ELSE %]
There were no comments this month.
[%- END %]
[%- END %]
[%# ---------------------------------------------------------------------------------------- -%]
[%- IF includefile.defined -%]
<h2>Mailing List discussions</h2>
<p>
Policy decisions surrounding HPR are taken by the community as a whole. This
discussion takes place on the <a href="https://hackerpublicradio.org/maillist"
target="_blank">Mail List</a> which is open to all HPR listeners and
contributors. The discussions are open and available on the HPR server under
<a href="[% mailbase %]">Mailman</a>.
</p>
<p>The threaded discussions this month can be found here:</p>
[% INCLUDE $includefile -%]
[%- END %]
[%# ---------------------------------------------------------------------------------------- -%]
<h2>Events Calendar</h2>
<p>With the kind permission of <strong>LWN.net</strong> we are linking to
<a href="https://lwn.net/Calendar/" target="_blank">The LWN.net Community Calendar</a>.</p>
<p>Quoting the site:</p>
<blockquote>This is the LWN.net community event calendar, where we track
events of interest to people using and developing Linux and free software.
Clicking on individual events will take you to the appropriate web
page.</blockquote>
[%# ---------------------------------------------------------------------------------------- -%]
[%# Any other business? -%]
[% IF aob == 1 -%]
<h2>Any other business</h2>
[% INCLUDE $aobfile -%]
[%- END %]
[%#
# vim: syntax=tt2:ts=8:sw=4:ai:et:tw=78:fo=tcrqn21
-%]

View File

@@ -0,0 +1,95 @@
[%# shownote_template.tpl -%]
[%- correspondents = "http://hackerpublicradio.org/correspondents.php" %]
[%- DEFAULT skip_comments = 0 %]
<!DOCTYPE HTML>
<html>
<body>
<h1>HPR Community News for [% review_month %]</h1>
<h2>New hosts</h2>
<p>
[% IF hosts.size > 0 -%]
Welcome to our new hosts: <br />
[%- count = 0 %]
[%- FOREACH row IN hosts %]
[%- count = count + 1 %]
<a href="[% correspondents %]?hostid=[% row.hostid %]">[% row.host %]</a>
[%- count < hosts.size ? ', ' : '.' %]
[%- END %]
[% ELSE -%]
There were no new hosts this month.
[% END -%]
</p>
<h2>Last Month's Shows</h2>
<table>
<thead>
<tr>
<th align="left">Id</th>
<th align="left">Date</th>
<th align="left">Title</th>
<th align="left">Host</th>
</tr>
</thead>
<tbody>
[%- FOREACH row IN shows %]
<tr valign="top">
<td align="left"><strong>[% row.eps_id %]</strong></td>
<td align="left">[% row.date %]</td>
<td align="left"><a href="http://hackerpublicradio.org/eps.php?id=[% row.eps_id %]">[% row.title FILTER html_entity %]</a></td>
<td align="left"><a href="[% correspondents %]?hostid=[% row.ho_hostid %]">[% row.ho_host FILTER html_entity %]</a></td>
</tr>
[%- END %]
</tbody>
</table>
[%- IF includefile.defined %]
<h2>Mailing List discussions</h2>
<p>
Policy decisions surrounding HPR are taken by the community as a whole. This discussion takes
place on the <a href="http://hackerpublicradio.org/maillist">Mail List</a> which is open to all
HPR listeners and contributors. The discussions are open and available on the
<a href="http://news.gmane.org/gmane.network.syndication.podcast.hacker-public-radio">Gmane</a>
archive.
</p>
<p>
Discussed this month were:
[%- INCLUDE $includefile %]
</p>
[%- END %]
[%# Skip comments if told to by the caller %]
[%- IF skip_comments == 0 %]
<h2>Comments this month</h2>
[% IF comments.size > 0 -%]
<p>There are [% comments.size %] comments:</p>
<ul>
[%- last_ep = 0 %]
[%- FOREACH row IN comments %]
[%- IF last_ep != row.episode %]
<hr/>
[%- END %]
[%- last_ep = row.episode %]
<li><strong>hpr[% row.episode %]</strong> [% row.comment_author_name FILTER html_entity -%]:
[%- IF row.comment_title.length > 0 %]
"[% row.comment_title FILTER html_entity %]",
[%- ELSE -%]
"[no title]",
[%- END -%]
relating to the show <a href="http://hackerpublicradio.org[% row.comment_identifier%]">hpr[% row.episode %]</a>
([% row.date %]) "<em>[% row.title FILTER html_entity %]</em>"
by <a href="[% correspondents %]?hostid=[% row.hostid %]">[% row.host %]</a>.</li>
[%- END %]
</ul>
[%- ELSE %]
There were no comments this month.
[%- END %]
[%- END %]
</body>
</html>
[%#
# vim: syntax=tt2:ts=8:sw=4:ai:et:tw=78:fo=tcrqn21
-%]

View File

@@ -0,0 +1,102 @@
[%# shownote_template3.tpl -%]
[%- USE date -%]
[%- correspondents = "http://hackerpublicradio.org/correspondents.php" -%]
[%- DEFAULT skip_comments = 0 -%]
<!DOCTYPE HTML>
<html>
<body>
<h1>HPR Community News for [% review_month %]</h1>
<h2>New hosts</h2>
<p>
[% IF hosts.size > 0 -%]
Welcome to our new hosts: <br />
[%- count = 0 %]
[%- FOREACH row IN hosts %]
[%- count = count + 1 %]
<a href="[% correspondents %]?hostid=[% row.hostid %]">[% row.host %]</a>
[%- count < hosts.size ? ', ' : '.' %]
[%- END %]
[% ELSE -%]
There were no new hosts this month.
[% END -%]
</p>
<h2>Last Month's Shows</h2>
<table>
<thead>
<tr>
<th align="left">Id</th>
<th align="left">Date</th>
<th align="left">Title</th>
<th align="left">Host</th>
</tr>
</thead>
<tbody>
[%- FOREACH row IN shows %]
<tr valign="top">
<td align="left"><strong>[% row.eps_id %]</strong></td>
<td align="left">[% row.date %]</td>
<td align="left"><a href="http://hackerpublicradio.org/eps.php?id=[% row.eps_id %]">[% row.title FILTER html_entity %]</a></td>
<td align="left"><a href="[% correspondents %]?hostid=[% row.ho_hostid %]">[% row.ho_host FILTER html_entity %]</a></td>
</tr>
[%- END %]
</tbody>
</table>
[%- IF includefile.defined -%]
<h2>Mailing List discussions</h2>
<p>
Policy decisions surrounding HPR are taken by the community as a whole. This discussion takes
place on the <a href="http://hackerpublicradio.org/maillist">Mail List</a> which is open to all
HPR listeners and contributors. The discussions are open and available on the
<a href="http://news.gmane.org/gmane.network.syndication.podcast.hacker-public-radio">Gmane</a>
archive.
</p>
<p>
Discussed this month were:
[%- INCLUDE $includefile %]
</p>
[%- END -%]
[%# Skip comments if told to by the caller -%]
[%- IF skip_comments == 0 -%]
<h2>Comments this month</h2>
[% IF comments.size > 0 -%]
<p>There are [% comments.size %] comments:</p>
<ul>
[%- last_ep = 0 -%]
[%- FOREACH row IN comments -%]
[%= IF last_ep != row.episode =%]
[%= IF last_ep != 0 %]
</ol><br/></li>
[%= END %]
<li><strong><a href="http://hackerpublicradio.org[% row.comment_identifier %]">hpr[% row.episode %]</a></strong>
([% row.date %]) "<em>[% row.title FILTER html_entity %]</em>"
by <a href="[% correspondents %]?hostid=[% row.hostid %]">[% row.host %]</a>.
<ol>
[%- END -%]
[%- last_ep = row.episode %]
<li>[% row.comment_author_name FILTER html_entity -%] on [% date.format(row.comment_timestamp,'%Y-%m-%d') -%]:
[%- IF row.comment_title.length > 0 -%]
"[% row.comment_title FILTER html_entity %]"
[%- ELSE -%]
"[no title]"
[%- END -%]
</li>
[%- END -%]
</ol>
</li>
</ul>
[%- ELSE %]
There were no comments this month.
[%- END %]
[%- END %]
</body>
</html>
[%#
# vim: syntax=tt2:ts=8:sw=4:ai:et:tw=78:fo=tcrqn21
-%]

View File

@@ -0,0 +1,121 @@
[%# shownote_template4.tpl -%]
[%- correspondents = "http://hackerpublicradio.org/correspondents.php" %]
[%- DEFAULT skip_comments = 0 %]
<!DOCTYPE HTML>
<html>
<body>
<h1>HPR Community News for [% review_month %]</h1>
<h2>New hosts</h2>
<p>
[% IF hosts.size > 0 -%]
Welcome to our new [% hosts.size == 1 ? 'host' : 'hosts' %]: <br />
[%- count = 0 %]
[%- FOREACH row IN hosts %]
[%- count = count + 1 %]
<a href="[% correspondents %]?hostid=[% row.hostid %]">[% row.host %]</a>
[%- count < hosts.size ? ', ' : '.' %]
[%- END %]
[% ELSE -%]
There were no new hosts this month.
[% END -%]
</p>
<h2>Last Month's Shows</h2>
<table>
<thead>
<tr>
<th align="left">Id</th>
<th align="left">Date</th>
<th align="left">Title</th>
<th align="left">Host</th>
</tr>
</thead>
<tbody>
[%- FOREACH row IN shows %]
<tr valign="top">
<td align="left"><strong>[% row.eps_id %]</strong></td>
<td align="left">[% row.date %]</td>
<td align="left"><a href="http://hackerpublicradio.org/eps.php?id=[% row.eps_id %]">[% row.title FILTER html_entity %]</a></td>
<td align="left"><a href="[% correspondents %]?hostid=[% row.ho_hostid %]">[% row.ho_host FILTER html_entity %]</a></td>
</tr>
[%- END %]
</tbody>
</table>
[%- IF includefile.defined %]
<h2>Mailing List discussions</h2>
<p>
Policy decisions surrounding HPR are taken by the community as a whole. This discussion takes
place on the <a href="http://hackerpublicradio.org/maillist">Mail List</a> which is open to all
HPR listeners and contributors. The discussions are open and available on the
<a href="http://news.gmane.org/gmane.network.syndication.podcast.hacker-public-radio">Gmane</a>
archive.
</p>
<p>
Discussed this month were:
[%- INCLUDE $includefile %]
</p>
[%- END %]
[%# Skip comments if told to by the caller %]
[%- IF skip_comments == 0 %]
<h2>Comments this month</h2>
[% IF comments.size > 0 -%]
<p>There are [% comments.size %] comments:</p>
<table border="1">
<thead>
<tr>
<th align="left">Show</th>
<th align="left">Title</th>
<th align="left">Host</th>
<th align="left">From</th>
<th align="left">Subject</th>
</tr>
</thead>
<tbody>
[%- FOREACH row IN comments %]
<tr valign="top">
<td><a href="http://hackerpublicradio.org/eps.php?id=[% row.episode %]">[% row.episode %]</a></td>
<td>[% row.title FILTER html_entity %]</td>
<td><a href="[% correspondents %]?hostid=[% row.hostid %]">[% row.host %]</a></td>
<td>[% row.comment_author_name FILTER html_entity %]</td>
<td>
[%- IF row.comment_title.length > 0 %]
[% row.comment_title FILTER html_entity %]
[%- ELSE %]
-
[%- END %]
</tr>
[%- END %]
</td>
</tbody>
</table>
<ul>
[%- FOREACH row IN comments %]
<li><strong>hpr[% row.episode %]</strong>
[% row.comment_author_name FILTER html_entity %]:
[%- IF row.comment_title.length > 0 %]
"[% row.comment_title FILTER html_entity %]",
[%- ELSE %]
"[no title]",
[%- END %]
relating to the show <a href="http://hackerpublicradio.org[% row.comment_identifier%]">hpr[% row.episode %]</a>
([% row.date %]) "<em>[% row.title FILTER html_entity %]</em>"
by <a href="[% correspondents %]?hostid=[% row.hostid %]">[% row.host %]</a>.</li>
[%- END %]
</ul>
[%- ELSE %]
There were no comments this month.
[%- END %]
[%- END %]
</body>
</html>
[%#
# vim: syntax=tt2:ts=8:sw=4:ai:et:tw=78:fo=tcrqn21
-%]

View File

@@ -0,0 +1,100 @@
[%# shownote_template5.tpl 2016-07-23 -%]
[%# HTML snippet for insertion into the database -%]
[%- USE date -%]
[%- correspondents = "http://hackerpublicradio.org/correspondents.php" -%]
[%- DEFAULT skip_comments = 0 -%]
[%# <h1>HPR Community News for {% review_month %}</h1> -%]
<h2>New hosts</h2>
<p>
[% IF hosts.size > 0 -%]
Welcome to our new host[%- hosts.size > 1 ? 's' : '' -%]: <br />
[%- count = 0 %]
[%- FOREACH row IN hosts %]
[%- count = count + 1 %]
<a href="[% correspondents %]?hostid=[% row.hostid %]" target="_blank">[% row.host %]</a>
[%- count < hosts.size ? ', ' : '.' %]
[%- END %]
[% ELSE -%]
There were no new hosts this month.
[% END -%]
</p>
<h2>Last Month's Shows</h2>
[%# The 'summary' attribute is deprecated in HTML5 but is included here to -%]
[%# prevent errors being reported in the note checker -%]
<table id="t01" summary="Last month's shows">
<tr>
<th align="left">Id</th>
<th align="left">Day</th>
<th align="left">Date</th>
<th align="left">Title</th>
<th align="left">Host</th>
</tr>
[%- FOREACH row IN shows %]
<tr valign="top">
<td align="left"><strong><a href="http://hackerpublicradio.org/eps.php?id=[% row.eps_id %]" target="_blank">[% row.eps_id %]</a></strong></td>
<td align="left">[% date.format(row.date,'%a') %]</td>
<td align="left">[% date.format(row.date,'%Y-%m-%d') %]</td>
<td align="left"><a href="http://hackerpublicradio.org/eps.php?id=[% row.eps_id %]" target="_blank">[% row.title %]</a></td>
<td align="left"><a href="[% correspondents %]?hostid=[% row.ho_hostid %]" target="_blank">[% row.ho_host FILTER html_entity %]</a></td>
</tr>
[%- END %]
</table>
[%- IF includefile.defined -%]
<h2>Mailing List discussions</h2>
<p>
Policy decisions surrounding HPR are taken by the community as a whole. This discussion takes
place on the <a href="http://hackerpublicradio.org/maillist" target="_blank">Mail List</a> which is open to all
HPR listeners and contributors. The discussions are open and available on the
<a href="http://news.gmane.org/gmane.network.syndication.podcast.hacker-public-radio" target="_blank">Gmane</a>
archive.
</p>
<p>The main threads this month were:</p>
[% INCLUDE $includefile -%]
[%- END %]
[%# Skip comments if told to by the caller -%]
[%- IF skip_comments == 0 -%]
<h2>Comments this month</h2>
[% IF comment_count > 0 -%]
<p>These are comments which have been made during the past month, either to shows
released during the month or to past shows.</p>
<p>There [%- comment_count == 1 ? "is $comment_count comment" : "are $comment_count comments" -%]:</p>
<ul>
[%- last_ep = 0 -%]
[%- FOREACH row IN comments -%]
[%= IF last_ep != row.episode =%]
[%= IF last_ep != 0 %]
</ul><br/></li>
[%= END %]
<li><strong><a href="[% row.identifier_url %]#comments" target="_blank">hpr[% row.episode %]</a></strong>
([% row.date %]) "<em>[% row.title %]</em>"
by <a href="[% correspondents %]?hostid=[% row.hostid %]" target="_blank">[% row.host %]</a>.
<ul>
[%- END -%]
[%- last_ep = row.episode %]
[%= IF row.in_range =%]
<li><a href="[% row.identifier_url %]#[% row.index %]" target="_blank">Comment [% row.index %]</a>:
[% row.comment_author_name FILTER html_entity -%] on [% date.format(row.comment_timestamp,'%Y-%m-%d') -%]:
[%- IF row.comment_title.length > 0 %]
"[% row.comment_title FILTER html_entity %]"
[%- ELSE -%]
"[no title]"
[%- END -%]
</li>
[%- END -%]
[%- END -%]
</ul>
</li>
</ul>
[%- ELSE %]
There were no comments this month.
[%- END %]
[%- END %]
[%#
# vim: syntax=tt2:ts=8:sw=4:ai:et:tw=78:fo=tcrqn21
-%]

View File

@@ -0,0 +1,107 @@
[%# shownote_template6.tpl 2016-08-17 -%]
[%# HTML snippet for insertion into the database -%]
[%# This one uses the new format for the mailing list data -%]
[%- USE date -%]
[%- prefix = "http://hackerpublicradio.org"
correspondents = "$prefix/correspondents.php"
mailthreads = "$prefix/pipermail/hpr_hackerpublicradio.org/$review_year-$review_month/thread.html" -%]
[%- DEFAULT skip_comments = 0 -%]
[%# For the '-mailnotes' option without a file we generate our own inclusion. -%]
[%# We pretend 'default_mail' is a filename in the calling script. Messy. -%]
[% BLOCK default_mail -%]
<a href="[% mailthreads %]" target="_blank">[% mailthreads %]</a>
[% END -%]
<h2>New hosts</h2>
<p>
[% IF hosts.size > 0 -%]
Welcome to our new host[%- hosts.size > 1 ? 's' : '' -%]: <br />
[%- count = 0 %]
[%- FOREACH row IN hosts %]
[%- count = count + 1 %]
<a href="[% correspondents %]?hostid=[% row.hostid %]" target="_blank">[% row.host %]</a>
[%- count < hosts.size ? ', ' : '.' %]
[%- END %]
[% ELSE -%]
There were no new hosts this month.
[% END -%]
</p>
<h2>Last Month's Shows</h2>
[%# The 'summary' attribute is deprecated in HTML5 but is included here to -%]
[%# prevent errors being reported in the note checker -%]
<table id="t01" summary="Last month's shows">
<tr>
<th align="left">Id</th>
<th align="left">Day</th>
<th align="left">Date</th>
<th align="left">Title</th>
<th align="left">Host</th>
</tr>
[%- FOREACH row IN shows %]
<tr valign="top">
<td align="left"><strong><a href="http://hackerpublicradio.org/eps.php?id=[% row.eps_id %]" target="_blank">[% row.eps_id %]</a></strong></td>
<td align="left">[% date.format(row.date,'%a') %]</td>
<td align="left">[% date.format(row.date,'%Y-%m-%d') %]</td>
<td align="left"><a href="http://hackerpublicradio.org/eps.php?id=[% row.eps_id %]" target="_blank">[% row.title %]</a></td>
<td align="left"><a href="[% correspondents %]?hostid=[% row.ho_hostid %]" target="_blank">[% row.ho_host FILTER html_entity %]</a></td>
</tr>
[%- END %]
</table>
[%- IF includefile.defined -%]
<h2>Mailing List discussions</h2>
<p>
Policy decisions surrounding HPR are taken by the community as a whole. This discussion takes
place on the <a href="http://hackerpublicradio.org/maillist" target="_blank">Mail List</a> which is open to all
HPR listeners and contributors. The discussions are open and available on the
<a href="http://news.gmane.org/gmane.network.syndication.podcast.hacker-public-radio" target="_blank">Gmane</a>
archive and the <a href="http://hackerpublicradio.org/pipermail/hpr_hackerpublicradio.org/">Mailman</a> archive.
</p>
<p>The threaded discussions this month can be found here:</p>
[% INCLUDE $includefile -%]
[%- END %]
[%# Skip comments if told to by the caller -%]
[%- IF skip_comments == 0 -%]
<h2>Comments this month</h2>
[% IF comment_count > 0 -%]
<p>These are comments which have been made during the past month, either to shows
released during the month or to past shows.</p>
<p>There [%- comment_count == 1 ? "is $comment_count comment" : "are $comment_count comments" -%]:</p>
<ul>
[%- last_ep = 0 -%]
[%- FOREACH row IN comments -%]
[%= IF last_ep != row.episode =%]
[%= IF last_ep != 0 %]
</ul><br/></li>
[%= END %]
<li><strong><a href="[% row.identifier_url %]#comments" target="_blank">[% row.past ? "[hpr$row.episode]" : "hpr$row.episode" %]</a></strong>
([% row.date %]) "<em>[% row.title %]</em>"
by <a href="[% correspondents %]?hostid=[% row.hostid %]" target="_blank">[% row.host %]</a>.
<ul>
[%- END -%]
[%- last_ep = row.episode %]
[%= IF row.in_range =%]
<li><a href="[% row.identifier_url %]#[% row.index %]" target="_blank">Comment [% row.index %]</a>:
[% row.comment_author_name FILTER html_entity -%] on [% date.format(row.comment_timestamp,'%Y-%m-%d') -%]:
[%- IF row.comment_title.length > 0 %]
"[% row.comment_title FILTER html_entity %]"
[%- ELSE -%]
"[no title]"
[%- END -%]
</li>
[%- END -%]
[%- END -%]
</ul>
</li>
</ul>
[%- ELSE %]
There were no comments this month.
[%- END %]
[%- END %]
[%#
# vim: syntax=tt2:ts=8:sw=4:ai:et:tw=78:fo=tcrqn21
-%]

View File

@@ -0,0 +1,138 @@
[%# shownote_template7.tpl 2016-10-02 -%]
[%# HTML snippet for insertion into the database -%]
[%# This one uses the new format for the mailing list data, and partitions -%]
[%# comments into past and current. It requires make_shownotes > V0.0.21 -%]
[%- USE date -%]
[%- prefix = "http://hackerpublicradio.org"
correspondents = "$prefix/correspondents.php"
mailthreads = "$prefix/pipermail/hpr_hackerpublicradio.org/$review_year-$review_month/thread.html" -%]
[%- DEFAULT skip_comments = 0 -%]
[%# For the '-mailnotes' option without a file we generate our own inclusion. -%]
[%# We pretend 'default_mail' is a filename in the calling script. Messy. -%]
[% BLOCK default_mail -%]
<a href="[% mailthreads %]" target="_blank">[% mailthreads %]</a>
[% END -%]
<h2>New hosts</h2>
<p>
[% IF hosts.size > 0 -%]
Welcome to our new host[%- hosts.size > 1 ? 's' : '' -%]: <br />
[%- count = 0 %]
[%- FOREACH row IN hosts %]
[%- count = count + 1 %]
[%- hostname = (row.host.search(',') ? row.host.replace('^(.*)$','"$1"') : row.host) %]
<a href="[% correspondents %]?hostid=[% row.hostid %]" target="_blank">[% hostname %]</a>
[%- count < hosts.size ? ', ' : '.' %]
[%- END %]
[% ELSE -%]
There were no new hosts this month.
[% END -%]
</p>
<h2>Last Month's Shows</h2>
[%# The 'summary' attribute is deprecated in HTML5 but is included here to -%]
[%# prevent errors being reported in the note checker -%]
<table id="t01" summary="Last month's shows">
<tr>
<th>Id</th>
<th>Day</th>
<th>Date</th>
<th>Title</th>
<th>Host</th>
</tr>
[%- FOREACH row IN shows %]
<tr valign="top">
<td><strong><a href="http://hackerpublicradio.org/eps.php?id=[% row.eps_id %]" target="_blank">[% row.eps_id %]</a></strong></td>
<td>[% date.format(row.date,'%a') %]</td>
<td>[% date.format(row.date,'%Y-%m-%d') %]</td>
<td><a href="http://hackerpublicradio.org/eps.php?id=[% row.eps_id %]" target="_blank">[% row.title %]</a></td>
<td><a href="[% correspondents %]?hostid=[% row.ho_hostid %]" target="_blank">[% row.ho_host FILTER html_entity %]</a></td>
</tr>
[%- END %]
</table>
[%- IF includefile.defined -%]
<h2>Mailing List discussions</h2>
<p>
Policy decisions surrounding HPR are taken by the community as a whole. This
discussion takes place on the <a href="http://hackerpublicradio.org/maillist"
target="_blank">Mail List</a> which is open to all HPR listeners and
contributors. The discussions are open and available in the archives run
externally by <a href="http://news.gmane.org/gmane.network.syndication.podcast.hacker-public-radio" target="_blank">Gmane</a>
(see below) and on the HPR server under <a href="http://hackerpublicradio.org/pipermail/hpr_hackerpublicradio.org/">Mailman</a>.
</p>
<p><em>Note: since the summer of 2016 Gmane has changed location and is currently
being reestablished. At the moment the HPR archive is not available there.</em></p>
<p>The threaded discussions this month can be found here:</p>
[% INCLUDE $includefile -%]
[%- END %]
[%# Skip comments if told to by the caller -%]
[%- IF skip_comments == 0 -%]
<h2>Comments this month</h2>
[% IF comment_count > 0 -%]
<p>These are comments which have been made during the past month, either to shows
released during the month or to past shows.<br/>
There [%- comment_count == 1 ? "is $comment_count comment" : "are $comment_count comments" -%] in total.</p>
[% IF past_count > 0 -%]
<p>There [% past_count == 1 ? "is $past_count comment" : "are $past_count comments" %] on
[% past.size %] previous [% past.size == 1 ? "show" : "shows" %]:</p>
<ul>
[%- FOREACH ep IN past.keys.sort -%]
[%- arr = past.$ep -%]
<li><strong><a href="[% arr.0.identifier_url %]#comments" target="_blank">hpr[% arr.0.episode %]</a></strong>
([% arr.0.date %]) "<em>[% arr.0.title %]</em>"
by <a href="[% correspondents %]?hostid=[% arr.0.hostid %]" target="_blank">[% arr.0.host %]</a>.</li>
<li style="list-style: none; display: inline">
<ul>
[%- FOREACH row IN arr -%]
<li><a href="[% row.identifier_url %]#[% row.index %]" target="_blank">Comment [% row.index %]</a>:
[% row.comment_author_name FILTER html_entity -%] on [% date.format(row.comment_timestamp,'%Y-%m-%d') -%]:
[%- IF row.comment_title.length > 0 %]
"[% row.comment_title FILTER html_entity %]"
[%- ELSE -%]
"[no title]"
[%- END -%]
</li>
[%- END -%]
</ul><br/>
</li>
[%- END -%]
</ul>
[%- END %]
[%# ---------------------------------------------------------------------------------------- -%]
[% cc = (comment_count - past_count) -%]
[% IF cc > 0 -%]
<p>There [% cc == 1 ? "is $cc comment" : "are $cc comments" %] on [% current.size %] of this month's shows:</p>
<ul>
[%- FOREACH ep IN current.keys.sort -%]
[%- arr = current.$ep -%]
<li><strong><a href="[% arr.0.identifier_url %]#comments" target="_blank">hpr[% arr.0.episode %]</a></strong>
([% arr.0.date %]) "<em>[% arr.0.title %]</em>"
by <a href="[% correspondents %]?hostid=[% arr.0.hostid %]" target="_blank">[% arr.0.host %]</a>.</li>
<li style="list-style: none; display: inline">
<ul>
[%- FOREACH row IN arr -%]
<li><a href="[% row.identifier_url %]#[% row.index %]" target="_blank">Comment [% row.index %]</a>:
[% row.comment_author_name FILTER html_entity -%] on [% date.format(row.comment_timestamp,'%Y-%m-%d') -%]:
[%- IF row.comment_title.length > 0 %]
"[% row.comment_title FILTER html_entity %]"
[%- ELSE -%]
"[no title]"
[%- END -%]
</li>
[%- END -%]
</ul><br/>
</li>
[%- END -%]
</ul>
[%- END %]
[%- ELSE %]
There were no comments this month.
[%- END %]
[%- END %]
[%#
# vim: syntax=tt2:ts=8:sw=4:ai:et:tw=78:fo=tcrqn21
-%]

View File

@@ -0,0 +1,164 @@
[%# shownote_template8.tpl 2017-09-10 -%]
[%# HTML snippet for insertion into the database -%]
[%# This one uses the new format for the mailing list data, and partitions -%]
[%# comments into past and current. It also marks comments that don't need -%]
[%# to be read when -markcomments is selected. It requires make_shownotes > V0.0.22 -%]
[%- USE date -%]
[%- prefix = "http://hackerpublicradio.org"
correspondents = "$prefix/correspondents.php"
mailthreads = "$prefix/pipermail/hpr_hackerpublicradio.org/$review_year-$review_month/thread.html" -%]
[%- DEFAULT skip_comments = 0
mark_comments = 0 -%]
[%- IF mark_comments == 1 %]
<style>
p#ignore, li#ignore {
background-color: lightgreen;
color:maroon;
}
</style>
[%- END %]
[%# For the '-mailnotes' option without a file we generate our own inclusion. -%]
[%# We pretend 'default_mail' is a filename in the calling script. Messy. -%]
[% BLOCK default_mail -%]
<a href="[% mailthreads %]" target="_blank">[% mailthreads %]</a>
[% END -%]
<h2>New hosts</h2>
<p>
[% IF hosts.size > 0 -%]
Welcome to our new host[%- hosts.size > 1 ? 's' : '' -%]: <br />
[%- count = 0 %]
[%# List the new hosts. If a name contains a comma quote it. -%]
[%- FOREACH row IN hosts %]
[%- count = count + 1 %]
[%- hostname = (row.host.search(',') ? row.host.replace('^(.*)$','"$1"') : row.host) %]
<a href="[% correspondents %]?hostid=[% row.hostid %]" target="_blank">[% hostname %]</a>
[%- count < hosts.size ? ', ' : '.' %]
[%- END %]
[% ELSE -%]
There were no new hosts this month.
[% END -%]
</p>
<h2>Last Month's Shows</h2>
[%# The 'summary' attribute is deprecated in HTML5 but is included here to -%]
[%# prevent errors being reported in the note checker -%]
<table id="t01" summary="Last month's shows">
<tr>
<th>Id</th>
<th>Day</th>
<th>Date</th>
<th>Title</th>
<th>Host</th>
</tr>
[%- FOREACH row IN shows %]
<tr valign="top">
<td><strong><a href="http://hackerpublicradio.org/eps.php?id=[% row.eps_id %]" target="_blank">[% row.eps_id %]</a></strong></td>
<td>[% date.format(row.date,'%a') %]</td>
<td>[% date.format(row.date,'%Y-%m-%d') %]</td>
<td><a href="http://hackerpublicradio.org/eps.php?id=[% row.eps_id %]" target="_blank">[% row.title %]</a></td>
<td><a href="[% correspondents %]?hostid=[% row.ho_hostid %]" target="_blank">[% row.ho_host FILTER html_entity %]</a></td>
</tr>
[%- END %]
</table>
[%- IF includefile.defined -%]
<h2>Mailing List discussions</h2>
<p>
Policy decisions surrounding HPR are taken by the community as a whole. This
discussion takes place on the <a href="http://hackerpublicradio.org/maillist"
target="_blank">Mail List</a> which is open to all HPR listeners and
contributors. The discussions are open and available in the archives run
externally by <a href="http://news.gmane.org/gmane.network.syndication.podcast.hacker-public-radio" target="_blank">Gmane</a>
(see below) and on the HPR server under <a href="http://hackerpublicradio.org/pipermail/hpr_hackerpublicradio.org/">Mailman</a>.
</p>
<p><em>Note: since the summer of 2016 Gmane has changed location and is currently
being reestablished. At the moment the HPR archive is not available there.</em></p>
<p>The threaded discussions this month can be found here:</p>
[% INCLUDE $includefile -%]
[%- END %]
[%# Skip comments if told to by the caller -%]
[%- IF skip_comments == 0 -%]
<h2>Comments this month</h2>
[% IF comment_count > 0 -%]
[%- IF mark_comments == 1 -%]
<p id="ignore"><b>Note to Volunteers</b>: Comments marked in green were read in the last
Community News show and should be ignored in this one.</p>
[%- END -%]
<p>These are comments which have been made during the past month, either to shows
released during the month or to past shows.<br/>
There [%- comment_count == 1 ? "is $comment_count comment" : "are $comment_count comments" -%] in total.</p>
[% IF past_count > 0 -%]
<p>There [% past_count == 1 ? "is $past_count comment" : "are $past_count comments" %] on
[% past.size %] previous [% past.size == 1 ? "show" : "shows" %]:</p>
<ul>
[%- FOREACH ep IN past.keys.sort -%]
[%- arr = past.$ep -%]
<li><strong><a href="[% arr.0.identifier_url %]#comments" target="_blank">hpr[% arr.0.episode %]</a></strong>
([% arr.0.date %]) "<em>[% arr.0.title %]</em>"
by <a href="[% correspondents %]?hostid=[% arr.0.hostid %]" target="_blank">[% arr.0.host %]</a>.</li>
<li style="list-style: none; display: inline">
<ul>
[%- FOREACH row IN arr -%]
[%- IF mark_comments == 1 && (row.comment_timestamp_ut <= last_recording) -%]
<li id="ignore">
[%- ELSE %]
<li>
[%- END %]
<a href="[% row.identifier_url %]#[% row.index %]" target="_blank">Comment [% row.index %]</a>:
[% row.comment_author_name FILTER html_entity -%] on [% date.format(row.comment_timestamp_ut,'%Y-%m-%d') -%]:
[%- IF row.comment_title.length > 0 %]
"[% row.comment_title FILTER html_entity %]"
[%- ELSE -%]
"[no title]"
[%- END -%]
</li>
[%- END -%]
</ul><br/>
</li>
[%- END -%]
</ul>
[%- END %]
[%# ---------------------------------------------------------------------------------------- -%]
[% cc = (comment_count - past_count) -%]
[% IF cc > 0 -%]
<p>There [% cc == 1 ? "is $cc comment" : "are $cc comments" %] on [% current.size %] of this month's shows:</p>
<ul>
[%- FOREACH ep IN current.keys.sort -%]
[%- arr = current.$ep -%]
<li><strong><a href="[% arr.0.identifier_url %]#comments" target="_blank">hpr[% arr.0.episode %]</a></strong>
([% arr.0.date %]) "<em>[% arr.0.title %]</em>"
by <a href="[% correspondents %]?hostid=[% arr.0.hostid %]" target="_blank">[% arr.0.host %]</a>.</li>
<li style="list-style: none; display: inline">
<ul>
[%- FOREACH row IN arr -%]
<li><a href="[% row.identifier_url %]#[% row.index %]" target="_blank">Comment [% row.index %]</a>:
[% row.comment_author_name FILTER html_entity -%] on [% date.format(row.comment_timestamp,'%Y-%m-%d') -%]:
[%- IF row.comment_title.length > 0 %]
"[% row.comment_title FILTER html_entity %]"
[%- ELSE -%]
"[no title]"
[%- END -%]
</li>
[%- END -%]
</ul><br/>
</li>
[%- END -%]
</ul>
[%- END %]
[%- ELSE %]
There were no comments this month.
[%- END %]
[%- END %]
[%# ---------------------------------------------------------------------------------------- -%]
[%# Any other business? -%]
[% IF aob == 1 -%]
<h2>Any other business</h2>
[% INCLUDE $aobfile -%]
[%- END %]
[%#
# vim: syntax=tt2:ts=8:sw=4:ai:et:tw=78:fo=tcrqn21
-%]

View File

@@ -0,0 +1,164 @@
[%# shownote_template9.tpl 2017-12-20 -%]
[%# HTML snippet for insertion into the database -%]
[%# This one uses the new format for the mailing list data, and partitions -%]
[%# comments into past and current. It also marks comments that don't need -%]
[%# to be read when -markcomments is selected. It requires make_shownotes > V0.0.22 -%]
[%- USE date -%]
[%- prefix = "http://hackerpublicradio.org"
correspondents = "$prefix/correspondents.php"
mailthreads = "$prefix/pipermail/hpr_hackerpublicradio.org/$review_year-$review_month/thread.html" -%]
[%- DEFAULT skip_comments = 0
mark_comments = 0 -%]
[%- IF mark_comments == 1 %]
<style>
p#ignore, li#ignore {
background-color: lightgreen;
color:maroon;
}
</style>
[%- END %]
[%# For the '-mailnotes' option without a file we generate our own inclusion. -%]
[%# We pretend 'default_mail' is a filename in the calling script. Messy. -%]
[% BLOCK default_mail -%]
<a href="[% mailthreads %]" target="_blank">[% mailthreads %]</a>
[% END -%]
<h2>New hosts</h2>
<p>
[% IF hosts.size > 0 -%]
Welcome to our new host[%- hosts.size > 1 ? 's' : '' -%]: <br />
[%- count = 0 %]
[%# List the new hosts. If a name contains a comma quote it. -%]
[%- FOREACH row IN hosts %]
[%- count = count + 1 %]
[%- hostname = (row.host.search(',') ? row.host.replace('^(.*)$','"$1"') : row.host) %]
<a href="[% correspondents %]?hostid=[% row.hostid %]" target="_blank">[% hostname %]</a>
[%- count < hosts.size ? ', ' : '.' %]
[%- END %]
[% ELSE -%]
There were no new hosts this month.
[% END -%]
</p>
<h2>Last Month's Shows</h2>
[%# The 'summary' attribute is deprecated in HTML5 but is included here to -%]
[%# prevent errors being reported in the note checker -%]
<table id="t01" summary="Last month's shows">
<tr>
<th>Id</th>
<th>Day</th>
<th>Date</th>
<th>Title</th>
<th>Host</th>
</tr>
[%- FOREACH row IN shows %]
<tr valign="top">
<td><strong><a href="http://hackerpublicradio.org/eps.php?id=[% row.eps_id %]" target="_blank">[% row.eps_id %]</a></strong></td>
<td>[% date.format(row.date,'%a') %]</td>
<td>[% date.format(row.date,'%Y-%m-%d') %]</td>
<td><a href="http://hackerpublicradio.org/eps.php?id=[% row.eps_id %]" target="_blank">[% row.title %]</a></td>
<td><a href="[% correspondents %]?hostid=[% row.ho_hostid %]" target="_blank">[% row.ho_host FILTER html_entity %]</a></td>
</tr>
[%- END %]
</table>
[%# ---------------------------------------------------------------------------------------- -%]
[%# Skip comments if told to by the caller -%]
[%- IF skip_comments == 0 -%]
<h2>Comments this month</h2>
[% IF comment_count > 0 -%]
[%- IF mark_comments == 1 -%]
<p id="ignore"><b>Note to Volunteers</b>: Comments marked in green were read in the last
Community News show and should be ignored in this one.</p>
[%- END -%]
<p>These are comments which have been made during the past month, either to shows
released during the month or to past shows.<br/>
There [%- comment_count == 1 ? "is $comment_count comment" : "are $comment_count comments" -%] in total.</p>
[% IF past_count > 0 -%]
<p>There [% past_count == 1 ? "is $past_count comment" : "are $past_count comments" %] on
[% past.size %] previous [% past.size == 1 ? "show" : "shows" %]:</p>
<ul>
[%- FOREACH ep IN past.keys.sort -%]
[%- arr = past.$ep -%]
<li><strong><a href="[% arr.0.identifier_url %]#comments" target="_blank">hpr[% arr.0.episode %]</a></strong>
([% arr.0.date %]) "<em>[% arr.0.title %]</em>"
by <a href="[% correspondents %]?hostid=[% arr.0.hostid %]" target="_blank">[% arr.0.host %]</a>.</li>
<li style="list-style: none; display: inline">
<ul>
[%- FOREACH row IN arr -%]
[%- IF mark_comments == 1 && (row.comment_timestamp_ut <= last_recording) -%]
<li id="ignore">
[%- ELSE %]
<li>
[%- END %]
<a href="[% row.identifier_url %]#[% row.index %]" target="_blank">Comment [% row.index %]</a>:
[% row.comment_author_name FILTER html_entity -%] on [% date.format(row.comment_timestamp_ut,'%Y-%m-%d') -%]:
[%- IF row.comment_title.length > 0 %]
"[% row.comment_title FILTER html_entity %]"
[%- ELSE -%]
"[no title]"
[%- END -%]
</li>
[%- END -%]
</ul><br/>
</li>
[%- END -%]
</ul>
[%- END %]
[%# ---------------------------------------------------------------------------------------- -%]
[% cc = (comment_count - past_count) -%]
[% IF cc > 0 -%]
<p>There [% cc == 1 ? "is $cc comment" : "are $cc comments" %] on [% current.size %] of this month's shows:</p>
<ul>
[%- FOREACH ep IN current.keys.sort -%]
[%- arr = current.$ep -%]
<li><strong><a href="[% arr.0.identifier_url %]#comments" target="_blank">hpr[% arr.0.episode %]</a></strong>
([% arr.0.date %]) "<em>[% arr.0.title %]</em>"
by <a href="[% correspondents %]?hostid=[% arr.0.hostid %]" target="_blank">[% arr.0.host %]</a>.</li>
<li style="list-style: none; display: inline">
<ul>
[%- FOREACH row IN arr -%]
<li><a href="[% row.identifier_url %]#[% row.index %]" target="_blank">Comment [% row.index %]</a>:
[% row.comment_author_name FILTER html_entity -%] on [% date.format(row.comment_timestamp_ut,'%Y-%m-%d') -%]:
[%- IF row.comment_title.length > 0 %]
"[% row.comment_title FILTER html_entity %]"
[%- ELSE -%]
"[no title]"
[%- END -%]
</li>
[%- END -%]
</ul><br/>
</li>
[%- END -%]
</ul>
[%- END %]
[%- ELSE %]
There were no comments this month.
[%- END %]
[%- END %]
[%# ---------------------------------------------------------------------------------------- -%]
[%- IF includefile.defined -%]
<h2>Mailing List discussions</h2>
<p>
Policy decisions surrounding HPR are taken by the community as a whole. This
discussion takes place on the <a href="http://hackerpublicradio.org/maillist"
target="_blank">Mail List</a> which is open to all HPR listeners and
contributors. The discussions are open and available on the HPR server under
<a href="http://hackerpublicradio.org/pipermail/hpr_hackerpublicradio.org/">Mailman</a>.
</p>
<p>The threaded discussions this month can be found here:</p>
[% INCLUDE $includefile -%]
[%- END %]
[%# ---------------------------------------------------------------------------------------- -%]
[%# Any other business? -%]
[% IF aob == 1 -%]
<h2>Any other business</h2>
[% INCLUDE $aobfile -%]
[%- END %]
[%#
# vim: syntax=tt2:ts=8:sw=4:ai:et:tw=78:fo=tcrqn21
-%]

1710
Community_News/summarise_mail Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,44 @@
[%# tag_contributors.tpl
A file to contain tag/summary contributor data. Made as a separate file to
be invoked with a PROCESS directive in the main Markdown file. If the
statements are placed there they look like some kind of Markdown stuff and
mess up Vim's formatting.
-%]
[% MACRO host(id) GET "http://hackerpublicradio.org/correspondents.php?hostid=$id" -%]
[% kenfallon = host(30) -%]
[% windigo = host(215) -%]
[% perloid = host(225) -%]
[% nybill = host(235) -%]
[% tonyhughes = host(338) -%]
[% bjb = host(357) -%]
[% ahuka = host(198) -%]
[% baffled = "Kirk Reiser" -%]
[% claudiom = host(152) -%]
[% archer72 = host(318) -%]
[% crvs = host(385) -%]
[% danielpersson = host(382) -%]
[% roan = host(293) -%]
[%# NOTE: Add variables as '$var' -%]
[% contributors = [
"[Archer72]($archer72)"
"[Rho`n]($roan)"
]
-%]
[% everyone = [
"[Ahuka]($ahuka)"
"[archer72]($archer72)"
"[bjb]($bjb)"
"[ClaudioM]($claudiom)"
"[crvs]($crvs)"
"[Daniel Persson]($danielpersson)"
"[Dave Morriss]($perloid)"
"[Ken Fallon]($kenfallon)"
"[Kirk Reiser]($baffled)"
"[NYbill]($nybill)"
"[Rho`n]($roan)"
"[Tony Hughes]($tonyhughes)"
"[Windigo]($windigo)"
]
-%]