日記
欲しけりゃ作ろう (20:38)Edit

rss_recentプラグインで、各項目に日付を出力するパッチ。rss_recentに第4引数を追加し、そこで出力したい日付フォーマットを指定する。上記では'%Y-%m-%d'を指定している。

*** rss-recent.rb.org   2004-09-20 20:29:01.000000000 +0900
--- rss-recent.rb     2004-09-20 20:36:04.000000000 +0900
***************
*** 21,27 ****
"Using RSS parser version is #{::RSS::VERSION}.",
}
! def rss_recent(url, max=5, cache_time=3600)
url.untaint
cache_file = "#{@cache_path}/rss-recent.#{CGI.escape(url)}"
--- 21,27 ----
"Using RSS parser version is #{::RSS::VERSION}.",
}
! def rss_recent(url, max=5, cache_time=3600, dateformat = '')
url.untaint
cache_file = "#{@cache_path}/rss-recent.#{CGI.escape(url)}"
***************
*** 39,44 ****
--- 39,47 ----
rv << '<li>'
rv << %Q[<span class="#{rss_recent_modified_class(time)}">]
unless url.nil?
+       if dateformat != ''
+         rv << %Q[#{CGI.escapeHTML(time.strftime(dateformat))} ]
+       end
rv << %Q[<a href="#{CGI.escapeHTML(url)}" title="#{CGI.escapeHTML(title)}]
rv << %Q[ (#{CGI.escapeHTML(time.localtime.to_s)})] unless time.nil?
rv << %Q[">]

Published At2004-09-20 00:00Updated At2004-09-20 00:00