Show
Ignore:
Timestamp:
07/05/08 20:23:58 (5 months ago)
Author:
sho
Message:

platform/tdiary/contrib/plugin/nicovideo.rb: separated language resources.

Location:
platform/tdiary/plugin
Files:
3 added
1 modified

Legend:

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

    r14647 r15203  
    4040 
    4141def nicovideo_inline( elem, label = nil, link = nil ) 
    42         url = link || elem.to_a( 'watch_url' )[0].text 
    43         thumb = elem.to_a( 'thumbnail_url' )[0].text 
    44         title = label || elem.to_a( 'title' )[0].text 
    45         desc = label ? nil : elem.to_a( 'description' )[0].text 
    46         comment = label ? nil : elem.to_a( 'last_res_body' )[0].text 
    47         length = elem.to_a( 'length' )[0].text 
    48         view = elem.to_a( 'view_counter' )[0].text 
    49         comment_num = elem.to_a( 'comment_num' )[0].text 
    50         mylist = elem.to_a( 'mylist_counter' )[0].text 
     42        i = {} 
     43        i[:url] = link || elem.to_a( 'watch_url' )[0].text 
     44        i[:thumb] = elem.to_a( 'thumbnail_url' )[0].text 
     45        i[:title] = label || elem.to_a( 'title' )[0].text 
     46        i[:desc] = elem.to_a( 'description' )[0].text 
     47        i[:comment] = @conf.mobile_agent? ? '' : elem.to_a( 'last_res_body' )[0].text 
     48        i[:length] = elem.to_a( 'length' )[0].text 
     49        i[:view] = elem.to_a( 'view_counter' )[0].text 
     50        i[:comment_num] = elem.to_a( 'comment_num' )[0].text 
     51        i[:mylist] = elem.to_a( 'mylist_counter' )[0].text 
    5152 
    52         if @conf.mobile_agent? then 
    53                 comment = '' 
    54         end 
    55  
    56         if feed? or label then 
     53        if feed? then 
    5754                result = <<-HTML 
    5855                        <table border="0" cellpadding="4" cellspacing="0" summary="#{title}"><tr valign="top"> 
     
    6259                HTML 
    6360        else 
    64                 result = <<-HTML 
    65                         <table border="0" cellpadding="4" cellspacing="0" summary="#{title}" style="margin-left:0em;"> 
    66                         <tr valign="top"> 
    67                         <td style="font-size:70%;border-width:0px;"> 
    68                         <div style="margin:4px 0px;"><a href="#{url}" target="_blank"><img alt="#{title}" src="#{thumb}" width="130" height="100" style="border:solid 1px #333;"></a></div> 
    69                         <p><strong>#{length.split(/:/).map{|i|'%02d' % i.to_i}.join(':')}</strong><br> 
    70                         再生: <strong>#{view.scan(/\d+?(?=\d{3}*$)/).join(",")}</strong><br> 
    71                         コメント: <strong>#{comment_num.scan(/\d+?(?=\d{3}*$)/).join(",")}</strong><br> 
    72                         マイリスト: <strong>#{mylist.scan(/\d+?(?=\d{3}*$)/).join(",")}</strong></p> 
    73                         </td> 
    74                         <td width="100%" style="font-size:80%;border-width:0px;"> 
    75                         <p><a href="#{url}" target="_blank" class="video"><strong>#{title}</strong></a><br>#{desc}</p> 
    76                         <div style="background:#FFF; border:solid 2px #CCC; padding:6px; margin-top:4px;"> 
    77                         <p><strong>#{comment}</strong></p> 
    78                         </div> 
    79                         </td> 
    80                         </tr> 
    81                         </table> 
    82                 HTML 
     61                result = nicovideo_html( i ) 
    8362        end 
    8463        result.gsub( /^\t+/, '' ) 
     
    10786                        s = "?w=#{h size[0]}&h=#{h size[1]}" 
    10887                end 
    109                 %Q|<script type="text/javascript" src="http://www.nicovideo.jp/thumb_watch/#{video_id}#{s}"></script>| 
     88                %Q|<script type="text/javascript" src="#{nicovideo_player_path}/thumb_watch/#{video_id}#{s}"></script>| 
    11089        end 
    11190end