[FFmpeg-cvslog] [ffmpeg-web] branch master updated. dc7f9f9 web/Makefile/rss: parse news archive for RSS too

gitolite ffmpeg-cvslog at ffmpeg.org
Thu Nov 28 02:15:56 CET 2013


The branch, master has been updated
       via  dc7f9f90795f7a933de9b6d487071e7c4f343298 (commit)
       via  f4c4145a82d69a24292df4c02b8b8ebe59c4884f (commit)
      from  e1834f8dc0ffb83555f08f159f7d7da5b31a334a (commit)


- Log -----------------------------------------------------------------
commit dc7f9f90795f7a933de9b6d487071e7c4f343298
Author:     Timothy Gu <timothygu99 at gmail.com>
AuthorDate: Sun Nov 24 15:47:38 2013 -0800
Commit:     Lou Logan <lou at lrcd.com>
CommitDate: Wed Nov 27 16:14:11 2013 -0900

    web/Makefile/rss: parse news archive for RSS too
    
    Signed-off-by: Timothy Gu <timothygu99 at gmail.com>
    Reviewed-by: Stefano Sabatini <stefasab at gmail.com>

diff --git a/Makefile b/Makefile
index 36e9818..5fa2882 100644
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,7 @@ htdocs/%.html: src/% src/%_title $(PAGE_DEPS)
 	cat src/template_head1 $<_title src/template_head2 $< \
 	src/template_footer > $@
 
-htdocs/main.rss: htdocs/index.html
+htdocs/main.rss: htdocs/index.html htdocs/archive.html
 	./rss-gen.sh start $@
 	$(foreach html, $^, ./rss-gen.sh middle $@ $(html);)
 	./rss-gen.sh end   $@

commit f4c4145a82d69a24292df4c02b8b8ebe59c4884f
Author:     Timothy Gu <timothygu99 at gmail.com>
AuthorDate: Mon Nov 25 14:25:05 2013 -0800
Commit:     Lou Logan <lou at lrcd.com>
CommitDate: Wed Nov 27 16:13:14 2013 -0900

    web: move RSS generation to a seperate shell script
    
    Easier to read.
    
    Signed-off-by: Timothy Gu <timothygu99 at gmail.com>
    Reviewed-by: Stefano Sabatini <stefasab at gmail.com>

diff --git a/Makefile b/Makefile
index db2ac28..36e9818 100644
--- a/Makefile
+++ b/Makefile
@@ -18,22 +18,8 @@ htdocs/%.html: src/% src/%_title $(PAGE_DEPS)
 	src/template_footer > $@
 
 htdocs/main.rss: htdocs/index.html
-	echo '<?xml version="1.0" encoding="UTF-8" ?>' > $@
-	echo '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">' >> $@
-	echo '<channel>' >> $@
-	echo '    <title>FFmpeg RSS</title>' >> $@
-	echo '    <link>http://ffmpeg.org</link>' >> $@
-	echo '    <description>FFmpeg RSS</description>' >> $@
-	echo '    <atom:link href="http://ffmpeg.org/main.rss" rel="self" type="application/rss+xml" />' >> $@
-	grep '<a *id=".*" *></a><h3>.*20..,.*</h3>' $< | sed 'sX<a *id="\(.*\)" *> *</a> *<h3>\(.*20..\), *\(.*\)</h3>X\
-    <item>\
-        <title>\2, \3</title>\
-        <link>http://ffmpeg.org/index.html#\1</link>\
-        <guid>http://ffmpeg.org/index.html#\1</guid>\
-    </item>\
-X' >> $@
-	echo '</channel>' >> $@
-	echo '</rss>' >> $@
-
+	./rss-gen.sh start $@
+	$(foreach html, $^, ./rss-gen.sh middle $@ $(html);)
+	./rss-gen.sh end   $@
 
 .PHONY: all clean
diff --git a/rss-gen.sh b/rss-gen.sh
new file mode 100755
index 0000000..a2edb07
--- /dev/null
+++ b/rss-gen.sh
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+die() {
+    cat <<EOT >&2
+Usage: $0 <mode> <htdocs/output.rss> [<input.html>]
+
+This utility parses & converts generated FFmpeg news HTML page into RSS format.
+"mode" can be begin, middle, or end. If mode is middle, then input HTML is
+required.
+EOT
+    exit 1
+}
+
+# Sanity checks and parsing command line
+
+MODE=$1
+RSS=$2
+HTML=$3
+
+HTML_NODIR=${HTML##*/}
+
+if test $# -lt 2; then
+    echo 'Too few arguments' >&2
+    die
+elif test $# -gt 3; then
+    echo 'Too many arguments' >&2
+    die
+elif test $MODE = "middle" && test $# -ne 3; then
+    echo 'No HTML specified' >&2
+    die
+fi
+
+if test $MODE = "start"; then
+    cat << EOT > $RSS
+<?xml version="1.0" encoding="UTF-8" ?>
+<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
+<channel>
+    <title>FFmpeg RSS</title>
+    <link>http://ffmpeg.org</link>
+    <description>FFmpeg RSS</description>
+    <atom:link href="http://ffmpeg.org/main.rss" rel="self" type="application/rss+xml" />
+EOT
+elif test $MODE = "middle"; then
+    grep '<a *id=".*" *></a><h3>.*20..,.*</h3>' $HTML | sed 'sX<a *id="\(.*\)" *> *</a> *<h3>\(.*20..\), *\(.*\)</h3>X\
+    <item>\
+        <title>\2, \3</title>\
+        <link>http://ffmpeg.org/'$HTML_NODIR'#\1</link>\
+        <guid>http://ffmpeg.org/'$HTML_NODIR'#\1</guid>\
+    </item>\
+X' >> $RSS
+elif test $MODE = "end"; then
+    cat << EOT >> $RSS
+</channel>
+</rss>
+EOT
+else
+    echo 'Unknown mode' >&2
+    die
+fi

-----------------------------------------------------------------------

Summary of changes:
 Makefile   |   22 ++++------------------
 rss-gen.sh |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+), 18 deletions(-)
 create mode 100755 rss-gen.sh


hooks/post-receive
-- 



More information about the ffmpeg-cvslog mailing list