Add HTML index generation

This commit is contained in:
Lucidiot 2021-03-15 22:24:06 +01:00
parent a60b3cbfef
commit aadf1b633e
Signed by: lucidiot
GPG Key ID: 3358C1CA6906FB8D
5 changed files with 201 additions and 1015 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
feeds
feeds.opml
index.html
*~
*.sw[a-z]

View File

@ -2,3 +2,4 @@
[ -z "$DIR" ] && DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
xsltproc "$DIR/xslt/feedgen.xsl" "$DIR/itsb.xml" | DIR="$DIR" bash -s -- "$@"
xsltproc "$DIR/xslt/opml.xsl" "$DIR/itsb.xml" > "$DIR/feeds.opml"
xsltproc "$DIR/xslt/html.xsl" "$DIR/itsb.xml" > "$DIR/index.html"

1015
index.html

File diff suppressed because it is too large Load Diff

View File

@ -13,6 +13,10 @@
</ul>
<p>but hey, i can still browse webpages to find the reports&mdash;what if i parsed those pages?</p>
<p>this is the whole goal of this project; to centralize accident reports into manageable RSS feeds and maybe more formats later on.</p>
<p>
you can get all the feeds at once in one OPML file:
<a href="./feeds.opml" target="_blank"><img src="img/opml.gif" alt="OPML Feeds" /></a>
</p>
]]>
</content>
</section>

195
xslt/html.xsl Normal file
View File

@ -0,0 +1,195 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:itsb="http://tilde.town/~lucidiot/itsb/">
<xsl:output method="html" />
<xsl:variable name="lowercase" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
<xsl:key name="feedKey" match="itsb:feed" use="concat(../@id, ' ', @lang, ' ', @type)" />
<xsl:template match="/">
<html>
<head>
<title>international transport safety bureau</title>
<link rel="stylesheet" type="text/css" href="../theme.css" />
<link rel="shortcut icon" type="image/x-icon" href="../img/favicon.ico"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="author" content="~lucidiot" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body class="container" id="top">
<div class="centered">
<img src="img/itsb.gif" alt="itsb logo: an antenna receives an alert from an airplane" />
<h1>international transport safety bureau</h1>
<p>
<xsl:for-each select="//itsb:section">
<a href="{concat('#', @id)}">
<xsl:value-of select="@name" />
</a>
<xsl:if test="position() != last()">
<xsl:text> &#8212; </xsl:text>
</xsl:if>
</xsl:for-each>
</p>
</div>
<xsl:apply-templates />
</body>
</html>
</xsl:template>
<xsl:template match="itsb:section">
<div class="section" id="{@id}">
<a href="#top" class="toplink">back to top</a>
<h2>
<xsl:value-of select="@name" />
</h2>
<xsl:apply-templates />
</div>
</xsl:template>
<xsl:template match="itsb:content">
<xsl:value-of select="text()" disable-output-escaping="yes" />
</xsl:template>
<xsl:template match="itsb:source">
<h3 id="{@id}">
<xsl:value-of select="itsb:name/text()" />
</h3>
<xsl:apply-templates select="itsb:description" />
<table>
<tbody>
<xsl:apply-templates select="itsb:region | itsb:type | itsb:frequency | itsb:license" />
<xsl:choose>
<xsl:when test="count(itsb:feed[generate-id(.) = generate-id(key('feedKey', concat(../@id, ' ', @lang, ' ', @type)))]) = 1">
<tr>
<td>
<strong>Language</strong>
</td>
<td>
<xsl:value-of select="itsb:feed/@lang" />
</td>
</tr>
<tr>
<td>
<strong>Feed</strong>
</td>
<td>
<xsl:apply-templates select="itsb:feed[generate-id(.) = generate-id(key('feedKey', concat(../@id, ' ', @lang, ' ', @type)))]" />
</td>
</tr>
</xsl:when>
<xsl:otherwise>
<tr>
<td>
<strong>Feeds</strong>
</td>
<td>
<table>
<tbody>
<xsl:for-each select="itsb:feed[generate-id(.) = generate-id(key('feedKey', concat(../@id, ' ', @lang, ' ', @type)))]">
<xsl:variable name="lang" select="@lang" />
<xsl:variable name="type" select="@type" />
<tr>
<td>
<xsl:value-of select="concat(translate(substring($lang, 1, 1), $lowercase, $uppercase), substring($lang, 2))" />
<xsl:if test="$lang and $type">
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:value-of select="concat(translate(substring($type, 1, 1), $lowercase, $uppercase), substring($type, 2))" />
</td>
<td>
<xsl:apply-templates select="../itsb:feed[(@lang = $lang or (not(@lang) and not ($lang))) and (@type = $type or (not(@type) and not($type)))]" />
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
</td>
</tr>
</xsl:otherwise>
</xsl:choose>
</tbody>
</table>
</xsl:template>
<xsl:template match="itsb:description">
<xsl:value-of select="text()" disable-output-escaping="yes" />
</xsl:template>
<xsl:template match="itsb:region">
<tr>
<td>
<strong>Region</strong>
</td>
<td>
<xsl:value-of select="text()" />
</td>
</tr>
</xsl:template>
<xsl:template match="itsb:type">
<tr>
<td>
<strong>Types</strong>
</td>
<td>
<xsl:value-of select="text()" />
</td>
</tr>
</xsl:template>
<xsl:template match="itsb:frequency">
<tr>
<td>
<strong>Frequency</strong>
</td>
<td>
<xsl:value-of select="text()" />
</td>
</tr>
</xsl:template>
<xsl:template match="itsb:license">
<tr>
<td>
<strong>License</strong>
</td>
<td>
<xsl:choose>
<xsl:when test="@url">
<a href="{@url}" target="_blank">
<xsl:value-of select="text()" />
</a>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="text()" />
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:template>
<xsl:template match="itsb:feed">
<xsl:variable name="href">
<xsl:choose>
<xsl:when test="itsb:link">
<xsl:value-of select="itsb:link/text()" />
</xsl:when>
<xsl:otherwise>
<xsl:text>feeds/</xsl:text>
<xsl:value-of select="itsb:output/text()" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<a href="{$href}" target="_blank">
<img src="img/{@format}.gif" alt="{@format}" />
</a>
<xsl:text> </xsl:text>
</xsl:template>
</xsl:stylesheet>