# navi_user.rb $Revision: 1.5 $ # # navi_user: 前日,翌日→前の日記,次の日記 # modeがday/commentのときに表示される「前日」「翌日」ナビゲーション # リンクを,「前の日記」,「次の日記」に変更するplugin.前の日記,次 # の日記がない場合は,ナビゲーションを表示しない.月またぎにも対応. # # @secure=true では動作しません. # # Copyright (c) 2002 Junichiro KITA # Distributed under the GPL =begin ChangeLog 2003-01-12 TADA Tadashi * Change labels. thanks to Shintaro KAKUTANI . 2002-10-06 TADA Tadashi * for tDiary 1.5.0.20021003. =end eval( <#{navi_index}\n] unless @index_page.empty? if /^(day|comment)$/ =~ @mode cgi = CGI.new def cgi.referer; nil; end days = [] yms = [] today = @date.strftime('%Y%m%d') this_month = @date.strftime('%Y%m') @years.keys.each do |y| yms += @years[y].collect {|m| y + m} end yms |= [this_month] yms.sort! yms.unshift(nil).push(nil) yms[yms.index(this_month) - 1, 3].each do |ym| next unless ym cgi.params['date'] = [ym] m = TDiaryMonth.new(cgi, '', @conf) days += m.diaries.keys.sort end days |= [today] days.sort! days.unshift(nil).push(nil) prev_day, cur_day, next_day = days[days.index(today) - 1, 3] if prev_day result << %Q[<#{navi_prev_diary(navi_user_format(prev_day))}\n] end if next_day result << %Q[#{navi_next_diary(navi_user_format(next_day))}>\n] end end result << %Q[#{navi_latest}\n] unless @mode == 'latest' result end def navi_user_format( day ) Time::local( *day.scan( /^(\d{4})(\d\d)(\d\d)$/ )[0] ) end