]
end
id +=1
end
if n_image > 0
r << %Q[]
end
r << %Q[]
end
# vim: set ts=3 sw=3 noexpandtab :
tdiary-contrib-3.2.2/plugin/image_gps.rb 0000664 0000000 0000000 00000007200 12136327440 0020227 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# image_gps.rb $Revision: 1.7 $
#
# 概要:
# 画像にGPSによる位置情報が含まれている場合は、対応する地図へのリンクを生成する。
#
# 使い方:
# 絵日記Plugin(image.rb)とおなじ
#
# Copyright (c) 2004,2010 kp
# Distributed under the GPL
#
=begin ChangeLog
2010-04-21 kp
* リンク先をGoogleに統一
2009-06-01 kp
* モバイルモード時も世界測地系とする
2009-05-26 kp
* walk.eznavi.jpの場合のクエリを修正
* リンク先をGoogle Mapsに
* wgs2tkyを使用しない
2008-05-22 kp
* MapDatumがTOKYO以外の場合、WGS-84と類推する
2008-01-17 kp
* いろいろ変更
2006-03-28 kp
* cooperation with ALPSLAB clip!
2006-03-27 kp
* use exifparser
2005-07-25 kp
* correct link URL when access with mobile.
2005-07-19 kp
* MapDatum macth to WGS84
2005-05-25 kp
* correct URL link to Mapion.
2005-05-24 kp
* create link to http://walk.eznavi.jp when access with mobile.
2004-11-30 kp
* first version
=end
require 'exifparser'
def tky2wgs lat,lon
lat_w = lat - lat*0.00010695 + lon*0.000017464 + 0.0046017
lon_w = lon - lat*0.000046038 - lon*0.000083043 + 0.010040
lat = lat_w
lon = lon_w
return lat,lon
end
def image( id, alt = 'image', thumbnail = nil, size = nil, place = 'photo' )
if @conf.secure then
image = "#{@image_date}_#{id}.jpg"
image_t = "#{@image_date}_#{thumbnail}.jpg" if thumbnail
else
image = image_list( @image_date )[id.to_i]
image_t = image_list( @image_date )[thumbnail.to_i] if thumbnail
end
if size then
if size.kind_of?(Array)
size = %Q[ width="#{size[0]}" height="#{size[1]}"]
else
size = %Q[ width="#{size.to_i}"]
end
else
size = ""
end
#m_map = 'http://m.google.com/maps'
map = 'http://maps.google.co.jp'
exif = ExifParser.new("#{@image_dir}/#{image}".untaint) rescue nil
datum = nil
if exif
if @conf['image_gps.add_info']
alt += ' '+exif['Model'].to_s if exif.tag?('Model')
alt += ' '+exif['FocalLength'].to_s if exif.tag?('FocalLength')
alt += ' '+exif['ExposureTime'].to_s if exif.tag?('ExposureTime')
alt += ' '+exif['FNumber'].to_s if exif.tag?('FNumber')
end
begin
lat = exif['GPSLatitude'].value
lat = lat[0].to_f + lat[1].to_f/60 + lat[2].to_f/3600
lat = -lat if exif['GPSLatitudeRef'].value == 'S'
lon = exif['GPSLongitude'].value
lon = lon[0].to_f + lon[1].to_f/60 + lon[2].to_f/3600
lon = -lon if exif['GPSLongitudeRef'].value == 'W'
datum = exif['GPSMapDatum'].value if exif.tag?('GPSMapDatum')
rescue
lat = nil
end
end
unless lat.nil?
lat,lon = tky2wgs(lat,lon) if datum == 'TOKYO'
end
if thumbnail
url = %Q[ ]
elsif lat.nil?
url = %Q[ ]
else
if @conf.mobile_agent?
url = %Q[]
else
url = %Q[ ]
end
url += %Q[ ]
end
url
end
add_conf_proc('image_gps','image_gpsの設定','etc') do
if @mode == 'saveconf' then
@conf['image_gps.add_info'] = @cgi.params['image_gps.add_info'][0]
end
<<-HTML
撮影条件の表示
タイトルに撮影条件を追加する
HTML
end
tdiary-contrib-3.2.2/plugin/inline_wiki.rb 0000664 0000000 0000000 00000000177 12136327440 0020603 0 ustar 00root root 0000000 0000000 # Copyright (C) 2009 Hideki Sakamoto
require 'hikidoc'
def inline_wiki(buf)
HikiDoc::to_html(buf)
end
tdiary-contrib-3.2.2/plugin/instagr.rb 0000664 0000000 0000000 00000003456 12136327440 0017754 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
#
# instagr.rb - plugin to insert images on instagr.am
#
# Copyright (C) 2011, tamoot
# You can redistribute it and/or modify it under GPL2.
#
# usage:
# <%= instagr 'short URL instag.ram' =>
# <%= instagr 'short URL instag.ram', size} =>
#
# available size option:
# :small => 150x150 pixel
# :medium => 306x306 pixel (default)
# :large => 612x612 pixel
require 'cgi'
require 'json'
require 'net/http'
def instagr( short_url, size = :medium)
return %Q|Argument is empty.. #{short_url}
| if !short_url or short_url.empty?
option = option.nil? ? {} : option
# img size
maxwidth_data = {:small => 150, :medium => 306, :large => 612}
maxwidth = maxwidth_data[ size ] ? maxwidth_data[ size ] : maxwidth_data[:medium]
# proxy
px_host, px_port = (@conf['proxy'] || '').split( /:/ )
px_port = 80 if px_host and !px_port
# query
query = "?url=#{CGI::escape(short_url)}&maxwidth=#{maxwidth}"
begin
Net::HTTP.version_1_2
res = Net::HTTP::Proxy(px_host, px_port).get('instagram.com', "/api/v1/oembed/#{query}")
json_data = JSON::parse( res, &:read )
width = option[:width] ? option[:width] : json_data["width"]
height = option[:height] ? option[:height] : json_data["height"]
return <<-INSTAGR_DOM
#{h json_data["author_name"]}'s photo.
INSTAGR_DOM
rescue
return %Q|Failed Open URL.. #{short_url} #{h $!}
|
end
end
alias :instagram :instagr
# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:
# vim: ts=3
tdiary-contrib-3.2.2/plugin/ja/ 0000775 0000000 0000000 00000000000 12136327440 0016342 5 ustar 00root root 0000000 0000000 tdiary-contrib-3.2.2/plugin/ja/add_bookmark.rb 0000664 0000000 0000000 00000001122 12136327440 0021300 0 ustar 00root root 0000000 0000000 # ja/add_bookmark.rb $Revision 1.3 $
#
# Japanese resource of add_bookmark.rb
# You can redistribute it and/or modify it under GPL2.
#
@add_bookmark_label = 'ブックマーク追加'
@add_bookmark_desc = 'ページに埋め込みたいリンクをチェックしてください。'
@caption_delicious = 'del.icio.usに追加'
@caption_hatena = 'はてなブックマークに追加'
@caption_livedoor = 'livedoor クリップに追加'
@caption_buzzurl = 'Buzzurl に追加'
@bookmark_label = [
'del.icio.us',
'はてなブックマーク',
'livedoor クリップ',
'Buzzurl'
]
tdiary-contrib-3.2.2/plugin/ja/del_footer.rb 0000664 0000000 0000000 00000000476 12136327440 0021020 0 ustar 00root root 0000000 0000000 #
# English resource of delicious plugin $Revision: 1.0 $
#
# Copyright (C) 2006 SHIBATA Hiroshi
# You can redistribute it and/or modify it under GPL2.
#
@delicious_label_conf = 'del.icio.us'
@delicious_label_id = 'del.icio.usのユーザーID'
@delicious_label_pw = 'del.icio.usのパスワード'
tdiary-contrib-3.2.2/plugin/ja/flickr.rb 0000664 0000000 0000000 00000006456 12136327440 0020154 0 ustar 00root root 0000000 0000000 # flickr.rb Japanese resources
add_conf_proc('flickr', 'Flickr プラグイン') do
if @mode == 'saveconf'
@conf['flickr.default_size'] = @cgi.params['flickr.default_size'][0]
@conf['flickr.user_id'] = @cgi.params['flickr.user_id'][0]
if @cgi.params['flickr.clear'][0] == "true"
flickr_clear_cache
end
end
flickr_bookmarklet = CGI.escapeHTML %Q{javascript:(function(){var w=window;w.page_photo_id||/^\/photos\/[^/]+\/(\d+)\//.test(w.location.pathname)?w.location.href="#{@conf.base_url}#{@update}?#{FLICKER_FORM_PID}="+w.page_photo_id||RegExp.$1:void(0);})()}
r = <<-_HTML
Flickr に登録した画像を日記に表示するプラグインです。日記の本文中で下記のように呼び出します。
<%=flickr 画像ID, 画像サイズ%>
画像ID
それぞれの写真に一意に付けられる番号です。 画像IDは Flickr で画像を表示したときの URL に含まれています。
画像サイズ
表示する画像の大きさを square, thumbnail, small, medium, large から指定します。 この値は省略できます。省略すると、画像は設定画面(この画面)で指定したサイズで表示されます。
標準の画像サイズ
画像サイズを省略してプラグインを呼び出した場合のサイズを指定します。
_HTML
%w(square thumbnail small medium large).each do |size|
selected = (size == @conf['flickr.default_size']) ? 'selected' : ''
r << %Q|#{size} |
end
r <<<<-_HTML
FlickrのユーザID
Flickr上でのあなたのユーザIDを入力してください。
※ Flickr ID は「19594487@N00」のような文字列です。分からないときは idgettr.com で調べることができます。
Bookmarklet
写真をかんたんに tDiary の日記へ載せるための Bookmarklet です。Bookmarklet を登録しなくても Flickr プラグインは使えますが、登録すればより便利になります。
Flickr to tDiary (このリンクをブラウザのお気に入り・ブックマークに登録してください)
使い方
Flickr にアクセスし、日記に載せたい写真のページを開いて、この Bookmarklet を実行してください。
日記の編集フォームの下に先ほどの写真が表示されます。
「本文に追加」ボタンを押すと、日記中にこの写真を表示するための記述(プラグイン)が追記されます。
キャッシュファイルの削除
Flickrプラグインが使用しているキャッシュを削除します。
キャッシュを削除する
_HTML
end
tdiary-contrib-3.2.2/plugin/ja/git-register.rb 0000664 0000000 0000000 00000000253 12136327440 0021274 0 ustar 00root root 0000000 0000000 @git_register_conf_label = 'Git'
@git_register_conf_header = 'Gitへ再登録'
@git_register_conf_description = 'Gitへ再登録する場合はOKを押してください'
tdiary-contrib-3.2.2/plugin/ja/google_sitemaps.rb 0000664 0000000 0000000 00000003323 12136327440 0022051 0 ustar 00root root 0000000 0000000 # google_sitemap.rb
# Copyright (c) 2006 http://d.bulkitem.com/
# Distributed under the GPL
add_conf_proc('google_sitemaps', 'Google sitemap') do
saveconf_google_sitemaps
request_uri = File::dirname(@cgi.request_uri)
if request_uri == "/"
@conf['google_sitemaps.uri_format'] ||= 'http://' + @cgi.server_name + '/index.cgi?date=%s'
else
@conf['google_sitemaps.uri_format'] ||= 'http://' + @cgi.server_name + request_uri + '/index.cgi?date=%s'
end
@conf['google_sitemaps.output_file'] ||= File::dirname(ENV['SCRIPT_FILENAME']) + '/sitemap.xml'
if File.writable_real?(@conf['google_sitemaps.output_file']) == false
msg = "[NG] 指定されているファイルの書き込み権限がありません。 "
else
msg = "[OK] 指定されているファイルの書き込み権限があります。"
end
<<-HTML
Google ウェブマスターツール用のSitemap XMLを出力する設定を行います。
アドレスフォーマット
日付別表示時のURLフォーマットを指定します。日付文字列の部分は%s にしてください。
eg. http://www.example.com/inex.cgi?date=%s http://www.example.com/%s .html
XMLファイルの出力先
出力するファイルを絶対パスで指定します。
#{msg}
HTML
end
tdiary-contrib-3.2.2/plugin/ja/livedoor_weather.rb 0000664 0000000 0000000 00000002424 12136327440 0022233 0 ustar 00root root 0000000 0000000 #
# Japanese resource of livedoor_weather plugin $Revision$
#
# Copyright (C) 2006 SHIBATA Hiroshi
# You can redistribute it and/or modify it under GPL2.
#
#
# tdiary.confにおける設定:
# @options['lwws.city_id'] : 天気情報を取得したい都市のIDを指定(設定画面から編集可能)
#
@lwws_plugin_name = 'livedoor 天気情報'
@lwws_label_city_id = '都市IDの設定'
@lwws_desc_city_id = '天気情報を取得する都市IDを指定します。全国の地点定義表(RSS) 内の「1次細分区(cityタグ)」のidから選択してください。(初期設定は東京)'
@lwws_label_disp_item = '表示項目の設定'
@lwws_desc_disp_item = '表示させたい項目を選択してください。'
@lwws_icon_label = 'アイコン表示の設定'
@lwws_icon_desc = '天気情報をアイコン表示にする(詳細へのリンクは画像に設定)'
@lwws_max_temp_label = '最高気温'
@lwws_min_temp_label = '最低気温'
@celsius_label = '℃'
@lwws_label_cache = 'キャッシュの自動更新'
@lwws_desc_cache = '自動更新を有効にする。'
@lwws_desc_cache_time = 'キャッシュの更新間隔を時間で指定します。(初期設定は6時間)'
tdiary-contrib-3.2.2/plugin/ja/microsummary.rb 0000664 0000000 0000000 00000001004 12136327440 0021411 0 ustar 00root root 0000000 0000000 # ja/microsummary.rb
#
# Japanese resources for microsummary.rb
#
# Copyright (c) 2006 elytsllams
# Distributed under the GPL
#
if @mode == 'conf' || @mode == 'saveconf'
add_conf_proc( 'microsummary', 'Microsummary Generator' ) do
saveconf_microsummary
microsummary_init
<<-HTML
URI for microsummary generator XML
HTML
end
end
tdiary-contrib-3.2.2/plugin/ja/nicovideo.rb 0000664 0000000 0000000 00000003312 12136327440 0020645 0 ustar 00root root 0000000 0000000 #
# ja/nicovideo.rb - Japanese resource
#
# Copyright (C) TADA Tadashi
# Distributed under GPL.
#
def nicovideo_player_path
'http://www.nicovideo.jp'
end
def nicovideo_feed( i )
<<-HTML
HTML
end
def nicovideo_html( i )
<<-HTML
#{i[:date][0,10]}
再生: #{i[:view].scan(/\d+?(?=\d{3}*$)/).join(",")}
コメント: #{i[:comment_num].scan(/\d+?(?=\d{3}*$)/).join(",")}
マイリスト: #{i[:mylist].scan(/\d+?(?=\d{3}*$)/).join(",")}
#{h i[:title]} (#{i[:length].split(/:/).map{|j|'%02d' % j.to_i}.join(':')}) #{i[:desc]}
HTML
end
tdiary-contrib-3.2.2/plugin/ja/openid.rb 0000664 0000000 0000000 00000000575 12136327440 0020154 0 ustar 00root root 0000000 0000000 # openid.rb: Japanese resource
@openid_conf_label = 'OpenID'
@openid_service_label = 'OpenID認証サービス名'
@openid_service_desc = 'あなたが使っているOpenIDの認証サービス名を選んでください'
@openid_id_label = 'あなたのID'
@openid_id_desc = '上で選択した認証サービスに登録してある、あなたのIDを入力してください'
tdiary-contrib-3.2.2/plugin/ja/section_footer.rb 0000664 0000000 0000000 00000000677 12136327440 0021723 0 ustar 00root root 0000000 0000000 # section_footer.rb: Japanese resource
@section_footer_delicious_label = "このエントリの del.icio.us history"
@section_footer_hatenabm_label = "このエントリを含むはてなブックマーク"
@section_footer_ldclip_label = "このエントリを含む livedoor クリップ"
@section_footer_buzzurl_label = "このエントリを含む Buzzurl"
@section_footer_yahoobm_label = "このエントリを含む Yahoo!ブックマーク"
tdiary-contrib-3.2.2/plugin/ja/section_footer2.rb 0000664 0000000 0000000 00000000257 12136327440 0021777 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# section_footer2.rb: Japanese resource
@section_footer2_delicious_label = "このエントリの Delicious history"
@section_footer2_locale = 'ja_JP'
tdiary-contrib-3.2.2/plugin/ja/socialbutton.rb 0000664 0000000 0000000 00000000466 12136327440 0021403 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# section_footer2.rb: Japanese resource
@socialbutton_label_conf = 'ソーシャルボタン'
@socialbutton_label_enables = 'ボタンを表示するサービス'
@socialbutton_label_twitter_via = 'ツイート時に表示するユーザ名(あなたのTwitterアカウント名)'
tdiary-contrib-3.2.2/plugin/jdate.rb 0000664 0000000 0000000 00000001221 12136327440 0017360 0 ustar 00root root 0000000 0000000 # jdate.rb $Revision: 1.1 $
#
#「%J」で日本語の曜日名を出す
# pluginに入れるだけで動作する。
# 日付フォーマットなどで「%J」を指定するとそこが日本語の曜日になる
#
# Copyright (c) 2003 TADA Tadashi
# You can distribute this file under the GPL.
#
unless Time::new.respond_to?( :strftime_jdate_backup ) then
eval( <<-MODIFY_CLASS, TOPLEVEL_BINDING )
class Time
alias strftime_jdate_backup strftime
JWDAY = %w(日 月 火 水 木 金 土)
def strftime( format )
strftime_jdate_backup( format.gsub( /%J/, JWDAY[self.wday] ) )
end
end
MODIFY_CLASS
end
tdiary-contrib-3.2.2/plugin/jholiday.rb 0000664 0000000 0000000 00000000670 12136327440 0020103 0 ustar 00root root 0000000 0000000 require 'Calendar.rb'
require 'date'
unless Time::new.respond_to?( :strftime_holiday_backup )
then
eval( <<-MODIFY_CLASS, TOPLEVEL_BINDING )
class Time
alias strftime_holiday_backup strftime
def strftime( format )
holiday = ""
day = Day.new(self.day,self.month,self.year,self.wday)
holiday = day.holiday_name_jp if day.holiday?
strftime_holiday_backup( format.gsub( /%K/, holiday ) )
end
end
MODIFY_CLASS
end
tdiary-contrib-3.2.2/plugin/jmonth.rb 0000664 0000000 0000000 00000001354 12136327440 0017577 0 ustar 00root root 0000000 0000000 # jmonth.rb $Revision: 1.1 $
#
#「%i」で日本語の陰暦月名を出す
# pluginに入れるだけで動作する。
# 日付フォーマットなどで「%i」を指定するとそこが陰暦月名になる
#
# Copyright (c) 2005 sasasin/SuzukiShinnosuke
# You can distribute this file under the GPL.
#
unless Time::new.respond_to?( :strftime_jmonth_backup ) then
eval( <<-MODIFY_CLASS, TOPLEVEL_BINDING )
class Time
alias strftime_jmonth_backup strftime
JMONTH = %w(睦月 如月 弥生 卯月 皐月 水無月 文月 葉月 長月 神無月 霜月 師走)
def strftime( format )
strftime_jmonth_backup( format.gsub( /%i/, JMONTH[self.month-1] ) )
end
end
MODIFY_CLASS
end
tdiary-contrib-3.2.2/plugin/jquery_ui_theme.rb 0000664 0000000 0000000 00000002327 12136327440 0021477 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
#
# jquery_ui.rb - use jQuery UI
#
# Copyright (C) 2012, tamoot
# You can redistribute it and/or modify it under GPL.
#
#
# not support
#
return if feed? || @conf.mobile_agent?
add_header_proc do
if /\A(?:form|preview|append|edit|update)\z/ =~ @mode
themes = @conf['jquery_ui.theme']
if themes.nil? || theme == ''
themes = 'base'
end
jquery_ui = ''
jquery_ui << %Q| \n|
jquery_ui
else
''
end
end
add_conf_proc( 'jquery_ui_theme', 'jQuery UI Theme' ) do
if @mode == 'saveconf' then
@conf['jquery_ui.theme'] = @cgi.params['jquery_ui.theme'][0]
end
<<-HTML
Theme name
sample) blitzer, flick .. See JQuery UI Theme.
default is base .
HTML
end
# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:
# vim: ts=3
tdiary-contrib-3.2.2/plugin/jroku.rb 0000664 0000000 0000000 00000001676 12136327440 0017441 0 ustar 00root root 0000000 0000000 # jroku.rb $Revision: 1.1 $
#
#「%R」で六曜を出す
# 動かすためには
# http://www.funaba.org/calendar.html#calendar
# で配布されているClendarモジュールと付属しているcalclass.rbが必要
# 日付フォーマットなどで「%R」を指定するとそこが六曜になる
#
# Copyright (c) 2005 SHIBATA Hiroshi
# You can distribute this file under the GPL.
#
require 'calclass.rb'
unless Time::new.respond_to?( :strftime_jroku_backup ) then
eval( <<-MODIFY_CLASS, TOPLEVEL_BINDING )
class Time
alias strftime_jroku_backup strftime
JROKU = %w(大安 赤口 先勝 友引 先負 仏滅)
def strftime( format )
d=Gregorian.new(self.month, self.day, self.year)
q_d = Calendar.kyureki_from_absolute(d.abs)
index = (q_d[0] + q_d[2]) % 6
strftime_jroku_backup( format.gsub( /%R/, JROKU[index] ) )
end
end
MODIFY_CLASS
end
tdiary-contrib-3.2.2/plugin/jyear.rb 0000664 0000000 0000000 00000002135 12136327440 0017410 0 ustar 00root root 0000000 0000000 # jyear.rb $Revision: 1.1 $
#
# 西暦を和暦に変換するプラグイン。
# 日記やツッコミの日付フォーマットで使う。
# 「%Y」で「2005」のところを、「%K」で「平成17」と表示。
# pluginに入れるだけで動作する。
#
# Copyright (c) 2005 sasasin/SuzukiShinnosuke
# You can distribute this file under the GPL.
#
unless Time::new.respond_to?( :strftime_jyear_backup ) then
eval( <<-MODIFY_CLASS, TOPLEVEL_BINDING )
class Time
alias strftime_jyear_backup strftime
def strftime( format )
case self.year
when 0 .. 1926
gengo = "昔々"
if self.year == 1926 && self.month == 12 && self.day >=25 then
gengo = "昭和元年"
end
when 1927 .. 1989
jyear = self.year - 1925
gengo = "昭和" + jyear.to_s
if self.year == 1989 && self.month == 1 && self.day >= 8 then
gengo = "平成元年"
end
else
jyear = self.year - 1988
gengo = "平成" + jyear.to_s
end
strftime_jyear_backup( format.gsub( /%K/, gengo ) )
end
end
MODIFY_CLASS
end
tdiary-contrib-3.2.2/plugin/latlonglab_route.rb 0000664 0000000 0000000 00000001260 12136327440 0021631 0 ustar 00root root 0000000 0000000 #
# latlonglab_route.rb - tDiary plugin for LatLongLab Route
#
# Copyright (C) 2009, Michitaka Ohno
# Copyright (C) 2010, KAYA Satoshi
# You can redistribute it and/or modify it under GPL2.
#
def route( id, w = 480, h = 480 )
if feed? or @conf.mobile_agent?
return %Q|Link to LatLongLab Route
|
end
if @conf.iphone?
w = 240
h = 380
end
<<-HTML
HTML
end
tdiary-contrib-3.2.2/plugin/lazy_referer.rb 0000664 0000000 0000000 00000001762 12136327440 0020774 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8; -*-
#
# lazy_referer.rb: lazy loading referer
#
# Copyright (C) 2013 by MATSUOKA Kohei
# You can distribute it under GPL.
#
if /^(day|form|edit)$/ =~ @mode and not bot? then
enable_js('referer.js')
#
# overwrite method: draw only referer area (content will feach with ajax)
#
def referer_of_today_long( diary, limit )
return if limit == 0
return unless diary
date = diary.date.strftime('%Y%m%d')
# FIXME: endpoint is should created by TDiary::Plugin, because easy customize routing
endpoint = "#{@conf.index}?plugin=referer&date=#{date}"
%Q[#{referer_today} \n]
end
end
#
# return referer of date as is (html)
#
add_content_proc('referer') do |date|
diary = @diaries[date]
referer_load_current( diary )
referer_of_today_long( diary, 100 )
end
# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:
tdiary-contrib-3.2.2/plugin/livedoor_weather.rb 0000664 0000000 0000000 00000013246 12136327440 0021645 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# livedoor_weather.rb
#
# insert weather information using livedoor weather web service.
#
# Copyright (C) 2007 SHIBATA Hiroshi
# You can redistribute it and/or modify it under GPL2.
#
require 'open-uri'
require 'timeout'
require 'time'
@lwws_rest_url = 'http://weather.livedoor.com/forecast/webservice/json/v1'
def lwws_init
@conf['lwws.city_id'] ||= 130010
@conf['lwws.icon.disp'] ||= ""
@conf['lwws.max_temp.disp'] ||= ""
@conf['lwws.min_temp.disp'] ||= ""
@conf['lwws.cache'] ||= ""
@conf['lwws.cache_time'] ||= 6
end
def lwws_request( city_id )
url = @lwws_rest_url.dup
url << "?city=#{city_id}"
proxy = @conf['proxy']
proxy = 'http://' + proxy if proxy
timeout( 10 ) do
open( url, :proxy => proxy ) {|f| f.read }
end
end
def lwws_get
lwws_init
city_id = @conf['lwws.city_id']
cache_time = @conf['lwws.cache_time'] * 60 * 60
file_name = "#{@cache_path}/lwws/#{Time.now.strftime("%Y%m%d")}.json"
begin
Dir.mkdir("#{@cache_path}/lwws") unless File.directory?("#{@cache_path}/lwws")
cached_time = if File.exist?( file_name )
File.mtime( file_name )
else
nil
end
update = true if @conf['lwws.cache'] == "t" && cached_time && Time.now > cached_time + cache_time
if cached_time.nil? || update
json = lwws_request(city_id)
File.open(file_name, 'wb') {|f| f.write(json)}
end
rescue => e
@logger.error( e )
end
end
def lwws_to_html(date)
lwws_init
file_name = "#{@cache_path}/lwws/#{date.strftime("%Y%m%d")}.xml"
begin
# http://weather.livedoor.com/help/restapi_close
if Time.parse('20130331') < date
file_name.sub!(/xml/, 'json')
require 'json'
doc = JSON.parse(File.read(file_name))
telop = @conf.to_native( doc["forecasts"][0]["telop"], 'utf-8' )
# 「今日」のデータに気温は含まれない場合がある
max_temp = doc["forecasts"][0]["temperature"]["max"]["celsius"] rescue nil
min_temp = doc["forecasts"][0]["temperature"]["min"]["celsius"] rescue nil
detail_url = doc["link"]
title = @conf.to_native( doc["forecasts"][0]["image"]["title"], 'utf-8' )
url = doc["forecasts"][0]["image"]["url"]
width = doc["forecasts"][0]["image"]["width"]
height = doc["forecasts"][0]["image"]["height"]
else
require 'rexml/document'
doc = REXML::Document.new(File.read(file_name)).root
telop = @conf.to_native( doc.elements["telop"].text, 'utf-8' )
max_temp = doc.elements["temperature/max/celsius"].text
min_temp = doc.elements["temperature/min/celsius"].text
detail_url = doc.elements["link"].text
title = @conf.to_native( doc.elements["image/title"].text, 'utf-8' )
url = doc.elements["image/url"].text
width = doc.elements["image/width"].text
height = doc.elements["image/height"].text
end
result = ""
result << %Q||
if @conf['lwws.icon.disp'] != "t" or @conf.mobile_agent? then
result << %Q|
#{telop} |
else
result << %Q|
|
end
if @conf['lwws.max_temp.disp'] == "t" and not max_temp.nil? then
result << %Q| #{@lwws_max_temp_label}:#{h(max_temp)}#{@celsius_label}|
end
if @conf['lwws.min_temp.disp'] == "t" and not min_temp.nil? then
result << %Q| #{@lwws_min_temp_label}:#{h(min_temp)}#{@celsius_label}|
end
result << %Q|
|
result
rescue StandardError, Errno::ENOENT => e
@logger.error( e )
''
end
end
def lwws_conf_proc
lwws_init
if @mode == 'saveconf' then
@conf['lwws.city_id'] = @cgi.params['lwws.city_id'][0].to_i
@conf['lwws.icon.disp'] = @cgi.params['lwws.icon.disp'][0]
@conf['lwws.max_temp.disp'] = @cgi.params['lwws.max_temp.disp'][0]
@conf['lwws.min_temp.disp'] = @cgi.params['lwws.min_temp.disp'][0]
@conf['lwws.cache'] = @cgi.params['lwws.cache'][0]
@conf['lwws.cache_time'] = @cgi.params['lwws.cache_time'][0].to_i
end
result = ''
result << <<-HTML
#{@lwws_label_city_id}
#{@lwws_desc_city_id}
HTML
result << %Q|#{@lwws_icon_label} |
checked = "t" == @conf['lwws.icon.disp'] ? ' checked' : ''
result << %Q| #{@lwws_icon_desc}
|
result << %Q|#{@lwws_label_disp_item} |
result << %Q|#{@lwws_desc_disp_item}
|
result << %Q||
result << %Q|#{@lwws_label_cache} |
checked = "t" == @conf['lwws.cache'] ? ' checked' : ''
result << %Q| #{@lwws_desc_cache}
|
result << %Q|#{@lwws_desc_cache_time}
|
result << %Q|
|
result
end
add_body_enter_proc do |date|
unless @conf.mobile_agent? or @conf.iphone? or feed? or bot?
lwws_to_html(date)
end
end
add_update_proc do
lwws_get
end
add_conf_proc( 'lwws', @lwws_plugin_name ) do
lwws_conf_proc
end
# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:
# vim: ts=3
tdiary-contrib-3.2.2/plugin/make_link.rb 0000664 0000000 0000000 00000002043 12136327440 0020226 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright (C) 2011, KADO Masanori
# You can redistribute it and/or modify it under GPL.
# needs category.rb plugin
add_edit_proc do
<<-HTML
Link URL:
Get Title and Link
HTML
end
tdiary-contrib-3.2.2/plugin/makerss_category.rb 0000664 0000000 0000000 00000001612 12136327440 0021637 0 ustar 00root root 0000000 0000000 #
# makerss_category.rb: extension for makerss plugin.
#
# Copyright (C) 2007 by SHIBATA Hiroshi
# Distributed under GPL2.
#
# Usage:
# @conf['makerss.category'] = ["mixi", "sns"]
#
class MakeRssCategory < MakeRssFull
def title
'(category only)'
end
def item( seq, body, rdfsec )
return unless rdfsec.section.respond_to?( :body_to_html )
return if rdfsec.section.categories.length == 0
rdfsec.section.categories.each do |category|
if @conf['makerss.category'].include?(category)
super
end
end
end
def file
f = @conf['makerss.category.file'] || 'category.rdf'
f = 'category.rdf' if f.length == 0
f
end
def write( encoder )
super( encoder )
end
def url
u = @conf['makerss.category.url'] || "#{@conf.base_url}category.rdf"
u = "#{@conf.base_url}category.rdf" if u.length == 0
u
end
end
@makerss_rsses << MakeRssCategory::new( @conf )
tdiary-contrib-3.2.2/plugin/makerss_comment.rb 0000664 0000000 0000000 00000001254 12136327440 0021466 0 ustar 00root root 0000000 0000000 #
# makerss_comment.rb: extension for makerss plugin.
#
# Copyright (C) 2007 by SHIBATA Hiroshi
# Distributed under GPL2.
#
class MakeRssComments < MakeRssFull
def title
'(comments only)'
end
def item( seq, body, rdfsec )
return if rdfsec.section.respond_to?( :body_to_html )
super
end
def file
f = @conf['makerss.no_comments.file'] || 'comments.rdf'
f = 'comments.rdf' if f.length == 0
f
end
def write( encoder )
super( encoder )
end
def url
u = @conf['makerss.no_comments.url'] || "#{@conf.base_url}comments.rdf"
u = "#{@conf.base_url}comments.rdf" if u.length == 0
u
end
end
@makerss_rsses << MakeRssComments::new( @conf )
tdiary-contrib-3.2.2/plugin/microsummary.rb 0000664 0000000 0000000 00000003354 12136327440 0021031 0 ustar 00root root 0000000 0000000 # microsummary.rb
#
# Copyright (c) 2006 elytsllams
# Distributed under the GPL
#
add_header_proc do
generator_xml = @conf['generator.xml']
if generator_xml != nil and @mode == 'latest' and !@cgi.valid?( 'date' )
%Q|\t \n|
end
end
def create_xml file_name
xml = <<-XML
-
-
^#{@conf.base_url.gsub(/\./, '\\.')}$
XML
begin
File::open( file_name, 'w' ) do |f|
f.print to_utf8( xml )
end
rescue
end
end
def microsummary_init
@conf['generator.xml'] ||= ""
create_xml( @conf['generator.xml'] ) unless File::exists? @conf['generator.xml']
end
if @mode == 'saveconf'
def saveconf_microsummary
@conf['generator.xml'] = @cgi.params['generator.xml'][0]
end
end
tdiary-contrib-3.2.2/plugin/mm_footer.rb 0000664 0000000 0000000 00000012415 12136327440 0020267 0 ustar 00root root 0000000 0000000 #
# mm_footer.rb
#
# MM ( http://1470.net/mm/) のmylistを各日付に貼り付けるtDiaryプラグイン
#
# Licence: GPL
# Author: ishinao
#
require 'nkf'
add_body_leave_proc(Proc.new do |date|
oldest_date = Time.local(2005, 1, 11)
if date > oldest_date
if @mode == 'day' or @mode == 'latest'
if date < Time.local(2006, 7, 6)
mm_user = 82 # your MM id
url = "http://1470.net/mm/mylist.html/#{mm_user}?date=#{date.strftime('%Y-%m-%d')}"
rssurl = "http://1470.net/mm/mylist.html/#{mm_user}?date=#{date.strftime('%Y-%m-%d')}&mode=rss"
template_list = '#{content} '
else
userName = 'hsbt' # your 1470.net id
url = "http://1470.net/user/#{userName}/#{date.strftime('%Y/%m/%d')}"
rssurl = "http://1470.net/user/#{userName}/#{date.strftime('%Y/%m/%d')}/feed"
template_list = '#{content.gsub(/href="\//, "href=\"http://1470.net\/")} '
end
template_head = %Q[\n"
cache_time = 3600;
if date.strftime('%Y-%m-%d') != Time.now.strftime('%Y-%m-%d')
cache_time = 3600 * 12;
end
NKF.nkf('-e', mm_footer(rssurl, 50, cache_time, template_head, template_list, template_foot))
else
''
end
end
end)
require "rss/rss"
MM_FOOTER_FIELD_SEPARATOR = "\0"
MM_FOOTER_ENTRY_SEPARATOR = "\1"
MM_FOOTER_VERSION = "0.0.5i"
MM_FOOTER_HTTP_HEADER = {
"User-Agent" => "tDiary RSS recent plugin version #{MM_FOOTER_VERSION}. " <<
"Using RSS parser version is #{::RSS::VERSION}.",
}
def mm_footer(url, max = 5, cache_time = 3600, \
template_head = "\n", \
template_list = ' \n', \
template_foot = " \n")
url.untaint
cache_file = "#{@cache_path}/rss-recent/rss-recent.#{CGI.escape(url)}"
mm_footer_cache_rss(url, cache_file, cache_time.to_i)
return '' unless test(?r, cache_file)
rv = template_head
i = 0
mm_footer_read_from_cache(cache_file).each do |title, url, time, content|
break if i >= max
next if (url.nil? or title.nil?)
rv << eval('%Q[' + template_list + ']')
i += 1
end
rv << template_foot
if i > 0
rv
else
''
end
end
class InvalidResourceError < StandardError; end
def mm_footer_cache_rss(url, cache_file, cache_time)
cached_time = nil
cached_time = File.mtime(cache_file) if File.exist?(cache_file)
if cached_time.nil? or Time.now > cached_time + cache_time
require 'time'
require 'open-uri'
require 'net/http'
require 'uri/generic'
require 'rss/parser'
require 'rss/1.0'
require 'rss/2.0'
require 'rss/dublincore'
require 'rss/content'
begin
uri = URI.parse(url)
raise URI::InvalidURIError if uri.scheme != "http"
rss_source = mm_footer_fetch_rss(uri, cached_time)
raise InvalidResourceError if rss_source.nil?
# parse RSS
rss = ::RSS::Parser.parse(rss_source, false)
raise ::RSS::Error if rss.nil?
# pre processing
begin
rss.output_encoding = @conf.charset || charset
rescue ::RSS::UnknownConversionMethodError
end
rss_infos = rss.items.collect do |item|
mm_footer_pubDate_to_dc_date(item)
[item.title, item.link, item.dc_date, item.content_encoded]
end
mm_footer_write_to_cache(cache_file, rss_infos)
rescue URI::InvalidURIError
mm_footer_write_to_cache(cache_file, [['Invalid URI', url]])
rescue InvalidResourceError, ::RSS::Error
# mm_footer_write_to_cache(cache_file, [['Invalid Resource', url]])
# when cannot get valid RSS, use old cache
end
end
end
def mm_footer_fetch_rss(uri, cache_time)
rss = nil
begin
uri.open(mm_footer_http_header(cache_time)) do |f|
case f.status.first
when "200"
rss = f.read
# STDERR.puts "Got RSS of #{uri}"
when "304"
# not modified
# STDERR.puts "#{uri} does not modified"
else
raise InvalidResourceError
end
end
rescue TimeoutError, SocketError, StandardError,
SecurityError # occured in redirect
raise InvalidResourceError
end
rss
end
def mm_footer_http_header(cache_time)
header = MM_FOOTER_HTTP_HEADER.dup
if cache_time.respond_to?(:rfc2822)
header["If-Modified-Since"] = cache_time.rfc2822
end
header
end
def mm_footer_write_to_cache(cache_file, rss_infos)
File.open(cache_file, 'w') do |f|
f.flock(File::LOCK_EX)
rss_infos.each do |info|
f << info.join(MM_FOOTER_FIELD_SEPARATOR)
f << MM_FOOTER_ENTRY_SEPARATOR
end
f.flock(File::LOCK_UN)
end
end
def mm_footer_read_from_cache(cache_file)
require 'time'
infos = []
File.open(cache_file) do |f|
while info = f.gets(MM_FOOTER_ENTRY_SEPARATOR)
info = info.chomp(MM_FOOTER_ENTRY_SEPARATOR)
infos << info.split(MM_FOOTER_FIELD_SEPARATOR)
end
end
infos.collect do |title, url, time, content|
[
mm_footer_convert(title),
mm_footer_convert(url),
mm_footer_convert(time) {|time| Time.parse(time)},
mm_footer_convert(content)
]
end
end
def mm_footer_convert(str)
if str.nil? or str.empty?
nil
else
if block_given?
yield str
else
str
end
end
end
def mm_footer_pubDate_to_dc_date(target)
if target.respond_to?(:pubDate)
class << target
alias_method(:dc_date, :pubDate)
end
end
end
tdiary-contrib-3.2.2/plugin/monthly_autopagerize.rb 0000664 0000000 0000000 00000003415 12136327440 0022551 0 ustar 00root root 0000000 0000000 #
# monthly_autopagerize.rb - tDiary plugin
#
# add and tags for AutoPagerize at monthly mode
#
# Copyright (C) 2009 MATSUI Shinsuke
# You can redistribute it and/or modify it under GPL2.
#
if @mode == 'month' then
add_header_proc do
stream = @conf['monthly_autopagerize.stream'] || 0
result = String.new
ym = []
@years.keys.each do |y|
ym += @years[y].collect {|m| y + m}
end
ym.sort!
now = @date.strftime( '%Y%m' )
return '' unless ym.index( now )
prev_month = ym.index( now ) == 0 ? nil : ym[ym.index( now )-1]
next_month = ym[ym.index( now )+1]
case stream
#when 0
# rel_prev_month = 'next'
# rel_next_month = 'prev'
when 1
rel_prev_month = 'prev'
rel_next_month = 'next'
else
rel_prev_month = 'next'
rel_next_month = 'prev'
end
if prev_month then
result << %Q[ \n\t]
end
if next_month then
result << %Q[ \n\t]
end
result.chop.chop
end
end
add_conf_proc( 'monthly_autopagerize', 'Monthly AutoPagerize' ) do
if @mode == 'saveconf' then
@conf['monthly_autopagerize.stream'] = @cgi.params['monthly_autopagerize.stream'][0].to_i
end
<<-HTML
Stream of Monthly AutoPagerize
To Past
To Future
HTML
end
# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:
# vi: ts=3 sw=3
tdiary-contrib-3.2.2/plugin/my_hotentry.rb 0000664 0000000 0000000 00000007734 12136327440 0020671 0 ustar 00root root 0000000 0000000 # show my hot-entry in Hatena::Bookmark
#
# usage:
# <%= my_hotentry %>
#
# Copyright (c) MATSUOKA Kohei
# Distributed under the GPL
#
require 'uri'
require 'open-uri'
require 'rexml/document'
require 'pstore'
require 'timeout'
# 人気の日記のソート順(新着順: eid, 注目順: hot, 人気順: count)
@conf ||= {}
@conf['my_hotentry.sort'] ||= 'hot'
class MyHotEntry
def initialize(dbfile)
@dbfile = dbfile
end
# 人気の日記の一覧を返す
def entries
r = nil
PStore.new(@dbfile).transaction(true) do |db|
r = db[:entries]
end
r || []
end
# 人気の日記一覧を取得する
def update(base_url, options = {})
options[:title] ||= ''
options[:sort] ||= 'eid'
options[:threshold] ||= 3
# RSSを取得
rss = nil
rss_url = 'http://b.hatena.ne.jp/entrylist?mode=rss&url='
rss_url << URI.escape(base_url, /[^-.!~*'()\w]/n)
rss_url << "&sort=#{options[:sort]}&threshold=#{options[:threshold]}"
begin
timeout(5) do
# convert Tempfile to String because REXML can't accept Tempfile
open(rss_url) do |f|
rss = REXML::Document.new(f.readlines.join("\n"))
end
end
rescue TimeoutError => e
return
end
# RDF/itemが空ならDBを更新しない (たまにitemが空のデータが返るため)
return if rss.elements['rdf:RDF/item'].nil?
# キャッシュに格納する
PStore.new(@dbfile).transaction do |db|
db[:entries] = []
rss.elements.each('rdf:RDF/item') do |item|
url = item.elements['link'].text
title = item.elements['title'].text
# リンク先のタイトルからサイト名と日付を取り除く
title.sub!(/(?: - )?#{options[:html_title]}(?: - )?/, '')
title.sub!(/\(\d{4}-\d{2}-\d{2}\)/, '')
db[:entries].push({ :url => url, :title => title })
end
end
end
end
# キャッシュファイルのパスを取得する
def my_hotentry_dbfile
cache_dir = "#{@cache_path}/hatena"
Dir::mkdir(cache_dir) unless File::directory?(cache_dir)
"#{cache_dir}/my_hotentry.dat"
end
# 人気の日記一覧を表示する
def my_hotentry(count = 5)
dbfile = my_hotentry_dbfile
hotentry = MyHotEntry.new(dbfile)
r = %Q||
r << %Q|\n|
end
# 人気の日記一覧を更新する
def my_hotentry_update
dbfile = my_hotentry_dbfile
hotentry = MyHotEntry.new(dbfile)
hotentry.update(@conf.base_url,
:html_title => @conf.html_title,
:sort => @conf['my_hotentry.sort'])
end
if __FILE__ == $0
# コマンドラインから実行した場合
# tdiary.conf に base_url を設定しないと動作しない
begin
require 'tdiary'
rescue LoadError
STDERR.puts "tdiary.rb not found."
STDERR.puts "please execute in tdiary base directory"
exit 1
end
cgi = CGI::new
@conf = TDiary::Config::new(cgi)
@cache_path = @conf.cache_path || "#{@conf.data_path}cache"
my_hotentry_update
puts my_hotentry
else
# 人気の日記一覧を取得する (日記更新時)
add_update_proc do
# ツッコミ時は実行しない
if @mode == 'append' or @mode == 'replace'
begin
my_hotentry_update
rescue
end
end
end
end
tdiary-contrib-3.2.2/plugin/navi_day.rb 0000664 0000000 0000000 00000007047 12136327440 0020077 0 ustar 00root root 0000000 0000000 #
# navi_day.rb
#
# navi_day: 「前の日記」や「次の日記」を“月またぎ”に対応させる。
#
# 日単位での表示の時の「前の日記」や「次の日記」のリンクが、
# 異なる月の日記を正しく指せない場合があるという tDiary の制限を
# 解消するプラグインです。以前よりある navi_user.rb と機能的には
# 同じですが、navi_user.rb よりは処理がずっと軽くなっています。
# また、日記の表示状態(非表示の日記)に対する考慮もなされています。
#
# tDiary 2.0 以降で使えると思います。セキュアモードでも使えますが、
# セキュアモードの場合は、モバイル端末からのアクセスに対しては
# このプラグインは効力を持ちません(tDiary セキュア環境の制限:
# モバイル端末の場合は本文を出力するときに calc_links が呼ばれる
# ため)。
#
# navi_user.rb と併用すると navi_user.rb の方が優先されますので、
# このプラグインを使うときには必ず navi_user.rb を外してください。
#
# Copyright (C) 2007, MIYASAKA Masaru
# You can redistribute it and/or modify it under GPL2.
#
# Last Modified : May 27, 2007
#
# for tDiary 2.0.X
if not TDiaryMonth.method_defined?(:diaries) then
eval( <<-MODIFY_CLASS, TOPLEVEL_BINDING )
module TDiary
class TDiaryMonth
attr_reader :diaries
end
end
MODIFY_CLASS
end
class NaviDayCGI
attr_reader :params
def referer; nil; end
def initialize
@params = Hash.new([])
end
end
alias :calc_links_navi_day_backup :calc_links
def calc_links
if not (@conf.secure and @conf.mobile_agent?) and \
(/day|edit/ =~ @mode or \
(@conf.mobile_agent? and /latest|month|nyear/ =~ @mode)) then
if /(latest|month|nyear)/ === @mode
today = @diaries.keys.sort[-1]
else
today = @date.strftime('%Y%m%d')
end
days = @diaries.keys
days |= [today]
days.sort!
days.unshift(nil).push(nil)
today_index = days.index(today)
days[0 .. today_index - 1].reverse_each do |prev_day|
@prev_day = prev_day
break unless @prev_day
break if (@mode == 'edit') or @diaries[@prev_day].visible?
end
days[today_index + 1 .. -1].each do |next_day|
@next_day = next_day
break unless @next_day
break if (@mode == 'edit') or @diaries[@next_day].visible?
end
if not @prev_day or not @next_day then
cgi = NaviDayCGI.new
years = []
@years.each do |k, v|
v.each do |m|
years << k + m
end
end
this_month = @date.strftime('%Y%m')
years |= [this_month]
years.sort!
years.unshift(nil).push(nil)
this_month_index = years.index(this_month)
years[0 .. this_month_index - 1].reverse_each do |prev_month|
break unless not @prev_day and prev_month
cgi.params['date'] = [prev_month]
diaries = TDiaryMonth.new(cgi, '', @conf).diaries
days = diaries.keys.sort
days.unshift(nil)
days.reverse_each do |prev_day|
@prev_day = prev_day
break unless @prev_day
break if (@mode == 'edit') or diaries[@prev_day].visible?
end
end
years[this_month_index + 1 .. -1].each do |next_month|
break unless not @next_day and next_month
cgi.params['date'] = [next_month]
diaries = TDiaryMonth.new(cgi, '', @conf).diaries
days = diaries.keys.sort
days.push(nil)
days.each do |next_day|
@next_day = next_day
break unless @next_day
break if (@mode == 'edit') or diaries[@next_day].visible?
end
end
end
else
calc_links_navi_day_backup
end
end
tdiary-contrib-3.2.2/plugin/navi_this_month.rb 0000664 0000000 0000000 00000000630 12136327440 0021465 0 ustar 00root root 0000000 0000000 # navi-this-month.rb
# ref. http://www.tom.sfc.keio.ac.jp/~sakai/d/?date=20080628#p01
#
alias navi_this_month__orig__navi_user_day navi_user_day
def navi_user_day
result = navi_this_month__orig__navi_user_day
if @mode=='day'
this_month = @date.strftime( '%Y%m' )
result << navi_item( "#{@index}#{anchor this_month}", "#{navi_this_month}" )
end
result
end
def navi_this_month; "月表示"; end
tdiary-contrib-3.2.2/plugin/nicovideo.rb 0000664 0000000 0000000 00000010203 12136327440 0020250 0 ustar 00root root 0000000 0000000 #
# nicovideo.rb - tDiary plugin for Nico Nico Video
#
# Copyright (C) 2012 TADA Tadashi
# You can modify and/or distribute it under GPL.
#
# usage:
# Link to the movie and show thumbnail, description...:
# <%= nicovideo 'sm99999999' %>
#
# Link to the movie with original label:
# <%= nicovideo 'sm99999999', 'movie title' %>
#
# Link to the movie with original label and link:
# <%= nicovideo 'sm99999999', 'movie title', 'http://example.com/video' %>
#
# Show Inline player:
# <%= nicovideo_player 'sm99999999' %>
#
# Show Inline player with size:
# <%= nicovideo_player 'sm99999999', [400,300] %>
#
require 'net/http'
require 'timeout'
require 'rexml/document'
enable_js( 'nicovideo.js' )
def nicovideo_call_api( video_id )
uri = "http://ext.nicovideo.jp/api/getthumbinfo/#{video_id}"
proxy = @conf['proxy']
proxy = 'http://' + proxy if proxy
xml = timeout( feed? ? 10 : 2 ) {
px_host, px_port = (@conf['proxy'] || '').split( /:/ )
px_port = 80 if px_host and !px_port
Net::HTTP::Proxy( px_host, px_port ).get_response( URI::parse( uri ) ).body
}
doc = REXML::Document::new( xml ).root
res = doc.elements.to_a( '/nicovideo_thumb_response' )[0]
if res.attributes['status'] == 'ok' then
res.elements.to_a( 'thumb' )[0]
else
raise ::Errno::ENOENT::new
end
end
def nicovideo_inline( video_id, elem, label = nil, link = nil )
i = {}
i[:id] = video_id
i[:url] = link || elem.to_a( 'watch_url' )[0].text
i[:thumb] = elem.to_a( 'thumbnail_url' )[0].text
i[:title] = label || elem.to_a( 'title' )[0].text
i[:desc] = elem.to_a( 'description' )[0].text
i[:comment] = @conf.mobile_agent? ? '' : elem.to_a( 'last_res_body' )[0].text
i[:date] = elem.to_a( 'first_retrieve' )[0].text
i[:length] = elem.to_a( 'length' )[0].text
i[:view] = elem.to_a( 'view_counter' )[0].text
i[:comment_num] = elem.to_a( 'comment_num' )[0].text
i[:mylist] = elem.to_a( 'mylist_counter' )[0].text
if feed? then
result = nicovideo_feed( i )
else
result = nicovideo_html( i )
end
result.gsub( /^\t+/, '' )
end
def nicovideo_iframe( video_id )
%Q|\n|
end
def nicovideo_player( video_id, size = [544,384] )
if feed? or @conf.mobile_agent? or @conf.iphone? then
nicovideo( video_id )
else
q = ''
if size then
q = "?w=#{h size[0]}&h=#{h size[1]}"
end
%Q||
end
end
def nicovideo( video_id, label = nil, link = nil )
begin
r = ''
r << %Q||
api = nicovideo_call_api( video_id ).elements
thumb = @conf.to_native( nicovideo_inline( video_id, api, label, link ), 'UTF-8' )
thumb.gsub!( /"INLINE_PLAYER"/, %Q|"#" onclick="return nicovideoPlayer( '#{video_id}' );"| )
r << thumb
r << '
'
if feed? or @conf.mobile_agent? or @conf.iphone? then
r.gsub!( /]*)?>/, '' )
r.gsub!( %r{ }, '' )
else
r << %Q||
end
r
rescue ::Errno::ENOENT
"Sorry, #{video_id} was deleted. "
rescue Timeout::Error, NoMethodError, SecurityError, StandardError
nicovideo_iframe( video_id )
end
end
tdiary-contrib-3.2.2/plugin/notify_miniblog.rb 0000664 0000000 0000000 00000007220 12136327440 0021466 0 ustar 00root root 0000000 0000000 #
# Copyright (C) 2007 peo
# You can redistribute it and/or modify it under GPL2.
#
# modified hsbt.
require 'net/http'
@miniblog_config = (Struct.const_defined?("MiniBlogConfig") ? Struct::MiniBlogConfig :
Struct.new("MiniBlogConfig", :host, :path))
@miniblog_list = {
'HatenaHaiku' => @miniblog_config.new('h.hatena.ne.jp', '/api/statuses/update.json'),
}
module Miniblog
class Updater
def initialize( user, pass, config )
@user = user
@pass = pass
@config = config
end
# this code is based on http://la.ma.la/blog/diary_200704111918.htm
def update( status )
Net::HTTP.version_1_2
req = Net::HTTP::Post.new(@config.path)
req.basic_auth(@user, @pass)
req.body = status
Net::HTTP.start( @config.host, 80 ) do |http|
response = http.request(req)
if response.body =~ /error/
raise 'update failed.'
end
end
end
end
end
def notify_miniblog
notify_miniblog_init
date = @date.strftime('%Y%m%d')
diary = @diaries[date]
sectitle = ''
index = 0
diary.each_section do |sec|
index += 1
sectitle = sec.subtitle
end
# strip category
sectitle.gsub!(/\[[^\]]+\] */, '')
url = URI.encode(@conf.base_url + anchor("#{date}p%02d" % index), /[^-.!~*'()\w]/n)
prefix = @conf['miniblog.notify.prefix']
format = @conf['miniblog.notify.format']
source = 'tdiary/notify_miniblog.rb'
status = 'status=' + format % [prefix, sectitle, url] + '&source=' + source
if @conf['miniblog.service'] == "HatenaHaiku" then
status += '&keyword=id:' + @conf['miniblog.user']
end
config = @miniblog_list[@conf['miniblog.service']]
begin
miniblog_updater = Miniblog::Updater.new(@conf['miniblog.user'], @conf['miniblog.pass'], config)
miniblog_updater.update( status )
rescue => e
@logger.debug( e )
end
end
def notify_miniblog_init
@conf['miniblog.notify.prefix'] ||= '[blog update]'
@conf['miniblog.notify.format'] ||= '%s %s %s'
@conf['miniblog.service'] ||= 'Twitter'
end
add_update_proc do
if @mode == 'append' then
notify_miniblog if @cgi.params['miniblog.notify'][0] == 'true'
end
end
add_edit_proc do
checked = ''
if @mode == 'preview' then
checked = @cgi.params['miniblog.notify'][0] == 'true' ? ' checked' : ''
end
<<-HTML
Post the update to #{@conf['miniblog.service']}
HTML
end
add_conf_proc( 'notify_miniblog', 'MiniBlog' ) do
notify_miniblog_init
if @mode == 'saveconf' then
@conf['miniblog.service'] = @cgi.params['miniblog.service'][0]
@conf['miniblog.user'] = @cgi.params['miniblog.user'][0]
@conf['miniblog.pass'] = @cgi.params['miniblog.pass'][0]
@conf['miniblog.notify.prefix'] = @cgi.params['miniblog.notify.prefix'][0]
@conf['miniblog.notify.format'] = @cgi.params['miniblog.notify.format'][0]
end
options = ''
@miniblog_list.each_key do |key|
options << %Q|#{h key} \n|
end
<<-HTML
MiniBlog Service
#{options}
Account Name
Account Password
Notify prefix
Notify status format
HTML
end
# vim:ts=3
tdiary-contrib-3.2.2/plugin/ogp.rb 0000664 0000000 0000000 00000003233 12136327440 0017063 0 ustar 00root root 0000000 0000000 # ogp.rb - add Open Graph Protocol tags to header
#
# Copyright (c) 2011 MATSUOKA Kohei
# You can redistribute it and/or modify it under GPL2.
#
# @conf['ogp.facebook.app_id'] - your facebook application ID.
# @conf['ogp.facebook.admins'] - your facebook ID.
def ogp_description
section_index = @cgi.params['p'][0]
# section_index = "1"
if @mode == 'day' and section_index
diary = @diaries[@date.strftime('%Y%m%d')]
sections = diary.instance_variable_get(:@sections)
section = sections[section_index.to_i - 1].body_to_html
@conf.shorten(apply_plugin(section, true), 200)
else
@conf.description
end
end
add_header_proc do
headers = {
# TODO: og:urlへ対応
'og:title' => title_tag.match(/>([^<]+)).to_a[1],
'og:site_name' => @conf.html_title,
'og:description' => ogp_description,
'og:image' => @conf.banner,
'og:type' => (@mode == 'day') ? 'article' : 'blog',
'og:author' => @conf.author_name,
'fb:app_id' => @conf['ogp.facebook.app_id'],
'fb:admins' => @conf['ogp.facebook.admins']
}
headers.select {|key, val|
val && !val.empty?
}.map {|key, val|
%Q| |
}.join("\n")
end
add_conf_proc('Open Graph Protocol', 'Open Graph Protocol') do
if @mode == 'saveconf'
@conf['ogp.facebook.app_id'] = @cgi.params['ogp.facebook.app_id'][0]
@conf['ogp.facebook.admins'] = @cgi.params['ogp.facebook.admins'][0]
end
<<-HTML
Facebook Application ID
Facebook User ID
HTML
end
tdiary-contrib-3.2.2/plugin/ohmsha_estore.rb 0000664 0000000 0000000 00000003447 12136327440 0021145 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# You can redistribute it and/or modify it under the same license as tDiary.
#
# display book info in http://estore.ohmsha.co.jp/ like amazon.rb
# USAGE: {{ohmsha_estore '978427406694P'}}
def ohmsha_estore_cache_dir
cache = "#{@cache_path}/ohmsha-estore"
Dir.mkdir( cache ) unless File.directory?( cache )
cache
end
def ohmsha_estore_cache_set( id, result )
File.open( "#{ohmsha_estore_cache_dir}/#{id}", "w" ) do |f|
f.write result
end
end
def ohmsha_estore_cache_get( id )
File.open( "#{ohmsha_estore_cache_dir}/#{id}", "r" ) do |f|
f.read
end
rescue
nil
end
def ohmsha_estore( id, doc = nil )
if !@conf.secure and !(result = ohmsha_estore_cache_get(id)).nil?
return result
end
domain = "http://estore.ohmsha.co.jp"
image = "#{domain}/images/covers/#{id}.gif"
link = "#{domain}/titles/#{id}"
require 'open-uri'
doc ||= open(link)
require 'rexml/document'
xml = REXML::Document.new( doc )
biblio = "//html/body/div/div[2]/div/div/div/div[2]"
title = REXML::XPath.match( xml,
"#{biblio}/h2").first.text
author = REXML::XPath.match( xml,
"#{biblio}/div" ).first.text
description =
REXML::XPath.match( xml, '//html/body/div/div[2]/div/div/div[2]' ).
first.text
result = <<-EOS
#{h title}
#{h author}
#{h description}
EOS
ohmsha_estore_cache_set( id, result ) unless @conf.secure
result
end
# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:
tdiary-contrib-3.2.2/plugin/openid.rb 0000664 0000000 0000000 00000007712 12136327440 0017562 0 ustar 00root root 0000000 0000000 #
# openid.rb: Insert OpenID delegation information. $Revision: 1.10 $
#
# Copyright (C) 2005, TADA Tadashi
# You can redistribute it and/or modify it under GPL2.
#
@openid_config = (Struct.const_defined?("OpenIdConfig") ? Struct::OpenIdConfig :
Struct.new("OpenIdConfig", :openid, :openid2, :x_xrds_location))
if /^(?:latest|conf|saveconf)$/ =~ @mode then
@openid_list = {
# service => @openid_config.new(
# [openid.server, openid.delegate(replace as account name)], # openid
# [openid2.provider, openid2.local_id(replace as account name)], # openid2
# 'X-XRDS-Location(replace as account name)'),
'Hatena' => @openid_config.new(['https://www.hatena.ne.jp/openid/server', 'http://www.hatena.ne.jp//']),
'livedoor' => @openid_config.new(['http://auth.livedoor.com/openid/server', 'http://profile.livedoor.com/']),
'LiveJournal' => @openid_config.new(['http://www.livejournal.com/openid/server.bml', 'http://.livejournal.com/']),
'OpenID.ne.jp' => @openid_config.new(
['http://www.openid.ne.jp/user/auth', 'http://.openid.ne.jp'],
nil,
'http://.openid.ne.jp/user/xrds'),
'TypeKey' => @openid_config.new(['http://www.typekey.com/t/openid/', 'http://profile.typekey.com//']),
'Vox' => @openid_config.new(['http://www.vox.com/services/openid/server', 'http://.vox.com/']),
'myopenid.com' => @openid_config.new(
['http://www.myopenid.com/server', 'http://.myopenid.com'], # openid
['http://www.myopenid.com/server', 'http://.myopenid.com'], # openid2
"http://www.myopenid.com/xrds?username="),
'claimID.com' => @openid_config.new(
['http://openid.claimid.com/server', 'http://openid.claimid.com/'],
nil, #['http://openid.claimid.com/server', 'http://openid.claimid.com/'],
'http://claimid.com//xrds'),
'Personal Identity Provider (PIP)' => @openid_config.new(
['http://pip.verisignlabs.com/server', 'http://.pip.verisignlabs.com/'],
['http://pip.verisignlabs.com/server', 'http://.pip.verisignlabs.com/'],
'http://pip.verisignlabs.com/user//yadisxrds'),
'Yahoo! Japan' => @openid_config.new(
nil,
['https://open.login.yahooapis.jp/openid/op/auth', 'https://me.yahoo.co.jp/a/'],
'http://open.login.yahoo.co.jp/openid20/www.yahoo.co.jp/xrds'),
'Yahoo!' => @openid_config.new(
nil,
['https://open.login.yahooapis.com/openid/op/auth', 'https://me.yahoo.com/a/'],
'http://open.login.yahooapis.com/openid20/www.yahoo.com/xrds'),
}
if @conf['openid.service'] and @conf['openid.id'] then
openid_service = @openid_list[@conf['openid.service']]
openid_id = @conf['openid.id']
result = ''
add_header_proc do
result = <<-HTML if openid_service.openid
HTML
result << <<-HTML if openid_service.openid2
HTML
result << <<-HTML if openid_service.x_xrds_location
HTML
result.gsub( /^\t{2}/, '' )
end if openid_service
end
end
add_conf_proc( 'openid', @openid_conf_label ) do
if @mode == 'saveconf' then
@conf['openid.service'] = @cgi.params['openid.service'][0]
@conf['openid.id'] = @cgi.params['openid.id'][0]
end
options = ''
@openid_list.each_key do |key|
options << %Q|#{h key} \n|
end
<<-HTML
#{@openid_service_label}
#{@openid_service_desc}
#{options}
#{@openid_id_label}
#{@openid_id_desc}
HTML
end
tdiary-contrib-3.2.2/plugin/opensearch_ad.rb 0000664 0000000 0000000 00000002050 12136327440 0021065 0 ustar 00root root 0000000 0000000 # opensearch_ad.rb $Revision: 1.1 $
#
# Copyright (c) 2008 SHIBATA Hiroshi
# Distributed under the GPL
#
if /\A(?:latest|day)\z/ =~ @mode then
if @conf['opensearch.xml'] and @conf['opensearch.title'] then
opensearch_xml = @conf['opensearch.xml']
opensearch_title = @conf['opensearch.title']
add_header_proc do
result = <<-HTML
HTML
result.gsub( /^\t\t/, '' )
end
end
end
add_conf_proc( 'opensearch_ad', 'OpenSearch Auto-Discovery' ) do
if @mode == 'saveconf'
@conf['opensearch.xml'] = @cgi.params['opensearch.xml'][0]
@conf['opensearch.title'] = @cgi.params['opensearch.title'][0]
end
<<-HTML
Tilte for OpenSearch
URI for OpenSearch description XML
HTML
end
tdiary-contrib-3.2.2/plugin/picasa.rb 0000664 0000000 0000000 00000002730 12136327440 0017537 0 ustar 00root root 0000000 0000000 # show photo image on Picasa Web Album
#
# usage:
# picasa( src[, title[, place]] )
# - src: The url of the photo to show.
# - title: title of photo. (optional)
# - place: class name of img element. default is 'photo'.
#
# picasa_left( src[, title] )
#
# picasa_right( src[, title] )
#
# options configurable through settings:
# @conf['picasa.user'] : picasa username
# @conf['picasa.default_size'] : default image size
#
# Copyright (c) hb
# Distributed under the GPL.
#
def picasa( src, alt = "photo", place = 'photo' )
src.sub!( %r|/s\d+/|, "/s200/" ) if @conf.iphone?
if @cgi.mobile_agent?
body = %Q|#{alt} |
else
body = %Q| |
end
body
end
def picasa_left( src, alt = "photo" )
picasa( src, alt, 'left' )
end
def picasa_right( src, alt = "photo" )
picasa( src, alt, 'right' )
end
if /\A(form|edit|preview|showcomment)\z/ === @mode then
enable_js( 'picasa.js' )
add_js_setting( '$tDiary.plugin.picasa' )
add_js_setting( '$tDiary.plugin.picasa.userId', %Q|'#{@conf['picasa.user']}'| )
add_js_setting( '$tDiary.plugin.picasa.imgMax', %Q|'#{@conf[ 'picasa.default_size'] || 400}'| )
end
add_edit_proc do |date|
unless @conf['picasa.user']
'[ERROR] picasa.rb: Picasa username is not specified.
'
else
<<-HTML
Picasa Web Album
HTML
end
end
tdiary-contrib-3.2.2/plugin/plugin_checker.rb 0000664 0000000 0000000 00000002770 12136327440 0021265 0 ustar 00root root 0000000 0000000 # plugin_checker.rb
#
# Copyright (c) 2012 MATSUOKA Kohei
# You can redistribute it and/or modify it under GPL2.
#
def plugin_checker_js_settings
enable_js('plugin_checker.js')
add_js_setting('$tDiary.plugins', plugins.to_json)
add_js_setting('$tDiary.mode', @mode.to_json)
end
if /\A(form|edit|preview|showcomment)\z/ === @mode
add_header_proc do
<<-STYLE
STYLE
end
plugin_checker_js_settings
end
tdiary-contrib-3.2.2/plugin/popit.rb 0000664 0000000 0000000 00000001660 12136327440 0017433 0 ustar 00root root 0000000 0000000 # popit.rb:plugin embedding POP on POPit(http://pop-it.jp)
#
# usage:
# popit(pop_id) - pop_id: The id of the POP on POPit (e.g. 2000 http://pop-it.jp/item/amazon/1989/pop/2000 )
#
# Copyright (c) KAYA Satoshi
# You can redistributed it and/or modify if under GPL2.
#
def popit(pop_id, size = "large")
return unless pop_id
width_size = {"large" => "260", "small" => "180" }
height_size = {"large" => "380", "small" => "220" }
width_style = {"large" => "220px", "small" => "160px" }
sizequery = size == "large" ? "?size=large" : ''
r = ""
r << %Q||
r << %Q||
return r
end
tdiary-contrib-3.2.2/plugin/prettify.rb 0000664 0000000 0000000 00000001153 12136327440 0020143 0 ustar 00root root 0000000 0000000 # prettify.rb
if /\A(?:latest|day|month|nyear)\z/ =~ @mode then
add_header_proc do
<<-HTML
HTML
end
end
tdiary-contrib-3.2.2/plugin/prezi.rb 0000664 0000000 0000000 00000002155 12136327440 0017431 0 ustar 00root root 0000000 0000000 #
# prezi.rb: plugin embedding presentation on prezi.com
#
# Copyright (C) 2010 TADA Tadashi
# You can redistribute it and/or modify it under GPL2.
#
def prezi( prezi_id, label = 'Link to presentation', size = [512,384] )
%Q| |
end
tdiary-contrib-3.2.2/plugin/profile.rb 0000664 0000000 0000000 00000014314 12136327440 0017740 0 ustar 00root root 0000000 0000000 #
# profile.rb: profile plugin for tDiary
#
# usage:
# profile(id[, service = :twitter])
# - id: user ID for profile service
# - service: profile service (default is :twitter)
# Choose from :github, :twitter, :friendfeed, :iddy
#
# Copyright (C) 2009 by MATSUOKA Kohei < http://www.machu.jp/ >
# Distributed under the GPL.
#
require 'timeout'
require 'rexml/document'
require 'open-uri'
require 'digest/md5'
require 'pstore'
module ::Profile
module Service
# base class for profile services
class Base
# default attributes
attr_reader :id
attr_reader :image
attr_reader :name
attr_reader :mail
attr_reader :description
attr_reader :link
# class instance variables
class << self
attr_reader :properties
attr_reader :endpoint_proc
end
# set property and xpath pair for parse XML document
def self.property(property, path)
@properties ||= {}
@properties[property] = path
end
# set endpoint proc (this proc is called by initialize method with id)
def self.endpoint(&block)
@endpoint_proc = block
end
def initialize(id, options = {})
@id = id
@options = options
if self.class.endpoint_proc
endpoint = self.class.endpoint_proc.call(id)
doc = fetch(endpoint)
parse(doc)
end
end
# get a XML document from endpoint and create REXML::Document instance
def fetch(endpoint)
timeout(5) do
open(endpoint) do |f|
doc = REXML::Document.new(f)
end
end
end
# parse XML document with properties
def parse(doc)
self.class.properties.each do |property, path|
if doc.elements[path]
value = doc.elements[path].text
instance_variable_set("@#{property}", value)
end
end
end
end
# github.com
class GitHub < Base
property :name, 'name'
property :mail, 'email'
endpoint {|id| "https://api.github.com/users/#{id}" }
def image
# "http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(@mail)}.jpg"
Gravatar.new(@mail, @options).image
end
def link
"http://github.com/#{@id}"
end
def fetch(endpoint)
require 'json'
timeout(5) do
doc = open(endpoint) {|f| JSON.parse(f.read) }
end
end
def parse(doc)
self.class.properties.each do |property, key|
instance_variable_set("@#{property}", doc[key]) if doc[key]
end
end
end
# twitter.com
class Twitter < Base
property :name, '//user/name'
property :image, '//user/profile_image_url'
property :description, '//user/description'
endpoint {|id| "http://twitter.com/users/show/#{id}.xml" }
def link
"http://twitter.com/#{@id}"
end
end
# friendfeed.com
class FriendFeed < Base
property :name, '//feed/name'
property :description, '//feed/description'
endpoint {|id| "http://friendfeed-api.com/v2/feed/#{id}?format=xml&num=0" }
def image
"http://friendfeed-api.com/v2/picture/#{id}"
end
def link
"http://friendfeed.com/#{@id}"
end
end
# iddy.jp
# this class is based on iddy.rb
class Iddy < Base
######################################################################
# If you will modify or release another version of this code,
# please get your own application key from iddy.jp and replace below.
######################################################################
API_KEY = '9262ea8ffba962aabb4f1a1d3f1cfa953b11aa23' unless defined? API_KEY
property :name, '//response/users/user/accountname'
property :image, '//response/users/user/imageurl'
property :description, '/response/users/user/profile'
endpoint {|id| "http://iddy.jp/api/user/?apikey=#{API_KEY}&accountname=#{id}" }
def link
"http://iddy.jp/profile/#{@id}/"
end
end
# gravatar.com
class Gravatar < Base
def image
size = @options[:size] ? "?s=#{@options[:size]}" : ""
"http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(@id.downcase)}.jpg#{size}"
end
end
class Hatena < Base
def image
prefix = id[0..1]
"http://www.hatena.ne.jp/users/#{prefix}/#{id}/profile.gif"
end
def link
"http://www.hatena.ne.jp/#{id}/"
end
end
end
end
PROFILE_VERSION = '20090909'
def profile(id, service = :twitter, options = {})
html = ''
service_class = {
:twitter => Profile::Service::Twitter,
:github => Profile::Service::GitHub,
:friendfeed => Profile::Service::FriendFeed,
:iddy => Profile::Service::Iddy,
:gravatar => Profile::Service::Gravatar,
:hatena => Profile::Service::Hatena,
}[service.to_s.downcase.to_sym]
# TODO: create cache manager class
# cache = "#{@cache_path}/profile.yaml"
cache = "#{@cache_path}/profile.pstore"
profile = nil
# db = YAML::Store.new(cache)
db = PStore.new(cache)
db.transaction do
key = service_class.name
db[key] ||= {} # initialize db
updated = db[key][:updated]
if updated && (Time::now < updated + 60 * 60) && db[key][:version] == PROFILE_VERSION
# use cache
profile = db[key][:profile]
else
# get latest date and update cache
begin
profile = service_class.new(id, options)
rescue Timeout::Error, StandardError
return html << %Q{ no profile
}
end
db[key][:updated] = Time::now
db[key][:profile] = profile
db[key][:version] = PROFILE_VERSION
end
end
html << %Q{ }
end
tdiary-contrib-3.2.2/plugin/pygments_css.rb 0000664 0000000 0000000 00000010342 12136327440 0021013 0 ustar 00root root 0000000 0000000 #
# pygments.rb: insert CSS for html formatted code with Pygments.
#
# Copyright (C) 2012 SHIBATA Hiroshi
# You can redistribute it and/or modify it under GPL2.
#
require 'pygments'
add_header_proc do
<<-STYLE
STYLE
end
tdiary-contrib-3.2.2/plugin/rating.rb 0000664 0000000 0000000 00000030032 12136327440 0017557 0 ustar 00root root 0000000 0000000 # $Revision:0.1$
# rating.rb: ʣˤ뵭ɾȥɽ
# for tDiary
#
# Ȥ
# Τޤ plugin ǥ쥯ȥ֤ޤ
# '' -> 'rating.rb Configuration' ǡɾ
# ɽƤꡣ
# 路
# http://www.maripo.jp/diary/?date=20071019
#
# Copyright (c) 2007 Mariko/Maripo GODA
# http://www.maripo.jp/
# You can redistribute it and/or modify it under GPL.
require 'pstore'
require 'cgi'
@dbase = "#{@cache_path}/rating.db"
#########################################
# Config (Form)
#########################################
add_conf_proc('rating', 'rating.rb Configuration') do
rating_config = RatingConfig.new(@dbase)
form_string = ""
if @mode == 'saveconf'
# save conf
index = 0
# edit axes
rating_config.each { |axis_config|
#check values
if (@cgi.params["label" + index.to_s][0] != "" && (@cgi.params["range" + index.to_s][0]).to_i > 0)
axis_config.edit(@cgi.params["label" + index.to_s][0], @cgi.params["label_max" + index.to_s][0],@cgi.params["label_min" + index.to_s][0],@cgi.params["range" + index.to_s][0].to_i,@cgi.params["order" + index.to_s][0].to_i,@cgi.params["display" + index.to_s][0]!=nil)
index += 1
end
}
if (@cgi.params["label_new"][0] != "" && @cgi.params["range_new"][0].to_i > 0)
# add new axis
rating_config.add_axis(@cgi.params["label_new"][0], @cgi.params["label_max_new"][0], @cgi.params["label_min_new"][0], @cgi.params["range_new"][0].to_i)
end
rating_config.save_to_db
end
# print conf form
form_string += <
եɥХåեޤϤĤǤ뤳ȤǤޤ
blog ɲþƤ뤫⤷ޤ
ˡ
ɽ֤Ǥۤ¤Ӥޤֹ椬ǤOK
ɽ ʤϥåƤޤäƤ
̾ () "εϻͤˤʤޤ"
٥ "ޤäͤˤʤʤ"
ǹ٥ "ȤƤ⻲ͤˤʤä"
: 155ʳʤ "5"
'
form_string #evaluate
end
#########################################
# Entry of the day
#########################################
add_body_leave_proc do |date|
graph_string = ""
form_string = ""
contentString = ""
#initialize DateEval object
todays_eval = DateEval.new(date.strftime('%Y%m%d'), @dbase)
#initialize RatingConfig object
@rating_config = RatingConfig.new(@dbase)
graph_string += <
[ʬۤߤ]
HTML
form_string += '' + "\n"
form_string += ('
'+"\n"
(form_string + graph_string)
end
#########################################
# class RatingConfig
#########################################
class RatingConfig
@axes
@max_axis_id= 0
@dbase
def initialize (dbase)
@dbase = dbase
db = PStore.new(@dbase)
db.transaction do
#begin transaction
if db.root?("config")
@axes = Hash.new
obj = db["config"]
@max_axis_id = obj[0]
obj.each{|ary|
id = ary[4]
@axes[id] = AxisConfig.new(ary[0],ary[1],ary[2],ary[3],ary[4],ary[5],ary[6])
}
else
@axes = Hash.new
@max_axis_id = 0
end
end
#end transaction
end #end initialize
def save_to_db
save_array = Array.new
db = PStore.new(@dbase)
save_array.push(@max_axis_id)
each {|axis_config|
save_array.push(axis_config.to_array)
}
db.transaction do
#begin transaction
db["config"] = save_array
end
#end transaction
end #end save_to_db
def add_axis (label, label_max, label_min, range)
@max_axis_id += 1
new_axis = AxisConfig.new(label, label_max, label_min, range, @max_axis_id, 0, true)
@axes[@max_axis_id] = new_axis
end #end add_axis
def edit_axis (axis_id, label, label_max, label_min, range, order,display)
target_axis = @axes[axis_id]
target_axis.edit(label, label_max, label_min, range, order,display)
end
def length
return @axes.size
end #end length
def each
@axes.to_a.sort {|a, b| a[1].order <=> b[1].order}.each {|key ,axis_conf|
yield axis_conf
}
end #end each
end
#########################################
# class AxisConfig
#########################################
class AxisConfig
@label
@label_max
@label_min
@range
@id
@order
@display = true
#accessors
attr_reader :label, :label_max, :label_min, :range, :id, :order, :display
def initialize (label, label_max, label_min, range, id,order,display)
@label = label
@label_max = label_max
@label_min = label_min
@range = range
@id = id
@order = order
@display = display
end #end initialize
def edit (label, label_max, label_min, range, order, display)
@label = label
@label_max = label_max
@label_min = label_min
@range = range
@order = order
@display = display
end #end initialize
def to_array
return [@label, @label_max, @label_min, @range, @id, @order,@display]
end
def disable
@hidden = true
end #end disable
def enable
@hidden = false
end #end disable
def check_label
return @display? "checked":""
end #end check_label
end
#########################################
# class DateEval
#########################################
class DateEval
@axes #axes[id][rank]
@date_string = ""
@dbase
@average #average[id]
@total #total[id]
GRAPH_PIXEL_LENGTH = 300
attr_reader :axes, :average, :total
# constructor
def initialize (date_string, dbase)
@dbase = dbase
@date_string = date_string
db = PStore.new(@dbase)
db.transaction do
#begin transaction
if db.root?(date_string)
#read
@axes = db[date_string]
else
#initialize
@axes = Hash.new
end
end
#end transaction
end #end constructor
def get_value(id, rank)
if @axes.key?(id) && @axes[id][rank] != nil
return @axes[id][rank]
else
return 0
end
end
def get_average(id)
sum = 0
vote = 0
unless @axes.key?(id)
return 0
end
for index in 0..@axes[id].length - 1
if @axes.key?(id) && @axes[id][index] != nil
vote += @axes[id][index]
sum += @axes[id][index] * index
end
end
if @axes[id].length == 0
return 0
else
return sum.to_f/vote + 1
end
end
def vote(id, rank)
unless @axes.key?(id)
@axes[id] = Array.new
end
if @axes[id][rank] != nil
@axes[id][rank] += 1
else
@axes[id][rank] = 1
end
end
def save_to_db
db = PStore.new(@dbase)
db.transaction do
#begin transaction
#save
db[@date_string] = @axes
end
#end transaction
end #end save_to_db
def get_graph_length (id, rank)
unless @axes.key?(id)
return 0
end
if @axes[id][rank] != nil
total = 0
@axes[id].each {|val|
unless val == nil
total += val
end
}
return (@axes[id][rank] * GRAPH_PIXEL_LENGTH / total).to_i
else
return 0
end
end #end
end # class dateEval end
#########################################
# Comment (vote)
#########################################
if (@mode == 'comment')
if @cgi.params["body"][0] != 'rating'
return
end
@dbase = "#{@cache_path}/rating.db"
#initialize RatingConfig object
rating_config = RatingConfig.new(@dbase)
#initialize DateEval object
todays_eval = DateEval.new(@cgi.params['date'][0], @dbase)
rating_config.each { |axis_config|
if @cgi.params["axis" + axis_config.id.to_s][0]!= nil
todays_eval.vote(axis_config.id, @cgi.params["axis" + axis_config.id.to_s][0].to_i)
end
}
todays_eval.save_to_db
end
tdiary-contrib-3.2.2/plugin/recent_estraier.rb 0000664 0000000 0000000 00000002622 12136327440 0021455 0 ustar 00root root 0000000 0000000 # recent_estraier.rb $Revision 1.1 $
#
# recent_estraier: Estraier検索語新しい順
# estsearch.cgiが作成する検索キーワードログから
# 最新xx件分の検索語を表示します。
# パラメタ:
# file: 検索キーワードログファイル名(絶対パス表記)
# estraier: estseach.cgiのパス
# limit: 表示件数(未指定時:5)
# make_link:
を生成するか?(未指定時:生成する)
#
#
# Copyright (c) 2005 SHIBATA Hiroshi
# Distributed under the GPL2.
#
require 'nkf'
def recent_estraier(file, estraier, limit = 5, make_link = true)
begin
lines = []
log = open(file)
if log.stat.size > 300 * limit then
log.seek(-300 * limit,IO::SEEK_END)
end
log.each_line do |line|
lines << line
end
result = ""
lines.reverse.each_with_index do |line,idx|
break if idx >= limit
word = NKF::nkf('-We -m0', line.split(/\t/)[2])
if word.empty? then
limit += 1
else
if make_link
result << %Q|#{h word} |
else
result << %Q|#{h word}|
end
end
end
result << %Q[ ]
rescue
%Q[#$! (#{$!.class}) cannot read #{file}.
]
end
end
tdiary-contrib-3.2.2/plugin/recent_tweet.rb 0000664 0000000 0000000 00000004116 12136327440 0020767 0 ustar 00root root 0000000 0000000 #
# recemt_tweet.rb: Twitter status plugin for tDiary
#
# Copyright (C) 2007 by Nishimoto Masaki
# Distributed under GPL.
#
require 'open-uri'
require 'timeout'
require 'rexml/document'
def recent_tweet( id, count )
begin
cache = "#{@cache_path}/recent_tweet.xml"
xml = open( cache ) {|f| f.read }
if Time::now > File::mtime( cache ) + 10*60 then
File::delete( cache ) # clear cache 10 minutes later
end
rescue Errno::ENOENT
begin
xml = recent_tweet_call_api( id )
open( cache, 'wb' ) {|f| f.write( xml ) }
rescue Timeout::Error, StandardError
return %Q||
end
end
begin
doc = REXML::Document::new( xml )
if doc then
html = ''
@conf.to_native( html )
else
return ''
end
rescue REXML::ParseException
return ''
end
end
def recent_tweet_call_api( id )
request = "http://twitter.com/statuses/user_timeline/#{id}.xml"
proxy = @conf['proxy']
proxy = 'http://' + proxy if proxy
timeout( 10 ) do
open( request, :proxy => proxy ) {|f| f.read }
end
end
tdiary-contrib-3.2.2/plugin/retweet.rb 0000664 0000000 0000000 00000005236 12136327440 0017762 0 ustar 00root root 0000000 0000000 #
# retweet.rb - show retweet count in each section
# This plugin uses a Topsy Retweet Button for Web Sites powered by Topsy.com
#
# Copyright (C) 2010, MATSUOKA Kohei
# You can redistribute it and/or modify it under GPL2.
#
#
# settings for Topsy Retweet Button.
# see: http://labs.topsy.com/button/retweet-button/#global_settings
#
# your Twitter username
@topsy_nick = "your_twitter_account"
# retweet button color
#@topsy_theme = "blue"
# retweet button text
#@topsy_retweet_text = "retweet"
unless defined?(permalink)
def permalink( date, index, escape = true )
ymd = date.strftime( "%Y%m%d" )
uri = @conf.index.dup
uri.sub!( %r|\A(?!https?://)|i, @conf.base_url )
uri.gsub!( %r|/\.(?=/)|, "" ) # /././ -> /
link = uri + anchor( "#{ymd}p%02d" % index )
link.sub!( "#", "%23" ) if escape
link
end
end
unless defined?(subtitle)
def subtitle( date, index, escape = true )
diary = @diaries[date.strftime( "%Y%m%d" )]
return "" unless diary
sn = 1
diary.each_section do |section|
if sn == index
old_apply_plugin = @options["apply_plugin"]
@options["apply_plugin"] = true
title = apply_plugin( section.subtitle_to_html, true )
@options["apply_plugin"] = old_apply_plugin
title.gsub!( /(?=")/, "\\" ) if escape
return title
end
sn += 1
end
end
end
# load Tospy's script and initialize
add_header_proc do
r = ""
r << %Q|\n|
return r unless @topsy_theme or @topsy_nick or @topsy_retweet_text
r << %Q|\n|
end
# show retweet button in top of section
add_section_enter_proc do |date, index|
<<-"EOS"
EOS
end
# show retweet button in end of section
add_section_leave_proc do |date, index|
<<-"EOS"
EOS
end
tdiary-contrib-3.2.2/plugin/rubykaigi.rb 0000664 0000000 0000000 00000010075 12136327440 0020266 0 ustar 00root root 0000000 0000000 #
# rubykaigi.rb: make badges of RubyKaigi.
#
# usage: <%= rubykaigi 'role', 'size' %>
# role: attendee (default), speaker, sponsor, staff, committer, individual sponsor, away
# size: large(160x160), small(160x90)
#
# Copyright (C) TADA Tadashi
# Distributed under GPL.
#
def rubykaigi2013( role = 'attendee', size = nil )
r = role.split(/[ _]+/).map{|s| s.capitalize}.join
s = "@#{h size}" unless size.nil?
%Q| |
end
def sappororubykaigi2012( role = 'attendee' )
r = role.split(/[ _]+/).map{|s| s.capitalize}.join
%Q| |
end
def kansairubykaigi04( role = 'attendee' )
badges = {
'attendee' => "attendee_taiyou",
'speaker' => "speaker_shika",
'staff' => "staff_daibutsu"
}
%Q| |
end
def rubykaigi2011( role = 'attendee', size = 'large' )
badges = Hash::new( 'attendee' ).update({
'committer' => 'committer',
'individual sponsor' => 'individualSponsor',
'sponsor' => 'sponsor',
'staff' => 'staff',
'speaker' => 'speaker',
'attendee' => 'attendee',
'away' => 'attendeeAway'
})
width, height = size == 'large' ? ['160','160'] : ['160', '90']
%Q| |
end
alias :rubykaigi :rubykaigi2011
#----- OLD EDITIONS -----#
def sappororubykaigi03( role = 'attendee' )
%Q| |
end
def rubykaigi2010( role = 'attendee' )
badges = Hash::new( 'attendee' ).update({
'committer' => 'committer',
'individual sponsor' => 'individual_sponsor',
'sponsor' => 'sponsor',
'staff' => 'staff',
'speaker' => 'speaker',
'attendee' => 'attendee',
'away' => 'away'
})
%Q| |
end
def rubykaigi2009( role = 'attendee' )
%Q| |
end
def rubykaigi2008( role = 'attendee' )
img = case role
when 'speaker'
1
when 'sponsor'
2
when 'staff'
3
else
role = 'attendee'
0
end
%Q| |
end
def sappororubykaigi02( role = 'attendee' )
%Q| |
end
# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:
# vim: ts=3
tdiary-contrib-3.2.2/plugin/search-bing.rb 0000664 0000000 0000000 00000004610 12136327440 0020460 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
#
# search-bing.rb - site search plugin sample using Bing API.
#
# Copyright (C) 2011, TADA Tadashi
# You can redistribute it and/or modify it under GPL.
#
# Needed these options below:
#
# @options['search-bing.appid'] : Your Bing AppId
# @options['search.result_filter'] : your dialy's URL format of DAY mode into Regexp.
#
require 'timeout'
require 'json'
require 'open-uri'
def search_title
'全文検索 by Bing'
end
def search_input_form( q )
r = <<-HTML
HTML
end
def search_bing_api( q, start = 0 )
appid = @conf['search-bing.appid']
u = 'https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/v1/Web'
u << "?Query=%27#{q}%27&Options=%27EnableHighlighting%27&$top=50&$skip=#{start}&$format=Json"
uri = URI( u )
open( uri, {:http_basic_authentication => [appid, appid]} ).read
### FIX ME: this code failed on Timeout error, temporary using open-uri above.
# px_host, px_port = (@conf['proxy'] || '').split( /:/ )
# px_port = 8080 if px_host and !px_port
# res = Net::HTTP::Proxy( px_host, px_port ).start( uri.host, uri.port ) do |http|
# req = Net::HTTP::Get.new( uri.request_uri )
# req.basic_auth( appid, appid )
# res = http.request( req )
# end
# res.body
end
def search_to_html( str )
(str || '').gsub( /\uE000/, '' ).gsub( /\uE001/, ' ' )
end
def search_result
query = CGI::unescape( @cgi.params['q'][0] )
start = CGI::unescape( @cgi.params['start'][0] || '0' ).to_i
begin
uri = URI::parse( @conf.base_url )
#uri = URI::parse( 'http://sho.tdiary.net/' ) ### FOR DEBUGGING ###
q = "#{query} site:#{uri.host}"
q << %Q| inurl:"#{uri.path}"| unless uri.path == '/'
xml = search_bing_api( u( q.untaint ), start )
json = JSON::parse( xml )
rescue Net::HTTPError
return %Q|#$!
|
end
r = search_input_form( query )
r << ''
r << ''
# no search navi on Bing search because no total result not supported
r << '
'
r
end
tdiary-contrib-3.2.2/plugin/search-default.rb 0000664 0000000 0000000 00000013533 12136327440 0021171 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
#
# search-default.rb - site search plugin sample using DefaultIO.
#
# Copyright (C) 2003-2005 Minero Aoki
# Copyright (C) 2012, TADA Tadashi
# You can redistribute it and/or modify it under GPL2.
#
#
def search_title
'全文検索'
end
class WrongQuery < StandardError; end
module DefaultIOSearch
module_function
def setup_patterns(query)
patterns = split_string(query).map {|pat|
check_pattern pat
Regexp.new( Regexp.quote(pat), Regexp::IGNORECASE )
}
raise WrongQuery, 'no pattern' if patterns.empty?
raise WrongQuery, 'too many sub patterns' if patterns.length > 8
patterns
end
def check_pattern(pat)
raise WrongQuery, 'no pattern' unless pat
raise WrongQuery, 'empty pattern' if pat.empty?
raise WrongQuery, "pattern too short: #{pat}" if pat.length < 2
raise WrongQuery, 'pattern too long' if pat.length > 128
end
def split_string(str)
str.split(/[\s ]+/ou).reject {|w| w.empty? }
end
INF = 1 / 0.0
def match_components(patterns, data_path)
foreach_diary_from_latest(data_path) do |diary|
next unless diary.visible?
num = 1
diary.each_section do |sec|
if patterns.all? {|re| re =~ sec.to_src }
yield diary, fragment('p', num), sec
end
num += 1
end
diary.each_visible_comment(INF) do |cmt, num|
if patterns.all? {|re| re =~ cmt.body }
yield diary, fragment('c', num), cmt
end
end
end
end
def fragment(type, num)
sprintf('%s%02d', type, num)
end
#
# tDiary Implementation Dependent
#
def foreach_diary_from_latest(data_path, &block)
foreach_data_file(data_path.sub(%r+\z>, '')) do |path|
read_diaries(path).sort_by {|diary| diary.date }.reverse_each(&block)
end
end
def foreach_data_file(data_path, &block)
Dir.glob("#{data_path}/[0-9]*/*.td2").sort.reverse_each do |path|
yield path.untaint
end
end
def read_diaries(path)
d = nil
diaries = {}
load_tdiary_textdb(path) do |header, body|
begin
d = diary_class(header['Format']).new(header['Date'], '', body)
rescue ArgumentError
next
end
d.show(header['Visible'] != 'false')
diaries[d.ymd] = d
end
(Years[d.y] ||= []).push(d.m) if d
load_comments diaries, path
diaries.values
end
DIARY_CLASS_CACHE = {}
def diary_class(style)
c = DIARY_CLASS_CACHE[style]
return c if c
require "tdiary/style/#{style.downcase}_style.rb"
c = eval("TDiary::#{style.capitalize}Diary")
c.__send__(:include, DiaryClassDelta)
DIARY_CLASS_CACHE[style] = c
c
end
module DiaryClassDelta
def ymd
date().strftime('%Y%m%d')
end
def y_m_d
date().strftime('%Y-%m-%d')
end
def y
'%04d' % date().year
end
def m
'%02d' % date().month
end
end
def load_comments(diaries, path)
cmtfile = path.sub(/2\z/, 'c')
return unless File.file?(cmtfile)
load_tdiary_textdb(cmtfile) do |header, body|
c = TDiary::Comment.new(header['Name'], header['Mail'], body,
Time.at(header['Last-Modified'].to_i))
c.show = (header['Visible'] != 'false')
d = diaries[header['Date']]
d.add_comment c if d
end
end
def load_tdiary_textdb(path)
File.open(path) {|f|
ver = f.gets.strip
raise "unkwnown format: #{ver}" unless ver == 'TDIARY2.00.00' or ver == 'TDIARY2.01.00'
f.each('') do |header|
h = {}
header.untaint.strip.each_line do |line|
begin
n, v = *line.split(':', 2)
rescue ArgumentError
next
end
h[n.strip] = v.strip
end
body = f.gets("\n.\n").chomp(".\n").untaint
yield h, body
end
}
end
def short_html(component)
# Section classes do not have common superclass, we can't use class here.
case component.class.name
when /Section/
section = component
if section.subtitle
sprintf('%s %s',
tdiary2text(section.subtitle_to_html),
tdiary2text(section.body_to_html))
else
tdiary2text(section.body_to_html)
end
when /Comment/
cmt = component
shorten(escape((cmt.name + ': ' + cmt.body)))
else
raise "must not happen: #{component.class}"
end
end
def tdiary2text(html)
re = Regexp.new('<[^>]*>', Regexp::EXTENDED)
shorten(apply_tdiary_plugins(html).gsub(re, ''))
end
Years = {}
TDiary::Plugin.__send__(:public, :apply_plugin)
def apply_tdiary_plugins(html)
#@plugin.apply_plugin(html, false)
html
end
@plugin = nil
#
# Utils
#
HTML_ESCAPE_TABLE = {
'&' => '&',
'<' => '<',
'>' => '>',
'"' => '"'
}
def escape(str)
tbl = HTML_ESCAPE_TABLE
str.gsub(/[&"<>]/) {|ch| tbl[ch] }
end
def shorten(str, len = 200)
matched = str.gsub( /\n/, ' ' ).scan( /^.{0,#{len - 3}}/u )[0]
if $'.nil? || $'.empty?
matched
else
matched + '...'
end
end
end
def search_input_form( q )
r = <<-HTML
HTML
end
def search_result
unless @conf.io_class == TDiary::DefaultIO
return %Q|could not use this plugin under #{@conf.io_class}.
|
end
query = CGI::unescape( @cgi.params['q'][0] )
start = CGI::unescape( @cgi.params['start'][0] || '0' ).to_i
begin
patterns = DefaultIOSearch::setup_patterns(query)
r = search_input_form( query )
r << ''
r << ''
r << "
#{too_many ? 'too many' : count} hits.
"
r << '
'
r
rescue WrongQuery
search_input_form( query ) + %Q|#{$!.message}
|
end
end
tdiary-contrib-3.2.2/plugin/search-google-custom.rb 0000664 0000000 0000000 00000004302 12136327440 0022323 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
#
# search-google-custom.rb - site search plugin using Goole Custom Search.
#
# Copyright (C) 2011, hb
# You can redistribute it and/or modify it under GPL.
#
# Needed these options below:
#
# @options["search-google-custom.id"] : Your Google Custome Search ID
# @options["search-google-custom.cof"] : 広告の表示場所(9:右,10:一番上と右,11:一番上と下)
# @options["search-google-custom.width"] : 検索結果のフレームの幅
# @options["search-google-custom.height"] : 検索結果のフレームの高さ
# @options["search-google-custom.search_label"] : 検索テキストボックス左のラベル
# @options["search-google-custom.button_text"] : 検索ボタンに書かれる文字列
#
def search_title
'全文検索 by Google カスタム検索'
end
add_footer_proc do
%Q||
end
def search_input_form(q='')
cof = @conf["search-google-custom.cof"] || 9
search_label = @conf["search-google-custom.search_label"] || '検索キーワード:'
button_text = @conf["search-google-custom.button_text"] || '検索'
r = <<-HTML
HTML
end
def search_result
w = @conf["search-google-custom.width"] || 600
h = @conf["search-google-custom.height"] || 1300
r = <<-HTML
HTML
end
tdiary-contrib-3.2.2/plugin/search-yahoo-websearch.rb 0000664 0000000 0000000 00000007241 12136327440 0022624 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
#
# search-yahoo-websearch.rb - Yahoo!デベロッパーネットワークのWeb検索APIを利用した検索プラグイン.
#
# Copyright (C) 2011, hb
# You can redistribute it and/or modify it under GPL.
#
# オプション
#
# @options['search-yahoo-websearch.appid'] : アプリケーションID(必須)
# @options['search-yahoo-websearch.premium'] : アップグレード版利用時はtrueを指定する(任意)
#
def search_title
'全文検索 by Yahoo! ウェブ検索'
end
def search_input_form( q )
r = <<-HTML
HTML
end
def request_url
if @conf['search-yahoo-websearch.premium']
'http://search.yahooapis.jp/PremiumWebSearchService/V1/webSearch'
else
'http://search.yahooapis.jp/WebSearchService/V2/webSearch'
end
end
def search_to_html( str )
(str || '').gsub( /(?:]*)?>)+/, '' ).gsub( %r{<(/?)b[ \t\n\r]*>}, '<\\1strong>' )
end
def yahoo_websearch_api( q, start = 1 )
url = request_url
appid = @conf['search-yahoo-websearch.appid']
uri = URI::parse( @conf.base_url )
url << "?appid=#{appid}&query=#{q}&results=20&start=#{start}&format=html&site=#{uri.host}"
proxy = @conf['proxy']
proxy = 'http://' + proxy if proxy
proxy_host, proxy_port = nil
if proxy
proxy_host = proxy_uri.host
proxy_port = proxy_uri.port
end
proxy_class = Net::HTTP::Proxy(proxy_host, proxy_port)
query = URI.parse(url)
req = Net::HTTP::Get.new(query.request_uri)
http = proxy_class.new(query.host, query.port)
http.open_timeout = 20
http.read_timeout = 20
res = http.start do
http.request(req)
end
res.body
end
def yahoo_websearch_attribution
<<-EOF
EOF
end
def search_result
query = CGI::unescape( @cgi.params['q'][0] )
start = CGI::unescape( @cgi.params['start'][0] || '1' ).to_i
begin
uri = URI::parse( @conf.base_url )
xml = yahoo_websearch_api( u( query.untaint ), start )
doc = REXML::Document::new( REXML::Source.new( xml ) ).root
err = doc.elements.to_a( '/Error/Message' )[0]
if err
return %Q|ERROR - #{err.text}
|
end
rescue OpenURI::HTTPError
return %Q|#$!
|
end
r = ''
r << ''
pos = doc.elements["/ResultSet"].attributes["firstResultPosition"]
unless pos == '1'
r << %Q|
<前の20件 |
end
total = doc.elements["/ResultSet"].attributes["totalResultsAvailable"]
ret = doc.elements["/ResultSet"].attributes["totalResultsReturned"]
if ret.to_i == 20 and pos.to_i + 19 < 1000
r << %Q|
次の20件> |
end
r << '
'
r << yahoo_websearch_attribution
r
end
tdiary-contrib-3.2.2/plugin/search-yahoo.rb 0000664 0000000 0000000 00000005755 12136327440 0020673 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
#
# search-yahoo.rb - site search plugin sample using Yahoo! Search BOSS API.
#
# Copyright (C) 2009, TADA Tadashi
# You can redistribute it and/or modify it under GPL.
#
# Needed these options below:
#
# @options['search-yahoo.appid'] : Your BOSS APPID
# @options['search-yahoo.result_filter'] : your dialy's URL format of DAY mode into Regexp.
#
require 'timeout'
require 'rexml/document'
require 'net/http'
Net::HTTP.version_1_2
def search_title
'全文検索 by Yahoo! Search BOSS'
end
def search_input_form( q )
r = <<-HTML
HTML
end
def search_boss_api( q, start = 0 )
url = 'http://boss.yahooapis.com/ysearch/web/v1/'
appid = @conf['search-yahoo.appid']
url << "#{q}?appid=#{appid}&format=xml&count=20&start=#{start}"
proxy = @conf['proxy']
proxy = 'http://' + proxy if proxy
proxy_host, proxy_port = nil
if proxy
proxy_host = proxy_uri.host
proxy_port = proxy_uri.port
end
proxy_class = Net::HTTP::Proxy(proxy_host, proxy_port)
query = URI.parse(url)
req = Net::HTTP::Get.new(query.request_uri)
http = proxy_class.new(query.host, query.port)
http.open_timeout = 20
http.read_timeout = 20
res = http.start do
http.request(req)
end
res.body
end
def search_to_html( str )
(str || '').gsub( /(?:]*)?>)+/, '' ).gsub( %r{<(/?)b[ \t\n\r]*>}, '<\\1strong>' )
end
def search_result
query = CGI::unescape( @cgi.params['q'][0] )
start = CGI::unescape( @cgi.params['start'][0] || '0' ).to_i
begin
uri = URI::parse( @conf.base_url )
q = "#{query} site:#{uri.host}"
q << %Q| inurl:"#{uri.path}"| unless uri.path == '/'
xml = search_boss_api( u( q.untaint ), start )
doc = REXML::Document::new( REXML::Source.new( xml ) ).root
res = doc.elements.to_a( '/ysearchresponse' )[0]
unless res.attribute( 'responsecode' ).value == '200' then
return 'ERROR
'
end
rescue OpenURI::HTTPError
return %Q|#$!
|
end
r = search_input_form( query )
r << ''
r << ''
doc.elements.to_a( '/ysearchresponse/prevpage' ).each do |p|
if /start=\d+/ =~ p.text then
r << %Q|
<前の20件 |
end
end
doc.elements.to_a( '/ysearchresponse/nextpage' ).each do |n|
if /start=\d+/ =~ n.text then
r << %Q|
次の20件> |
end
end
r << '
'
r
end
tdiary-contrib-3.2.2/plugin/section_footer.rb 0000664 0000000 0000000 00000014724 12136327440 0021327 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# section_footer.rb
#
# Copyright (c) 2005 SHIBATA Hiroshi
# You can redistribute it and/or modify it under GPL2.
#
require 'digest/md5'
require 'open-uri'
require 'timeout'
def permalink( date, index, escape = true )
ymd = date.strftime( "%Y%m%d" )
uri = @conf.index.dup
uri.sub!( %r|\A(?!https?://)|i, @conf.base_url )
uri.gsub!( %r|/\.(?=/)|, "" ) # /././ -> /
link = uri + anchor( "#{ymd}p%02d" % index )
link.sub!( "#", "%23" ) if escape
link
end
add_header_proc do
<<-SCRIPT
SCRIPT
end
add_section_enter_proc do |date, index|
@category_to_tag_list = {}
end
alias subtitle_link_original subtitle_link
def subtitle_link( date, index, subtitle )
s = ''
if subtitle then
s = subtitle.sub( /^(\[([^\[]+?)\])+/ ) do
$&.scan( /\[(.*?)\]/ ) do |tag|
@category_to_tag_list[tag] = false # false when diary
end
''
end
end
subtitle_link_original( date, index, s.strip )
end
add_section_leave_proc do |date, index|
r = '\n"
end
def add_permalink(date, index)
r = " | "
r << %Q|Permalink |
return r
end
def add_hatenabm(date, index)
r = " | "
r << %Q| |
return r
end
def add_ldclip(date, index)
r = " | "
r << %Q| |
return r
end
def add_buzzurl(date, index)
r = " | "
r << %Q| |
return r
end
def add_delicious(date, index)
url_md5 = Digest::MD5.hexdigest(permalink(date, index, false))
r = " | "
r << %Q| |
return r
end
def add_delicious_json(date, index)
require 'fileutils'
begin
require 'json'
rescue
retry if require 'rubygems'
end
url_md5 = Digest::MD5.hexdigest(permalink(date, index, false))
cache_dir = "#{@cache_path}/delicious/#{date.strftime( "%Y%m" )}/"
file_name = "#{cache_dir}/#{url_md5}.json"
cache_time = 8 * 60 * 60 # 8 hour
update = false
count = 0
r = " | "
r << %Q| |
begin
FileUtils.mkdir_p( cache_dir ) unless File::directory?( cache_dir )
cached_time = nil
cached_time = File::mtime( file_name ) if File::exist?( file_name )
unless cached_time.nil?
if Time.now > cached_time + cache_time
update = true
end
end
if cached_time.nil? or update
begin
timeout(10) do
open( "http://feeds.delicious.com/v2/json/urlinfo/#{url_md5}") do |file|
File::open( file_name, 'wb' ) do |f|
f.write( file.read )
end
end
end
rescue => e
@logger.debug( e )
end
end
rescue
end
begin
File::open( file_name ) do |f|
data = JSON.parse(@conf.to_native( f.read, 'utf-8' ))
unless data[0].nil?
count = data[0]["total_posts"].to_i
end
end
rescue
end
if count > 0
r << %Q| #{count} users |
else
r << %Q| |
end
return r
end
def add_yahoobm(date, index)
r = " | "
r << %Q|
|
return r
end
tdiary-contrib-3.2.2/plugin/section_footer2.rb 0000664 0000000 0000000 00000017055 12136327440 0021411 0 ustar 00root root 0000000 0000000 # section_footer2.rb
#
# Copyright (c) 2008 SHIBATA Hiroshi
# You can redistribute it and/or modify it under GPL2.
#
require 'digest/md5'
require 'timeout'
require 'open-uri'
require 'yaml'
require 'pathname'
begin
require 'json'
rescue LoadError
retry if require 'rubygems'
end
def permalink( date, index, escape = true )
ymd = date.strftime( "%Y%m%d" )
uri = @conf.index.dup
uri.sub!( %r|\A(?!https?://)|i, @conf.base_url )
uri.gsub!( %r|/\.(?=/)|, "" ) # /././ -> /
link = uri + anchor( "#{ymd}p%02d" % index )
link.sub!( "#", "%23" ) if escape
link
end
unless defined?(subtitle)
def subtitle( date, index, escape = true )
diary = @diaries[date.strftime( "%Y%m%d" )]
return "" unless diary
sn = 1
diary.each_section do |section|
if sn == index
old_apply_plugin = @options["apply_plugin"]
@options["apply_plugin"] = true
title = apply_plugin( section.subtitle_to_html, true )
@options["apply_plugin"] = old_apply_plugin
title.gsub!( /(?=")/, "\\" ) if escape
return title
end
sn += 1
end
''
end
end
def init_buttons_status
@installed_buttons = ['yaml', 'delicious', 'hatena', 'facebook', 'twitter', 'plusone']
if @conf['section_footer2.isDisplay'].nil?
@conf['section_footer2.isDisplay'] = ''
end
end
add_header_proc do
<<-"EOS"
EOS
end
add_section_enter_proc do |date, index|
@category_to_tag_list = {}
init_buttons_status
''
end
alias section_footer2_subtitle_link_original subtitle_link unless defined?( section_footer2_subtitle_link_original )
def subtitle_link( date, index, subtitle )
s = ''
@subtitle = subtitle
if subtitle then
s = subtitle.sub( /^(?:\[[^\[]+?\])+/ ) do
$&.scan( /\[(.*?)\]/ ) do |tag|
@category_to_tag_list[tag.shift] = false # false when diary
end
''
end
end
section_footer2_subtitle_link_original( date, index, s.strip )
end
add_section_leave_proc do |date, index|
unless @conf.mobile_agent? or @conf.iphone? or feed? or bot?
r = '\n"
end
end
def call_delicious_json( url_md5 )
json = nil
begin
timeout(10) do
open( "http://feeds.delicious.com/v2/json/urlinfo/#{url_md5}" ) do |f|
json = JSON.parse( f.read )
end
end
rescue => e
@logger.debug( e )
end
return json
end
def add_delicious( date, index )
url_md5 = Digest::MD5.hexdigest(permalink(date, index, false))
db_file = "#{@cache_path}/delicious.cache"
r = ''
r << %Q| |
begin
cache_time = 8 * 60 * 60 # 12 hour
PStore.new(db_file).transaction do |db|
entry = db[url_md5]
entry = { :count => 0, :update=> Time.at(0) } if entry.nil?
if Time.now > entry[:update] + cache_time
json = call_delicious_json( url_md5 )
entry[:count] = json[0]["total_posts"].to_i unless json[0].nil?
entry[:update] = Time.now
db[url_md5] = entry
end
if entry[:count] > 0
r << %Q| #{entry[:count]} user|
r << 's' if entry[:count] > 1
end
end
rescue => e
@logger.debug( e )
end
r << ' '
r << ' | '
return r
end
def add_hatena( date, index )
%Q! | !
end
def add_facebook(date, index)
# add Facebook Like!
r = ''
r << %Q! | !
end
def add_twitter(date, index)
r = <<-"EOS"
|
EOS
end
def add_plusone(date, index)
%Q! | !
end
def add_yaml(date, index)
r = ''
yaml_dir = "#{@cache_path}/yaml/"
Dir.glob( yaml_dir + "*.yaml" ) do |file|
r << parse_sbm_yaml(file, date, index)
end
return r
end
def add_button_by_service(date, index)
r = ''
@installed_buttons.each do |button|
if @conf['section_footer2.isDisplay'].include?(button) then
method = "add_" + button + "(date, index)"
unless method.nil? then
r << instance_eval(method)
end
end
end
return r
end
def parse_sbm_yaml(file, date, index)
config = YAML.load( Pathname.new( file ).expand_path.read )
r = ""
unless config.nil?
url = config["url"]
unless config['usesubtitle'].nil?
sub = (@subtitle || '').sub( /\A(?:\[[^\]]*\])+ */, '' )
sub = apply_plugin( sub, true ).strip
regexp = config["usesubtitle"]
url.gsub!(regexp, sub)
char_space = ' '
end
title = config["title"][@conf.lang]
r << %Q||
r << %Q| |
r << %Q| | unless config["counter"].nil?
r << ' '
r << ' | '
end
return r
end
add_conf_proc('section_footer2', 'Section Footer Button') do
if @mode == 'saveconf' then
@conf['section_footer2.isDisplay'] = ''
@cgi.params['section_footer2.isDisplay'].each do |item|
@conf['section_footer2.isDisplay'] << item + '\n'
end
end
r = '表示するボタンをチェックしてください(YAMLをチェックすると各自でインストールしたYAMLのボタンをすべて表示します) '
r << ''
init_buttons_status
@installed_buttons.each do |button|
if @conf['section_footer2.isDisplay'].include?(button) then
item_checked = "checked"
else
item_checked = ''
end
r << %Q| #{button}|
end
r << '
'
end
# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:
# vim: ts=3
tdiary-contrib-3.2.2/plugin/section_permalink.rb 0000664 0000000 0000000 00000003034 12136327440 0022003 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright (C) 2011, KADO Masanori
# You can redistribute it and/or modify it under GPL.
#
# section_permalink.rb
# - enables section permalink and shows section title
def section_mode?
@mode == 'day' and @cgi.params['p'][0].to_s != ""
end
# Change permalink
def anchor( s )
if /^([\-\d]+)#?([pct]\d*)?$/ =~ s then
if $2 then
s1 = $1
s2 = $2
if $2 =~ /^p/
"?date=#{s1}&p=#{s2.gsub(/p/, '')}"
else
"?date=#{s1}.html##{s2}"
end
else
"?date=#$1"
end
else
""
end
end
# Change HTML title to section name
alias :_orig_title_tag :title_tag
def title_tag
if section_mode? and diary = @diaries[@date.strftime('%Y%m%d')]
sections = diary.instance_variable_get(:@sections)
title = ""
section = sections[@cgi.params['p'][0].to_i - 1].stripped_subtitle_to_html
title << apply_plugin(section, true).chomp
title << " - #{h @html_title}"
title << "(#{@date.strftime( '%Y-%m-%d' )})" if @date
title << " "
return title
else
_orig_title_tag
end
rescue
_orig_title_tag
end
add_header_proc do
if section_mode? and diary = @diaries[@date.strftime('%Y%m%d')]
index = @cgi.params['p'][0]
<<-EOS
EOS
end
end
# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:
# vim: ts=3
tdiary-contrib-3.2.2/plugin/section_permalink_anchor.rb 0000664 0000000 0000000 00000001326 12136327440 0023337 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright (C) 2011, KADO Masanori
# You can redistribute it and/or modify it under GPL.
#
# section_permalink_anchor.rb
# - enables section permalink with mod_rewrite
# - depends on section_permalink.rb
#
# sample .htaccess:
#
# RewriteEngine on
# RewriteRule ^([0-9\-]+)p?([0-9]*)\.html$ ?date=$1&p=$2 [L]
#
def anchor( s )
if /^([\-\d]+)#?([pct]\d*)?$/ =~ s then
if $2 then
s1 = $1
s2 = $2
if $2 =~ /^p/
"#{s1}#{s2}.html"
else
"#{s1}.html##{s2}"
end
else
"#$1.html"
end
else
""
end
end
# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:
# vim: ts=3
tdiary-contrib-3.2.2/plugin/select_style.rb 0000664 0000000 0000000 00000002415 12136327440 0020776 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
#
# select_style.rb: a plugin for selecting styles
# Distributed under the GPL
#
# [CAUTION] You need to insert a line to tdiary.conf after "load_cgi_conf"
# @style = @options2['style'] if @options2['style']
#
# styles
def saveconf_style
if @mode == 'saveconf' then
@conf['style'] = @cgi.params['style'][0]
end
end
if @mode =~ /^(conf|saveconf)$/ then
@conf_style_list = []
Dir::glob( "#{::TDiary::PATH}/tdiary/{style/,}*_style.rb" ) do |style_file|
style = File::basename( style_file ).sub( /_style\.rb$/, '' )
@conf_style_list << style
end
end
add_conf_proc( 'style', 'スタイル' ) do
saveconf_style
r = <<-HTML
スタイルの指定
#{"スタイル (日記の文法) を指定します。
" unless @conf.mobile_agent?}
HTML
@conf_style_list.each do |style|
r << %Q|#{style} |
end
r << <<-HTML
#{"スタイルについての詳細はスタイル - tDiary の記法 をごらんください。
" unless @conf.mobile_agent?}
HTML
end
tdiary-contrib-3.2.2/plugin/select_theme.rb 0000664 0000000 0000000 00000004332 12136327440 0020740 0 ustar 00root root 0000000 0000000 # Copyright (C) 2005 akira yamada
# You can redistribute it and/or modify it under GPL2.
THEME_BASE = File.join(::TDiary::PATH, 'theme')
CACHE_FILE = File.join(@cache_path, 'theme_list')
def get_theme_list
if FileTest.exist?(CACHE_FILE) &&
File.mtime(CACHE_FILE) >= File.mtime(THEME_BASE)
File.open(CACHE_FILE, 'r') do |i|
i.flock(File::LOCK_EX)
return Marshal.load(i.read)
end
end
list = []
Dir.glob(File.join(THEME_BASE, '*')).sort.each do |dir|
theme = dir.sub(%r[.*/theme/], '')
next unless FileTest::file?("#{dir}/#{theme}.css".untaint)
name = theme.split(/_/).collect{|s| s.capitalize}.join(' ')
list << [theme, name]
end
File.open(CACHE_FILE, 'w') do |o|
o.flock(File::LOCK_EX)
o.puts Marshal.dump(list)
end
return list
end
def select_theme_form
options = ''
get_theme_list.each do |theme, name|
options << %Q!\t#{h name} \n!
if theme == DEFAULT_THEME
options = %Q!\t(default) \n! + options
end
end
<
#{options}
HTML
end
def label
'use'
end
def check_theme(name)
return false if name.nil? || name.empty?
FileTest.file?(File.join(THEME_BASE, name, name + '.css'))
end
with_cgiparam = false
theme = nil
if @cgi.params['select_theme'] && @cgi.params['select_theme'][0]
tmp = @cgi.params['select_theme'][0].gsub(/[^-.\w]/, '')
tmp.untaint
if check_theme(tmp)
theme = tmp
with_cgiparam = true
end
end
if theme.nil? && @cgi.cookies && @cgi.cookies.include?('tdiary_select_theme')
tmp = @cgi.cookies['tdiary_select_theme'][0].gsub(/[^-.\w]/, '')
tmp.untaint
theme = tmp if check_theme(tmp)
end
if theme.nil?
theme = @conf.theme
end
cookie_path = File::dirname( @cgi.script_name )
cookie_path += '/' if cookie_path !~ /\/$/
cookie = CGI::Cookie::new(
'name' => 'tdiary_select_theme',
'value' => theme,
'path' => cookie_path,
'expires' => Time::now.gmtime + 90*24*60*60) # 90days
add_cookie(cookie)
# XXX: OK?
DEFAULT_THEME = @conf.theme
@conf.theme = theme
tdiary-contrib-3.2.2/plugin/show_and_hide.rb 0000664 0000000 0000000 00000003370 12136327440 0021073 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
#
# show_and_hide.rb - Show or hide the elements with a sliding motion using jQuery.
#
# Copyright (C) 2011, tamoot
# You can redistribute it and/or modify it under GPL2.
#
require 'digest/md5'
if /\A(?:latest|day|month|nyear|preview)\z/ =~ @mode
enable_js('show_and_hide.js')
end
def show_and_hide(contents, title = 'Show contents',
type = :link,
rss_title = '(Hide contents on RSS. See my page...)')
data_id = show_and_hide_id(contents)
toggle_attr = {:class => 'show_and_hide_toggle',
:"data-showandhideid" => data_id}
dom_contents = ''
if feed? # RSS
dom_contents = h(rss_title)
elsif type.to_s == 'button'
toggle_attr.merge!(:value => title, :type => "button")
dom_contents = %Q| | +
show_and_hide_contents(contents, data_id)
else
toggle_attr.merge!(:href => 'javascript:void(0)')
dom_contents = %Q|#{h(title)} | +
show_and_hide_contents(contents, data_id)
end
dom_contents
end
def show_and_hide_id(contents)
@@show_and_hide_counter ||= 0
@@show_and_hide_counter += 1
"#{Time::now.strftime("%s")}_#{@@show_and_hide_counter}_#{ Digest::MD5.hexdigest(contents)}"
end
def show_and_hide_contents(contents, id)
%Q|#{h(contents)} |
end
def hash2attr(hash)
attrs = []
hash.keys.each do |k|
attrs << %Q|#{k}="#{hash[k]}"|
end
attrs.join(" ")
end
# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:
# vim: ts=3
tdiary-contrib-3.2.2/plugin/slideshare.rb 0000664 0000000 0000000 00000000605 12136327440 0020421 0 ustar 00root root 0000000 0000000 #
# slideshare.rb - insert some services of slideshare.net
#
# Copyright (C) 2011, Kiwamu Okabe .
# You can redistribute it and/or modify it under GPL2.
#
def slideshare( embed_code )
%Q||
end
tdiary-contrib-3.2.2/plugin/socialbutton.rb 0000664 0000000 0000000 00000003715 12136327440 0021011 0 ustar 00root root 0000000 0000000 # socialbutton.rb
#
# Copyright (c) 2011 MATSUOKA Kohei
# You can redistribute it and/or modify it under GPL2.
#
# enable social button names
@conf['socialbutton.enables'] ||= 'twitter,hatena,facebook_like'
# screen name of the user to attribute the tweet to
@conf['socialbutton.twitter.via'] ||= ''
def socialbutton_js_settings
enable_js('jquery.socialbutton.js')
enable_js('socialbutton.js')
add_js_setting('$tDiary.plugin.socialbutton')
# convert array to json
add_js_setting('$tDiary.plugin.socialbutton.enables',
%Q|["#{@conf['socialbutton.enables'].split(',').join('", "')}"]|)
if @conf['socialbutton.twitter.via'] != ''
options = "{ twitter: { via: '#{@conf['socialbutton.twitter.via']}' } }"
else
options = "{}"
end
add_js_setting('$tDiary.plugin.socialbutton.options', options)
end
socialbutton_footer = Proc.new { %Q|
| }
if blogkit?
add_body_leave_proc(socialbutton_footer)
else
add_section_leave_proc(socialbutton_footer)
end
add_conf_proc('socialbutton', @socialbutton_label_conf) do
@conf['socialbutton.enables'] ||= []
if @mode == 'saveconf'
@conf['socialbutton.enables'] = @cgi.params['socialbutton.enables'].join(",")
@conf['socialbutton.twitter.via'] = @cgi.params['socialbutton.twitter.via'][0]
end
result = <<-HTML
#{@socialbutton_label_enables}
#{@socialbutton_label_twitter_via}
HTML
end
# load javascript
socialbutton_js_settings()
tdiary-contrib-3.2.2/plugin/tatsu_zine.rb 0000664 0000000 0000000 00000004732 12136327440 0020470 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright (C) 2011, KADO Masanori
# You can redistribute it and/or modify it under GPL.
#
# display book info in http://tatsu-zine.com/ like amazon.rb
# USAGE: {{tatsu_zine 1}}
require 'open-uri'
def tatsu_zine_cache_dir
cache = "#{@cache_path}/tatsu-zine"
Dir.mkdir( cache ) unless File.directory?( cache )
cache
end
def tatsu_zine_cache_set( id, result )
File.open( "#{tatsu_zine_cache_dir}/#{id}", "w" ) do |f|
f.write result
end
end
def tatsu_zine_cache_get( id )
File.open( "#{tatsu_zine_cache_dir}/#{id}", "r" ) do |f|
f.read
end
rescue
nil
end
def tatsu_zine( id, doc = nil )
if !@conf.secure and !(result = tatsu_zine_cache_get(id)).nil?
return result
end
link = "http://tatsu-zine.com/books/#{id}"
doc ||= open( link ).read
title = doc.match(%r| |).to_a[1]
image = doc.match(%r| |).to_a[1]
price = doc.match(%r|[\r\n]?(.*?)[\r\n]?
|m).to_a[1].
gsub(/\s/, '')
author = doc.match(%r|(.*)
|).to_a[1]
result = <<-EOS
#{h title}
#{h author}
#{h price}
EOS
tatsu_zine_cache_set( id, result ) unless @conf.secure
result
rescue
link
end
if __FILE__ == $0
require 'test/unit'
class TestTatsuZine < Test::Unit::TestCase
def setup
@conf = Struct.new("Conf", :secure).new(true)
def h(str); str; end
end
def test_tatsu_zine
expect = <<-EOS
Ruby環境構築講座 Windows編
arton
1,000円(税込)
EOS
assert_equal expect, tatsu_zine('winrubybuild')
end
end
end
# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:
tdiary-contrib-3.2.2/plugin/tdiarygraph_flashstyle.rb 0000664 0000000 0000000 00000041106 12136327440 0023053 0 ustar 00root root 0000000 0000000 # tdiarygraph_flashstyle.rb $Revision: 1.3 $
#
# Copyright (c) 2004 phonondrive
# Distributed under the GPL
#
# プラグイン配布ページ:
# http://phonondrive.com/trd/
# --------------------------------------------------------------------
#
#
#
# Abstract:
# --------------------------------------------------------------------
# counter.rb のカウンタログ (counter.log) をグラフ化した
# Flash アプレットを表示します。
#
#
# Usage:
# --------------------------------------------------------------------
# プラグインは、プラグインフォルダに入れてください。
# tdiarygraph*.swf を tdiary.rb と同じフォルダにアップロードします。
# ヘッダ、フッタ部に記述した <%= tdiarygraph_flashstyle %> の部分に、
# Flash アプレットが表示されます。
# counter.log は日記登録時に .swf と同じフォルダにコピーされます。
#
# ※ counter.rb を使用しており、かつカウンタログ (counter.log) の出力を
# オンにしている必要があります。
#
#
# Options:
# --------------------------------------------------------------------
# グラフの色、透明度、サイズなどは、プリファレンス画面で設定できます。
#
#
# In secure mode:
# --------------------------------------------------------------------
# たぶん動作しません。
#
#
# Acknowledgements:
# --------------------------------------------------------------------
# counter.rb (counter.log)
#
# Copyright (c) 2002 MUTOH Masao
# Distributed under the GPL2.
# http://ponx.s5.xrea.com/hiki/ja/counter.rb.html
#
#
=begin ChangeLog
2004.04.27 phonondrive
* version 1.3.0
キャッシュ対策としてユニークIDを付加してファイル取得するオプションを追加
対応 Flash ファイルを e 系列に変更
フォントを _sans から 04b03b に変更
04b03b.ttf, copyright (c) 1998-2001 YUJI OSHIMOTO
http://www.04.jp.org/
2004.04.10 phonondrive
* version 1.2.1
レポート書式で改行タグが機能しない不具合を修正
背景の枠線を表示しないオプションを追加
対応 Flash ファイルを d 系列に変更
2004.04.09 phonondrive
* version 1.2.0
ログファイルが転送されない不具合を修正
作成するログのデフォルト名を変更 (tdiarygraph.log → counter.log)
線幅を絶対値で指定出来るオプションを追加
レポート書式のカスタマイズオプションを追加
対応 Flash ファイルを c 系列に変更
2004.04.05 phonondrive
* version 1.1.1
線の太さを変更するオプションを追加
対応 Flash ファイルに b 系列を追加
2004.04.05 phonondrive
* version 1.1.0
Ruby 1.6.x に対応 (1.6.7 で動作確認)
作成するログのデフォルト名を変更 (counter.log → tdiarygraph.log)
2004.04.04 phonondrive
* version 1.0.0
=end
# --------------------------------------------------------------------
# プラグインの表示
# --------------------------------------------------------------------
def tdiarygraph_flashstyle
if @conf['tdiarygraph_f.templete'] == nil or @conf['tdiarygraph_f.templete'] == ""
%Q|使用を開始するには、プリファレンス画面 にて一度設定を完了して下さい。(tdiarygraph-flashstyle)|
else
logname = ((@conf['tdiarygraph_f.log_path'] != "" and @conf['tdiarygraph_f.log_path'] != nil) ? @conf['tdiarygraph_f.log_path'] : "counter.log")
@conf['tdiarygraph_f.templete'].sub(/&uid/, "\\&=#{File.mtime(logname.untaint).to_i}")
end
end
# --------------------------------------------------------------------
# 日記登録時の処理 (counter.log のコピー)
# --------------------------------------------------------------------
if /\A(?:append|replace)\z/ =~ @mode and @cgi.params['hide'][0] != 'true' then
logname = ((@conf['tdiarygraph_f.log_path'] != "" and @conf['tdiarygraph_f.log_path'] != nil) ? @conf['tdiarygraph_f.log_path'] : "counter.log")
open("#{@cache_path}/counter/counter.log"){|input|
open(logname, "w"){|output|
output.write(input.read)
}
}
end
# --------------------------------------------------------------------
# プリファレンス画面での設定
# --------------------------------------------------------------------
add_conf_proc( 'tdiarygraph_f', 'tdiarygraph-flashstyle の設定' ) do
if @mode == 'saveconf' then
filename = "tdiarygraph468x60e.swf"
width = "468"
height = "60"
argvs = ""
argv = Array.new
@conf['tdiarygraph_f.uid'] = @cgi.params['uid'][0]
argv << "#{Time.now.to_i}&uid" if @conf['tdiarygraph_f.uid'] == "1"
@conf['tdiarygraph_f.type'] = @cgi.params['type'][0]
@conf['tdiarygraph_f.filename'] = @cgi.params['filename'][0]
@conf['tdiarygraph_f.width'] = @cgi.params['width'][0]
@conf['tdiarygraph_f.height'] = @cgi.params['height'][0]
@conf['tdiarygraph_f.log_path'] = @cgi.params['log_path'][0]
argv << "log_path=#{@cgi.params['log_path'][0]}" if @cgi.params['log_path'][0] != ""
@conf['tdiarygraph_f.init_num'] = @cgi.params['init_num'][0]
argv << "init_num=#{@cgi.params['init_num'][0]}" if @cgi.params['init_num'][0] != ""
@conf['tdiarygraph_f.text_text'] = @cgi.params['text_text'][0].upcase
argv << "text_text=#{h NKF::nkf('-s', @cgi.params['text_text'][0].upcase)}" if @cgi.params['text_text'][0] != ""
@conf['tdiarygraph_f.text_rgb'] = @cgi.params['text_rgb'][0]
argv << "text_rgb=0x#{@cgi.params['text_rgb'][0]}" if @cgi.params['text_rgb'][0] != ""
@conf['tdiarygraph_f.text_report'] = @cgi.params['text_report'][0]
argv << "text_report=#{@cgi.params['text_report'][0]}" if @cgi.params['text_report'][0] == "0"
@conf['tdiarygraph_f.text_report_format'] = @cgi.params['text_report_format'][0]
argv << "text_report_format=#{tdiarygraph_flashstyle_text_report_format(@cgi.params['text_report_format'][0])}" if @cgi.params['text_report_format'][0] != ""
@conf['tdiarygraph_f.text_report_rgb'] = @cgi.params['text_report_rgb'][0]
argv << "text_report_rgb=0x#{@cgi.params['text_report_rgb'][0]}" if @cgi.params['text_report_rgb'][0] != ""
@conf['tdiarygraph_f.bg_rgb'] = @cgi.params['bg_rgb'][0]
argv << "bg_rgb=0x#{@cgi.params['bg_rgb'][0]}" if @cgi.params['bg_rgb'][0] != ""
@conf['tdiarygraph_f.bg_alpha'] = @cgi.params['bg_alpha'][0]
argv << "bg_alpha=#{@cgi.params['bg_alpha'][0]}" if @cgi.params['bg_alpha'][0] != ""
@conf['tdiarygraph_f.bg_frame'] = @cgi.params['bg_frame'][0]
argv << "bg_frame=#{@cgi.params['bg_frame'][0]}" if @cgi.params['bg_frame'][0] == "1"
@conf['tdiarygraph_f.bar_rgb'] = @cgi.params['bar_rgb'][0]
argv << "bar_rgb=0x#{@cgi.params['bar_rgb'][0]}" if @cgi.params['bar_rgb'][0] != ""
@conf['tdiarygraph_f.bar_alpha'] = @cgi.params['bar_alpha'][0]
argv << "bar_alpha=#{@cgi.params['bar_alpha'][0]}" if @cgi.params['bar_alpha'][0] != ""
@conf['tdiarygraph_f.line_rgb'] = @cgi.params['line_rgb'][0]
argv << "line_rgb=0x#{@cgi.params['line_rgb'][0]}" if @cgi.params['line_rgb'][0] != ""
@conf['tdiarygraph_f.line_alpha'] = @cgi.params['line_alpha'][0]
argv << "line_alpha=#{@cgi.params['line_alpha'][0]}" if @cgi.params['line_alpha'][0] != ""
@conf['tdiarygraph_f.bar_width'] = @cgi.params['bar_width'][0]
argv << "bar_width=#{@cgi.params['bar_width'][0]}" if @cgi.params['bar_width'][0] != ""
@conf['tdiarygraph_f.line_width'] = @cgi.params['line_width'][0]
argv << "line_width=#{@cgi.params['line_width'][0]}" if @cgi.params['line_width'][0] != ""
@conf['tdiarygraph_f.bold'] = @cgi.params['bold'][0]
argv << "bold=#{@cgi.params['bold'][0]}" if @cgi.params['bold'][0] != ""
@conf['tdiarygraph_f.preview'] = @cgi.params['preview'][0]
if @cgi.params['type'][0] == "0"
filename = @cgi.params['filename'][0]
width = @cgi.params['width'][0]
height = @cgi.params['height'][0]
elsif @cgi.params['type'][0]
filename = "tdiarygraph#{@cgi.params['type'][0].delete('-')}.swf"
width = @cgi.params['type'][0].split('-').first.split('x')[0]
height = @cgi.params['type'][0].split('-').first.split('x')[1]
end
if argv.size > 0 then argvs = "?#{argv.join('&')}" end
@conf['tdiarygraph_f.templete'] = tdiarygraph_flashstyle_templete(filename, argvs, width, height)
end
<<-HTML
設定の概要
() 内は初期値です。初期値を使用する場合は、空欄のままで構いません。色は RRGGBB 形式で指定して下さい。不透明度は 0 (透明) 〜 100 (不透明) です。線幅はピクセルで指定します。
プレビュー
#{tdiarygraph_flashstyle_preview}
表示する Flash アプレットの選択
プリセットを使用しない
tdiarygraph468x60e.swf, 468x60
tdiarygraph728x90e.swf, 728x90
tdiarygraph125x125e.swf, 125x125
tdiarygraph240x180e.swf, 240x180
tdiarygraph120x90e.swf, 120x90
プリセットを使用しない場合は、以下で指定して下さい。
Flash のファイル名
Flash の表示幅
Flash の表示高さ
アクセスログデータ
本プラグインが作成する counter.log の複製のファイル名 (counter.log)
累計アクセス数の初期値。(0) counter.rb で init_num を指定している場合は、同じ値 (#{@conf['counter.init_num']}) を設定してください。
タイトルテキスト
タイトルテキスト (TDIARYGRAPH-FLASHSTYLE) 使用出来る文字は、英大文字 (A-Z) と数字 (0-9)、および記号のみです。
タイトルテキストの色 (FFFFFF)
レポートテキスト
レポートの表示有無 (表示)
表示
非表示
レポートテキストの色 (CCCCCC)
レポート書式のカスタマイズ
タグを埋め込んだ位置にデータが展開されます。 使用出来る文字 (タグを除く) は、英大文字 (A-Z) と数字 (0-9)、および記号のみです。
[ 使用出来るタグ ] <firstday> : ログ初日, <lastday> : ログ最終日, <days> : ログ日数, <total> : 累計アクセス数, <peak> : 日別最大アクセス数, <br> : 改行
背景や棒グラフの色
背景の色 (333333)
背景の不透明度 (100)
背景の枠線 (非表示)
非表示
左と上に表示
日別アクセス数棒グラフの色 (CCCCCC)
日別アクセス数棒グラフの不透明度 (100)
累計アクセス数棒グラフの色 (666666)
累計アクセス数棒グラフの不透明度 (100)
棒グラフの線幅
日別アクセス数棒グラフの線幅を絶対値で指定します。
累計アクセス数棒グラフの線幅を絶対値で指定します。
モアレ対策
棒グラフの線幅を相対的に微調整します。(0) 設定した値に対して線幅がリニアに変更されるわけではありません。
ユニークID を使用したファイル取得
ファイル取得のリクエストにユニークID (例えば ?#{Time.now.to_i}) を含めることにより、古いファイルがブラウザにキャッシュされたままになるのを防ぎます。Flash のユニークID はプリファレンス設定時に、ログファイルのユニークID はエントリ登録時に更新されます。
ユニークID の付加 (付加する)
付加する
付加しない
プレビュー
表示したい SWF ファイル (.swf) が tdiary.rb と同じフォルダにアップロードされている必要があります。また、カウンタログファイルが SWF ファイルと同じフォルダに転送されていない場合にはグラフが表示されません。
プレビュー (非表示)
非表示
表示
HTML
end
def tdiarygraph_flashstyle_preview
unless @conf.mobile_agent?
<<-r
#{if @conf['tdiarygraph_f.preview'] == "1" then "#{tdiarygraph_flashstyle}" else "プレビュー表示を有効にすると、ここに Flash が表示されます。" end}
r
end
end
def tdiarygraph_flashstyle_templete( filename="tdiarygraph468x60e.swf", argvs="", width="468", height="60" )
<<-r
r
end
def tdiarygraph_flashstyle_text_report_format( format="" )
if format != ""
r = format.gsub('<', '<').gsub('>', '>').gsub(' ', '+')
end
end
tdiary-contrib-3.2.2/plugin/tdiarytimes.rb 0000664 0000000 0000000 00000011727 12136327440 0020643 0 ustar 00root root 0000000 0000000 # tdiarytimes.rb $Revision: 1.2 $
#
# Copyright (c) 2003 neuichi
# Distributed under the GPL
#
# プラグイン配布ページ
# http://nmnl.jp/hiki/software/?tDiary+%3A%3A+Plugin
#
# 動作条件:
# ruby-gdが使える環境が必要です。
#
# 使い方:
# このプラグインをプラグインディレクトリに入れ、
# index.rbと同じディレクトリに、tdiarytimes.pngという名前の
# サーバが書き込み権限を持っているファイルを作ります。
# これで日記に書き込みするごとに、tdiarytimes.pngに
# 画像を書き込みます。
#
# 日記上からこのpngファイルを呼び出すには、
# tDiray上からプラグインとして
# <%=tdiarytimes%>
# として呼び出します。
# 引数としてimgタグのaltの文字列を指定することも出来ます。
# <%=tdiarytimes '文字列'%>
#
# また、tdiary.confに以下のオプションを書き込むことにより、
# カスタマイズをすることが出来ます。
#
# @options['tdiarytimes.width'] = 400
# 四角の横幅。デフォルト値400。
# 実際に出力される画像サイズは、これに+10したサイズ。
#
# @options['tdiarytimes.height'] = 20
# 四角の縦幅。デフォルト値20。
# 実際に出力される画像サイズは、これに+16したサイズ。
#
# @options['tdiarytimes.file'] = 'tdiarytimes.png'
# 出力する画像ファイル名。デフォルトは'tdiarytimes.png'
#
# @options['tdiarytimes.fillcolor'] = '#444444'
# 四角の色。デフォルトは'#444444'
#
# @options['tdiarytimes.linecolor'] = '#ffffff'
# 縦棒の色。デフォルトは'#ffffff'
#
# @options['tdiarytimes.textcolor'] = '#444444'
# 文字色。デフォルトは'#444444'
#
# @options['tdiarytimes.text'] = 'T D I A R Y T I M E S'
# 出力する文字。デフォルトは'T D I A R Y T I M E S'。なお半角英数字のみ対応。
#
# @options['tdiarytimes.day'] = 30
# ログを保存する最大日数。デフォルトは30。
# この場合、30日以上経ったデータは消去され、縦棒として描画されなくなる。
#
require 'GD'
if /^(append|replace)$/ =~ @mode then
#初期設定
width = @options['tdiarytimes.width'] || 400
height = @options['tdiarytimes.height'] || 20
file = @options['tdiarytimes.file'] || 'tdiarytimes.png'
fillcolor = @options['tdiarytimes.fillcolor'] || '#444444'
linecolor = @options['tdiarytimes.linecolor'] || '#ffffff'
textcolor = @options['tdiarytimes.textcolor'] || '#444444'
text = @options['tdiarytimes.text'] || 'T D I A R Y T I M E S'
day = @options['tdiarytimes.day'] || 30
cache = "#{@cache_path}/tdiarytimes"
Dir::mkdir( cache ) unless File::directory?( cache )
image = GD::Image.new(width + 10,height + 16)
transcolor = image.colorAllocate("#fffffe")
image.transparent(transcolor)
image.interlace = TRUE
fillcolor = image.colorAllocate(fillcolor)
linecolor = image.colorAllocate(linecolor)
textcolor = image.colorAllocate(textcolor)
#帯の描画
image.filledRectangle(5,8,width + 4,height + 7,fillcolor)
#時間挿入
if width >= 160
hour = 2
hour_w = width / 12.0
image.string(GD::Font::TinyFont, 2, height + 8, "0", textcolor)
11.times {
image.string(GD::Font::TinyFont, (hour_w * hour/2).to_i , height + 8, hour.to_s, textcolor)
hour += 2
}
image.string(GD::Font::TinyFont, width + 2, height + 8, "0", textcolor)
else
hour = 0
hour_w = width / 6.0
6.times {
image.string(GD::Font::TinyFont, (hour_w * hour/4).to_i + 4, height + 8, hour.to_s, textcolor)
hour += 4
}
image.string(GD::Font::TinyFont, width + 2, height + 8, "0", textcolor)
end
#現在時刻の保存,読み込み
begin
io = open("#{cache}/tdiarytimes.dat","r")
ary_times = Marshal.load(io)
io.close
rescue
ary_times = []
end
ary_times << Time.now.to_f
ary_times_new = []
while ary_times.size != 0
time = ary_times.shift
time_now = Time.now.to_f.to_i
ary_times_new << time.to_i if (86400 * day) > (time_now - time).to_i
end
ary_times = ary_times_new
io = open("#{cache}/tdiarytimes.dat","w")
Marshal.dump(ary_times,io)
io.close
#時間軸の挿入
while ary_times.size != 0
time = Time.at(ary_times.shift)
time_w = ((time.to_a[2] * 60 + time.to_a[1]) / 1440.0 * width).to_i
image.line(time_w + 5, 8 ,time_w + 5,height + 7, linecolor)
end
#文字の挿入
image.string(GD::Font::TinyFont, 5, 0, text, textcolor)
pngfile = open(file, 'w')
image.png(pngfile)
pngfile.close
end
def tdiarytimes(alt = nil)
width = @options['tdiarytimes.width'].to_i || 400
width += 10
height = @options['tdiarytimes.height'].to_i || 20
height += 16
file = @options['tdiarytimes.file'] || 'tdiarytimes.png'
text = @options['tdiarytimes.text'] || 'T D I A R Y T I M E S'
result = ""
if alt
result << %Q| |
else
result << %Q| |
end
result
end
tdiary-contrib-3.2.2/plugin/tdiarytimes2.rb 0000664 0000000 0000000 00000026530 12136327440 0020723 0 ustar 00root root 0000000 0000000 # tdiarytimes.rb $originalRevision: 1.1 $
#
# Copyright (c) 2003 neuichi
# Distributed under the GPL
#
# 2003-12-01 circle extention added by Minero Aoki
# $Id: tdiarytimes2.rb,v 1.2 2007/01/11 02:55:26 tadatadashi Exp $
#
# プラグイン配布ページ
# http://i.loveruby.net/w/tdiarytimes.html
#
# 動作条件:
# ruby-gdが使える環境が必要です。
#
# 使い方:
# このプラグインをプラグインディレクトリに入れ、
# index.rbと同じディレクトリに、tdiarytimes.pngという名前の
# サーバが書き込み権限を持っているファイルを作ります。
# これで日記に書き込みするごとに、tdiarytimes.pngに
# 画像を書き込みます。
#
# 日記上からこのpngファイルを呼び出すには、
# tDiray上からプラグインとして
# <%=tdiarytimes%>
# として呼び出します。
# 引数としてimgタグのaltの文字列を指定することも出来ます。
# <%=tdiarytimes '文字列'%>
#
# また、tdiary.confに以下のオプションを書き込むことにより、
# カスタマイズをすることが出来ます。
#
# @options['tdiarytimes.width'] = 400
# 四角の横幅。デフォルト値400。
# 実際に出力される画像サイズは、これに+10したサイズ。
#
# @options['tdiarytimes.height'] = 20
# 四角の縦幅。デフォルト値20。
# 実際に出力される画像サイズは、これに+16したサイズ。
#
# @options['tdiarytimes.file'] = 'tdiarytimes.png'
# 出力する画像ファイル名。デフォルトは'tdiarytimes.png'
#
# @options['tdiarytimes.fillcolor'] = '#444444'
# 四角の色。デフォルトは'#444444'
#
# @options['tdiarytimes.linecolor'] = '#ffffff'
# 縦棒の色。デフォルトは'#ffffff'
#
# @options['tdiarytimes.textcolor'] = '#444444'
# 文字色。デフォルトは'#444444'
#
# @options['tdiarytimes.fadeout'] = false
# フェードアウトするか。デフォルトはfalse。
# フェードアウトしたいときには true にすればよい。
#
# @options['tdiarytimes.fadeoutcolor'] = '#ffffff'
# フェードアウトするとき、
# デフォルトではfillcolorへとフェードアウトしていく。
# ここで色を指定するとその色へとフェードアウトしていく。
# デフォルトは false
#
# @options['tdiarytimes.text'] = 'T D I A R Y T I M E S'
# 出力する文字。デフォルトは'T D I A R Y T I M E S'。なお半角英数字のみ対応。
#
# @options['tdiarytimes.day'] = 30
# ログを保存する最大日数。デフォルトは30。
# この場合、30日以上経ったデータは消去され、縦棒として描画されなくなる。
#
require 'GD'
::GD::Image.module_eval {
def tiny_string(text, x, y, color)
string(GD::Font::TinyFont, x, y, text, color)
end
def small_string(text, x, y, color)
string(GD::Font::SmallFont, x, y, text, color)
end
}
# Ruby 1.6 missing File.read
unless ::File.respond_to?(:read)
def (::File).read(fname)
File.open(fname) {|f|
return f.read
}
end
end
# Ruby 1.6 missing MatchData#captures
unless ::MatchData.method_defined?(:captures)
::MatchData.module_eval {
def captures
a = to_a()
a.shift
a
end
}
end
class TDiaryTimes
class << TDiaryTimes
alias newobj new
end
def TDiaryTimes.new(datadir, options)
case options['tdiarytimes.shape']
when 'bar', nil
c = TDiaryTimesBar
when 'circle'
c = TDiaryTimesCircle
else
raise ArgumentError, "unknown tdiarytimes.shape: #{options['tdiarytimes.shape']}"
end
c.newobj("#{datadir}/tdiarytimes", options)
end
def initialize(dbfile, options)
@dbfile = dbfile
@image_file = options['tdiarytimes.file'] || 'tdiarytimes.png'
@day = options['tdiarytimes.day'] || 30
@keepdb = options['tdiarytimes.keepdb']
end
attr_reader :image_file
def update_image
now = Time.now
mtimes = (load_database() + [now]).reject {|tm|
(now - tm) > (60 * 60 * 24 * @day)
}
image = create_image(mtimes)
File.open(@image_file, 'w') {|png|
image.png(png)
}
save_database(mtimes) unless @keepdb
end
private
#
# database
#
def load_database
begin
return Marshal.load(File.read(@dbfile))
rescue Errno::ENOENT
return []
end
end
def save_database(content)
File.open(@dbfile, 'w') {|f|
Marshal.dump(content, f)
}
end
#
# common paint methods
#
def fadeout_color(srccolor, destcolor, time)
par = (Time.now - time).to_f / (60 * 60 * 24 * @day)
r, g, b = *zip(parse_rgb(srccolor), parse_rgb(destcolor))\
.map {|src, dest| src - (src - dest) * par }.map {|c| c.to_i }
sprintf('#%02x%02x%02x', r, g, b)
end
def parse_rgb(str)
hex = '[\da-f]'
m = /\A\#(#{hex}{2})(#{hex}{2})(#{hex}{2})\z/io.match(str) or
raise ArgumentError, "tdiarytimes: not color: #{str.inspect}"
m.captures.map {|c| c.hex }
end
def zip(*lists)
result = []
lists[0].each_index do |idx|
result.push lists.map {|lst| lst[idx] }
end
result
end
end
class TDiaryTimesBar < TDiaryTimes
def initialize(dbfile, options)
super
@text = options['tdiarytimes.text'] || 'T D I A R Y T I M E S'
@width = options['tdiarytimes.width'].to_i || 400
@height = options['tdiarytimes.height'].to_i || 20
@textcolor = options['tdiarytimes.textcolor'] || '#444444'
@fillcolor = options['tdiarytimes.fillcolor'] || '#444444'
@linecolor = options['tdiarytimes.linecolor'] || '#ffffff'
@fadeoutcolor = options['tdiarytimes.fadeoutcolor'] || @fillcolor
@fadeoutp = options['tdiarytimes.fadeout']
end
def html(alt)
%Q[ ].gsub(/\s+/, ' ')
end
private
GAP_W = 16
GAP_H = 16
def create_image(mtimes)
image = GD::Image.new(@width + GAP_W, @height + GAP_H)
image.transparent(image.colorAllocate('#fffffe'))
image.interlace = true
image.tiny_string @text, (GAP_W / 2), 0, image.colorAllocate(@textcolor)
image.filledRectangle 0 + GAP_W / 2, 0 + GAP_H / 2,
image.width - GAP_W / 2, image.height - GAP_H / 2,
image.colorAllocate(@fillcolor)
if @fadeoutp
paint_lines_fadeout image, mtimes, @linecolor, @fadeoutcolor
else
paint_lines image, mtimes, @linecolor
end
paint_hours image, image.colorAllocate(@textcolor),
(image.width - GAP_W > 160 ? 2 : 4)
image
end
def paint_lines(image, mtimes, color)
gdcolor = image.colorAllocate(color)
mtimes.each do |time|
line image, time, gdcolor
end
end
def paint_lines_fadeout(image, mtimes, linecolor, destcolor)
mtimes.each do |time|
line image, time,
image.colorAllocate(fadeout_color(linecolor, destcolor, time))
end
end
def line(image, time, color)
x0 = (image.width - GAP_W).to_f * (time.hour * 60 + time.min) / (60 * 24)
x = (x0 + (GAP_W / 1.25)).to_i
image.line x, 0 + (GAP_H / 2),
x, image.height - (GAP_H / 2),
color
end
def paint_hours(image, color, stepping)
0.step(24, stepping) do |hour|
image.tiny_string hour.to_s,
(image.width - GAP_W) * (hour.to_f / 24) + (GAP_W / 2) - 4,
image.height - (GAP_H / 2),
color
end
end
end
class TDiaryTimesCircle < TDiaryTimes
def initialize(dbfile, options)
super
#@text # cannot change now
@width = options['tdiarytimes.width'].to_i || 80
@height = options['tdiarytimes.height'].to_i || 80
@textcolor = options['tdiarytimes.textcolor'] || '#444444'
@fillcolor = options['tdiarytimes.fillcolor'] || '#444444'
@linecolor = options['tdiarytimes.linecolor'] || '#ffffff'
@fadeoutcolor = options['tdiarytimes.fadeoutcolor'] || @fillcolor
@fadeoutp = options['tdiarytimes.fadeout']
end
def html(alt)
%Q[ ].gsub(/\s+/, ' ')
end
private
MIN_DEGREE = 0
MAX_DEGREE = 250
BAR_WIDTH = 24
TRANSCOLOR = '#ffffff'
def create_image(mtimes)
image = GD::Image.new(@width, @height)
trans = image.colorAllocate(TRANSCOLOR)
image.transparent trans
image.interlace = true
paint_outer_circle image, trans
if @fadeoutp
paint_lines_fadeout image, mtimes, @linecolor, @fadeoutcolor
else
paint_lines image, mtimes, @linecolor
end
paint_inner_circle image, trans
textcolor = image.colorAllocate(@textcolor)
image.small_string 'tdiary', @width / 2 + 1, 11, textcolor
image.small_string 'times', @width / 2 + 4, 21, textcolor
image
end
def paint_outer_circle(image, trans)
image.filledArc @width / 2, @height / 2,
@width, @height,
MIN_DEGREE, MAX_DEGREE,
if @fillcolor == TRANSCOLOR
then trans
else image.colorAllocate(@fillcolor)
end,
0
end
def paint_inner_circle(image, trans)
image.filledArc @width / 2, @height / 2,
@width - BAR_WIDTH * 2,
(@width - BAR_WIDTH * 2) * (@height.to_f / @width),
0, 360, trans, 0
end
def paint_lines(image, mtimes, color)
gdcolor = image.colorAllocate(color)
mtimes.each do |time|
line image, time, gdcolor
end
end
def paint_lines_fadeout(image, mtimes, linecolor, destcolor)
mtimes.each do |time|
line image, time,
image.colorAllocate(fadeout_color(linecolor, destcolor, time))
end
end
def line(image, time, color)
d0 = (time.hour * 60 + time.min).to_f / (60 * 24)
d = MIN_DEGREE + (MAX_DEGREE - MIN_DEGREE) * d0
image.line @width / 2, @height / 2,
@width / 2 + degcos(d) * (@width / 2) * 0.95,
@height / 2 + degsin(d) * (@height / 2) * 0.95,
color
end
include Math
def degsin(d)
sin(d / (180 / Math::PI))
end
def degcos(d)
cos(d / (180 / Math::PI))
end
end
def tdiarytimes(alt = nil)
TDiaryTimes.new(@conf.data_path, @options).html(alt)
end
if $0 == __FILE__ # debugging
tmp_options_bar = {
'tdiarytimes.shape' => 'bar',
'tdiarytimes.textcolor' => '#666666',
'tdiarytimes.linecolor' => '#df0000',
'tdiarytimes.fillcolor' => '#0f5f0f',
'tdiarytimes.fadeout' => true,
'tdiarytimes.keepdb' => false # for debug
}
tmp_options_circle = {
'tdiarytimes.shape' => 'circle',
'tdiarytimes.textcolor' => '#000000',
'tdiarytimes.linecolor' => '#bfbfbf',
'tdiarytimes.fillcolor' => '#2f2f7f',
'tdiarytimes.fadeout' => true,
'tdiarytimes.keepdb' => false # for debug
}
@mode = 'latest'
@conf = Object.new
def @conf.data_path
'.'
end
case ARGV[0]
when 'bar'
@options = tmp_options_bar
else
@options = tmp_options_circle
end
TDiaryTimes.new(@conf.data_path, @options).update_image
puts tdiarytimes()
exit 0
end
if /append|replace/ =~ @mode
TDiaryTimes.new(@conf.data_path, @options).update_image
end
tdiary-contrib-3.2.2/plugin/tdiarytimes_flashstyle.rb 0000664 0000000 0000000 00000035605 12136327440 0023102 0 ustar 00root root 0000000 0000000 # tdiarytimes_flashstyle.rb $Revision: 1.2 $
#
# Copyright (c) 2004 phonondrive
# Distributed under the GPL
#
# プラグイン配布ページ:
# http://phonondrive.com/trd/
# --------------------------------------------------------------------
#
#
#
# Abstract:
# --------------------------------------------------------------------
# 日記を登録した時間帯をタイムライン上に記録します。記録されたエントリは
# 日時の経過と共にフェードアウトしていきます。このような MTBlogTimes や
# tdiarytimes.rb と同等の機能を Flash で実現します。
# ruby-gd のインストール作業も必要ないため、すぐに使用出来ます。
#
#
# Usage:
# --------------------------------------------------------------------
# プラグインは、プラグインフォルダに入れて下さい。
#
# プラグインは、プラグインフォルダに入れてください。
# tdiarytimes*.swf を tdiary.rb と同じフォルダにアップロードします。
# ヘッダ、フッタ部に記述した <%= tdiarytimes_flashstyle %> の部分に、
# Flash アプレットが表示されます。
# tdiarytimes.log は日記登録時に .swf と同じフォルダに作成されます。
#
# ※ tdiarytimes_textstyle.rb との互換性はありません。
#
#
# Options:
# --------------------------------------------------------------------
# タイムラインの色、透明度、サイズなどは、プリファレンス画面で設定できます。
#
#
# In secure mode:
# --------------------------------------------------------------------
# たぶん動作しません。
#
#
=begin ChangeLog
2004.05.02 phonondrive
* version 1.1.2
タイムラインが曜日別の Flash を追加
2004.05.02 phonondrive
* version 1.1.1
タイムラインが円形で、時刻盤が曜日表示の Flash を追加
ログファイルが存在しない時にエラーが出る不具合を修正
2004.04.28 phonondrive
* version 1.1.0
タイムラインが円形の Flash を追加
2004.04.27 phonondrive
* version 1.0.1
時刻目盛テキストの色が変更されない不具合を修正
2004.04.25 phonondrive
* version 1.0.0
=end
# --------------------------------------------------------------------
# プラグインの動作
# --------------------------------------------------------------------
def tdiarytimes_flashstyle
if @conf['tdiarytimes_f.templete'] == nil or @conf['tdiarytimes_f.templete'] == ""
%Q|使用を開始するには、プリファレンス画面 にて一度設定を完了して下さい。(tdiarytimes-flashstyle)|
else
logname = ((@conf['tdiarytimes_f.log_path'] != "" and @conf['tdiarytimes_f.log_path'] != nil) ? @conf['tdiarytimes_f.log_path'] : "tdiarytimes.log")
@conf['tdiarygraph_f.templete'].sub(/&uid/, "\\&=#{File.mtime(logname.untaint).to_i}")
end
end
# --------------------------------------------------------------------
# 日記登録時の処理
# --------------------------------------------------------------------
if /\A(?:append|replace)\z/ =~ @mode and @cgi.params['hide'][0] != 'true' then
logname = ((@conf['tdiarytimes_f.log_path'] != "" and @conf['tdiarytimes_f.log_path'] != nil) ? @conf['tdiarytimes_f.log_path'] : "tdiarytimes.log")
entr_lifetime = ((@conf['tdiarytimes_f.entr_lifetime'] != "" and @conf['tdiarytimes_f.entr_lifetime'] != nil) ? @conf['tdiarytimes_f.entr_lifetime'].to_i * 60 * 60 * 24 : 30 * 24 * 60 * 60)
entr_interval = ((@conf['tdiarytimes_f.entr_interval'] != "" and @conf['tdiarytimes_f.entr_interval'] != nil) ? @conf['tdiarytimes_f.entr_interval'] : 2 * 60 * 60)
begin
logs = open(logname){|io| io.read }.chomp.split(',')
rescue
logs = ""
end
if (Time.now.to_i - logs.max.to_i) > entr_interval.to_i
logs << "#{Time.now.to_i}"
open(logname, "w"){|io|
io.write(logs.find_all{|item| (Time.now.to_i - item.to_i) < entr_lifetime.to_i }.join(','))
}
end
end
# --------------------------------------------------------------------
# プリファレンス画面での設定
# --------------------------------------------------------------------
add_conf_proc( 'tdiarytimes_f', 'tdiarytimes-flashstyle の設定' ) do
if @mode == 'saveconf' then
filename = "tdiarytimes234x30.swf"
width = "234"
height = "30"
argvs = ""
argv = Array.new
@conf['tdiarytimes_f.uid'] = @cgi.params['uid'][0]
argv << "#{Time.now.to_i}&uid" if @conf['tdiarytimes_f.uid'] == "1"
@conf['tdiarytimes_f.type'] = @cgi.params['type'][0]
@conf['tdiarytimes_f.filename'] = @cgi.params['filename'][0]
@conf['tdiarytimes_f.width'] = @cgi.params['width'][0]
@conf['tdiarytimes_f.height'] = @cgi.params['height'][0]
@conf['tdiarytimes_f.log_path'] = @cgi.params['log_path'][0]
argv << "log_path=#{@cgi.params['log_path'][0]}" if @cgi.params['log_path'][0] != ""
@conf['tdiarytimes_f.text_visible'] = @cgi.params['text_visible'][0]
argv << "text_visible=#{@cgi.params['text_visible'][0]}" if @cgi.params['text_visible'][0] == "0"
@conf['tdiarytimes_f.text_text'] = @cgi.params['text_text'][0]
argv << "text_text=#{CGI::escape @cgi.params['text_text'][0].upcase}" if @cgi.params['text_text'][0] != ""
@conf['tdiarytimes_f.text_rgb'] = @cgi.params['text_rgb'][0]
argv << "text_rgb=0x#{@cgi.params['text_rgb'][0]}" if @cgi.params['text_rgb'][0] != ""
@conf['tdiarytimes_f.face_visible'] = @cgi.params['face_visible'][0]
argv << "face_visible=#{@cgi.params['face_visible'][0]}" if @cgi.params['face_visible'][0] == "0"
@conf['tdiarytimes_f.face_rgb'] = @cgi.params['face_rgb'][0]
argv << "face_rgb=0x#{@cgi.params['face_rgb'][0]}" if @cgi.params['face_rgb'][0] != ""
@conf['tdiarytimes_f.stage_rgb'] = @cgi.params['stage_rgb'][0]
argv << "stage_rgb=0x#{@cgi.params['stage_rgb'][0]}" if @cgi.params['stage_rgb'][0] != ""
@conf['tdiarytimes_f.stage_alpha'] = @cgi.params['stage_alpha'][0]
argv << "stage_alpha=#{@cgi.params['stage_alpha'][0]}" if @cgi.params['stage_alpha'][0] != ""
@conf['tdiarytimes_f.bg_rgb'] = @cgi.params['bg_rgb'][0]
argv << "bg_rgb=0x#{@cgi.params['bg_rgb'][0]}" if @cgi.params['bg_rgb'][0] != ""
@conf['tdiarytimes_f.bg_alpha'] = @cgi.params['bg_alpha'][0]
argv << "bg_alpha=#{@cgi.params['bg_alpha'][0]}" if @cgi.params['bg_alpha'][0] != ""
@conf['tdiarytimes_f.bar_rgb'] = @cgi.params['bar_rgb'][0]
argv << "bar_rgb=0x#{@cgi.params['bar_rgb'][0]}" if @cgi.params['bar_rgb'][0] != ""
@conf['tdiarytimes_f.bar_width'] = @cgi.params['bar_width'][0]
argv << "bar_width=#{@cgi.params['bar_width'][0]}" if @cgi.params['bar_width'][0] != ""
@conf['tdiarytimes_f.entr_interval'] = @cgi.params['entr_interval'][0]
@conf['tdiarytimes_f.entr_lifetime'] = @cgi.params['entr_lifetime'][0]
@conf['tdiarytimes_f.fade_time'] = @cgi.params['fade_time'][0]
argv << "fade_time=#{@cgi.params['fade_time'][0]}" if @cgi.params['fade_time'][0] != ""
@conf['tdiarytimes_f.preview'] = @cgi.params['preview'][0]
if @cgi.params['type'][0] == "0"
filename = @cgi.params['filename'][0]
width = @cgi.params['width'][0]
height = @cgi.params['height'][0]
elsif @cgi.params['type'][0]
filename = "tdiarytimes#{@cgi.params['type'][0].delete('-')}.swf"
width = @cgi.params['type'][0].split('-').first.split('x')[0]
height = @cgi.params['type'][0].split('-').first.split('x')[1]
end
if argv.size > 0 then argvs = "?#{argv.join('&')}" end
@conf['tdiarytimes_f.templete'] = tdiarytimes_flashstyle_templete(filename, argvs, width, height)
end
<<-HTML
設定の概要
() 内は初期値です。初期値を使用する場合は、空欄のままで構いません。色は RRGGBB 形式で指定して下さい。不透明度は 0 (透明) 〜 100 (不透明) です。線幅はピクセルで指定します。
プレビュー
#{tdiarytimes_flashstyle_preview}
表示する Flash アプレットの選択
プリセットを使用しない
tdiarytimes125x30.swf, 125x30
tdiarytimes234x30.swf, 234x30
tdiarytimes468x30.swf, 468x30
tdiarytimes125x125r.swf, 125x125 (円形)
tdiarytimes125x125r7.swf, 125x125 (円形, 曜日)
tdiarytimes125x125s.swf, 125x125 (曜日別)
プリセットを使用しない場合は、以下で指定して下さい。
Flash のファイル名
Flash の表示幅
Flash の表示高さ
タイトルテキスト
タイトルテキストの表示有無 (表示)
表示
非表示
タイトルテキスト (TDIARYTIMES-FLASHSTYLE) 使用出来る文字は、英大文字 (A-Z) と数字 (0-9)、および記号のみです。
タイトルテキストの色 (333333)
時刻目盛テキスト
時刻目盛テキストの表示有無 (表示)
表示
非表示
時刻目盛テキストの色 (333333)
背景や棒グラフの色
背景の色 (FFFFFF)
背景の不透明度 (0)
タイムラインの背景の色 (333333)
タイムラインの背景の不透明度 (100)
タイムラインに記録される棒グラフの色 (EEEEEE)
タイムラインに記録される棒グラフの線幅 (1)
タイムラインに記録される棒グラフの寿命日数 (30)
ログ管理
前回の日記登録から設定時間内はエントリを新規登録しない (2)
設定日数後にログファイルからエントリを削除する (30)
本プラグインが作成するログファイル名 (tdiarytimes.log)
ユニークID を使用したファイル取得
ファイル取得のリクエストにユニークID (例えば ?#{Time.now.to_i}) を含めることにより、古いファイルがブラウザにキャッシュされたままになるのを防ぎます。Flash のユニークID はプリファレンス設定時に、ログファイルのユニークID はエントリ登録時に更新されます。
ユニークID の付加 (付加する)
付加する
付加しない
プレビュー
表示したい SWF ファイル (.swf) が tdiary.rb と同じフォルダにアップロードされている必要があります。また、ログファイルが SWF ファイルと同じフォルダに作成されていない場合にはグラフが表示されません。
プレビュー (非表示)
非表示
表示
HTML
end
def tdiarytimes_flashstyle_preview
unless @conf.mobile_agent?
<<-r
#{if @conf['tdiarytimes_f.preview'] == "1" then "#{tdiarytimes_flashstyle}" else "プレビュー表示を有効にすると、ここに Flash が表示されます。" end}
r
end
end
def tdiarytimes_flashstyle_templete( filename="tdiarytimes234x30.swf", argvs="", width="234", height="30" )
<<-r
r
end
tdiary-contrib-3.2.2/plugin/tdiarytimes_textstyle.rb 0000664 0000000 0000000 00000027211 12136327440 0022763 0 ustar 00root root 0000000 0000000 # tdiarytimes_textstyle.rb $Revision: 1.3 $
#
# Copyright (c) 2004 phonondrive
# Distributed under the GPL
#
# プラグイン配布ページ:
# http://phonondrive.com/trd/
# --------------------------------------------------------------------
#
#
#
# Abstract:
# --------------------------------------------------------------------
# 日記を登録した時間帯をタイムライン上に記録します。
# 記録されたエントリは日時の経過と共にフェードアウトしていきます。
# このような MTBlogTimes や tdiarytimes と同等の機能をテキストで実現します。
# また、テキストベースであることを生かした柔軟なサイトデザインが可能です。
# ruby-gd のインストール作業も必要ないため、すぐに使用出来ます。
#
#
# Usage:
# --------------------------------------------------------------------
# プラグインは、プラグインフォルダに入れてください。
# ヘッダ、あるいはフッタ部に入力した <%= tdiarytimes_textstyle %>
# の位置にタイムライン文字列が展開されます。
# 新しいエントリの記録や保持期間の過ぎた古いエントリの削除は、
# 日記の追加および登録時に行われます。
# ただし、エントリのフェードアウト効果はリアルタイムに計算されます。
# エントリの表示分解能は10分ごとです。
#
#
# Options:
# --------------------------------------------------------------------
#
# 現在、次の9つのオプションが用意されています。
#
# init_text 日記の登録されていない時間帯の文字列 (任意の文字列)
# entr_text 日記が登録された時間帯の文字列 (任意の文字列)
# init_color 日記の登録されていない時間帯の文字列の色 (RRBBGG形式で指定)
# entr_color 日記が登録された時間帯の文字列の色 (RRBBGG形式で指定)
# fade_color 日記が登録された時間帯の文字列のフェードアウト先の色 (RRBBGG形式で指定)
# init_css タイムライン文字列全体のCSS設定 (CSSの書式に準拠)
# entr_css 日記が登録された時間帯の文字列のCSS設定 (CSSの書式に準拠)
# title_text オブジェクト上にマウスをポイントした時のTIPS文字列 (任意の文字列)
# fade_time ログとして保存しておく(フェードアウトに要する)日数 (任意の数値)
# entr_interval 前回のエントリ登録から指定時間以内は新規登録しない (任意の数値)
#
# オプション値の設定方法には3つの方法があり、その優先順位は次の通りです。
# <%= tdiarytimes_textstyle %> 引数指定 > tdiary.conf設定値 > デフォルト値
#
# entr_intervalを除いた全てのオプション値は <%= %> への引数指定により設定出来るため、
# ページにごとに意匠を変更するなど自由度の高いサイトデザインが可能です。
# 一方で、全てのオプションにデフォルト値が用意されているため、
# 全く設定を行わなくても動作します。
# デフォルト値の具体的な値については、tdiary.confへの記述方法の項を参照して下さい。
#
#
# <%= tdiarytimes_textstyle %>への引数指定によるオプション設定方法
# --------------------------------------------------------------------
#【書式】
# <%= tdiarytimes_textstyle init_text, entr_text, init_color, entr_color, fade_color, init_css, entr_css, title_text, fade_time %>
#
#【記述例】
# <%=tdiarytimes_textstyle "●","●","004400","66ff66","004400","background-color:#002200;font-size:9px",nil,"TEXTSTYLE!!",15 %>
#
# ※ tdiary.conf指定値、またはデフォルト値を使用したい場合は、引数に nil を指定してください。
#
#
# tdiary.confへの記述によるオプション設定方法
# --------------------------------------------------------------------
#【記述例】 (例として指定されている値は、プラグイン本体の持つデフォルト値です)
# @options['tdiarytimes_textstyle.init_text'] = "|"
# @options['tdiarytimes_textstyle.entr_text'] = "|"
# @options['tdiarytimes_textstyle.init_color'] = "444444"
# @options['tdiarytimes_textstyle.entr_color'] = "eeeeee"
# @options['tdiarytimes_textstyle.fade_color'] = "444444"
# @options['tdiarytimes_textstyle.init_css'] = "background-color:#444444;"
# @options['tdiarytimes_textstyle.entr_css'] = ""
# @options['tdiarytimes_textstyle.title_text'] = "TDIARYTIMES-TEXTSTYLE"
# @options['tdiarytimes_textstyle.fade_time'] = 30
# @options['tdiarytimes_textstyle.entr_interval'] = 1
#
# ※ fade_time の単位は日、entr_interval の単位は時間です。
# ※ ログとして保存しておく期間(フェードアウト期間)を過ぎたデータエントリは、
# 指定期間経過後の次回日記追加時にログファイルから削除されます。
# この期間を決定する fade_time 値は、<%= %> 引数からは指定出来ません。
# デフォルト値(30日)以外の値を用いたい場合は、必ず tdiary.conf にて指定して下さい。
# 同様に、entr_interval もデフォルト値(1時間)以外に設定したい場合は、
# tdiary.conf にて指定して下さい。ちなみに0.5だと30分間隔になります。
#
#
# In secure mode:
# --------------------------------------------------------------------
# 現在のところ動作しません。(ログファイルを読み込めない為)
#
#
# Acknowledgements:
# --------------------------------------------------------------------
# This plugin is based on tdiarytimes.rb $Revision: 1.3 $
# Copyright (c) 2003 neuichi
# Distributed under the GPL
# http://nmnl.jp/hiki/software/?tDiary+%3A%3A+Plugin
#
#
=begin ChangeLog
2004.03.04 phonondrive
* version 1.0.4
非応答USER-AGENTリストを更新しました。
2004.02.05 phonondrive
* version 1.0.3
フェードアウト効果の計算結果が正しく出力されない点を修正しました。
2004.01.30 phonondrive
* version 1.0.2
最低登録間隔のオプション (entr_interval) を追加。
前回のエントリ登録から指定時間以内は新規登録しないようにしました。
2004.01.29 phonondrive
* version 1.0.1
replace(登録)時もエントリを記録するようにしました。
次のUSER-AGENTからの呼び出しには結果を出力しないようにしました。
モバイル端末 (tDiary準拠)
テキストブラウザ (w3m, Lynx, links)
CSS非対応ブラウザ (Mosaic, Lite, iCab, JustView, WebExplorer)
検索ボット (bot, crawler, Spider, Slurp, inktomi, Sidewinder, naver)
その他 (libwww, antenna)
2004.01.28 phonondrive
* version 1.0.0
=end
# tDiarytimes_textstyle の結果を出力しない USER-AGENT リスト
# モバイル端末、テキストブラウザ、CSS非対応ブラウザ、検索ボット、アンテナなど
# 大文字・小文字は区別しません。
def tdiarytimes_textstyle_ignore_user_agent; "w3m|Lynx|links|Mosaic|Lite|iCab|JustView|WebExplorer|bot|crawler|Spider|Slurp|inktomi|Sidewinder|naver|libwww|archiver|http|check|WDB|WWWC|WWWD|samidare|tamatebako|NATSU-MICAN|hina|antenna"; end
# --------------------------------------------------------------------
# 日記登録時の処理
# --------------------------------------------------------------------
if /^(append|replace)$/ =~ @mode then
# オプション値(エントリ保持期間)の読み込みと設定
fade_time = @options['tdiarytimes_textstyle.fade_time'] || 30
fade_time = 24 * 60 * 60 * fade_time.to_f
entr_interval = @options['tdiarytimes_textstyle.entr_interval'] || 1
entr_interval = 60 * 60 * entr_interval.to_f
# ログデータの読み込み
cache = "#{@cache_path}/tdiarytimes_textstyle"
Dir::mkdir( cache ) unless File::directory?( cache )
begin
io = open("#{cache}/tdiarytimes_textstyle.dat","r")
ary_data = Marshal.load(io)
io.close
# 1.0.1 >> 1.0.2 ログデータ移行用
if ary_data.size == 144
ary_data.push(Time.now.to_i - entr_interval - 1)
end
rescue
# ログがない場合は仮データを用意
ary_data = Array.new(145) {|i| 0 }
end
# 不良データや寿命が来たエントリを削除する
(0..143).each {|i|
delta = (Time.now.to_i - ary_data[i])/fade_time.to_f
if delta < 0 || delta > 1
ary_data[i] = 0
end
}
# 最低登録間隔を経過していたら、日記が登録された時間帯に新しいエントリをセットする
if (Time.now.to_i - ary_data[144]) > entr_interval.to_f
ary_data[(Time.now.strftime('%H').to_i*6 + Time.now.strftime('%M').to_f/10).to_i] = Time.now.to_i
# 最終登録時間の記録
ary_data[144] = Time.now.to_i
end
# ログデータの書き込み
io = open("#{cache}/tdiarytimes_textstyle.dat","w")
Marshal.dump(ary_data,io)
io.close
end
# --------------------------------------------------------------------
# プラグイン表示時の動作
# --------------------------------------------------------------------
def tdiarytimes_textstyle(init_text = nil, entr_text = nil, init_color = nil, entr_color = nil, fade_color = nil, init_css = nil, entr_css = nil, title_text = nil, fade_time = nil)
# モバイル端末、テキストブラウザ、CSS非対応ブラウザ、検索ボットなどには結果を出力しない
unless @cgi.mobile_agent? || @cgi.user_agent =~ %r[(#{tdiarytimes_textstyle_ignore_user_agent})]i
r = ""
# オプション値の読み込みと設定
init_text = @options['tdiarytimes_textstyle.init_text'] || "|" unless init_text
entr_text = @options['tdiarytimes_textstyle.entr_text'] || "|" unless entr_text
init_color = @options['tdiarytimes_textstyle.init_color'] || "444444" unless init_color
entr_color = @options['tdiarytimes_textstyle.entr_color'] || "eeeeee" unless entr_color
fade_color = @options['tdiarytimes_textstyle.fade_color'] || "444444" unless fade_color
init_css = @options['tdiarytimes_textstyle.init_css'] || "background-color:#444444;" unless init_css
entr_css = @options['tdiarytimes_textstyle.entr_css'] || "" unless entr_css
title_text = @options['tdiarytimes_textstyle.title_text'] || "TDIARYTIMES-TEXTSTYLE" unless title_text
fade_time = @options['tdiarytimes_textstyle.fade_time'] || 30 unless fade_time
entr_color_rgb = entr_color.unpack("a2a2a2")
fade_color_rgb = fade_color.unpack("a2a2a2")
fade_time = 24 * 60 * 60 * fade_time.to_f
# ログデータの読み込み
cache = "#{@cache_path}/tdiarytimes_textstyle"
begin
io = open("#{cache}/tdiarytimes_textstyle.dat","r")
ary_data = Marshal.load(io)
io.close
rescue
# ログファイルが見つからない場合はエラーとダミーデータを表示
r << %Q|Error! cannot open log file.|
ary_data = Array.new(145) {|i| 0 }
end
# htmlデータの出力
r << %Q||
(0..143).each {|i|
data = ary_data[i]
if data != 0
delta = (Time.now.to_i - data)/fade_time.to_f
if delta < 0
# 不良エントリ対策
now_color = init_color
elsif delta > 1
# フェードアウト期間超過エントリ対策
now_color = fade_color
else
# 正常なエントリの処理
now_color = ""
(0..2).each{|i|
now_color << format("%02x", entr_color_rgb[i].hex + ((fade_color_rgb[i].hex - entr_color_rgb[i].hex)*delta).to_i)
}
end
r << %Q|#{entr_text} |
else
r << %Q|#{init_text}|
end
}
r << %Q| |
end
end
tdiary-contrib-3.2.2/plugin/title_anchor.rb 0000664 0000000 0000000 00000000444 12136327440 0020752 0 ustar 00root root 0000000 0000000 #
# title_anchor.rb:
#
# Copyright (C) 2007 by SHIBATA Hiroshi
# Distributed under GPL2.
#
def title_anchor
r = ''
if /^latest$/ =~ @mode
r << %Q|#{h @conf.html_title} |
else
r << %Q||
end
r
end
tdiary-contrib-3.2.2/plugin/tweet_quote.rb 0000664 0000000 0000000 00000006462 12136327440 0020652 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
#
# tweet_quote.rb - tDiary plugin to quote tweet on twitter.com,
# formaly known as blackbird-pie.rb
#
# Copyright (C) 2010, hb
#
# usage:
# <%= tweet_quote "id|url" %>
# or
# <%= twitter_quote "id|url" %>
# or
# <%= blackbird_pie "id|url" %>
# or
# <%= bbp "id|url" %>
#
require 'pstore'
require 'open-uri'
require 'timeout'
require 'rexml/document'
require 'time'
require 'uri'
def twitter_statuses_show_api( tweet_id )
url = "http://api.twitter.com/1/statuses/show/#{tweet_id}.xml"
proxy = @conf['proxy']
proxy = 'http://' + proxy if proxy
timeout( 20 ) do
open( url, :proxy => proxy ) {|f| f.read }
end
end
def tweet_quote( src )
if %r|http(?:s)?://twitter.com/(?:#!/)?[^/]{1,15}/status(?:es)?/([0-9]+)| =~ src.to_s.downcase
src = $1
end
return unless /\A[0-9]+\z/ =~ src.to_s
cache = "#{@cache_path}/blackbird.pstore"
xml = nil
db = PStore.new( cache )
db.transaction do
key = src
db[key] ||= {}
if db[key][:xml]
xml = db[key][:xml]
else
begin
xml = twitter_statuses_show_api( src )
rescue OpenURI::HTTPError
return %Q|#$!
|
end
db[key][:xml] = xml
end
end
doc = REXML::Document::new( REXML::Source.new( xml ) ).root
tweet_id = doc.elements['//id'].text
screen_name = doc.elements['//user/screen_name'].text
name = doc.elements['//user/name'].text
background_url = doc.elements['//user/profile_background_image_url'].text
profile_background_color = '#' + doc.elements['//user/profile_background_color'].text
avatar = doc.elements['//user/profile_image_url'].text
source = doc.elements['//source'].text
timestamp = Time.parse( doc.elements['//created_at'].text ).to_s
content = doc.elements['//text'].text
content.gsub!( URI.regexp( %w|http https| ) ){ %Q|#{$&} | }
content = content.split( /(<[^>]*>)/ ).map do |s|
next s if s[/\A]
s.gsub!( /@(?>([a-zA-Z0-9_]{1,15}))(?![a-zA-Z0-9_])/ ){ %Q|#{$&} | }
s.gsub( /#([a-zA-Z0-9]{1,16})/ ){ %Q|#{$&} | }
end.join
r = <<-HTML
HTML
end
alias :blackbird_pie :tweet_quote
alias :bbp :tweet_quote
alias :twitter_quote :tweet_quote
tdiary-contrib-3.2.2/plugin/twitpic.rb 0000664 0000000 0000000 00000000674 12136327440 0017767 0 ustar 00root root 0000000 0000000 #
# twitpic.rb: plugin to insert images on twitpic.com.
#
# Copyright (C) 2010 TADA Tadashi
# You can redistribute it and/or modify it under GPL2.
#
def twitpic( image_id, label = 'image on Twitpic', place = 'photo' )
%Q| |
end
tdiary-contrib-3.2.2/plugin/twitter.rb 0000664 0000000 0000000 00000002316 12136327440 0020001 0 ustar 00root root 0000000 0000000 # twitter.rb $Revision: 1.1 $
# Copyright (C) 2007 Michitaka Ohno
# 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( 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[]
r << %Q[
]
today_statuses.sort{|a, b| b.last<=>a.last}.each do |t, d|
r << %Q[
#{CGI::escapeHTML( t )} (#{d.strftime( '%H:%M:%S' )})
]
end
r << %Q[
]
else
''
end
end
tdiary-contrib-3.2.2/plugin/twitter_anywhere.rb 0000664 0000000 0000000 00000012725 12136327440 0021710 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
#
# twitter_anywhere.rb - bringing the Twitter communication platform to tDiary
# refer to the URL below.
# https://dev.twitter.com/docs/anywhere/welcome
#
# Copyright (C) 2010-2012, tamoot
# You can redistribute it and/or modify it under GPL2.
#
def follow_button(account)
return not_support_anywhere unless support_anywhere?
return not_ready_anywhere unless ready_anywhere?
if account.nil? || account == ''
return anywhere_plugin_error("Account name is not specified.")
end
<<-FOLLOW_API
FOLLOW_API
end
def tweet_box(label = nil, content = nil, option = {})
return not_support_anywhere unless support_anywhere?
return not_ready_anywhere unless ready_anywhere?
init_tweetbox
@tweetbox_opt.merge!(option)
@tweetbox_opt.merge!(:height => 120) unless option[:height].to_i > 0
@tweetbox_opt.merge!(:width => 480) unless option[:width].to_i > 0
@tweetbox_opt.merge!(:label => label) if label
@tweetbox_opt.merge!(:defaultContent => content) if content
%Q||
end
def twitter_anywhere_settings
enable_js('twitter_anywhere.js')
add_js_setting('$tDiary.plugin.twitter_anywhere')
selectors = @conf['twitter_anywhere.hovercards.selectors'].split(',').collect do |selector|
%Q|"#{selector.strip}"|
end
add_js_setting('$tDiary.plugin.twitter_anywhere.selectors',
"[#{selectors.join(',')}]" )
expanded = '{}'
if @conf['twitter_anywhere.hovercards.expand_default'] == 'true'
expanded = '{"expanded":true}'
end
add_js_setting('$tDiary.plugin.twitter_anywhere.hovercards')
add_js_setting('$tDiary.plugin.twitter_anywhere.hovercards.expand_default',
expanded)
end
add_header_proc do
if /\A(?:latest|day|month|nyear|preview)\z/ =~ @mode
if ready_anywhere?
%Q||
else
''
end
end
end
def init_tweetbox
@tweetbox_json_opt ||= []
@tweetbox_opt ||= {}
end
add_footer_proc do |date|
if /\A(?:latest|day|month|nyear|preview)\z/ =~ @mode
if ready_anywhere?
init_tweetbox
@tweetbox_opt.each_pair do |k, v|
@tweetbox_json_opt << "\"#{k}\":\"#{v}\""
end
tweet_box_call = %Q|\n|
else
''
end
else
''
end
end
add_conf_proc( 'twitter_anywhere', 'Twitter Anywhere' ) do
if @mode == 'saveconf' then
@conf['twitter_anywhere.id'] = @cgi.params['twitter_anywhere.id'][0]
@conf['twitter_anywhere.hovercards.selectors'] = @cgi.params['twitter_anywhere.hovercards.selectors'][0]
@conf['twitter_anywhere.hovercards.expand_default'] = @cgi.params['twitter_anywhere.hovercards.expand_default'][0]
end
expand_true = ""
expand_false = "selected"
if @conf['twitter_anywhere.hovercards.expand_default'] == "true"
expand_true = "selected"
expand_false = ""
end
<<-HTML
Consumer key
Register your tDiary and get Consumer key.
Go Twitter OAuth settings.
Rending Hovercards
CSS Selector To limit the scope of where Hovercards appear
example) div.section p, div.commentshort p, div.commentbody p
Expanded by Default
true
false
HTML
end
def support_anywhere?
return false if @conf.mobile_agent? || feed?
return true
end
def ready_anywhere?
if @conf['twitter_anywhere.id'] && @conf['twitter_anywhere.id'].size > 0
return true
end
return false
end
def not_support_anywhere
'[Twitter@Anywhere] not support this environment.'
end
def not_ready_anywhere
anywhere_plugin_error(
"Twitter consumer Key not specified.",
%Q|Go Twitter OAuth settings. |)
end
def anywhere_plugin_error(message, detail= '')
<<-PLUGIN_ERROR
[ERROR] twitter_anywhere.rb: #{message}
#{detail}
PLUGIN_ERROR
end
if /\A(?:latest|day|month|nyear|preview)\z/ =~ @mode
twitter_anywhere_settings
end
# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:
# vim: ts=3
tdiary-contrib-3.2.2/plugin/twitter_badge.rb 0000664 0000000 0000000 00000002104 12136327440 0021116 0 ustar 00root root 0000000 0000000 #
# twitter_badge.rb: insert 'Follow me' badge of Twitter.
#
# Copyright (C) 2010 TADA Tadashi
# You can redistribute it and/or modify it under GPL2.
#
def twitter_badge( account, opt = {} )
return '' unless account
@twitter_badge_setting = {
:account => account,
:label => (opt[:label] || 'follow-me'),
:color => (opt[:color] || '#35ccff'),
:side => (opt[:side] || 'right')[0,1],
:top => (opt[:top] || 136).to_i,
:delay => (opt[:delay] || 5).to_i * 1000,
}
'' # do nothing in this method.
end
add_footer_proc do
if @twitter_badge_setting then
t = @twitter_badge_setting
<<-TEXT
TEXT
else
''
end
end
tdiary-contrib-3.2.2/plugin/twitter_js.rb 0000664 0000000 0000000 00000003560 12136327440 0020477 0 ustar 00root root 0000000 0000000 # twitter_js.rb $Revision: 1.1 $
# Copyright (C) 2007 Michitaka Ohno
# You can redistribute it and/or modify it under GPL2.
if /\A(?:latest|day)\z/ =~ @mode then
if @conf['twitter.user'] then
twitter_user = @conf['twitter.user']
add_header_proc do
result = <<-HTML
HTML
result.gsub( /^\t\t/, '' )
end
add_body_leave_proc do |date|
result = <<-HTML
HTML
result.gsub( /^\t\t/, '' )
end
end
end
add_conf_proc( 'twitter_js', 'Twitter' ) do
if @mode == 'saveconf' then
@conf['twitter.user'] = @cgi.params['twitter.user'][0]
end
<<-HTML
Account Name
HTML
end
tdiary-contrib-3.2.2/plugin/ustream.rb 0000664 0000000 0000000 00000001161 12136327440 0017754 0 ustar 00root root 0000000 0000000 #
# ustream.rb - insert some services of Ustream.tv
#
# Copyright (C) 2010, TADA Tadashi .
# You can redistribute it and/or modify it under GPL2.
#
def ustream( id, type = :recorded )
if type == :live then
return ''
end
# insert recorded video
if @conf.mobile_agent? or @conf.iphone? or feed? then
return %Q|Link to Ustream ##{id} |
end
%Q||
end
tdiary-contrib-3.2.2/plugin/vimeo.rb 0000664 0000000 0000000 00000000772 12136327440 0017422 0 ustar 00root root 0000000 0000000 #
# vimeo.rb - insert some services of vimeo.com
#
# Copyright (C) 2011, Kiwamu Okabe .
# You can redistribute it and/or modify it under GPL2.
#
def vimeo( id )
if @conf.mobile_agent? or @conf.iphone? or feed? then
return %Q|Link to vimeo ##{id}
|
end
%Q||
end
tdiary-contrib-3.2.2/plugin/volatile.rb 0000664 0000000 0000000 00000004647 12136327440 0020127 0 ustar 00root root 0000000 0000000 # hide old diaries
#
# options configurable through settings:
# @conf['volatile.limit'] : number of diaries to show
#
# Copyright (c) MATSUOKA Kohei
# Distributed under the GPL
#
module ::TDiary
# 複数の日記を一括して更新するためのクラス
class TDiaryBulkUpdate < TDiaryUpdate
def initialize( cgi, rhtm, conf )
super
date = Time::local( *cgi.params['date'][0].scan( /^(\d{4})(\d\d)$/ )[0] )
@io.transaction( date ) do |diaries|
yield(diaries)
# DIRTY_DIARYは@ioへ日記を更新することを伝えるフラグ
DIRTY_DIARY
end
end
end
end
# 古い日記を非表示にするプラグイン
class VolatileDiaryPlugin
def initialize(conf)
@conf = conf
@limit = conf['volatile.limit'] || 10
end
# all を true にすると全ての日記を対象とする
def update(years, all = false)
each_recent_diary(years) do |date, diary, count|
diary.show(count <= @limit)
all || count <= @limit
end
end
def each_recent_diary(years)
cgi = CGI.new
count = 1
break_flag = false
years.keys.sort.reverse_each do |year|
years[year].sort.reverse_each do |month|
cgi.params['date'] = ["#{year}#{month}"]
cgi.params['year'] = [year]
cgi.params['month'] = [month]
cgi.params['day'] = ["1"]
m = TDiaryBulkUpdate::new(cgi, '', @conf) {|diaries|
# diaries.class is Hash (date => diary)
diaries.sort.reverse_each do |date, diary|
unless yield(date, diary, count)
break_flag = true
break
end
count += 1
end
}
break if break_flag
end
break if break_flag
end
end
end
add_update_proc do
# 古い日記を非表示にする
plugin = VolatileDiaryPlugin.new(@conf)
plugin.update(@years)
end
add_conf_proc('volatile', "揮発性日記", 'update') do
if @mode == 'saveconf' then
@conf['volatile.limit'] = @cgi.params['volatile.limit'][0].to_i
p = VolatileDiaryPlugin.new(@conf)
p.update(@years, true)
end
r = <<-HTML
日記の更新時に古い日記を非表示にします。
公開する日記の件数
公開したい日記の件数を入力してください。
HTML
r
end
tdiary-contrib-3.2.2/plugin/vote.rb 0000664 0000000 0000000 00000005612 12136327440 0017256 0 ustar 00root root 0000000 0000000 # tdiary_vote.rb $Revision: 2 $
# Copyright (C) 2006 Michitaka Ohno
# You can redistribute it and/or modify it under GPL2.
#
# ref. http://elpeo.jp/diary/20060622.html#p01
#
# .tdiary-vote {
# float: left;
# background-color: aqua;
# }
require 'digest/md5'
require 'pstore'
@tdiary_vote_db = "#{@cache_path}/tdiary_vote"
@tdiary_vote_label = "投票"
@tdiary_vote_date = nil
def vote( *items )
return '' unless @tdiary_vote_date
h, voted = get_vote( @tdiary_vote_date, @cgi.cookies['tdiary_vote'][0] )
max = h.empty? ? 1 : h.values.max
r = %Q[]
items.sort{|a, b| h[b] <=> h[a]}.each do |item|
num = h[item]
r << %Q[]
r << %Q[#{CGI.escapeHTML( item )} ]
r << %Q[ #{num} ]
unless voted then
r << %Q[]
r << %Q[]
r << %Q[ ]
end
r << %Q[ ]
end
r << %Q[
]
end
def get_vote( date, uid )
h = Hash.new(0)
voted = false
file = "#{@tdiary_vote_db}/#{date.strftime( "%Y%m%d" )}.db"
if File.exist?( file ) then
PStore.new( file ).transaction do |db|
h.update( db['vote'] ) if db.root?( 'vote' )
voted = db['voter'].include?( uid ) if db.root?( 'voter' )
db.abort
end
end
[h, voted]
end
def add_vote( date, item, uid )
Dir::mkdir( @tdiary_vote_db ) unless File::directory?( @tdiary_vote_db )
file = "#{@tdiary_vote_db}/#{date.strftime( "%Y%m%d" )}.db"
PStore.new( file ).transaction do |db|
db['voter'] = Hash.new unless db.root?( 'voter' )
db.abort if db['voter'].include?( uid )
db['voter'][uid] = @cgi.remote_addr
db['vote'] = Hash.new(0) unless db.root?( 'vote' )
db['vote'][item] += 1
end
end
add_body_enter_proc do |date|
@tdiary_vote_date = date
''
end
add_body_leave_proc do |date|
@tdiary_vote_date = nil
''
end
unless bot? then
if @mode == 'comment' && @cgi.valid?( 'vote' ) && @cgi.cookies['tdiary_vote'][0] then
add_vote( @date, @cgi.params['vote'][0], @cgi.cookies['tdiary_vote'][0] )
end
add_footer_proc do
uid = @cgi.cookies['tdiary_vote'][0] || Digest::MD5.hexdigest( @cgi.remote_addr + Time.now.to_s + rand.to_s )
cookie_path = File::dirname( @cgi.script_name )
cookie_path += '/' if cookie_path !~ /\/$/
cookie = CGI::Cookie::new(
'name' => 'tdiary_vote',
'value' => uid,
'path' => cookie_path,
'expires' => Time.now.gmtime + 30*24*60*60
)
add_cookie( cookie )
''
end
end
tdiary-contrib-3.2.2/plugin/wikiloc.rb 0000664 0000000 0000000 00000001733 12136327440 0017742 0 ustar 00root root 0000000 0000000 #
# wikiloc.rb: plugin embedding trip map on wikiloc.
#
# Copyright (C) 2008 MUNEDA Takahiro
# You can redistribute it and/or modify it under GPL2.
#
# derived from everytrail.rb, Copyright (C) 2008 TADA Tadashi
#
# Parameters:
# @trip_id : your trip id
# @measures : on/off
# @maptype : M/S/H/T
# @size : [width,height]
#
# Please see the following address about the details:
# http://www.wikiloc.com/forum/posts/list/14.page
#
# ChangeLog:
# 20080706: Initial release
# 20080713: Change default parameters
#
def wikiloc( trip_id, measures = "off", maptype = "M", size = [500,400] )
size.collect! {|i| i.to_i }
size[0] = 500 if size[0] == 0
size[1] = 400 if size[1] == 0
%Q||
end
tdiary-contrib-3.2.2/plugin/windex.rb 0000664 0000000 0000000 00000032711 12136327440 0017577 0 ustar 00root root 0000000 0000000 #!/usr/bin/env ruby
# windex.rb $Revision: 1.2 $
#
# windex: 索引を生成する
# パラメタ:
# str: キーワード文字列
# readname: 読み仮名
#
# wikw: 索引からアンカーを生成する
# パラメタ:
# str: キーワード文字列
#
# このファイルをtDiaryのトップディレクトリにも配置し、CGIとして
# 実行することで索引ページを出力できます。
#
# CGI動作時の引数
# http://(日記URL)/windex.rb?kw=(キーワード文字列)
# とキーワードを指定してアクセスすることでそのキーワードに関係する日記の
# 日付一覧を出力できます。一つだけの場合にはその日付の日記への
# リダイレクトを出力します。
#
# tdiary.confによる設定
# @options['windex.generate_all'] = true
# 全ての日記から索引を生成します。これは時間がかかるので、索引の全生成を
# 行いたいときだけtrueに設定して更新を行うような使い方を想定しています。
#
# Copyright (c) 2003 Gony
# Distributed under the GPL
#
mode = ""
if $0 == __FILE__
mode = "CGI"
if FileTest.symlink?(__FILE__) == true
org_path = File.dirname(File.readlink(__FILE__))
else
org_path = File.dirname(__FILE__)
end
$:.unshift(org_path)
require "pstore"
require "tdiary"
tdiarybase = TDiary::TDiaryBase
else
tdiarybase = TDiaryBase
end
class WITDiary < tdiarybase
def load_plugins
super
end
def generate_wordindex(date,plugin,index)
wordindex = WIWordIndex.new
@io.transaction(date) do |diaries|
wordindex.generate(diaries,plugin,index)
end
return wordindex
end
end
class WIWordIndex
def initialize
@windex = {}
@dates = []
end
def generate(diaries,plugin,index)
diaries.each_value do |diary|
num_section = 1
diary.each_section do |section|
anchor = index \
+ plugin.anchor(diary.date.strftime("%Y%m%d")) \
+ "#p%02d" % num_section
if section.subtitle != nil
scan(section.subtitle,anchor)
end
scan(section.body,anchor)
num_section = num_section + 1
end
end
end
def load(dir)
@windex = {}
Dir.mkdir(dir) unless File.directory?(dir)
PStore.new(dir + "/windex").transaction do |pstore|
@dates = pstore.roots
@dates.each do |key|
windex_tmp = pstore[key]
windex_tmp.each_key do |key_windex|
if @windex.has_key?(key_windex) == false
@windex[key_windex] = {"readname" => nil,
"anchor" => []}
end
if @windex[key_windex]["readname"] == nil \
&& windex_tmp[key_windex].has_key?("readname") == true
@windex[key_windex]["readname"] = windex_tmp[key_windex]["readname"]
end
@windex[key_windex]["anchor"].concat(windex_tmp[key_windex]["anchor"])
end
end
end
end
def save(dir,keyname)
if File.directory?(dir) == false
Dir.mkdir(dir,0755)
end
PStore.new(dir + "/windex").transaction do |pstore|
pstore[keyname] = @windex
end
end
def generate_html(page)
return page.generate_html(@windex)
end
def has_key?(key)
return @windex.has_key?(key)
end
def [](key)
return @windex[key]
end
private
def scan(body,anchor)
to_delimiter_end = {
"(" => ")","[" => "]","{" => "}","<" => ">",
}
wistrs = body.scan(%r[<%\s*=\s*windex\s*[^(<%)]*\s*%>])
wistrs.each do |wistr|
# 引数抽出
argstr = wistr.gsub(%r[<%\s*=\s*windex\s*],"")
argstr = argstr.gsub(%r[\s*%>],"")
args = []
flag_done = false
while flag_done == false
pos_delimiter = argstr.index(%r['|"|%[Qq].]) #"'
if pos_delimiter != nil
# デリミタ文字取得
delimiter = argstr.scan(%r['|"|%[Qq].])[0] #"'
if delimiter.length == 3
delimiter_end = delimiter[2].chr
if to_delimiter_end.has_key?(delimiter_end)
delimiter_end = to_delimiter_end[delimiter_end]
end
else
delimiter_end = delimiter
end
# デリミタまでの文字列を削除
argstr = argstr[(pos_delimiter + delimiter.length)..-1]
pos_delimiter = argstr.index(delimiter_end)
if pos_delimiter != nil
if pos_delimiter > 0
# 引数として取得
args << argstr[0..(pos_delimiter - 1)]
else
args << ""
end
# デリミタまでの文字列を削除
argstr = argstr[(pos_delimiter + delimiter_end.length)..-1]
else
flag_done = true
end
else
flag_done = true
end
end
if args.length > 0
if @windex.has_key?(args[0]) == false
# ハッシュを生成
@windex[args[0]] = {"readname" => nil,"anchor" => []}
end
if args.length > 1 && @windex[args[0]]["readname"] == nil && args[1] != ""
@windex[args[0]]["readname"] = args[1]
end
@windex[args[0]]["anchor"] << anchor
end
end
end
end
class WIIndexPage
def initialize(title,css)
@title = title
@css = css
end
def generate_html(windex)
body = ""
# 大項目名 => 名前の配列 のハッシュを生成
subindex_to_name = {}
windex.keys.each do |key|
subindex = ""
if windex[key]["readname"] != nil
subindex = get_subindex(windex[key]["readname"])
else
subindex = get_subindex(key)
end
if subindex_to_name.has_key?(subindex) == false
subindex_to_name[subindex] = []
end
subindex_to_name[subindex] << key
end
# 大項目名ごとにHTMLを生成
if subindex_to_name.has_key?("記号") == true
body << generate_html_subindex(windex,subindex_to_name,"記号")
end
subindex_to_name.keys.sort.each do |key|
if key != "記号"
body << generate_html_subindex(windex,subindex_to_name,key)
end
end
body = <<-BODY
#{h @title}(索引)
#{@css}
#{@title} [索引]
BODY
return body
end
private
def generate_html_subindex(windex,subindex_to_name,key)
readname_to_name = {}
subindex_to_name[key].each do |name|
key_new = ""
if windex[name]["readname"] != nil
key_new = windex[name]["readname"]
else
key_new = name
end
if readname_to_name.has_key?(key_new) == false
readname_to_name[key_new] = []
end
readname_to_name[key_new] << name
end
body = %Q[#{key} \n]
# 読み仮名のソートでループ -> 名前のソートでループ
keys = readname_to_name.keys
if keys.empty? == false
keys.sort.each do |readname|
readname_to_name[readname].sort.each do |name|
body << "
#{name} ... "
num_anchor = 1
windex[name]["anchor"].sort.each do |anchor|
body = body + %Q[#{num_anchor} ]
if num_anchor < windex[name]["anchor"].length
body = body + ","
end
num_anchor = num_anchor + 1
end
body << "
"
end
end
end
body << "\n
\n"
return body
end
def get_subindex(name)
to_plainhiragana = {
"ぁ" => "あ","ぃ" => "い","ぅ" => "う","ぇ" => "え","ぉ" => "お",
"が" => "か","ぎ" => "き","ぐ" => "く","げ" => "け","ご" => "こ",
"ざ" => "さ","じ" => "し","ず" => "す","ぜ" => "せ","ぞ" => "そ",
"だ" => "た","ぢ" => "ち","っ" => "つ","づ" => "つ","で" => "て","ど" => "と",
"ば" => "は","ぱ" => "は","び" => "ひ","ぴ" => "ひ","ぶ" => "ふ","ぷ" => "ふ","べ" => "へ","ぺ" => "へ","ぼ" => "ほ","ぽ" => "ほ",
"ゃ" => "や","ゅ" => "ゆ","ょ" => "よ",
"ゎ" => "わ","ヴ" => "う","ヵ" => "か","ヶ" => "け",
}
to_1byte = {
"!" => "!",'”' => '"',"#" => "#","$" => "$","%" => "%","&" => "&","’" => "'","(" => "(",")" => ")","*" => "*","+" => "+","," => ",","−" => "-","." => ".","/" => "/",
"0" => "0","1" => "1","2" => "2","3" => "3","4" => "4","5" => "5","6" => "6","7" => "7","8" => "8","9" => "9",":" => ":",";" => ";","<" => "<","=" => "=",">" => ">","?" => "?",
"@" => "@","A" => "A","B" => "B","C" => "C","D" => "D","E" => "E","F" => "F","G" => "G","H" => "H","I" => "I","J" => "J","K" => "K","L" => "L","M" => "M","N" => "N","O" => "O",
"P" => "P","Q" => "Q","R" => "R","S" => "S","T" => "T","U" => "U","V" => "V","W" => "W","X" => "X","Y" => "Y","Z" => "Z","[" => "[","¥" => "\\","]" => "]","^" => "^","_" => "_",
"a" => "a","b" => "b","c" => "c","d" => "d","e" => "e","f" => "f","g" => "g","h" => "h","i" => "i","j" => "j","k" => "k","l" => "l","m" => "m","n" => "n","o" => "o",
"p" => "p","q" => "q","r" => "r","s" => "s","t" => "t","u" => "u","v" => "v","w" => "w","x" => "x","y" => "y","z" => "z","{" => "{","|" => "|","}" => "}","‾" => "~",
}
topchr = name[0,1]
if topchr.count("\xA1-\xFE") == 1
# マルチバイト文字
topchr = name[0,2]
end
if to_1byte.has_key?(topchr) == true
topchr = to_1byte[topchr]
end
if topchr.length == 1
# シングルバイト文字の処理
topchr = topchr.upcase
if (0x21 <= topchr[0] && topchr[0] <= 0x2F) \
|| (0x3A <= topchr[0] && topchr[0] <= 0x40) \
|| (0x5B <= topchr[0] && topchr[0] <= 0x60) \
|| (0x7B <= topchr[0] && topchr[0] <= 0x7B)
topchr = "記号"
end
else
# マルチバイト文字の処理
# カタカナ->ひらがな変換
code = topchr[0] * 0x100 + topchr[1]
if 0xA5A1 <= code && code <= 0xA5F3
topchr = 0xA4.chr + topchr[1].chr
end
# 濁点 / 半濁点 撥音など変換
if to_plainhiragana.has_key?(topchr) == true
topchr = to_plainhiragana[topchr]
end
end
return topchr
end
end
class WIRedirectPage
def initialize(key)
@key = key
end
def generate_html(windex)
anchor = windex[@key]["anchor"][0]
body = <<-BODY
moving...
Wait or Click here!
BODY
return body
end
end
class WISinglePage
def initialize(title,date_format,css,key)
@title = title
@date_format = date_format
@css = css
@key = key
end
def generate_html(windex)
anchors = windex[@key]["anchor"]
body = %Q[#{@key} \n]
anchors.sort.each do |anchor|
str_date = anchor.scan(/\d{8}/)[0]
date = Time.local(str_date[0..3].to_i,str_date[4..5].to_i,str_date[6..7].to_i)
body << %Q[
#{date.strftime(@date_format)}
\n]
end
body << "\n
\n"
body = <<-BODY
#{h @title}(索引)
#{@css}
#{@title} [索引]
BODY
return body
end
end
class WIErrorPage
def initialize(title,css,key)
@title = title
@css = css
@key = key
end
def generate_html(windex)
body = <<-BODY
#{h @title}(索引)
#{@css}
#{@title} [索引]
キーワード「#{h @key}」は登録されていません。
BODY
return body
end
end
def windex(str,readname = "")
return str
end
def wikw(str)
if @wordindex.has_key?(str) == true
anchors = @wordindex[str]["anchor"]
if anchors.length == 1
return %Q[#{str} ]
else
body = "#{str}("
num_anchor = 1
anchors.sort.each do |anchor|
body << %Q[#{num_anchor} ]
if num_anchor < anchors.length
body << ","
end
num_anchor = num_anchor + 1
end
body << ")"
return body
end
end
return str
end
if mode != "CGI"
@wordindex = WIWordIndex.new
@wordindex.load(@cache_path + "/windex")
add_update_proc do
if @conf.options["windex.generate_all"] == true
tdiary = WITDiary.new(@cgi,"day.rhtml",@conf)
@years.each_key do |year|
@years[year.to_s].each do |month|
date = Time::local(year,month)
wordindex = tdiary.generate_wordindex(date,self,@conf.index)
wordindex.save(@cache_path + "/windex",date.strftime('%Y%m'))
end
end
else
wordindex = WIWordIndex.new
wordindex.generate(@diaries,self,@conf.index)
wordindex.save(@cache_path + "/windex",@date.strftime('%Y%m'))
end
end
else
cgi = CGI.new
conf = TDiary::Config.new(cgi)
cache_path = conf.data_path + "cache"
plugin = WITDiary.new(cgi,"day.rhtml",conf).load_plugins
wordindex = WIWordIndex.new
wordindex.load(cache_path + "/windex")
if cgi.valid?('kw') == true
key = cgi.params['kw'][0]
if wordindex.has_key?(key) == true
num_anchor = wordindex[key]["anchor"].length
if num_anchor == 0
page = WIErrorPage.new(conf.html_title,plugin.css_tag,key)
elsif num_anchor == 1
page = WIRedirectPage.new(key)
else
page = WISinglePage.new(conf.html_title,conf.date_format,plugin.css_tag,key)
end
else
page = WIErrorPage.new(conf.html_title,plugin.css_tag,key)
end
else
page = WIIndexPage.new(conf.html_title,plugin.css_tag)
end
body = wordindex.generate_html(page)
header = {
"type" => "text/html",
"charset" => "UTF-8",
"Content-Length" => body.size.to_s,
"Pragma" => "no-cache",
"Cache-Control" => "no-cache",
"Vary" => "User-Agent",
}
head = cgi.header(header)
print head
print body
end
tdiary-contrib-3.2.2/plugin/yahoo_kousei.rb 0000664 0000000 0000000 00000005436 12136327440 0021003 0 ustar 00root root 0000000 0000000 #
# yahoo_kousei.rb -
# Yahoo!JAPANデベロッパーネットワークの校正支援APIを利用して、
# 日本語文の校正作業を支援します。文字の入力ミスや言葉の誤用がないか、
# わかりにくい表記や不適切な表現が使われていないかなどをチェックします。
#
# Copyright (c) 2010, hb
# You can redistribute it and/or modify it under GPL.
#
# 設定:
#
# @options['yahoo_kousei.appid'] : アプリケーションID(必須)
# @options['yahoo_kousei.filter_group'] :
# 指摘グループの番号をコンマで区切って指定します。
# @options['yahoo_kousei.no_filter'] :
# filter_groupで指定した指摘グループから除外する指摘を指定します。
#
# 設定値は http://developer.yahoo.co.jp/webapi/jlp/kousei/v1/kousei.html を参照
#
require 'timeout'
require 'rexml/document'
require 'net/http'
Net::HTTP.version_1_2
def kousei_api( sentence )
appid = @conf['yahoo_kousei.appid']
query = "appid=#{appid}&sentence=#{URI.encode( sentence.gsub( /\n/, '' ) )}"
query << "&filter_group=" + @conf['yahoo_kousei.filter_group'] if @conf['yahoo_kousei.filter_group']
query << "&no_filter=" + @conf['yahoo_kousei.no_filter'] if @conf['yahoo_kousei.no_filter']
px_host, px_port = (@conf['proxy'] || '').split( /:/ )
px_port = 80 if px_host and !px_port
xml = ''
Net::HTTP::Proxy( px_host, px_port ).start( 'jlp.yahooapis.jp' ) do |http|
xml = http.post( '/KouseiService/V1/kousei', query ).body
end
xml
end
def kousei_result( result_set )
html = <<-HTML
文章校正結果
HTML
doc = REXML::Document::new( result_set )
results = REXML::XPath.match( doc, "//Result" )
if results.empty?
html << "指摘項目は見つかりませんでした。
"
else
html << ''
html << '対象表記 候補文字 詳細情報 場所 '
doc.elements.each( '//ResultSet/Result' ) do |r|
html << %Q|#{r.elements['Surface'].text} #{r.elements['ShitekiWord'].text} #{r.elements['ShitekiInfo'].text} #{r.elements['StartPos'].text},#{r.elements['Length'].text} |
end
html << '
'
end
html
end
add_edit_proc do
if @mode == 'preview' && @conf['yahoo_kousei.appid'] then
xml = kousei_api( @cgi.params['body'][0] )
<<-HTML
HTML
end
end
if /\A(form|edit|preview|showcomment)\z/ === @mode then
enable_js( 'yahoo_kousei.js' )
end
tdiary-contrib-3.2.2/plugin/yahoo_map.rb 0000664 0000000 0000000 00000007117 12136327440 0020257 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
#
# yahoo_map.rb - embeded Yahoo! JAPAN Map for tDiary
#
# Copyright (C) 2010, KAYA Satoshi
# You can redistribute it and/or modify it under GPL2.
#
add_header_proc do
init_ymap
r = ''
if @conf['yahoo_jp.appid'] and @conf['yahoo_jp.appid'].size > 0
r << %Q||
end
end
add_conf_proc( 'yahoo_jp_appid', 'Yahoo! JAPAN Application ID' ) do
if @mode == 'saveconf' then
@conf['yahoo_jp.appid'] = @cgi.params['yahoo_jp.appid'][0]
end
<<-HTML
Yahoo! JAPAN Application ID
Get Application id
HTML
end
add_footer_proc do |date|
insert_ymap_js
end
def init_ymap
@ymap_container = Array.new
end
def generate_ymapid(lat, lon, layer, size)
ymapid = 'ymapid' << lat.to_s << lon.to_s << layer.to_s << size
ymapid.delete('.')
end
def yahoo_map(lat, lon, options = {})
options[:layer] ||= 17
options[:size] ||= 'medium'
if feed? or @conf.mobile_agent? then
return %Q|Link to Yahoo! JAPAN Map
|
end
# define map size
height = {'iphone' => '240px', 'small'=> '240px', 'medium' => '360px', 'large' => '480px'}
width = {'iphone' => '240px', 'small' => '320px', 'medium' => '480px', 'large' => '640px'}
if @conf.iphone? then
size = 'iphone'
else
size = options[:size]
end
ymapid = generate_ymapid(lat, lon, options[:layer], options[:size])
ymap_info = {:ymapid => ymapid, :lat => lat, :lon => lon, :layer => options[:layer]}
@ymap_container << ymap_info
%Q|
|
end
def insert_ymap_js
r = ''
if @ymap_container.size > 0 and not feed? then
r << %Q||
end
end
# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:
# vim: ts=3
tdiary-contrib-3.2.2/plugin/youtube.rb 0000664 0000000 0000000 00000002314 12136327440 0017771 0 ustar 00root root 0000000 0000000 #
# youtube.rb: YouTube plugin for tDiary
#
# Copyright (C) 2010 by TADA Tadashi
#
# usage: <%= youtube 'VIDEO_ID' %>
#
def youtube( video_id, size = [425,350] )
if @conf.mobile_agent? or feed? then
%Q||
elsif defined?( :smartphone? ) and @conf.smartphone?
size = [240, 194]
<<-TAG
VIDEO
TAG
else
<<-TAG
VIDEO
TAG
end
end
def youtube_custom( video_id, size = [416,337] )
<<-TAG
TAG
end
tdiary-contrib-3.2.2/plugin/yshop.rb 0000664 0000000 0000000 00000014067 12136327440 0017447 0 ustar 00root root 0000000 0000000 # yshop.rb $Revision: 3 $
# Copyright (C) 2008 Michitaka Ohno
# You can redistribute it and/or modify it under GPL2.
# ja/yshop.rb
@yshop_label_conf ='Yahoo!ショッピング'
@yshop_label_appid = 'アプリケーションID'
@yshop_label_affiliate_type = 'アフィリエイトの種類'
@yshop_label_yid = 'Yahoo! JAPANアフィリエイト'
@yshop_label_vc = 'バリューコマースアフィリエイト'
@yshop_label_affiliate_id = 'アフィリエイトID'
@yshop_label_imgsize = '表示するイメージのサイズ'
@yshop_label_medium = '普通'
@yshop_label_small = '小さい'
@yshop_label_clearcache = 'キャッシュの削除'
@yshop_label_clearcache_desc = 'イメージ関連情報のキャッシュを削除する(Yahoo!ショッピング上の表示と矛盾がある場合に試して下さい)'
require 'rexml/document'
require 'open-uri'
require 'kconv'
eval( <<-TOPLEVEL_CLASS, TOPLEVEL_BINDING )
require 'erb'
include ERB::Util
TOPLEVEL_CLASS
def yshop_get( param, store )
if Hash === param then
param = param.dup
elsif /^(\d{8}|\d{13})$/ === param then
param = {:jan => $1}
else
param = {:query => param.to_s}
end
param[:store_id] = store if store
cache = "#{@cache_path}/yshop"
Dir::mkdir( cache ) unless File::directory?( cache )
file = "#{cache}/#{u( param.to_s )}.xml"
begin
xml = File::read( file )
rescue
qs = []
qs << 'appid='+u( @conf['yshop.appid']||'YahooDemo' )
qs << 'affiliate_type='+u( @conf['yshop.affiliate_type'] ) if @conf['yshop.affiliate_type']
qs << 'affiliate_id='+u( @conf['yshop.affiliate_id'] ) if @conf['yshop.affiliate_id']
[:query, :jan, :isbn, :store_id].each do |item|
qs << "#{item}="+u( param[item].toutf8 ) if param.include?( item )
end
qs << 'hits=1'
xml = open( 'http://shopping.yahooapis.jp/ShoppingWebService/V1/itemSearch?'+(qs*'&') ){|f| f.read}
open( file, 'wb' ) {|f| f.write( xml )} if xml
end
REXML::Document.new( xml ).root if xml
end
def yshop_get_image( doc )
img = Struct.new( :size, :src, :width, :height ).new
if @conf['yshop.imgsize'] == 1 then
img.size = 'Small'
img.width = img.height = 76
else
img.size = 'Medium'
img.width = img.height = 146
end
begin
img.src = doc.elements["Result/Hit/Image/#{img.size}"].text
rescue
img.src = "http://i.yimg.jp/images/sh/noimage/#{img.width}x#{img.height}.gif"
end
img
end
def yshop_get_brands( doc )
begin
@conf.to_native( doc.elements['Result/Hit/Brands/Name'].text )
rescue
'-'
end
end
def yshop_get_price( doc )
begin
r = doc.elements['Result/Hit/Price'].text
nil while r.gsub!(/(.*\d)(\d\d\d)/, '\1,\2')
"\\"+r
rescue
'(no price)'
end
end
def yshop_get_shop( doc )
begin
@conf.to_native( doc.elements['Result/Hit/Store/Name'].text )
rescue
'-'
end
end
def yshop_get_html( param, store, pos )
doc = yshop_get( param, store )
return unless doc && doc.attributes['totalResultsReturned'].to_i > 0
name = @conf.to_native( doc.elements["Result/Hit/Name"].text )
link = doc.elements["Result/Hit/Url"].text
img = yshop_get_image( doc )
r = %Q[]
r << %Q[ ] if img.src
r << h( name )
r << %Q[ ]
end
def yshop_image( param, store = nil )
yshop_get_html( param, store, 'amazon' )
end
def yshop_image_left( param, store = nil )
yshop_get_html( param, store, 'left' )
end
def yshop_image_right( param, store = nil )
yshop_get_html( param, store, 'right' )
end
def yshop_detail( param, store = nil )
doc = yshop_get( param, store )
return unless doc && doc.attributes['totalResultsReturned'].to_i > 0
name = @conf.to_native( doc.elements["Result/Hit/Name"].text )
link = doc.elements["Result/Hit/Url"].text
img = yshop_get_image( doc )
brands = yshop_get_brands( doc )
price = yshop_get_price( doc )
shop = yshop_get_shop( doc )
<<-HTML
#{h( name )}
#{h( brands )}
#{h( shop )}
#{h( price )}
HTML
end
add_conf_proc( 'yshop', @yshop_label_conf ) do
yshop_conf_proc
end
def yshop_conf_proc
if @mode == 'saveconf' then
@conf['yshop.imgsize'] = @cgi.params['yshop.imgsize'][0].to_i
if @cgi.params['yshop.clearcache'][0] == 'true' then
Dir["#{@cache_path}/yshop/*"].each do |cache|
File::delete( cache.untaint )
end
end
if @cgi.params['yshop.appid'][0].empty? then
@conf['yshop.appid'] = nil
else
@conf['yshop.appid'] = @cgi.params['yshop.appid'][0]
end
if @cgi.params['yshop.affiliate_id'][0].empty? then
@conf['yshop.affiliate_type'] = nil
@conf['yshop.affiliate_id'] = nil
else
@conf['yshop.affiliate_type'] = @cgi.params['yshop.affiliate_type'][0]
@conf['yshop.affiliate_id'] = @cgi.params['yshop.affiliate_id'][0]
end
end
<<-HTML
#{@yshop_label_appid}
#{@yshop_label_affiliate_type}
#{@yshop_label_yid}
#{@yshop_label_vc}
#{@yshop_label_affiliate_id}
#{@yshop_label_imgsize}
#{@yshop_label_medium}
#{@yshop_label_small}
#{@yshop_label_clearcache}
#{@yshop_label_clearcache_desc}
HTML
end
tdiary-contrib-3.2.2/plugin/zenback.rb 0000664 0000000 0000000 00000002044 12136327440 0017712 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright (C) 2011, KADO Masanori
# You can redistribute it and/or modify it under GPL.
def insert_zenback
return if feed?
@conf['zenback.script'] || ''
end
if @mode == 'day' and (respond_to?(:section_mode?) ? section_mode? : true)
add_title_proc do |date, title|
"#{title}"
end
add_body_enter_proc do
""
end
if defined? add_comment_leave_proc
add_comment_leave_proc do
"" +
insert_zenback
end
else
add_body_leave_proc do
"" +
insert_zenback
end
end
end
add_conf_proc( 'zenback', 'zenback', 'etc' ) do
if @mode == 'saveconf' then
@conf['zenback.script'] = @cgi.params['zenback.script'][0]
end
<<-HTML
Script Code
HTML
end
# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:
# vim: ts=3
tdiary-contrib-3.2.2/spec/ 0000775 0000000 0000000 00000000000 12136327440 0015404 5 ustar 00root root 0000000 0000000 tdiary-contrib-3.2.2/spec/apple_webclip_spec.rb 0000664 0000000 0000000 00000001756 12136327440 0021562 0 ustar 00root root 0000000 0000000 $:.unshift(File.dirname(__FILE__))
require 'spec_helper'
describe "apple_webclip plugin" do
def setup_apple_webclip_plugin( url )
fake_plugin(:apple_webclip) { |plugin|
plugin.conf['apple_webclip.url'] = url
}
end
describe "url is enabled" do
before do
plugin = setup_apple_webclip_plugin('http://example.com/example.png')
@header_snippet = plugin.header_proc
end
it "header include url" do
@header_snippet.should == %Q|\t |
end
end
describe "url is disabled" do
describe "url is empty" do
before do
plugin = setup_apple_webclip_plugin('')
@header_snippet = plugin.header_proc
end
it "header is empty" do
@header_snippet.should be_empty
end
end
describe "url is nil" do
before do
plugin = setup_apple_webclip_plugin(nil)
@header_snippet = plugin.header_proc
end
it "header is empty" do
@header_snippet.should be_empty
end
end
end
end
tdiary-contrib-3.2.2/spec/fixtures/ 0000775 0000000 0000000 00000000000 12136327440 0017255 5 ustar 00root root 0000000 0000000 tdiary-contrib-3.2.2/spec/fixtures/friendfeed.xml 0000664 0000000 0000000 00000074161 12136327440 0022103 0 ustar 00root root 0000000 0000000
44123b23 Ex-CTO of Facebook. Previously co-founder and CEO of FriendFeed. Programmer, food lover. user bret Bret Taylor FriendFeed Blog: Ben Darnell joins FriendFeed: Ben++! - <a rel="nofollow" href="http://blog.friendfeed.com/2009/07/ben-darnell-joins-friendfeed-ben.html" title="http://blog.friendfeed.com/2009/07/ben-darnell-joins-friendfeed-ben.html">http://blog.friendfeed.com/2009...</a>http://friendfeed.com/share/bookmarklet Bookmarklet user Bret Taylor bret http://m.friendfeed-media.com/d8a3d0cffc2d534fb6c7e87912928dd4ee8695b1 109 http://blog.friendfeed.com/2009/07/ben-darnell-joins-friendfeed-ben.html175 http://friendfeed.com/friendfeed-news/c970e279/friendfeed-blog-ben-darnell-joins 2009-07-27T22:52:09Z Welcome, Ben!user kfury Kevin Fox e/c970e27954f349869b58d30a2b75631a/c/affd43519b134e2f8b0175f97267affd 2009-07-27T22:52:53Z Right on! Congrats, Ben.user micahwittman Micah e/c970e27954f349869b58d30a2b75631a/c/3ae682d1abd74d9cbec58d8614d34c9f 2009-07-27T22:54:13Z Congrats Ben! Also, congrats to FF you are lucky to have him!user shellen Jason Shellen e/c970e27954f349869b58d30a2b75631a/c/a297cd5ec49d4196855bd042dbb8ae98 2009-07-27T23:14:34Z Data storage and scalability rock. :)user louisgray Louis Gray e/c970e27954f349869b58d30a2b75631a/c/0c562741868248cd80fe1b70c041fe64 2009-07-27T23:42:50Z Ben's feed is here: <a href="http://friendfeed.com/bdarnell">http://friendfeed.com/bdarnell</a>user Bret Taylor bret e/c970e27954f349869b58d30a2b75631a/c/31a62c1498c446c090ed63594205c226 2009-07-27T23:51:54Z Congrats, Ben! :-)user koltregaskes Kol Tregaskes e/c970e27954f349869b58d30a2b75631a/c/e79d0783d7b347a88f3905b722f5d776 2009-07-28T00:17:50Z Yeah Ben!!!user phoenix Rachel Lea Fox e/c970e27954f349869b58d30a2b75631a/c/28ca4607a72c4289ab196230d03e6f74 2009-07-28T00:41:58Z so i finally get my answer to this :) <a href="http://friendfeed.com/chris/3870e6df/v-excited-about-my-friend-new-job-his" title="http://friendfeed.com/chris/3870e6df/v-excited-about-my-friend-new-job-his">http://friendfeed.com/chris...</a>user parislemon MG Siegler e/c970e27954f349869b58d30a2b75631a/c/0dce0a67de704224b0215da71a2ba408 2009-07-28T00:44:52Z Yeah, sorry I couldn't respond to that one before. :-)user kfury Kevin Fox e/c970e27954f349869b58d30a2b75631a/c/2d9ae52ed9d942f988a18a028d4dc215 2009-07-28T01:01:55Z well i be darned .... we now can rejoice, since fast paced additions to already good product are surely fastly coming about off the feedpipe ... it'l be a hectic season of finest upgrades ... I'm sure they'l start with keyboard shortcutze. ... I mean Google Reader rules on that. Intelligent to the extreme. ..Google.com, on the other hand - are we sleeping? .. not even "/" ??.. and that is the first page on the planet! .. i'l be darned. ..... then, lets boost them blogging facilities ! ... i mean, how hard internet programming could be ???user petrbuben pb: e/c970e27954f349869b58d30a2b75631a/c/c17c8d9235a34d238c3ab4376f1b84ab 2009-07-28T01:21:05Z Congrats Ben! Totally agree with Jason. Our latest project wouldn't have become feasible without Ben -- I'm just so glad we managed to get a fraction of his time before he left! :)user stong Simon e/c970e27954f349869b58d30a2b75631a/c/e7e1b7c2bcbc4c3cb9c112238fb41108 2009-07-28T02:40:46Z Congratulations, Ben! You're joining an awesome team.user abouey Anne Bouey e/c970e27954f349869b58d30a2b75631a/c/c0428e7432994c73b40365644bf22f7e 2009-07-28T03:31:25Z Woohoo! Another Googler :)user timhoeck Tim Hoeck e/c970e27954f349869b58d30a2b75631a/c/14daa1eeb6f043b1b58f2213e75971f6 2009-07-28T03:59:39Z Congrats, you are now a "big company"! ;))))user yogar K.D. e/c970e27954f349869b58d30a2b75631a/c/9d52f70158314758a604daad75732657 2009-07-28T06:44:21Z That's not my picture! They got the picture wrong! In fact, I didn't get the letter of hire either. :( Oh, Hi there, Ben...if that's your real name. ;)user joshhaley True Josh Haley e/c970e27954f349869b58d30a2b75631a/c/531163c5e9e34b9f92c0db5f9d3888c6 2009-07-28T07:03:07Z Good luck Ben! With you our preferred service will go more interestinghttp://www.fftogo.com/ fftogo user postoditacco True Roberto e/c970e27954f349869b58d30a2b75631a/c/d2aeb1623ed14f089dc567f50f2c418c 2009-07-28T10:13:27Z you're building a friendfeed army there :-)user dobata Dobromir Hadzhiev e/c970e27954f349869b58d30a2b75631a/c/81b72085bac844868ac7321a6d6ebf07 2009-07-28T10:50:24Z Congratsuser portakal Özkan Altuner e/c970e27954f349869b58d30a2b75631a/c/c04066a9eec842508018999185260fd4 2009-07-28T12:42:29Z Nice, any former Google Reader-er is a friend of mine.user mikereynolds Mike Reynolds e/c970e27954f349869b58d30a2b75631a/c/833416de1ee14f3a88eb25b3a7ec21cc 2009-07-28T13:35:08Z gratz Ben!user timepilot timepilot e/c970e27954f349869b58d30a2b75631a/c/b9d20666d611497abf9be5213eb15b16 2009-07-28T18:09:12Z Welcome Bret!user jamessmith24 Michael_techie e/c970e27954f349869b58d30a2b75631a/c/04cdf733ae664d1f853698aa70090a42 2009-08-10T20:14:31Z So, Facebook...?user dpritchett True Daniel J. Pritchett e/c970e27954f349869b58d30a2b75631a/c/4c811104219a47d0be72b60a46493336 2009-08-10T21:16:06Z Poor Ben Darnell. The last to enter are always the first to leave in mergers.user beersage beersage e/c970e27954f349869b58d30a2b75631a/c/d6c86c49e7a84536821f3627f3debd07 2009-08-11T06:49:41Z Hiring new staff while in secret acquisition talks, not exactly classy guys. I hope Ben knew what he was getting intouser dalziel Glenn Slaven e/c970e27954f349869b58d30a2b75631a/c/7858bb2711894dc7ba792ac22a369c4b 2009-08-14T05:21:51Z Why on earth does he use the Duck Hunt theme?user vzx Vezquex e/c970e27954f349869b58d30a2b75631a/c/99acd29f314b4d9d821866b5d85770bc 2009-08-14T05:23:45Z I don't know.. but it is awesome! :)user timhoeck Tim Hoeck e/c970e27954f349869b58d30a2b75631a/c/bed22ee3baa84233a2a54a25d26e1756 2012-01-30T23:16:12Z Wow, looks like somebody bumped this!user kfury Kevin Fox e/c970e27954f349869b58d30a2b75631a/c/c52b519e6cb04a268f76c9ecb84b0be1 2012-01-30T23:21:48Z I think there were a bunch of spam comments made to some 2009-era posts by FF employees. For some reason even after the spam is nuked, the post stays bumped.user zeigen Stephen Mack e/c970e27954f349869b58d30a2b75631a/c/0ebcf885818a442bbf773526e4927268 2012-01-30T23:23:23Z Yes, I blocked a spammer that was bumping old posts about FF themes and what not.user zoblue Zulema ❧ spicy cocoa tart e/c970e27954f349869b58d30a2b75631a/c/18fcc8e1b02f46fc8a21589681cf0b92 2012-01-30T23:26:01Z OH HAI!user cstechcast Eric - Drop That Beat e/c970e27954f349869b58d30a2b75631a/c/244f5398cd4b4d4b9ca344fe66509ca9 2012-01-30T23:30:29Z Well, let's see this as an opportunity to raise a virtual glass to Ben and FriendFeed-that-was!user kfury Kevin Fox e/c970e27954f349869b58d30a2b75631a/c/5afdbcf261d047b392bed56298492e55 2012-01-30T23:32:55Z It probably had something to do with the Tornado 2.2 release. I noticed Ben was the one who posted about the release on HN earlier. Edit: Or it could have just been a spammer. *shrugs*user jimminy True Jimminy, CoG of FF e/c970e27954f349869b58d30a2b75631a/c/93fc5948d22d4e469ca400e41327b48b 2012-01-31T01:17:40Z I don't think it had anything to do with the tornado release - a spammer bumped a bunch of Bret's old posts today.user bdarnell Ben Darnell e/c970e27954f349869b58d30a2b75631a/c/2e2bccd6de854ebd8ed345bb15236f5c 2012-05-07T17:34:07Z Here, let me save future spammers some time: Hello my name is ____ and I am an attractive young ____ _____ and I would like to contact with you so that together you and I can ___ with ____ while _____ in a highly ____ manner. Please to be responding as soon as is practical. Without your help, the _____ in U.S. dollars will go unclaimed, and the herbal ______ remedy will wither and die. Yours in all urgent seriousness, _____.user zeigen Stephen Mack e/c970e27954f349869b58d30a2b75631a/c/7eed38db1bb44c3d90ce6a817ae8c1f6 2012-05-09T03:10:07Z :D, Stephen!user abouey Anne Bouey e/c970e27954f349869b58d30a2b75631a/c/f349034ca1804b3388ca2804156887a3 2012-08-21T14:40:59Z so sweet))loluser solncee solncee e/c970e27954f349869b58d30a2b75631a/c/9ea20c4da85f4c539e02d6e24ac94f45 2012-09-02T08:06:01Z Awesome Photo :)user adiprcike Adi Prcike e/c970e27954f349869b58d30a2b75631a/c/53cbf054f1b446fe8c473ef103d101ae 2012-09-03T01:06:48Z Which shows up more, this pic or the Asian gentlemen on the beach?http://friendfeed.com/about/tools iPhone user zeigen Stephen Mack e/c970e27954f349869b58d30a2b75631a/c/21725041bf364346840c39853efa3829 2012-09-14T15:39:14Z bret neler oluyor dostum? kardeşi kardeşe kırdıracaksın canım ülkemde!!! işinin başına dön lütfen..user aynebilm aynebilim e/c970e27954f349869b58d30a2b75631a/c/4d3788ce9afb420fb95c25ee5ae2d2da 2012-09-14T16:03:55Z testa di cazzo se arcasca tutto te veniamo a cercà e non saremo teneri come i musulmaniuser bonzo True Francesco M. e/c970e27954f349869b58d30a2b75631a/c/63f44ef4d4c7481187d0a199eae11a7c 2012-09-14T16:17:29Z kime dedin onu francesco?user aynebilm aynebilim e/c970e27954f349869b58d30a2b75631a/c/9298bbd497ff49699e6bdf9f23f7809e 2012-09-14T16:33:20Z Bence de Friendfeede sahip çıksın artık...user koleksiyoner koleksiyoner e/c970e27954f349869b58d30a2b75631a/c/890dfb635e734e2f9d0e68fc2ac806da 2012-09-14T17:47:38Z Welcome, Ben!user kfury Kevin Fox e/c970e27954f349869b58d30a2b75631a/c/ce9ad2c73c784595929fe89601aab957 2012-09-14T17:54:48Z <a href="http://friendfeed.com/search?q=%23timewarp">#timewarp</a>user worldofhiglet True WoH: Fairy Surreal e/c970e27954f349869b58d30a2b75631a/c/29a9cf0c27cd42628fe5192c349c4944 user Bret's feed bret group friendfeed-news FriendFeed News 2012-09-27T18:45:20Z user gerantamala Tamala Geran 2012-09-17T05:12:36Z user thelarimarshop thelarimarshop 2012-09-14T17:59:05Z user jobbler True Joe Silence 2012-09-14T16:07:47Z user kkapp Alex Kapranoff 2012-09-14T15:39:22Z user aynebilm aynebilim 2012-09-03T09:46:26Z user nganguemvictor True nganguem victor 2012-08-11T14:14:57Z user goroprask Goro Prask 2012-06-29T07:02:56Z user ageuferraz Ageu Ferraz 2012-06-05T08:53:02Z user hewoilsneed hewoilsneed 2012-06-04T06:39:34Z user florrygrip florrygrip 2012-05-24T00:30:59Z user hcivelek HasanCivelek 2012-05-07T17:42:47Z user worldofhiglet True WoH: Fairy Surreal 2012-05-07T17:38:23Z user jeffdoug True Jeff (Team マクダジ ) 2012-05-02T11:57:09Z user angelramon Angel 2012-04-30T08:21:22Z user sogoo /sg 2012-04-24T06:17:16Z user alidafeian True علی دافعیان 2012-04-24T06:11:00Z user amitkumar47 amit Kumar 2012-04-20T21:45:37Z user polymath22 True polymath22 2012-04-14T19:49:34Z user cy6erbr4in Cy6erBr4in 2012-04-02T10:37:30Z user lisalenea True Lisa L. Seifert | FHG™ 2012-03-24T10:32:02Z user aidr86 True aid@ 2012-02-20T06:40:47Z user mitchnielsen Mitch Nielsen 2012-02-14T16:09:31Z user katiao инопланетянин со стажем 2012-02-14T14:07:33Z user adamspring Adam Spring 2012-01-31T00:46:09Z user kmohr25 Kevin Mohr 2012-01-30T23:32:13Z user jimminy True Jimminy, CoG of FF 2009-12-25T20:16:40Z user bebekvegebelik "Serhat Ozan" 2009-08-11T12:11:30Z user iphigenie Iphigenie 2009-08-11T06:53:06Z user mortonfox Morton Fox 2009-08-11T05:28:21Z user yogamama amelia arapoff 2009-08-10T22:27:13Z user vmlemon Tyson Key 2009-08-10T22:15:39Z user kierancrotty Kieran Crotty 2009-08-10T21:31:59Z user angusb Angus Burton 2009-08-10T21:20:26Z user berkeleyisbetter Kelly 2009-08-10T20:14:47Z user svartling Svartling 2009-08-01T09:35:59Z user tandriamirado Thierry R. Andriamirado 2009-07-28T20:14:18Z user durukanduru Durukan Duru 2009-07-28T19:45:16Z user silas216 Steven Perez 2009-07-28T18:54:10Z user v9y True Vinay | विनय 2009-07-28T18:30:17Z user stanjourdan stanjourdan 2009-07-28T18:12:39Z user kamath The Fat Oracle 2009-07-28T18:00:07Z user minusone minus-one 2009-07-28T16:40:19Z user oflaherty Paul OFlaherty 2009-07-28T14:10:49Z user dpritchett True Daniel J. Pritchett 2009-07-28T14:00:48Z user silpol A. T. 2009-07-28T13:51:27Z user ajkohn AJ Kohn 2009-07-28T13:44:54Z user dannyrowley True Daniel Rowley 2009-07-28T13:40:01Z user ajbatac AJ Batac 2009-07-28T12:33:25Z user stevefarnworth Steve Farnworth 2009-07-28T12:23:08Z user bjtitus Brandon Titus 2009-07-28T12:09:31Z user nzbuu James Myatt 2009-07-28T11:11:08Z user lookon kang 2009-07-28T11:08:50Z user lutao Lu Tao 2009-07-28T11:07:33Z user pellesjoqvist Pelle Sjoqvist 2009-07-28T10:27:09Z user pastas9 True pastas9 2009-07-28T10:19:33Z user amberspence True The Amber 2009-07-28T10:18:31Z user ourielohayon Ouriel Ohayon 2009-07-28T10:12:49Z user dobata Dobromir Hadzhiev 2009-07-28T09:40:43Z user zijperspace Ton Zijp 2009-07-28T08:50:42Z user simonwicks Simon Wicks 2009-07-28T07:12:26Z user dffrnt vijay 2009-07-28T07:00:56Z user bfoster Bonnie Foster 2009-07-28T06:54:08Z user jrivero Jordi Rivero 2009-07-28T06:51:55Z user postoditacco True Roberto 2009-07-28T06:51:24Z user niron Nir Ben Yona 2009-07-28T06:44:26Z user joshhaley True Josh Haley 2009-07-28T05:54:52Z user bdarnell Ben Darnell 2009-07-28T05:02:43Z user mirthnadir Amani 2009-07-28T05:02:11Z user kof2002 HealingBrush 2009-07-28T04:59:02Z user susanbeebe Susan Beebe 2009-07-28T04:57:19Z user izuzak Ivan Zuzak 2009-07-28T04:54:41Z user krynsky Mark Krynsky 2009-07-28T04:23:31Z user clare Clare Dibble 2009-07-28T04:12:16Z user ruchira Ruchira S. Datta 2009-07-28T04:06:16Z user malaparte Andrei M. Marinescu 2009-07-28T03:56:13Z user yogar K.D. 2009-07-28T03:42:31Z user 1geeky True I /-\li 2009-07-28T03:41:02Z user derek Derek Collison 2009-07-28T03:40:11Z user majento Majento 2009-07-28T03:40:08Z user eldiablo Pete D 2009-07-28T03:37:44Z user bhc3 Hutch Carpenter 2009-07-28T03:33:46Z user monasfeed Mona Nomura 2009-07-28T03:30:49Z user timhoeck Tim Hoeck 2009-07-28T03:28:26Z user seanpercival True sean percival 2009-07-28T03:18:41Z user mehmetakif Mehmet ALP 2009-07-28T03:15:31Z user changeforge Ken Stewart | ChangeForge 2009-07-28T03:13:56Z user karen Karen Padham Taylor 2009-07-28T02:47:11Z user ericflo Eric Florenzano 2009-07-28T02:44:25Z user imabonehead imabonehead 2009-07-28T02:41:22Z user rodfather True Rodfather 2009-07-28T01:51:24Z user lizunlong Lizunlong 2009-07-28T01:38:39Z user pattonroberta True RAPatton 2009-07-28T01:09:26Z user nimaa True Nimaa 2009-07-28T01:02:49Z user looppacosmos Johni Fisher 2009-07-28T00:56:42Z user stong Simon 2009-07-28T00:42:18Z user banane anna sauce 2009-07-28T00:42:11Z user parislemon MG Siegler 2009-07-28T00:32:40Z user bettydarnell True Betty Darnell 2009-07-28T00:22:50Z user jworthington Johnny 2009-07-28T00:19:19Z user leblondb BEX 2009-07-28T00:18:17Z user dalziel Glenn Slaven 2009-07-28T00:15:00Z user phoenix Rachel Lea Fox 2009-07-28T00:10:05Z user romanzolotarev romanzolotarev 2009-07-28T00:04:42Z user eskimo April Buchheit 2009-07-28T00:04:15Z user teb tunahan 2009-07-27T23:59:04Z user ryanmassie Ryan Massie 2009-07-27T23:58:52Z user thejbf True Burcu Dogan 2009-07-27T23:58:24Z user mihai Mihai Parparita 2009-07-27T23:56:55Z user travispuk travispuk 2009-07-27T23:55:08Z user mokargas True Mo Kargas 2009-07-27T23:50:45Z user koltregaskes Kol Tregaskes 2009-07-27T23:50:04Z user itafroma Mark Trapp 2009-07-27T23:43:39Z user vadim Vadim Spivak 2009-07-27T23:21:04Z user gotti GOTTi 2009-07-27T23:16:10Z user lanjackal LANjackal 2009-07-27T23:14:24Z user louisgray Louis Gray 2009-07-27T23:12:43Z user tudor Tudor Bosman 2009-07-27T23:09:38Z user hberberoglu Hüseyin Berberoğlu 2009-07-27T23:07:55Z user casey Casey Muller 2009-07-27T23:03:21Z user scobleizer Robert Scoble 2009-07-27T23:02:17Z user colladude Kishore Balakrishnan 2009-07-27T23:02:15Z user bgolub Benjamin Golub 2009-07-27T22:58:04Z user ginger Ginger Makela Riker 2009-07-27T22:54:45Z user erensoydas Eren Soydaş 2009-07-27T22:54:31Z user atul Atul Arora 2009-07-27T22:53:02Z user thehenry TheHenry 2009-07-27T22:52:40Z user hdiwan Prolific Programmer 2009-07-27T22:52:40Z user paul Paul Buchheit 2009-07-27T22:52:37Z user jeffisageek (jeff)isageek 2009-07-27T22:52:11Z user dhsiao Dan Hsiao 2009-07-27T22:52:11Z user kfury Kevin Fox 2009-07-27T22:52:05Z user ross Ross Miller 2009-07-27T22:52:01Z e/c970e27954f349869b58d30a2b75631a