Develop and Download Open Source Software

Browse CVS Repository

Annotation of /tombo/htdocs/rssgen.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download) (as text)
Sat Aug 28 12:23:08 2004 UTC (19 years, 7 months ago) by hirami
Branch: MAIN
CVS Tags: V20050410, Tombo1_12, V20041017, V20040828, V20041121, V20060212, V20040915, HEAD
File MIME type: text/x-perl
RDF support

1 hirami 1.1 #! /usr/bin/perl
2    
3     $max_rss_items = 15;
4     $rssfile = "rss.rdf";
5    
6     $lang = "ja";
7     $rssurl = "http://tombo.sourceforge.jp/tombo.rdf";
8     $toppage = "http://tombo.sourceforge.jp";
9     $description = "メモ管理ツールTOMBO リリース情報、お知らせ等を提供しています";
10    
11     if ($#ARGV != 0 || !-d $ARGV[0]) {
12     print "Usage : rssgen.pl <TMPLDIR>\n";
13     exit 1;
14     }
15    
16     $srcdir = $ARGV[0];
17    
18     opendir(DIR, "$srcdir/news") || die;
19     my @l = sort( { $b <=> $a } readdir(DIR));
20     closedir(DIR);
21    
22    
23     my @items = ();
24    
25    
26     my $f, $d, $t, $sec, $headline, $cat, $dum;
27     my $i = 0;
28     foreach $f (@l) {
29     next if ($f eq "." || $f eq "..");
30     next unless ($f =~ /^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})\.txt$/);
31     last if ($i > $max_rss_items);
32    
33     $d = "$1-$2-$3";
34     $t = "$4:$5";
35     $sec = "$1$2$3$4$5";
36    
37     open(F, "$srcdir/news/$f") || die;
38    
39     $headline = <F>;
40     chop($headline);
41    
42     $cat = <F>; chop($cat); # category
43     $dum = <F>; # skip blank line
44    
45     $desc = "";
46     while(<F>) {
47     $desc .= $_;
48     }
49     close(F);
50    
51     my @itm = ($d, $t, $sec, $headline, $desc, $cat);
52     push(@items, \@itm);
53    
54     $i++;
55     }
56    
57     foreach $i (@items) {
58     ($d, $t, $sec, $headline, $desc, $cat) = @{$i};
59     # print "$d $t $sec $headline \n";
60     }
61    
62    
63     open(RSS, "| nkf -w > $srcdir/$rssfile") || die;
64     print RSS <<BASE ;
65     <?xml version="1.0" encoding="utf-8" ?>
66     <rdf:RDF
67     xmlns="http://purl.org/rss/1.0/"
68     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
69     xmlns:dc="http://purl.org/dc/elements/1.1/"
70     xml:lang="$lang">
71    
72     <channel rdf:about="$rssurl">
73     <title>TOMBO announce</title>
74     <link>$toppage</link>
75     <description>$description</description>
76     <items>
77     <rdf:Seq>
78     BASE
79    
80     foreach $i (@items) {
81     ($d, $t, $sec, $headline, $desc, $cat) = @{$i};
82     print RSS " <rdf:li rdf:resource=\"$toppage/history.html#$sec\"/>\n";
83     }
84    
85     print RSS " </rdf:Seq>\n";
86     print RSS " </items>\n";
87     print RSS "</channel>\n";
88    
89     foreach $i (@items) {
90     ($d, $t, $sec, $headline, $desc, $cat) = @{$i};
91     print RSS "<item rdf:about=\"$toppage/history.html#$sec\">\n";
92     print RSS " <title>$headline</title>\n";
93     print RSS " <link>$toppage/history.html#$sec</link>\n";
94     print RSS " <description>\n";
95     print RSS $desc;
96     print RSS " </description>\n";
97     print RSS " <dc:date>$d"."T$t:00+09:00</dc:date>\n";
98     print RSS " <dc:subject>$cat</dc:subject>\n";
99     print RSS "</item>\n";
100     }
101    
102     print RSS "</rdf:RDF>\n";
103    
104     close(RSS);

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26