Show
Ignore:
Timestamp:
06/01/08 18:28:13 (6 months ago)
Author:
hsbt
Message:

small refactoring.

Location:
platform/tdiary/plugin
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • platform/tdiary/plugin/en/livedoor_weather.rb

    r3325 r12982  
    1111# 
    1212 
    13 @lwws_rest_url = 'http://weather.livedoor.com/forecast/webservice/rest/v1' 
    1413@lwws_plugin_name = 'livedoor weather' 
    1514@lwws_label_city_id = 'City ID' 
  • platform/tdiary/plugin/ja/livedoor_weather.rb

    r5057 r12982  
    1111# 
    1212 
    13 @lwws_rest_url = 'http://weather.livedoor.com/forecast/webservice/rest/v1' 
    1413@lwws_plugin_name = 'livedoor 天気情報' 
    1514@lwws_label_city_id = '都市IDの設定' 
  • platform/tdiary/plugin/livedoor_weather.rb

    r12918 r12982  
    1010require 'timeout' 
    1111require 'rexml/document' 
     12 
     13@lwws_rest_url = 'http://weather.livedoor.com/forecast/webservice/rest/v1' 
    1214 
    1315def lwws_init 
     
    7577end 
    7678 
    77 def lwws_to_html( date_status, date = nil ) 
     79def lwws_to_html( date ) 
    7880        lwws_init 
    7981 
    8082        cache = "#{@cache_path}/lwws" 
    81  
    82         unless date 
    83                 file_name = "#{cache}/#{convert_date( date_status)}.xml" # file_name is YYYYMMDD 
     83        case date 
     84        when "today", "tommorow", "dayaftertommorow" 
     85                file_name = "#{cache}/#{convert_date( date_status)}.xml"  
    8486        else 
    8587                file_name = "#{cache}/#{date}.xml" 
    8688        end 
     89 
     90        today = Time.now.strftime("%Y%m%d") 
    8791 
    8892        begin 
     
    106110                        width = doc.elements["image/width"].text 
    107111                        height = doc.elements["image/height"].text 
    108                         result << %Q|<a href="#{link}"><img src="#{url}" border="0" alt="#{title}" title="#{title}" width=#{width} height="#{height}" /></a>| 
     112                        if date == today  
     113                                result << %Q|<a href="#{link}">| 
     114                        end 
     115                        result << %Q|<img src="#{url}" border="0" alt="#{title}" title="#{title}" width=#{width} height="#{height}" /></a>| 
     116                        if date == today 
     117                                result << %Q|</a>| 
     118                        end 
    109119                end 
    110120 
     
    123133                return '' 
    124134        end 
    125 end 
    126  
    127 def lwws_today 
    128         lwws_get( "today" ) 
    129         lwws_to_html( "today" ) 
    130 end 
    131  
    132 def lwws_tomorrow 
    133         lwws_get( "tomorrow" ) 
    134         lwws_to_html( "tomorrow" ) 
    135 end 
    136  
    137 def lwws_dayaftertomorrow 
    138         lwws_get( "dayaftertomorrow" ) 
    139         lwws_to_html( "dayaftertomorrow" ) 
    140 end 
    141  
    142 def lwws( date ) 
    143         lwws_to_html( "", date ) 
    144135end 
    145136 
     
    188179add_body_enter_proc do |date| 
    189180        unless feed? 
    190                 lwws_to_html( "", date.strftime("%Y%m%d")) 
     181                lwws_to_html( date.strftime("%Y%m%d") ) 
    191182        end 
    192183end 
  • platform/tdiary/plugin/zh/livedoor_weather.rb

    r3325 r12982  
    1111# 
    1212 
    13 @lwws_rest_url = 'http://weather.livedoor.com/forecast/webservice/rest/v1' 
    1413@lwws_plugin_name = 'livedoor weather' 
    1514@lwws_label_city_id = 'City ID'