[FFmpeg-devel] [PATCH 1/5] web/rss: Include content of the news article
Alexander Strasser
eclipse7 at gmx.net
Fri May 23 00:16:59 CEST 2014
Remove code for generating RSS from the Makefile
and re-implement it as externally in Perl. It is
easier to read and extend.
Fixes Trac ticket #844
Signed-off-by: Alexander Strasser <eclipse7 at gmx.net>
---
Makefile | 17 +----------------
gen-rss | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 16 deletions(-)
create mode 100755 gen-rss
diff --git a/Makefile b/Makefile
index db2ac28..0152d70 100644
--- a/Makefile
+++ b/Makefile
@@ -18,22 +18,7 @@ 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>' >> $@
+ ./gen-rss < $< > $@
.PHONY: all clean
diff --git a/gen-rss b/gen-rss
new file mode 100755
index 0000000..b808509
--- /dev/null
+++ b/gen-rss
@@ -0,0 +1,42 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+print '<?xml version="1.0" encoding="UTF-8" ?>
+<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
+<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" />
+';
+
+my $closing_tags = "";
+my $do_print = 0;
+while (<>) {
+ if (m{<a *id="(.*)" *> *</a> *<h3>(.*20..), *(.*)</h3>}) {
+ $do_print = 1;
+ my ($id, $date, $title) = ($1, $2, $3);
+ $_ = "$closing_tags <item>
+ <title>$date, $title</title>
+ <link>http://ffmpeg.org/index.html#$id</link>
+ <guid>http://ffmpeg.org/index.html#$id</guid>
+ <content:encoded><![CDATA[
+";
+ $closing_tags = " ]]></content:encoded>
+ </item>
+"
+ }
+ if (m{<h1>Older entries are in the .*news archive}) {
+ print $closing_tags;
+ last;
+ }
+ if ($do_print) {
+ print $_;
+ }
+}
+
+print '</channel>
+</rss>
+';
--
More information about the ffmpeg-devel
mailing list