root/platform/tdiary/plugin/account_ad.rb @ 5174

Revision 5174, 1.8 kB (checked in by hsbt, 5 years ago)

platform/tdiary/plugin/account_ad.rb: fix service url.

Line 
1# account_ad.rb $Revision: 1.3 $
2#
3# Copyright (c) 2008 SHIBATA  Hiroshi <h-sbt@nifty.com>
4# Distributed under the GPL
5#
6
7if /^(latest|day|conf|saveconf)$/ =~ @mode then
8       
9        @account_ad_list = {
10                # Service => ServiceHomepage
11                'Hatena' => 'http://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
26                        <!--
27                        <rdf:RDF
28                           xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
29                           xmlns:foaf="http://xmlns.com/foaf/0.1/">
30                        <rdf:Description rdf:about="#{permalink}">
31                           <foaf:maker rdf:parseType="Resource">
32                             <foaf:holdsAccount>
33                               <foaf:OnlineAccount foaf:accountName="#{h(account_name)}">
34                                 <foaf:accountServiceHomepage rdf:resource="#{h(account_service)}"/>
35                               </foaf:OnlineAccount>
36                             </foaf:holdsAccount>
37                           </foaf:maker>
38                        </rdf:Description>
39                        </rdf:RDF>
40                        -->
41           HTML
42                        result.gsub( /^\t\t/, '' )
43                end
44        end
45end
46
47add_conf_proc( 'account_ad', 'Account Auto-Discovery' ) do
48
49        if @mode == 'saveconf' then
50      @conf['account.name'] = @cgi.params['account.name'][0]
51      @conf['account.service'] = @cgi.params['account.service'][0]
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
67end
Note: See TracBrowser for help on using the browser.