From 4ec786cd24d2eafe5b924b24958d173f5e7e9db8 Mon Sep 17 00:00:00 2001 From: Manuel Graf Date: Fri, 15 Jan 2021 17:04:21 +0100 Subject: Add html rendering --- .gitignore | 1 + .../asien/hongkong/stylesheet_html.xml | 25 ++++++++++++++++++ generate | 30 ++++++++++++++++------ 3 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 derstandard.at/international/asien/hongkong/stylesheet_html.xml diff --git a/.gitignore b/.gitignore index fbd9934..1591f35 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ cookies feed.xml +*.html diff --git a/derstandard.at/international/asien/hongkong/stylesheet_html.xml b/derstandard.at/international/asien/hongkong/stylesheet_html.xml new file mode 100644 index 0000000..30842e4 --- /dev/null +++ b/derstandard.at/international/asien/hongkong/stylesheet_html.xml @@ -0,0 +1,25 @@ + + + + + <!DOCTYPE html> + + derStandard.at - <xsl:value-of select="normalize-space(//header/h1)"/> + + + + + + + + + diff --git a/generate b/generate index 0d5705d..47fb755 100755 --- a/generate +++ b/generate @@ -1,15 +1,29 @@ #!/bin/sh -test $# -ne 1 && - { - echo "Usage: ${0} " - exit 2 - } + +usage() { + echo "Usage: ${0} [atom | html]" + exit 2 +} + +test $# -ne 2 && usage "$0" echo "$1" | grep 'derstandard.at/international/asien/hongkong' -q && url='https://www.derstandard.at/international/asien/hongkong' # TODO: Add option to aggregate older articles using e.g. https://www.derstandard.at/international/asien/hongkong/2020/1/1 -curl -sL -b cookies "$url" | +out=$(curl -sL -b cookies "$url" | xmllint --html --xpath '//main' /dev/stdin 2>/dev/null | - xsltproc "$1" /dev/stdin | - xmllint --format /dev/stdin \ + xsltproc "$1" /dev/stdin) + +case "$2" in +atom) + printf "%s" "$out" | xmllint --format /dev/stdin \ >"$(dirname "$1")/feed.xml" + ;; +html) + printf "%s" "$out" | xmllint --format --html /dev/stdin \ + >"$(dirname "$1")/index.html" + ;; +*) + usage "$0" + ;; +esac -- cgit 1.4.1-2-gfad0