diff kuttukibbs-1.0rc2-dom/kuttukibbs.cgi kuttukibbs-1.0rc2-rss/kuttukibbs.cgi
*** kuttukibbs-1.0rc2-dom/kuttukibbs.cgi	Sat Nov 27 03:49:52 2004
--- kuttukibbs-1.0rc2-rss/kuttukibbs.cgi	Sat Nov 27 07:15:12 2004
***************
*** 18,23 ****
--- 18,33 ----
  my $page_template_edit;
  my $charset = "EUC-JP";		# Ê¸»ú¥³¡¼¥É
  
+ # RSS ´ØÏ¢ÊÑ¿ô
+ my $rdf_file;		# ½ÐÎÏ¤¹¤ë RSS ¤Î¥Õ¥¡¥¤¥ëÌ¾
+ my $rdf_content;
+ my $rdf_dcdate;
+ my $rdf_url;
+ my $rdf_id;
+ my $rdf_all_template;
+ my $rdf_seq_template;
+ my $rdf_item_template;
+ 
  ### ¥°¥í¡¼¥Ð¥ëÊÑ¿ô
  my $latest_id = -1;		# ºÇ¿·¤Î¥³¥á¥ó¥È¤Î ID
  my %com_hash;			# ¥³¥á¥ó¥È¤ò³ÊÇ¼¤¹¤ë¥Ï¥Ã¥·¥å
***************
*** 94,99 ****
--- 104,110 ----
  	    read_file($fn, \$all);
  	    set_comment_hash(\%com_hash, \$all);
              write_to_jsfile($fn_pref.".js"); # JavaScript Feed ¥Õ¥¡¥¤¥ë
+             write_to_rssfile(); # RSS ¥Õ¥¡¥¤¥ë
              %com_hash = ();
  	} else {
  	    print "wrong password!\n";
***************
*** 131,136 ****
--- 142,148 ----
  	
  	write_to_logfile();	# ¥í¥°¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤­¹þ¤ß
  	write_to_jsfile($fn_pref.".js"); # JavaScript Feed ¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤­¹þ¤ß
+ 	write_to_rssfile(); # RSS ¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤­¹þ¤ß
  	write_to_adminlogfile(); # ´ÉÍý¼ÔÍÑ¥í¥°¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤­¹þ¤ß
      }
  }
***************
*** 316,323 ****
  }
  
  
! ### ºÇ¶áÅê¹Æ¤µ¤ì¤¿¥³¥á¥ó¥È¤òÉ½¼¨
! sub output_latest {
      my @fl = <$log_dir/*.log>;
      my @lalist;
      foreach my $f (@fl) {
--- 328,335 ----
  }
  
  
! ### ºÇ¶áÅê¹Æ¤µ¤ì¤¿¥³¥á¥ó¥È¤òÆÀ¤ë
! sub get_latest {
      my @fl = <$log_dir/*.log>;
      my @lalist;
      foreach my $f (@fl) {
***************
*** 336,348 ****
  		   @lalist)[0..($latest_comment_display_num - 1)];
      }
      foreach my $i (@lalist) {
! 	last if $i eq "";
  	$comments .= make_comment_html($i, 0);
      }
  
      $cgi_url .= "?mode=latest";
  
      eval qq(\$page_html = << "FFF"\n$page_template_latest\nFFF\n);
      print $page_html;
      exit;
  }
--- 348,416 ----
  		   @lalist)[0..($latest_comment_display_num - 1)];
      }
      foreach my $i (@lalist) {
! 	last if ($i eq "" || $$i{'i'} eq "");
  	$comments .= make_comment_html($i, 0);
      }
+     return @lalist;
+ }
  
+ ### ºÇ¶áÅê¹Æ¤µ¤ì¤¿¥³¥á¥ó¥È¤òÉ½¼¨
+ sub output_latest {
+     my @lalist = get_latest();
+ 
      $cgi_url .= "?mode=latest";
  
      eval qq(\$page_html = << "FFF"\n$page_template_latest\nFFF\n);
      print $page_html;
      exit;
  }
+ 
+ ### RSS ¤Ç½ÐÎÏ
+ sub write_to_rssfile {
+     my @lalist = get_latest();
+     my $rdf_seq;
+     my $rdf_item;
+ 
+     foreach my $i (@lalist) {
+         last if ($i eq "" || $$i{'i'} eq "");
+         my $date = $$i{'d'};
+         my $id = $$i{'i'};
+         my $url = id2url($id);
+         my $desc = $$i{'n'} . " [" . $$i{'m'}. "]";
+         my $seqtmp;
+         my $itemtmp;
+ 
+         $date =~ s/(\d\d\d\d)-(\d\d)-(\d\d)\s(\d\d):(\d\d):(\d\d)/$1-$2-$3T$4:$5:$6+09:00/;
+ 
+         my $cont_max_len = 300;
+         if (length($desc) > $cont_max_len) {
+             $desc =~ s/^(.{$cont_max_len}).*$/$1/sm;
+             $desc =~ s/\n[^\n]*$//;
+             $desc .= "...";
+         }
+ 
+         $desc =~ s|<[^<>]+?>||gosm;
+         $desc =~ s/&/&amp;/go;
+         $desc =~ s/>/&gt;/go;
+         $desc =~ s/</&lt;/go;
+         $desc =~ s/"/&quot;/go; # ";
+         $desc =~ s/\t//g;
+ 
+         $rdf_content = $desc;
+         $rdf_dcdate = $date;
+         $rdf_url = $url;
+         $rdf_id = $id;
+ 
+         eval qq(\$seqtmp = << "FFF"\n$rdf_seq_template\nFFF\n);
+         eval qq(\$itemtmp = << "FFF"\n$rdf_item_template\nFFF\n);
+ 
+         $rdf_seq .= $seqtmp;
+         $rdf_item .= $itemtmp;
+     }
+     $rdf_dcdate = strftime "%Y-%m-%dT%H:%M:%S+09:00", localtime;
+     my $rdf;
+     eval qq(\$rdf = << "FFF"\n$rdf_all_template\nFFF\n);
+ 
+     save_file($rdf_file, \$rdf);
+ }
+ 
diff kuttukibbs-1.0rc2-dom/kuttukibbs.conf kuttukibbs-1.0rc2-rss/kuttukibbs.conf
*** kuttukibbs-1.0rc2-dom/kuttukibbs.conf	Thu Apr  8 22:27:02 2004
--- kuttukibbs-1.0rc2-rss/kuttukibbs.conf	Sat Nov 27 07:16:07 2004
***************
*** 9,14 ****
--- 9,18 ----
  $admin_log_file = "kblog/log.txt";
  
  # --------------------------------------------------------------------
+ # RSS ¥Õ¥¡¥¤¥ëÌ¾
+ $rdf_file = "kblog/bbs.rdf";
+ 
+ # --------------------------------------------------------------------
  # ´ÉÍý¼ÔÍÑ¥Ñ¥¹¥ï¡¼¥É: ¶õ¤À¤ÈÊÔ½¸¡¦ºï½ü¤¬¤Ç¤­¤Þ¤»¤ó¡£
  $passwd = "";
  
***************
*** 148,153 ****
--- 152,198 ----
  EDIT
      ;
  
+ # --------------------------------------------------------------------
+ # RSS ¤Î¥Æ¥ó¥×¥ì¡¼¥È
+ #
+ ## rdf:Seq ¤Î¥Æ¥ó¥×¥ì¡¼¥È
+ $rdf_seq_template = << 'RDFSEQ'
+ <rdf:li resource="http://quasiquote.org/bbs/?id=$rdf_id"/>
+ RDFSEQ
+     ;
+ 
+ $rdf_item_template = << 'RDFITEM'
+ <item rdf:about="$rdf_url">
+  <title>$rdf_id ¤Ø¤Î¤Ä¤Ã¤³¤ß</title>
+  <link>http://quasiquote.org/bbs/?id=$rdf_id</link>
+  <description>$rdf_content</description>
+  <dc:date>$rdf_dcdate</dc:date>
+ </item>
+ RDFITEM
+     ;
+ 
+ $rdf_all_template = << 'RDFALL'
+ <?xml version="1.0" encoding="$charset"?>
+ <rdf:RDF
+  xmlns="http://purl.org/rss/1.0/"
+  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+  xmlns:dc="http://purl.org/dc/elements/1.1/"
+  xmlns:lang="ja">
+ <channel rdf:about="http://quasiquote.org/bbs.rdf">
+ <title>Misc Change Log</title>
+ <link>http://quasiquote.org/log/</link>
+ <description>`OpenBSD ¤Ç scheme ¤Î¥¢¥×¥ê³«È¯' ¤ß¤¿¤¤¤Ê¤³¤È¤ò¤ä¤Ã¤Æ¤Þ¤¹¡£</description>
+ <dc:date>$rdf_dcdate</dc:date>
+ <items>
+ <rdf:Seq>
+ $rdf_seq
+ </rdf:Seq>
+ </items>
+ </channel>
+ $rdf_item
+ </rdf:RDF>
+ RDFALL
+     ;
  
  # --------------------------------------------------------------------
  # ID ¤ò URL ¤ËÊÑ´¹¤¹¤ë
