# $Id: monthindex.rb,v 1.3 2001/03/08 21:44:21 not Exp $ # edit 2000.03.13 =begin monthindex.rb nDiary Plug-in 月別ファイルのインデックス作成 月別のファイルへのリンクのインデックスを作成します。 option: month=en 月名を英語表記にします。 month=1 月名数字を0なしにします。 title=str インデックスに付けるタイトルを指定します。 style=simple を使わずにインデックスを作成します。 style=table
を使ってインデックスを作成します。 boder=n style=table 時の berder の サイズを指定します。 cellspacing=n style=table 時の cellspacing の サイズを指定します。 dst=filename 出力を ファイルfilename に切りかえます exsample: =end def plug(opt) case opt['month'] when 'en' monthname = %w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec) #####check##### when '1' monthname = %w(1 2 3 4 5 6 7 8 9 10 11 12) else monthname = %w(01 02 03 04 05 06 07 08 09 10 11 12) end opt['border'] = 1 if opt['border'] !~ /^\d+$/ opt['cellspacing'] = 0 if opt['cellspacing'] !~ /^\d+$/ firstYear = @months[0][0..3] lastYear = @months[@months.size - 1][0..3] case opt['style'] #####check##### when 'custom' # index = "\n" if opt['title'] then index = "
\n
#{opt['title']}
\n
#{index}
" index << "\n
\n\n" end when 'simple' index = "\n" if opt['title'] then index = "
\n
#{opt['title']}
\n
#{index}
" index << "\n
\n\n" end else index = "
\n" if opt['title'] index << '\n" end for year in firstYear..lastYear index << "\t\n\t\t\n" for month in "01".."12" if @months.index(year + month) for dd in "01".."31" date = year + month + dd if @allDiarys.key?(date) then href = date2monthlyfilelink(date) break end end if href.empty? and File::exist?("#{@outputDirectory}#{year}#{month}.html") then href = year + month + '.html' end index << "\t\t\n" else index << "\t\t\n" end end index << "\t\n\n" end index << "
' << opt['title'] << "
#{year}" index << monthname[month.to_i - 1] << "" << monthname[month.to_i - 1] << "
\n\n" end if opt['dst'] and (not opt['dst'].empty?) then if /^([a-zA-Z]:)?\// !~ opt['dst'] then opt['dst'] = File::expand_path(opt['dst'], @outputDirectory) end begin outfile = open(opt['dst'], "w") outfile.print index outfile.close index = "" rescue Errno::ENOENT $stderr.print "Plug-in error: monthindex > dst file not found!\n" index = "" end end return index end