Mike Gerwitz

Free Software Hacker+Activist

aboutsummaryrefslogtreecommitdiffstats
blob: 15f87dd72ad99a630757b2f47fb20e01f33f4527 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash
# Generate talks HTML page
#
#  Copyright (C) 2019 Mike Gerwitz
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Talks are organized along with abstract in $TALKFILE.  Abstracts are
# assumed to be Markdown-formatted and are run through Pandoc.  A link to
# the talk video is provided, along with any supplemental links provided via
# $TALKFILE (e.g. slides, source code, bibliography).
##

set -euo pipefail

# Recfile containing talk abstracts and metadata.
declare -r TALKFILE=${TALKFILE:-src/talks.rec}


# List ids of all talks in $TALKFILE.
talk-list()
{
  recsel -CP id "$TALKFILE"
}


# Retrieve field FIELD from talk identified by ID in $TALKFILE.
talk-field()
{
  local -r id=${1?Missing talk id}
  local -r field=${2?Missing talk field}

  recsel -P "$field" -e "id = '$id'" "$TALKFILE"
}


# Generate abstract for talk.
abstract()
{
  local -r id=${1?Missing talk id}

  local title location locimg date abstract url links
  title=$( talk-field "$id" title )
  location=$( talk-field "$id" location )
  locimg=$( talk-field "$id" locimg )
  date=$( talk-field "$id" date )
  abstract=$( talk-field "$id" abstract )
  url=$( talk-field "$id" video-url )
  links=$( talk-field "$id" link )

  local abstract_html
  abstract_html=$( pandoc -fmarkdown -thtml5 <<< "$abstract" )

  cat <<EOF
<article class="abstract talk">
  <h2 class="title" id="$id">$title</h2>

  <ul class="links">
    <li><a class="video $locimg" href="$url">Watch $location Talk</a></li>
    $(
      while read lurl ltitle; do
        printf "<li><a href="%s">%s</a></li>\n" "$lurl" "$ltitle"
      done <<< "$links"
    )
  </ul>

  $abstract_html

  <p class="date">Presented on $date.</p>
</article>
EOF
}


# Generate talks page.
main()
{
  src/mkheader talks Talks

  local talks
  talks=$( recsel -P id src/talks.rec )

  echo '<h1>Talks</h1>'
  talk-list | while read id; do abstract "$id"; done

  cat src/footer.tpl.htm
}


main "$@"