Skip to content

Instantly share code, notes, and snippets.

@elpeo

elpeo/gist:1613598

Created Jan 15, 2012
Embed
What would you like to do?
add Grow! button
--- a/plugin/section_footer2.rb
+++ b/plugin/section_footer2.rb
@@ -48,7 +48,7 @@ unless defined?(subtitle)
end
def init_buttons_status
- @installed_buttons = ['yaml', 'delicious', 'hatena', 'facebook', 'twitter', 'plusone']
+ @installed_buttons = ['yaml', 'delicious', 'hatena', 'facebook', 'twitter', 'plusone', 'grow']
if @conf['section_footer2.isDisplay'].nil?
@conf['section_footer2.isDisplay'] = ''
end
@@ -77,6 +77,13 @@ add_header_proc do
EOS
end
+add_footer_proc do
+ <<-"EOS"
+ <script src="http://growbutton.com/javascripts/button.js?apikey=#{u( @conf['section_footer2.grow.api_key'] )}&insert=false" type="text/javascript"></script>
+ <style type="text/css">.growbutton-ifm {margin-bottom: -7px !important; }</style>
+ EOS
+end
+
add_section_enter_proc do |date, index|
@category_to_tag_list = {}
init_buttons_status
@@ -194,6 +201,15 @@ def add_plusone(date, index)
%Q!<g:plusone size="medium" href="#{permalink(date, index, false)}"></g:plusone> | !
end
+def add_grow( date, index )
+ <<-HTML
+ <span itemscope itemref="rectangle" itemtype="http://growbutton.com/ns#button">
+ <span itemprop="url">#{permalink(date, index, false)}</span>
+ <span itemprop="title">#{h(subtitle(date, index))}</span>
+ </span> |
+ HTML
+end
+
def add_yaml(date, index)
r = ''
yaml_dir = "#{@cache_path}/yaml/"
@@ -253,6 +269,7 @@ add_conf_proc('section_footer2', 'Section Footer Button') do
@cgi.params['section_footer2.isDisplay'].each do |item|
@conf['section_footer2.isDisplay'] << item + '\n'
end
+ @conf['section_footer2.grow.api_key'] = @cgi.params['section_footer2.grow.api_key'][0]
end
r = '<h3>表示するボタンをチェックしてください(YAMLをチェックすると各自でインストールしたYAMLのボタンをすべて表示します)</h3>'
@@ -267,6 +284,8 @@ add_conf_proc('section_footer2', 'Section Footer Button') do
r << %Q|<input name="section_footer2.isDisplay" value="#{button}" #{item_checked} type="checkbox" />#{button}|
end
r << '</p>'
+ r << '<h3>Grow! API Key</h3>'
+ r << %Q|<input name="section_footer2.grow.api_key" value="#{h( @conf['section_footer2.grow.api_key'] )}" type="text" size="36" />|
end
# Local Variables:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment