[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[www] 01/03: first version of rss generator in python.
From: |
gnunet |
Subject: |
[www] 01/03: first version of rss generator in python. |
Date: |
Thu, 14 Nov 2019 02:42:12 +0100 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository www.
commit ad4e3f27ac49b6a253c5718faa13bea6d025fcbc
Author: ng0 <address@hidden>
AuthorDate: Thu Nov 14 01:37:13 2019 +0000
first version of rss generator in python.
---
GNUmakefile | 12 ++--
common/news.j2 | 4 +-
make_site.py | 6 +-
rssg | 220 ---------------------------------------------------------
www.yml | 61 +++++++++++-----
5 files changed, 56 insertions(+), 247 deletions(-)
diff --git a/GNUmakefile b/GNUmakefile
index 4a1aa38..a8ffdc3 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -39,16 +39,14 @@ all: css locale template
(cd rendered/node ; $(ln) -fs about.html 397)
($(cp) static/moved_about.html rendered/about.html)
(cd rendered ; $(ln) -fs about.html philosophy)
- (cd rendered; \
+# (cd rendered; \
for lang in en de es fr it; do \
$(sh) ../rssg $$lang/news/index.html 'GNUnet.org' >
$$lang/news/rss.xml; \
done)
- (cd rendered/en ; $(ln) -fs news/rss.xml rss.xml)
- (cd rendered/de ; $(ln) -fs news/rss.xml rss.xml)
- (cd rendered/es ; $(ln) -fs news/rss.xml rss.xml)
- (cd rendered/fr ; $(ln) -fs news/rss.xml rss.xml)
- (cd rendered/it ; $(ln) -fs news/rss.xml rss.xml)
-
+ (cd rendered; \
+ for lang in en de es fr it; do \
+ $(cp) $$lang/rss.xml $$lang/news/rss.xml; \
+ done)
# Extract translateable strings from jinja2 templates.
# Because of the local i18nfix extractor module we need
diff --git a/common/news.j2 b/common/news.j2
index cdc124b..9cdb06f 100644
--- a/common/news.j2
+++ b/common/news.j2
@@ -16,11 +16,9 @@
</div>
</div>
<div class="container">
- <!--BEGIN-->
- <article>
+ <article id="newspost-content">
{% block body_content %}{% endblock %}
</article>
- <!--END-->
</div>
</div>
{% include "common/footer.j2.inc" %}
diff --git a/make_site.py b/make_site.py
index 55b8510..16a67b9 100755
--- a/make_site.py
+++ b/make_site.py
@@ -12,7 +12,7 @@
#
# This script runs the jinja2 templating engine on an input template-file
# using the specified locale for gettext translations, and outputs
-# the resulting (HTML) ouptut-file.
+# the resulting (HTML) output-file.
#
# Note that the gettext files need to be prepared first. This script
# is thus to be invoked via the Makefile.
@@ -44,6 +44,10 @@ def main():
x = gen_site(DEBUG)
conf = x.load_config("www.yml")
x.gen_abstract(conf, "newsposts", "abstract", "page", 1000)
+ # for lang in conf["langs_full"]:
+ # x.gen_newspost_content(conf, "newsposts", "content", "page", lang)
+ x.gen_newspost_content(conf, "newsposts", "content", "page", "en")
+ x.gen_rss("inc", conf, env)
if DEBUG:
print("generating html from jinja2 templates...")
x.run("template", conf, env)
diff --git a/rssg b/rssg
deleted file mode 100755
index e21974f..0000000
--- a/rssg
+++ /dev/null
@@ -1,220 +0,0 @@
-#!/bin/sh
-#
-# https://www.romanzolotarev.com/bin/rssg
-# Copyright 2018 Roman Zolotarev <address@hidden>
-# Copyright 2019 ng0 <address@hidden>
-#
-# Permission to use, copy, modify, and/or distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-#
-set -e
-
-# TODO: Fix date -j for GNU date.
-# TODO: Fix base url (get_url)
-# TODO: Fix link OR a in get_url
-# TODO: get_title: be more dynamic about where the title can be.
-
-main () {
- test -n "$1" || usage
- test -n "$2" || usage
- test -f "$1" || no_file "$1"
-
-
- index_file=$(readlink -f "$1")
- test -z "${index_file##*html}" && html=$(cat "$index_file")
- test -z "${index_file##*md}" && html=$(md_to_html "$index_file")
- test -n "$html" || usage
-
- base="${index_file%/*}"
- base_url="$(echo "$html" | get_url | sed 's#\(.*\)/[^/]*#\1#')"
-
- url=$( echo "$html" | get_url)
-
- title="$2"
-
- description=$( echo "$html" | get_description |
- remove_tags |
- remove_nbsp )
-
- items=$( echo "$html" | get_items)
-
- rss=$( echo "$items" |
- render_items "$base" "$base_url" |
- render_feed "$url" "$title" "$description")
-
- >&2 echo "[rssg] ${index_file##$(pwd)/} $(echo "$rss" | grep -c
'<item>') items"
- echo "$rss"
-}
-
-
-usage() {
- echo "usage: ${0##*/} index.{html,md} title > rss.xml" >&2
- exit 1
-}
-
-
-no_file() {
- echo "${0##*/}: $1: No such file" >&2
- exit 2
-}
-
-
-md_to_html() {
- test -x "$(which lowdown)" || exit 3
- lowdown \
- -D html-skiphtml \
- -D smarty \
- -d metadata \
- -d autolink "$1"
-}
-
-
-get_title() {
- awk -F '[<>]' '/<h1/ { gsub(/<h1>/, ""); gsub(/<\/h1>/, ""); sub(/ .*/,
"", $3); print $0}' |
- sed 's/^[ \t]*//;s/[ \t]*$//' |
- awk 'FNR==1'
-}
-
-
-get_url() {
- grep -i '<link .*rss.xml"' | head -1 |
- sed 's#.*href="\(.*\)".*#\1#' |
- sed 's#../../#https://gnunet.org/#'
-}
-
-
-get_items() {
- grep -i 'href=".*" title="' |
- sed 's#.*href="\(.*\)" title="\(.*\)">\(.*\)</a>.*#\1 \2 \3#'
-}
-
-
-get_description() {
- start='sub("^.*<"s"*"t"("s"[^>]*)?>","")'
- stop='sub("</"s"*"t""s"*>.*","")&&x=1'
- awk -v 's=[[:space:]]' -v 't=[Pp]' "$start,$stop;x{exit}"
-}
-
-remove_tags() {
- sed 's#<[^>]*>##g;s#</[^>]*>##g'
-}
-
-
-remove_nbsp() {
- sed 's#\ # #g'
-}
-
-
-rel_to_abs_urls() {
- site_url="$1"
- base_url="$2"
-
- abs='s#(src|href)="/([^"]*)"#\1="'"$site_url"/'\2"#g'
- rel='s#(src|href)="([^:/"]*)"#\1="'"$base_url"/'\2"#g'
- sed -E "$abs;$rel"
-}
-
-
-date_rfc_822() {
- if date --version >/dev/null 2>&1; then
- in="$(echo "$1"| tr -cd '[:digit:]')0000"
- year=$(echo $in | cut -c1-4)
- month=$(echo $in | cut -c5-6)
- day=$(echo $in | cut -c7-8)
- hour=$(echo $in | cut -c9-10)
- minute=$(echo $in | cut -c11-12)
- date -d "$(echo "$year"-"$month"-"$day" "$hour":"$minute")"
--rfc-822
- else
- date -j '+%a, %d %b %Y %H:%M:%S %z' \
- "$(echo "$1"| tr -cd '[:digit:]')0000"
- fi
-}
-
-
-feed_date_rfc_822() {
- if date --version >/dev/null 2>&1; then
- k="$($1)"
- date -d "$(echo "$k")" --rfc-822
- else
- date -j '+%a, %d %b %Y %H:%M:%S %z' \
- "$(echo "$1"| tr -cd '[:digit:]')0000"
- fi
-}
-
-
-render_items() {
- while read -r i
- do render_item "$1" "$2" "$i"
- done
-}
-
-
-render_item() {
- base="$1"
- base_url="$2"
- item="$3"
-
- site_url="$(echo "$base_url"| sed 's#\(.*//.*\)/.*#\1#')"
-
- date=$(echo "$item"|awk '{print$2}')
-
- url=$(echo "$item"|awk '{print$1}')
-
- f="$base/$url"
- test -f "$f" && html=$(cat "$f")
- test -f "${f%\.html}.md" && html=$(md_to_html "${f%\.html}.md")
-
- description=$(
- echo "$html" |
- rel_to_abs_urls "$site_url" "$base_url" |
- remove_nbsp | awk '/<!--BEGIN-->/,/<!--END-->/'
- )
- title=$(echo "$description" | get_title)
- guid="$base_url/$(echo "$url" | sed 's#^/##')"
-
- echo '
-<item>
-<guid>'"$guid"'</guid>
-<link>'"$guid"'</link>
-<pubDate>'"$(date_rfc_822 "$date")"'</pubDate>
-<title>'"$title"'</title>
-<description><![CDATA[
-
-'"$description"'
-
-]]></description>
-</item>'
-}
-
-
-render_feed() {
- url="$1"
- title=$(echo "$2" | remove_nbsp)
- description="$3"
-
- base_url="$(echo "$url" | cut -d '/' -f1-3)"
-
- echo '<?xml version="1.0" encoding="UTF-8"?>
-<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
-<channel>
-<atom:link href="'"$url"'" rel="self" type="application/rss+xml" />
-<title>'"$title"'</title>
-<language>en</language>
-<description>'"$description"'</description>
-<link>'"$base_url"'/</link>
-<lastBuildDate>'"$(feed_date_rfc_822 date)"'</lastBuildDate>
-'"$(cat)"'
-</channel></rss>'
-}
-
-
-main "$@"
diff --git a/www.yml b/www.yml
index ce0fa3e..03f654a 100644
--- a/www.yml
+++ b/www.yml
@@ -1,3 +1,12 @@
+siteconf:
+ - baseurl: gnunet.org
+ newsloc: /news/
+ newsdir: news
+ rsstitle: GNUnet.org
+ rssdescr: "News posts published by GNUnet about changes related to GNUnet,
releases, and events"
+ rssloc:
+ rsslink:
+ rsslang:
langs_full: &langs
en: English
fr: Français
@@ -50,83 +59,103 @@ newsposts:
- page: 2019-11-ICANNUpdate.html
date: 2019-11-10
title: GNS@ICANN66
- abstract:
+ abstract:
+ content:
- page: 2019-0.11.8.html
date: 2019-10-30
title: GNUnet 0.11.8
abstract:
+ content:
- page: 2019-0.11.7.html
date: 2019-10-27
title: GNUnet 0.11.7
- abstract:
+ abstract:
+ content:
- page: 2019-10-ICANNPanel.html
date: 2019-10-20
title: GNUnet invited to ICANN Panel
- abstract:
+ abstract:
+ content:
- page: 2019-10-GNSSpec1.html
date: 2019-10-04
title: GNS Specification Milestone 1/4
- abstract:
+ abstract:
+ content:
- page: 2019-0.11.6.html
date: 2019-07-24
title: GNUnet 0.11.6
- abstract:
+ abstract:
+ content:
- page: 2019-07-GHM_Aug_2019.html
date: 2019-07-17
title: GNUnet Hacker Meeting 2019
- abstract:
+ abstract:
+ content:
- page: 2019-06-DSTJ.html
date: 2019-06-28
title: "Peer DSTJ is dead, long live peer Y924"
- abstract:
+ abstract:
+ content:
- page: 2019-0.11.5.html
date: 2019-06-05
title: GNUnet 0.11.5
- abstract:
+ abstract:
+ content:
- page: 2019-06.html
date: 2019-06-01
title: 2019-06
- abstract:
+ abstract:
+ content:
- page: 2019-0.11.4.html
date: 2019-05-12
title: GNUnet 0.11.4
- abstract:
+ abstract:
+ content:
- page: 2019-0.11.3.html
date: 2019-04-07
title: GNUnet 0.11.3
- abstract:
+ abstract:
+ content:
- page: 2019-0.11.2.html
date: 2019-04-04
title: GNUnet 0.11.2
- abstract:
+ abstract:
+ content:
- page: 2019-0.11.1.html
date: 2019-04-03
title: GNUnet 0.11.1
- abstract:
+ abstract:
+ content:
- page: 2019-0.11.0.html
date: 2019-02-28
title: GNUnet 0.11.0
- abstract:
+ abstract:
+ content:
- page: 2019-02.html
date: 2019-02-01
title: Google Summer of Code 2019
- abstract:
+ abstract:
+ content:
- page: 2018-08.html
date: 2018-08-14
title: GSoC 2018 - GNUnet Web-based User Interface
- abstract:
+ abstract:
+ content:
- page: 2018-07.html
date: 2018-07-01
title: Second GNUnet Hacker Meeting 2018
abstract:
+ content:
- page: 2018-06.html
date: 2018-06-06
title: GNUnet 0.11.0pre66
abstract:
+ content:
- page: 2017-10.html
date: 2017-10-01
title: Launching the new gnunet.org
abstract:
+ content:
# <!-- FIXME 2015: source only available on yt. <li>Ludovic Courtès, <a
href="">Reproducible Software Deployment with GNU Guix</a>, Inria</li> -->
# <!-- FIXME 2014: no source link on web. <li>Julian Kirsch, <a
href="">"Knocking down the HACIENDA"</a>, GNU Hacker Meeting 2014</li> -->
# <!-- FIXME 2014: no source link on web. <li>Peter Schaar, <a
href="">"Technik, Recht und Überwachung"</a>, Technische Universität
München</li> -->
--
To stop receiving notification emails like this one, please contact
address@hidden.