Changeset 5026

Show
Ignore:
Timestamp:
01/20/08 11:49:10 (5 years ago)
Author:
hsbt
Message:

platform/tdiary/*/account_ad.rb: refactoring, based on openid.rb

Location:
platform/tdiary
Files:
2 removed
2 modified

Legend:

Unmodified
Added
Removed
  • platform/tdiary/doc/ja/account_ad.txt

    r5024 r5026  
    66 
    77! 更新履歴 
     8!! 20080120 
     9* openid.rb をベースにリファクタリング 
    810 
    911!! 20070109 
  • platform/tdiary/plugin/account_ad.rb

    r3326 r5026  
    11# account_ad.rb $Revision: 1.3 $ 
    22# 
    3 # Copyright (c) 2005 SHIBATA  Hiroshi <h-sbt@nifty.com> 
     3# Copyright (c) 2008 SHIBATA  Hiroshi <h-sbt@nifty.com> 
    44# Distributed under the GPL 
    55# 
    66 
    7 add_header_proc do 
    8    account_ad_init 
    9  
    10    account_name = @conf['account.name'] 
    11    account_service = @conf['account.service'] 
    12  
    13    if @mode == "day" 
    14       permalink=@conf.base_url+anchor(@date.strftime('%Y%m%d')) 
    15    else 
    16       permalink=@conf.base_url 
    17    end 
    18  
    19         if account_name.length > 0 then 
    20         <<-HTML 
     7if /^(latest|day|conf|saveconf)$/ =~ @mode then 
     8         
     9        @account_ad_list = { 
     10                # Service => ServiceHomepage 
     11                'Hatena' => 'https://www.hatena.ne.jp/', 
     12        } 
     13         
     14        if @conf['account.service'] and @conf['account.name'] then 
     15                if @mode == "day" 
     16                        permalink=@conf.base_url+anchor(@date.strftime('%Y%m%d')) 
     17                else 
     18                        permalink=@conf.base_url 
     19                end 
     20                 
     21                account_service = @account_ad_list[@conf['account.service']] 
     22                account_name = @conf['account.name'] 
     23                 
     24                add_header_proc do       
     25                        result = <<-HTML 
    2126                        <!-- 
    2227                        <rdf:RDF 
     
    3439                        </rdf:RDF> 
    3540                        --> 
    36         HTML 
    37         else 
    38                 '' 
     41           HTML 
     42                        result.gsub( /^\t\t/, '' ) 
     43                end 
    3944        end 
    4045end 
    4146 
    42 def account_ad_init 
    43    @conf['account.name'] ||= "" 
    44    @conf['account.service'] ||= "http://www.hatena.ne.jp/" 
    45 end 
     47add_conf_proc( 'account_ad', 'Account Auto-Discovery' ) do 
    4648 
    47 if @mode == 'saveconf' 
    48    def saveconf_account_ad 
     49        if @mode == 'saveconf' then 
    4950      @conf['account.name'] = @cgi.params['account.name'][0] 
    5051      @conf['account.service'] = @cgi.params['account.service'][0] 
    51    end 
     52        end 
     53 
     54        options = '' 
     55        @account_ad_list.each_key do |key| 
     56                options << %Q|<option value="#{h key}"#{" selected" if @conf['account.service'] == key}>#{h key}</option>\n| 
     57        end 
     58                 
     59        <<-HTML 
     60   <h3 class="subtitle">Account Service</h3> 
     61        <p><select name="account.service"> 
     62                #{options} 
     63        </select></p> 
     64   <h3 class="subtitle">Account Name</h3> 
     65   <p><input name="account.name" value="#{h @conf['account.name']}" /></p> 
     66   HTML 
    5267end