/usr/share/tdiary/contrib/plugin/twitter.rb is in tdiary-contrib 5.0.8-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | # twitter.rb $Revision: 1.1 $
# Copyright (C) 2007 Michitaka Ohno <elpeo@mars.dti.ne.jp>
# You can redistribute it and/or modify it under GPL2.
require 'timeout'
require 'time'
require 'open-uri'
require 'rexml/document'
@twitter_statuses = []
if /^(latest|day)$/ =~ @mode then
add_header_proc do
xml = nil
Timeout.timeout( 5 ) do
begin
xml = open( "http://twitter.com/statuses/user_timeline/#{@conf['twitter.user']}.xml" ){|f| f.read}
rescue Exception
end
end
doc = REXML::Document.new( xml ).root if xml
if doc then
doc.elements.each( 'status' ) do |e|
@twitter_statuses << [@conf.to_native( e.elements['text'].text ), Time.parse( e.elements['created_at'].text ).localtime]
end
end
''
end
end
add_body_leave_proc do |date|
today_statuses = []
@twitter_statuses.each do |t, d|
today_statuses << [t, d] if d.to_a[3,3] == date.to_a[3,3]
end
if !today_statuses.empty?
r = %Q[<div class="section">]
r << %Q[<h3><a href="http://twitter.com/#{@conf['twitter.user']}">Twitter statuses</a></h3>]
today_statuses.sort{|a, b| b.last<=>a.last}.each do |t, d|
r << %Q[<p><strong>#{CGI::escapeHTML( t )}</strong> (#{d.strftime( '%H:%M:%S' )})</p>]
end
r << %Q[</div>]
else
''
end
end
|