From 6a0dd29d364844b24f1b6dc4beb2e20b5a634ac2 Mon Sep 17 00:00:00 2001 From: pux Date: Sat, 7 Jan 2023 14:17:56 +0100 Subject: update from pub-docs --- data/.gitignore | 4 ++-- data/pyreplace.py | 15 +++++++++++++++ data/rfc822date.py | 27 +++++++++++++++++++++++++++ data/template_rss_footer.xml | 3 +++ data/template_rss_header.xml | 11 +++++++++++ data/template_rss_item.xml | 10 ++++++++++ data/update.sh | 31 ++++++++++++++++++++++++++++++- 7 files changed, 98 insertions(+), 3 deletions(-) create mode 100755 data/pyreplace.py create mode 100755 data/rfc822date.py create mode 100644 data/template_rss_footer.xml create mode 100644 data/template_rss_header.xml create mode 100644 data/template_rss_item.xml diff --git a/data/.gitignore b/data/.gitignore index 8c1463c..1ea768b 100644 --- a/data/.gitignore +++ b/data/.gitignore @@ -1,3 +1,3 @@ -*.html INDEX.md -index.html +*.html +index.xml diff --git a/data/pyreplace.py b/data/pyreplace.py new file mode 100755 index 0000000..71e970e --- /dev/null +++ b/data/pyreplace.py @@ -0,0 +1,15 @@ +#!/bin/env python3 + +import sys + +if __name__ == '__main__': + if len(sys.argv) < 3: + sys.exit() + + data = [] + with open(sys.argv[3], 'r+') as file: + data = file.read() + data = data.replace(sys.argv[1], sys.argv[2]) + file.close() + with open(sys.argv[3], 'w') as filew: + filew.write(data) diff --git a/data/rfc822date.py b/data/rfc822date.py new file mode 100755 index 0000000..8ea9446 --- /dev/null +++ b/data/rfc822date.py @@ -0,0 +1,27 @@ +#!/bin/env python3 + +from datetime import datetime +import sys + +def help(): + print(sys.argv[0] + " YYYY-MM-DD-HHMMSS [+XXXX]") + +# test +#indate = "2022-12-22-182343" + +timezone = "+0000" + +if len(sys.argv) <= 1: + print("error no arg") + help() + sys.exit() +if len(sys.argv) == 3: + timezone = sys.argv[2] +if len(sys.argv) > 3: + print("error > 2 args") + help() + sys.exit() + +indate = sys.argv[1] +d = datetime.strptime(indate, "%Y-%m-%d-%H%M%S") +print(d.strftime("%a, %d %b %Y %H:%M:%S") + " " + timezone) diff --git a/data/template_rss_footer.xml b/data/template_rss_footer.xml new file mode 100644 index 0000000..a353561 --- /dev/null +++ b/data/template_rss_footer.xml @@ -0,0 +1,3 @@ + + + diff --git a/data/template_rss_header.xml b/data/template_rss_header.xml new file mode 100644 index 0000000..d15dbc9 --- /dev/null +++ b/data/template_rss_header.xml @@ -0,0 +1,11 @@ + + + $TITLE$ + $TITLE_LINK$ + $TITLE_DESC$ + + en-us + + + + diff --git a/data/template_rss_item.xml b/data/template_rss_item.xml new file mode 100644 index 0000000..5e74373 --- /dev/null +++ b/data/template_rss_item.xml @@ -0,0 +1,10 @@ + + $ITEM_TITLE$ + $ITEM_LINK$ + $ITEM_PUBDATE$ + $ITEM_LINK$ + + $ITEM_DESC$ + + + diff --git a/data/update.sh b/data/update.sh index 687c805..e7cb139 100755 --- a/data/update.sh +++ b/data/update.sh @@ -1,7 +1,21 @@ -#!/bin/sh +#!/bin/bash + +# RSS +RSS_TITLE='omeckman.net pub-docs' +RSS_TITLE_LINK='https://omeckman.net/pub-docs/' +RSS_TITLE_DESC='omeckman.net public documents / $blog' +RSS_MY_URL=${RSS_TITLE_LINK} cp INDEX_template.md INDEX.md +cp template_rss_header.xml index.xml + +#sed -i "s/\\\$TITLE> INDEX.md + + origdate=$(echo "$filename_wo_ext" | cut -f 1 -d '_') + pubdaterfc822=$(python3 rfc822date.py ${origdate}) + + RSS_ITEM_TITLE="$filename_wo_ext" + RSS_ITEM_LINK=${RSS_TITLE_LINK}${filename_wo_ext}.html + RSS_ITEM_PUBDATE=${pubdaterfc822} + RSS_ITEM_DESC=$RSS_ITEM_TITLE + cat template_rss_item.xml >> index.xml + python3 pyreplace.py '$ITEM_TITLE$' "${RSS_ITEM_TITLE}" index.xml + python3 pyreplace.py '$ITEM_LINK$' "${RSS_ITEM_LINK}" index.xml + python3 pyreplace.py '$ITEM_PUBDATE$' "${RSS_ITEM_PUBDATE}" index.xml + python3 pyreplace.py '$ITEM_DESC$' "${RSS_ITEM_DESC}" index.xml fi fi done +cat template_rss_footer.xml >> index.xml + ln -s INDEX.html index.html -- cgit v1.2.2-1-g5e49