Update of /cvsroot/compbench/compbenchmarks-web/lib
In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv2959
Added Files:
news.pl
Log Message:
First import.
--- NEW FILE: news.pl ---
# -----------------------------------------------------------------------------
# $Id: news.pl,v 1.1 2006/11/29 19:15:11 xfred Exp $
#
# This is free software.
# For details, see the GNU Public License in the COPYING file, or
# Look http://www.fsf.org
# -----------------------------------------------------------------------------
use strict;
use XML::XPath;
# use XML::XPath::XMLParser;
require "persistant.pl";
our $LT_TMP_DIR;
our $NEWS_FILE = "sf-news.xml";
sub show_a_news {
my $item = shift;
my $title = $item->findvalue('title');
# my $description = $item->findvalue('description');
my $pubDate = $item->findvalue('pubDate');
my $date;
my %months = ('Jan' => 1, 'Feb' => 2, 'Mar' => 3, 'Apr', => 4,
'May' => 5, 'Jun' => 6, 'Jul' => 7,
'Aug' => 8, 'Sep' => 9, 'Oct' => 10, 'Nov' => 11, 'Dec' => 12);
if ($pubDate =~ /.*, (\d+) (.*) (\d+) /) {
$date="$3-" . sprintf("%02d", $months{$2}) . "-$1";
} else {
$date=$pubDate;
}
# $description =~ s/\. /.<br>/g;
print "<li>$date : $title</li>";
}
sub news_display {
my $dbh = shift;
if (! -f "$LT_TMP_DIR/$NEWS_FILE") {
news_import($dbh, 1);
}
my $xp = XML::XPath->new(filename => "$LT_TMP_DIR/$NEWS_FILE");
my $items = $xp->find('//rss/channel/item');
my $item;
foreach $item ($items->get_nodelist) {
show_a_news($item);
}
}
sub news_import {
my $dbh = shift;
my $force = shift;
my $i = persistant_get($dbh, "news-import-threshold");
if (!defined($force)) {
$force=0;
}
if (!defined($i)) {
$i=1;
}
if (($i>=96) || ($force)) {
my $command = "wget -t1 -q http://sourceforge.net/export/rss2_projnews.php?group_id=150828 -O $LT_TMP_DIR/$NEWS_FILE";
`$command`;
if (! $force) {
$i=0;
}
}
$i++;
persistant_set($dbh, "news-import-threshold", $i);
}
1;
|