Show
Ignore:
Timestamp:
02/02/08 01:17:57 (5 years ago)
Author:
drry
Message:

platform/tdiary/plugin/section_footer2.rb: 文面等の細かい修整。正規表現の修正。ほか。

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • platform/tdiary/plugin/section_footer2.rb

    r5901 r6006  
    99require 'timeout' 
    1010require 'yaml' 
    11 require "pathname" 
     11require 'pathname' 
    1212 
    1313def permalink( date, index, escape = true ) 
     
    3131        s = '' 
    3232        if subtitle then 
    33                 s = subtitle.sub( /^(\[([^\[]+?)\])+/ ) do 
     33                s = subtitle.sub( /^(?:\[[^\[]+?\])+/ ) do 
    3434                        $&.scan( /\[(.*?)\]/ ) do |tag| 
    3535                                @category_to_tag_list[tag] = false # false when diary 
     
    5757                end 
    5858 
    59                 # 「このエントリを含む del.icio.us(json API)」 
     59                # 「このエントリの del.icio.us history (JSON API)」 
    6060                r << add_delicious_json(date, index) 
    6161 
     
    7575def add_delicious_json(date, index) 
    7676        require 'json' 
    77          
     77 
    7878        url_md5 = Digest::MD5.hexdigest(permalink(date, index, false)) 
    7979        cache_dir = "#{@cache_path}/delicious/#{date.strftime( "%Y%m" )}/" 
     
    8282        update = false 
    8383        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 = '' 
    8785 
    8886        begin 
     
    10098                        begin 
    10199                                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| 
    103101                                                File::open( file_name, 'wb' ) do |f| 
    104102                                                        f.write( file.read ) 
     
    115113        begin 
    116114                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' )) 
    118116                        unless data[0].nil? 
    119117                                count = data[0]["total_posts"].to_i 
     
    124122 
    125123        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>' 
    127128        end 
    128129 
    129         r << %Q|</a>| 
    130          
    131130        return r 
    132131end 
     
    135134        config = YAML.load(Pathname.new(file).expand_path.read) 
    136135 
    137         r = " | " 
     136        r = "" 
    138137        unless config.nil? then 
     138                r << ' | ' 
    139139                r << %Q|<a href="#{config["url"]}#{permalink(date, index)}">| 
    140140                r << %Q|<img src="#{config["src"]}" style="border: none;vertical-align: middle;" | 
     
    144144                        r << %Q| <img src="#{config["counter"]}#{permalink(date, index)}" style="border: none;vertical-align: middle;" />| 
    145145                end 
    146                 r << %Q|</a>| 
     146                r << '</a>' 
    147147        end 
    148148