1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
# makelirs.rb $Revision: 1.14 $
#
# LIRSեޥåȤΥեǤФ
#
# pluginǥ쥯ȥ֤ưޤ
#
# tdiary.confˤơ@options['makelirs.file']
# ե̾ꤹȡΥե
# LIRSեȤޤ̵ˤindex.rbƱ
# ѥantenna.lirsȤեˤʤޤ
# ⡢WebФ븢¤ɬפǤ
#
# Copyright (C) 2002 by Kazuhiro NISHIYAMA
#
add_header_proc do
<<-LINK
<!--link rel="alternate" type="application/x-lirs" title="lirs" href="#{File::basename( @options['makelirs.file'] || 'antenna.lirs' )}"-->
LINK
end
add_update_proc do
eval( <<-MODIFY_CLASS, TOPLEVEL_BINDING )
unless Time.method_defined?(:utc_offset)
class Time
def utc_offset
l = self.dup.localtime
u = self.dup.utc
if l.year != u.year
off = l.year < u.year ? -1 : 1
elsif l.mon != u.mon
off = l.mon < u.mon ? -1 : 1
elsif l.mday != u.mday
off = l.mday < u.mday ? -1 : 1
else
off = 0
end
off = off * 24 + l.hour - u.hour
off = off * 60 + l.min - u.min
off = off * 60 + l.sec - u.sec
return off
end
end
end
MODIFY_CLASS
file = @options['makelirs.file'] || 'antenna.lirs'
# create_lirs
cgi = @cgi.clone
conf = @conf.clone
def cgi.mobile_agent?; false; end
def conf.mobile_agent?; false; end
t = TDiaryLatest::new( cgi, "latest.rhtml", conf )
body = t.eval_rhtml
# escape comma
e = proc{|str| str.gsub(/[,\\]/) { "\\#{$&}" } }
now = Time.now
utc_offset = now.utc_offset
lirs = "LIRS,#{t.last_modified.tv_sec},#{Time.now.tv_sec},#{utc_offset},#{body.size},#{e[@conf.base_url]},#{e[@html_title]},#{e[@author_name]},,\n"
File::open( file, 'w' ) do |o|
o.puts lirs
end
begin
File::utime( t.last_modified.tv_sec, t.last_modified.tv_sec, file )
rescue
end
end
|