#filter/newtopic.rb
#ndiary.confの中でFILTERにnewtopicを追加する事
#lib/topic.rb 内の関数の再定義
#複数トピックを1行毎に表示・日付は各行先頭に
class Topics
def tohtml(diarys, putmonth = true)
loadtopics if @topic.empty?
body = ''
regexp = Regexp::compile(@regexp)
pattern = Regexp::compile(@pattern)
topic = Marshal::load(@topic)
topic.delete_if{ |month, days|
days.delete_if{ |date, topics|
topics.delete_if{ |line| regexp !~ line[1] }
topics.size.zero? or !diarys.include?(month + date)
}
days.size.zero?
}
topic.keys.sort.reverse.each{ |month|
monthlink = []
monthhtml = ''
topic[month].keys.sort.each{ |date|
d = Time::local(month[0..3], month[4..5], date)
#del; monthhtml << "\t\t
#{d.strftime2(@topicDateFormat)} : "
monthhtml << topic[month][date].collect!{ |t|
#add-1line;
monthlink << "#{@monthPartNames[date.to_i]}"
#del; "#{t[1].gsub(pattern, @replace)}"
#add-3line;
string = t[1].gsub(pattern, @replace)
string = "." if string == ""
"\t\t#{string}:#{d.strftime2(@topicDateFormat)}\n"
#replace-1line-for-like-LaD
# "\t\t#{d.strftime2(@topicDateFormat)}:#{string}\n"
#del; }.join(' / ')
#add-1line;
}.join()
#del; monthhtml << "\n"
}
body << "\n" if putmonth
if putmonth then
m = Time::local(month[0..3], month[4..5])
if @monthPartNames.uniq.size == 1 then
body << "\t"
body << "#{m.strftime2(@topicMonthFormat)}\n\t\n"
else
monthlink.uniq!
body << "\t- #{m.strftime2(@topicMonthFormat)} ( "
body << monthlink.join(' / ')
body << " )
\n\t\n"
end
end
body << monthhtml
}
if putmonth then
return "\n" + body + "
\n"
else
return "\n"
end
end
end
class Filter
def newtopic(str, type)
end
end