[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

RSS Feed for DWN?



RSS Feed for DWN

I've seen that somebody has included the RSS feed for DWN by damog in
Planet Debian.  I really wonder why this still hasn't been integrated
in www.debian.org.  I found a mail from March on this subject.  Hence,
I've sat down and wrote a converter on my own that will also be able
to cope with translations of DWN.

Do you mind me applying the following patch and importing the attached
program that'll generate the RDF files?

The script uses fake URLs (non-existing anchors) so that RSS
aggregators are not confused but following a link will point to the
the issue on our web server.

Room for improvements:
  . the program could use gettext to display 'Debian Weekly News'
    properly translated
  . the program could use the release date instead of the issue number
    by using the date spelling function in the templates directory


Index: Makefile
===================================================================
RCS file: /cvs/webwml/webwml/english/News/weekly/Makefile,v
retrieving revision 1.42
diff -u -p -r1.42 Makefile
--- Makefile	14 Nov 2003 01:11:47 -0000	1.42
+++ Makefile	21 Jun 2006 08:31:01 -0000
@@ -176,7 +176,20 @@ ifeq "$(LANGUAGE)" "zh"
 	$(TEMPLDIR)/weeklynews/footer.wml $(GETTEXTDEP)
 endif
 
+export LANGUAGE ENGLISHSRCDIR CUR_DIR
+dwn.$(LANGUAGE).rdf:
+	if [ -f $(shell cat $(ENGLISHSRCDIR)/$(CUR_DIR)/CURRENT-ISSUE-IS)/index.wml -a \
+	    $(shell cat $(ENGLISHSRCDIR)/$(CUR_DIR)/CURRENT-ISSUE-IS)/index.wml -nt \
+	        dwn.$(LANGUAGE).rdf ]; then \
+	    $(ENGLISHSRCDIR)/$(CUR_DIR)/dwn-to-rdf.pl; \
+	fi
+
+all:: dwn.$(LANGUAGE).rdf
+install:: dwn.$(LANGUAGE).rdf
+
 # Generate the mail for posting to debian-news. Requires the web page already
 # be updated.
 mail:
 	@./makemail.pl
+
+.PHONY:	dwn.$(LANGUAGE).rdf


Regards,

	Joey

-- 
This is GNU/Linux Country.  On a quiet night, you can hear Windows reboot.

Please always Cc to me when replying to me on the lists.
#! /usr/bin/perl

# dwn-to-rdf - Convert the current DWN issue into an RDF file
# Copyright (c) 2006  Martin Schulze <joey@infodrom.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.

# Caveat: In order to filter out security updates language maintainers
#         need to adjust the regular expression $headline !~ /()/ below.

use strict;
use warnings;

use XML::RSS;

#
# Extract the charset from $LANGUAGEDIR/.wmlrc
#
sub charset
{
    my $charset = 'iso-8859-1 xxx';

    if (open (F, "../../.wmlrc")) {
	while (<F>) {
	    $charset = $1 if (/^-D CHARSET=(.*)$/);
	}
	close (F);
    }
    return $charset;
}

#
# Extract the current issue
#
sub current_issue
{
    if (open (F, $ENV{ENGLISHSRCDIR}.'/'.$ENV{CUR_DIR}.'/CURRENT-ISSUE-IS')) {
	chomp ($_ = <F>);
	close (F);
    }
    return $_;
}

my $current = current_issue;
my $rdf = 'dwn.' . $ENV{LANGUAGE} . '.rdf';
my $url = 'http://www.debian.org/News/weekly/' . $current . '/';

sub rdf_add
{
    my $rss = shift;
    my $count = shift;
    my $headline = shift;
    my $body = shift;

    $body =~ s~\$\(HOME\)~http://www.debian.org~g;
    $body =~ s/\\\n//g;

    # Conversion for the content
    $body =~ s/&/&amp;/g;
    $body =~ s/</&lt;/g;
    $body =~ s/>/&gt;/g;

    $rss->add_item (title       => $headline,
		    description => $body,
		    link        => $url.'#'.$count,
		    );
}

my $rss = new XML::RSS (version => '1.0', encoding => charset);

$rss->channel (title          => 'Debian Weekly News',
	       description    => 'Debian Weekly News '. $current,
	       link           => $url,
	       );

my $count = 0;
my $headline = '';
my $body = '';
if (open (F, $current . '/index.wml')) {
    while (<F>) {
	if (/^<p><strong>(.*)<\/strong>\s*(.*)/) {
	    $headline = $1;
	    $body = $2."\n";
	    chop ($headline) if ($headline =~ /\.$/);
	} elsif (/^<p><strong>(.*)/) {
	    $headline = $1;
        } elsif (/^(.*)<\/strong>(.*)/) {
            $headline .= ' '.$1;
            $body = $2."\n";
            chop ($headline) if ($headline =~ /\.$/);
        } elsif (/^<p>(.*)/) {
            $body = $1."\n";
	} elsif (/(.*)<\/p>/) {
	    $body .= $1;

	    if ($body !~ /(newpkg_main|<code>wnpp-alert<\/code>|href="mailto:dwn\@debian.org";)/ &&
		$headline !~ /(Security\ Updates|
			       Aktualisierungen\ zur\ Systemsicherheit)/x) {

		if (!$headline) {
		    rdf_add ($rss, $count++, 'Debian Weekly News '.$current, $body) if ($count == 0);
		} else {
		    rdf_add ($rss, $count++, $headline, $body);
		}
	    }

	    $headline = $body = '';
	} elsif (length) {
	    $body .= $_;
	}
    }
    close (F);
}
# fill file

$rss->save ($rdf);

Reply to: