24
24
# CAUTION: Before using, make 'index.rdf' and 'no_comments.rdf' file
25
25
# into the directory of your diary, and permit writable to httpd.
27
# Copyright (c) 2004 TADA Tadashi <sho@spc.gr.jp>
27
# Copyright (c) 2009 TADA Tadashi <t@tdtds.jp>
28
28
# Distributed under the GPL
32
32
unless @conf.description
33
33
@conf.description = @conf['whatsnew_list.rdf.description']
35
eval( <<-TOPLEVEL_CLASS, TOPLEVEL_BINDING )
38
attr_reader :id, :time, :section, :diary_title
40
# 'id' has 'YYYYMMDDpNN' format (p or c).
41
# 'time' is Last-Modified this section as a Time object.
42
def initialize( id, time, section )
43
@id, @time, @section, @diary_title = id, time, section, diary_title
48
l = Time::local( g.year, g.month, g.day, g.hour, g.min, g.sec )
49
tz = (g.to_i - l.to_i)
50
zone = sprintf( "%+03d:%02d", tz / 3600, tz % 3600 / 60 )
51
@time.strftime( "%Y-%m-%dT%H:%M:%S" ) + zone
37
attr_reader :id, :time, :section, :diary_title
39
# 'id' has 'YYYYMMDDpNN' format (p or c).
40
# 'time' is Last-Modified this section as a Time object.
41
def initialize( id, time, section )
42
@id, @time, @section, @diary_title = id, time, section, diary_title
47
l = Time::local( g.year, g.month, g.day, g.hour, g.min, g.sec )
48
tz = (g.to_i - l.to_i)
49
zone = sprintf( "%+03d:%02d", tz / 3600, tz % 3600 / 60 )
50
@time.strftime( "%Y-%m-%dT%H:%M:%S" ) + zone
62
60
@makerss_rsses = @makerss_rsses || []
286
284
<channel rdf:about="#{h rdf_url}">
287
285
<title>#{h @conf.html_title}</title>
288
286
<link>#{h uri}</link>
289
<xhtml:link rel="alternate" media="handheld" type="text/html" href="#{h uri}" />
287
<xhtml:link xhtml:rel="alternate" xhtml:media="handheld" xhtml:type="text/html" xhtml:href="#{h uri}" />
290
288
<description>#{h desc}</description>
291
289
<dc:creator>#{h @conf.author_name}</dc:creator>
292
290
<dc:rights>#{h copyright}</dc:rights>
326
324
if rdfsec.section.respond_to?( :body_to_html ) then
327
325
rdf = %Q|<item rdf:about="#{h uri}#{anchor rdfsec.id}">\n|
328
326
rdf << %Q|<link>#{h uri}#{anchor rdfsec.id}</link>\n|
329
rdf << %Q|<xhtml:link rel="alternate" media="handheld" type="text/html" href="#{h uri}#{anchor rdfsec.id}" />\n|
327
rdf << %Q|<xhtml:link xhtml:rel="alternate" xhtml:media="handheld" xhtml:type="text/html" xhtml:href="#{h uri}#{anchor rdfsec.id}" />\n|
330
328
rdf << %Q|<dc:date>#{h rdfsec.time_string}</dc:date>\n|
331
329
a = rdfsec.id.scan( /(\d{4})(\d\d)(\d\d)/ ).flatten.map{|s| s.to_i}
332
330
date = Time::local( *a )
341
339
body_leave = body_leave_proc( date )
342
340
@makerss_in_feed = false
344
sub = apply_plugin( subtitle, true ).strip
345
sub.sub!( /^(\[([^\]]+)\])+ */, '' )
342
sub = (subtitle || '').sub( /^(\[([^\]]+)\])+ */, '' )
343
sub = apply_plugin( sub, true ).strip
347
345
sub = @conf.shorten( remove_tag( body ).strip, 20 )
364
362
text << body_leave
365
363
unless text.empty?
364
uri = @conf.index.dup
365
uri[0, 0] = @conf.base_url unless %r|^https?://|i =~ uri
366
uri.gsub!( %r|/\./|, '/' )
367
text = absolutify( text, uri )
366
368
text.gsub!( /\]\]>/, ']]]]><![CDATA[>' )
367
369
rdf << %Q|<content:encoded><![CDATA[#{text}|
368
unless @conf['makerss.comment_link']
369
ymd = date.strftime( "%Y%m%d" )
370
uri = @conf.index.dup
371
uri[0, 0] = @conf.base_url unless %r|^https?://|i =~ uri
372
uri.gsub!( %r|/\./|, '/' )
373
rdf << %Q|\n<p><a href="#{h uri}#{anchor "#{ymd}c"}">#{comment_new}</a></p>|
375
rdf << %Q|]]></content:encoded>\n|
370
unless @conf['makerss.comment_link']
371
ymd = date.strftime( "%Y%m%d" )
372
rdf << %Q|\n<p><a href="#{h uri}#{anchor "#{ymd}c"}">#{comment_new}</a></p>|
374
rdf << %Q|]]></content:encoded>\n|
433
checked = @cgi.params['makerss_update'][0] == 'false' ? ' checked' : ''
432
checked = if @cgi.params['makerss_update'][0] == 'false' then
434
elsif @date < (Time::now - 30*24*60*60) # older over a month
435
440
<div class="makerss"><label for="makerss_update">
436
441
<input type="checkbox" id="makerss_update" name="makerss_update" value="false"#{checked} tabindex="390">
694
699
text.gsub( /&[a-z]+;/im ) do |e|
695
@xml_entity_table[e.downcase] || e
700
@xml_entity_table[e] || e
704
# Copied from below which includes some tests
705
# http://github.com/zunda/ruby-absolutify/tree/master
706
def absolutify(html, baseurl)
707
@@_absolutify_attr_regexp ||= Hash.new
708
baseuri = URI.parse(URI.encode(baseurl))
709
r = html.gsub(%r|<\S[^>]*/?>|) do |tag|
710
type = tag.scan(/\A<(\S+)/)[0][0].downcase
711
if attr = {'a' => 'href', 'img' => 'src'}[type]
712
@@_absolutify_attr_regexp[attr] ||= %r|(.*#{attr}\s*=\s*)(['"]?)([^\2>]+?)(\2.*)|im
713
m = tag.match(@@_absolutify_attr_regexp[attr])
719
uri = URI.parse(location)
721
location = (baseuri + location).to_s
724
path += '?' + uri.query if uri.query
725
path += '#' + uri.fragment if uri.fragment
726
location = (baseuri + path).to_s
728
tag = prefix + location + postfix
729
rescue URI::InvalidURIError
740
# indent-tabs-mode: t
742
# ruby-indent-level: 3