# $Revision: 1.8 $ # recent_list: 最近書いた日記のタイトル,サブタイトルを表示する # パラメタ(カッコ内は未指定時の値): # days: 何日分の日記を表示するか(20) # date_format: 日付表示フォーマット(日記の日付フォーマット) # title_with_body: trueで各パラグラフへのリンクのtitle属性にそのパラグラフの一部を指定(false) # show_size: trueで日記長を表示(false) # show_title: trueで各日のタイトルを表示(false) # extra_erb: タイトルリスト生成後さらにERbを通すか(false) # # 注意: セキュアモードでは使えません。 # 備考: タイトルリストを日記に埋め込むは、レイアウトを工夫しなければ # なりません。ヘッダやフッタでtableタグを使ったり、CSSを書き換 # える必要があるでしょう。 # # Copyright (c) 2001,2002 Junichiro KITA # Distributed under the GPL # # # Source hacked by Atzm WATANABE , 10/26/2002 # Added param "rows" # eval( </, '')).split("\n") lines[0].concat('...') if lines[0] and lines[1] lines[0] end end MODIFY_CLASS def recent_list2(days = 10, date_format = nil, title_with_body = nil, show_size = nil, show_title = nil, extra_erb = nil, rows = 2) days = days.to_i date_format ||= @date_format result = "" cgi = CGI::new def cgi.referer; nil; end ret = days / rows catch(:exit) { result << %Q|\n| result << %Q|\n| result << "\n" @years.keys.sort.reverse_each do |year| @years[year].sort.reverse_each do |month| cgi.params['date'] = ["#{year}#{month}"] m = TDiaryMonth::new(cgi, '') m.diaries.keys.sort.reverse_each do |date| next unless m.diaries[date].visible? if days - ret <= 0 result << "\n" result << "\n" ret = days / rows end result << %Q|\n" days -= 1 rows -= 1 throw :exit if days == 0 end end end } result << "\n" result << "
Recent #{days}days title list
\n| result << %Q|

#{m.diaries[date].date.strftime(date_format)}\n| if show_title and m.diaries[date].title result << %Q| #{m.diaries[date].title}| end if show_size == true s = 0 m.diaries[date].each_paragraph do |paragraph| s = s + paragraph.to_s.size.to_i end result << ":#{s}" end result << %Q|

\n
\n| i = 1 m.diaries[date].each_paragraph do |paragraph| if paragraph.subtitle result << %Q| #{i}. | \ << %Q|#{paragraph.subtitle}
\n| end i += 1 end result << "
\n" result << "
\n" if extra_erb and /<%=/ === result ERbLight.new(result.untaint).result(binding) else result end end #@recent_list_cache = Cache.new(:recent_list, method(:recent_list), 10, '%Y/%m/%d', true, true) #add_update_proc @recent_list_cache.writer