commit 66cffce75bbf54446519cba10c7e46fe3aafa003
Author: Pavel Sanda <[email protected]>
Date:   Thu Jan 16 04:56:27 2025 +0100

    fix rss dates
    
    rss dates are broken for years as we currently use dates in
    news.inc in a different way. They were not in requested RFC even
    before that.
---
 misc/rss/lyx_rss_gen_data.sh | 22 ++++++++++++++++++++--
 misc/rss/makefile            |  2 +-
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/misc/rss/lyx_rss_gen_data.sh b/misc/rss/lyx_rss_gen_data.sh
index 4f9a43d4..4ef480c7 100644
--- a/misc/rss/lyx_rss_gen_data.sh
+++ b/misc/rss/lyx_rss_gen_data.sh
@@ -1,4 +1,22 @@
-#!/bin/sh
+#!/bin/bash
+
+function convert_date()
+{
+ date -u -R -d "$*" |sed 's/+0000$/GMT/'
+}
+
+#convert date prepared after '|' flag to RFC-822 as requested by feeds.
+#We expect the date from news.inc to be in format eg.: January 15, 2025
+#validator: https://validator.w3.org/feed/
+function fix_date_in_line()
+{
+ while read l ; do
+   d=`echo "$l"|cut -f 2 -d \|`
+   e=`echo "$l"|cut -f 3 -d \|`
+   f=`convert_date "$d"`
+   echo `echo "$l" | cut -f 1 -d \|`"$f""$e"
+ done
+}
 
 # location in our web checkout
 NEWS=../../farm/cookbook/LyX/news.inc
@@ -13,7 +31,7 @@ rss = RSS2(
 EOF
 
 echo -n '    '
-cat $NEWS |grep ^news_item|sed 
's/.*\"\(.*\)\".*\"\(.*\)\".*\"\(.*\)\".*/RSSItem(title=\"\1\",link=\"https:\/\/www.lyx.org\/News\",description=\"\2\",guid=Guid(\"LyX
 news feed \3\"),pubDate=\"\3\"),/'|grep -v news_item| sed 
's:pubDate=\"\(...\).\(.*\),.\(....\)\":pubDate=\"\2 \1 \3 00\:00\:00 
GMT\":'|head -n 8
+cat $NEWS |grep ^news_item|sed 
's/.*\"\(.*\)\".*\"\(.*\)\".*\"\(.*\)\".*/RSSItem(title=\"\1\",link=\"https:\/\/www.lyx.org\/News\",description=\"\2\",guid=Guid(\"LyX
 news feed \3\"),pubDate="\|\3\|"),/'|grep -v news_item|head -n 8 | 
fix_date_in_line
 echo '    ])'
 
 echo 'rss.write_xml(open("lyx_news_feed.rss.tmp", "w"))'
diff --git a/misc/rss/makefile b/misc/rss/makefile
index 3e379442..1904e09a 100644
--- a/misc/rss/makefile
+++ b/misc/rss/makefile
@@ -4,7 +4,7 @@
 
 all:
        cp PyRSS2Gen.py lyx_rss_gen.py
-       sh lyx_rss_gen_data.sh >> lyx_rss_gen.py
+       bash lyx_rss_gen_data.sh >> lyx_rss_gen.py
        python lyx_rss_gen.py
        #yes i know about needless cat
        cat lyx_news_feed.rss.tmp | sed 's/<item>/\n<item>/g' | sed 
's/<lastBuildDate>/\n<lastBuildDate>/' | sed 's:</channel>:\n</channel>:'> 
lyx_news_feed.xml
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to