root/platform/tdiary/plugin/retweet.rb @ 37277

Revision 37277, 2.0 kB (checked in by machu, 3 years ago)

add subtitle

Line 
1#
2# retweet.rb - show retweet count in each section
3#   This plugin uses a retweet button script powered by topsy.com
4#
5# Copyright (C) 2010, MATSUOKA Kohei <http://www.machu.jp/diary/>
6# You can redistribute it and/or modify it under GPL2.
7#
8
9#
10# topsy settings. see: http://labs.topsy.com/button/retweet-button/#global_settings
11#
12# your twitter nickname
13@topsy_nick = "your_twitter_account"
14# retweet button color
15@topsy_theme = "blue"
16# retweet button text
17@topsy_retweet_text = "ReTweet"
18
19unless defined?(permalink)
20  def permalink( date, index, escape = true )
21    ymd = date.strftime( "%Y%m%d" )
22    uri = @conf.index.dup
23    uri[0, 0] = @conf.base_url unless %r|^https?://|i =~ uri
24    uri.gsub!( %r|/\./|, '/' )
25    link = uri + anchor( "#{ymd}p%02d" % index )
26    link = link.sub( /#/, "%23" ) if escape
27    link
28  end
29end
30
31# load tospy script and initialize
32add_header_proc do
33        r = ''
34  r << %Q|<script type="text/javascript" src="http://cdn.topsy.com/topsy.js?init=topsyWidgetCreator"></script>|
35  r << %Q|<script type="text/javascript" id="topsy_global_settings">|
36  r << %Q|  var topsy_theme = "#{@topsy_theme}";| if @topsy_theme
37  r << %Q|  var topsy_nick = "#{@topsy_nick}";| if @topsy_nick
38  r << %Q|  var topsy_retweet_text = "#{@topsy_retweet_text}"| if @topsy_retweet_text
39  r << %Q|</script>|
40end
41
42# show retweet button in top of section
43add_section_enter_proc do |date, index|
44  <<-"EOS"
45  <div class="topsy_widget_data" style="float: right; margin-left: 1em;"> <!-- {
46    "url": "#{permalink(date, index)}",
47    "style": "big"
48  } --></div>
49  EOS
50end
51
52# show retweet button in end of section
53add_section_leave_proc do |date, index|
54  <<-"EOS"
55  <div class="tags">
56          <img src="http://www.machu.jp/diary/twitter_logo_small.png" height="16" width="62" alt="Twitter">:
57    <div class="topsy_widget_data" style="float: right; margin-left: 1em;"> <!-- {
58      "url": "#{permalink(date, index)}",
59      "title": "#{@subtitle || ''}",
60      "style": "small"
61    } --></div>
62  </div>
63  EOS
64end
Note: See TracBrowser for help on using the browser.