Show
Ignore:
Timestamp:
05/01/10 09:09:51 (5 years ago)
Author:
drry
Message:
  • fixed regexes.
  • fixed HTML.
  • et cetera.
Files:
1 modified

Legend:

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

    r3326 r37332  
    44# You can redistribute it and/or modify it under GPL2. 
    55 
     6require 'uri' 
     7 
    68def bookmark_init 
    7         @conf['add.bookmark.delicious'] ||= "" 
    8         @conf['add.bookmark.hatena'] ||= "" 
    9         @conf['add.bookmark.livedoor'] ||= "" 
    10         @conf['add.bookmark.buzzurl'] ||= "" 
     9        @conf['add.bookmark.delicious'] ||= '' 
     10        @conf['add.bookmark.hatena'] ||= '' 
     11        @conf['add.bookmark.livedoor'] ||= '' 
     12        @conf['add.bookmark.buzzurl'] ||= '' 
    1113end 
    1214 
    1315add_subtitle_proc do |date, index, subtitle| 
    1416        bookmark_init 
    15          
     17 
    1618        if @conf.mobile_agent? then 
    1719                caption = %Q|#{subtitle}| 
     
    2022 
    2123                section_url = @conf.base_url + anchor(date.strftime('%Y%m%d')) + '#p' + ('%02d' % index) 
    22                  
    23                 if @conf['add.bookmark.delicious'] == "t" then 
    24                         caption += %Q|<a href="http://del.icio.us/post/v4?url=#{h(section_url)}">| 
    25                         caption += %Q|<img src="http://images.del.icio.us/static/img/delicious.small.gif" width="10" height="10" style="border: none;vertical-align: middle;" alt="#{@caption_delicious}" title="#{@caption_delicious}" />| 
     24 
     25                if @conf['add.bookmark.delicious'] == 't' then 
     26                        escaped_url = URI.escape(section_url, /[^-.!~*'()\w]/n) 
     27                        caption += %Q|<a href="http://delicious.com/save?url=#{escaped_url}" onclick="window.open('http://delicious.com/save?v=5;noui;jump=close;url=#{escaped_url};title='+encodeURIComponent(document.title), 'delicious', 'toolbar=no,width=550,height=550'); return false">| 
     28                        caption += %Q|<img src="http://static.delicious.com/img/delicious.small.gif" width="10" height="10" style="border: 0 none;vertical-align: middle;" alt="#{@caption_delicious}">| 
    2629                        caption += %Q|</a> | 
    2730                end 
    2831 
    29                 if @conf['add.bookmark.hatena'] == "t" then 
     32                if @conf['add.bookmark.hatena'] == 't' then 
    3033                        caption += %Q|<a href="http://b.hatena.ne.jp/append?#{h(section_url)}">| 
    31                         caption += %Q|<img src="http://b.hatena.ne.jp/images/append.gif" width="16" height="12" style="border: none;vertical-align: middle;" alt="#{@caption_hatena}" title="#{@caption_hatena}" />| 
    32                         caption += %Q|</a> | 
    33                 end 
    34                          
    35                 if @conf['add.bookmark.livedoor'] == "t" then 
    36                         caption += %Q|<a href="http://clip.livedoor.com/redirect?link=#{h(section_url)}" class="ldclip-redirect">| 
    37                         caption += %Q|<img src="http://parts.blog.livedoor.jp/img/cmn/clip_16_16_w.gif" width="16" height="16" style="border: none;vertical-align: middle;" alt="#{@caption_livedoor}" title="#{@caption_livedoor}" />| 
     34                        caption += %Q|<img src="http://b.hatena.ne.jp/images/append.gif" width="16" height="12" style="border: 0 none;vertical-align: middle;" alt="#{@caption_hatena}" title="#{@caption_hatena}">| 
    3835                        caption += %Q|</a> | 
    3936                end 
    4037 
    41                 if @conf['add.bookmark.buzzurl'] == "t" then 
     38                if @conf['add.bookmark.livedoor'] == 't' then 
     39                        caption += %Q|<a href="http://clip.livedoor.com/redirect?link=#{h(section_url)}" class="ldclip-redirect">| 
     40                        caption += %Q|<img src="http://parts.blog.livedoor.jp/img/cmn/clip_16_16_w.gif" width="16" height="16" style="border: 0 none;vertical-align: middle;" alt="#{@caption_livedoor}" title="#{@caption_livedoor}">| 
     41                        caption += %Q|</a> | 
     42                end 
     43 
     44                if @conf['add.bookmark.buzzurl'] == 't' then 
    4245                        caption += %Q|<a href="http://buzzurl.jp/entry/#{h(section_url)}">| 
    43                         caption += %Q|<img src="http://buzzurl.jp/static/image/api/icon/add_icon_mini_10.gif" width="16" height="12" style="border: none;vertical-align: middle;" title="#{@caption_buzzurl}" alt="#{@caption_buzzurl}" class="icon" />| 
     46                        caption += %Q|<img src="http://buzzurl.jp/static/image/api/icon/add_icon_mini_10.gif" width="16" height="12" style="border: 0 none;vertical-align: middle;" title="#{@caption_buzzurl}" alt="#{@caption_buzzurl}" class="icon">| 
    4447                        caption += %Q|</a> | 
    4548                end 
    4649        end 
    47          
     50 
    4851        <<-HTML 
    4952        #{caption} 
     
    7073 
    7174        bookmark_categories.each_with_index do |idx,view| 
    72                 checked = "t" == @conf[idx] ? ' checked' : '' 
     75                checked = 't' == @conf[idx] ? ' checked' : '' 
    7376                label = @bookmark_label[view] 
    7477                r << %Q|<li><label for="#{idx}"><input id=#{idx} name=#{idx} type="checkbox" value="t"#{checked}>#{label}</label></li>|