Changeset 6006 for platform/tdiary/plugin/section_footer2.rb
- Timestamp:
- 02/02/08 01:17:57 (5 years ago)
- Files:
-
- 1 modified
-
platform/tdiary/plugin/section_footer2.rb (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
platform/tdiary/plugin/section_footer2.rb
r5901 r6006 9 9 require 'timeout' 10 10 require 'yaml' 11 require "pathname"11 require 'pathname' 12 12 13 13 def permalink( date, index, escape = true ) … … 31 31 s = '' 32 32 if subtitle then 33 s = subtitle.sub( /^( \[([^\[]+?)\])+/ ) do33 s = subtitle.sub( /^(?:\[[^\[]+?\])+/ ) do 34 34 $&.scan( /\[(.*?)\]/ ) do |tag| 35 35 @category_to_tag_list[tag] = false # false when diary … … 57 57 end 58 58 59 # 「このエントリ を含む del.icio.us(jsonAPI)」59 # 「このエントリの del.icio.us history (JSON API)」 60 60 r << add_delicious_json(date, index) 61 61 … … 75 75 def add_delicious_json(date, index) 76 76 require 'json' 77 77 78 78 url_md5 = Digest::MD5.hexdigest(permalink(date, index, false)) 79 79 cache_dir = "#{@cache_path}/delicious/#{date.strftime( "%Y%m" )}/" … … 82 82 update = false 83 83 count = 0 84 85 r = " | " 86 r << %Q|<a href="http://del.icio.us/url/#{url_md5}"><img src="http://images.del.icio.us/static/img/delicious.small.gif" style="border: none;vertical-align: middle;" alt="このエントリを含む del.icio.us" title="このエントリを含む del.icio.us">| 84 r = '' 87 85 88 86 begin … … 100 98 begin 101 99 timeout(10) do 102 open( 'http://badges.del.icio.us/feeds/json/url/data?hash=' + url_md5) do |file|100 open( "http://badges.del.icio.us/feeds/json/url/data?hash=#{url_md5}" ) do |file| 103 101 File::open( file_name, 'wb' ) do |f| 104 102 f.write( file.read ) … … 115 113 begin 116 114 File::open( file_name ) do |f| 117 data = JSON.parse(@conf.to_native( f.read, 'utf-8' ))115 data = JSON.parse(@conf.to_native( f.read, 'utf-8' )) 118 116 unless data[0].nil? 119 117 count = data[0]["total_posts"].to_i … … 124 122 125 123 if count > 0 126 r << %Q| #{count} users| 124 r << ' | ' 125 r << %Q{<a href="http://del.icio.us/url/#{url_md5}"><img src="http://images.del.icio.us/static/img/delicious.small.gif" style="border: none;vertical-align: middle;" alt="このエントリの del.icio.us history" title="このエントリの del.icio.us history"> #{count} user} 126 r << 's' if count > 1 127 r << '</a>' 127 128 end 128 129 129 r << %Q|</a>|130 131 130 return r 132 131 end … … 135 134 config = YAML.load(Pathname.new(file).expand_path.read) 136 135 137 r = " |"136 r = "" 138 137 unless config.nil? then 138 r << ' | ' 139 139 r << %Q|<a href="#{config["url"]}#{permalink(date, index)}">| 140 140 r << %Q|<img src="#{config["src"]}" style="border: none;vertical-align: middle;" | … … 144 144 r << %Q| <img src="#{config["counter"]}#{permalink(date, index)}" style="border: none;vertical-align: middle;" />| 145 145 end 146 r << %Q|</a>|146 r << '</a>' 147 147 end 148 148
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)