added built in ShareThis.com support
This commit is contained in:
parent
92a310fcde
commit
db77e492c6
2 changed files with 30 additions and 0 deletions
|
@ -31,5 +31,22 @@ class BlogPost < ActiveRecord::Base
|
|||
})
|
||||
end
|
||||
end
|
||||
|
||||
module ShareThis
|
||||
DEFAULT_KEY = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
|
||||
class << self
|
||||
def key
|
||||
RefinerySetting.find_or_set(:share_this_key, BlogPost::ShareThis::DEFAULT_KEY, {
|
||||
:scoping => :blog
|
||||
})
|
||||
end
|
||||
|
||||
def enabled?
|
||||
key = BlogPost::ShareThis.key
|
||||
key.present? and key != BlogPost::ShareThis::DEFAULT_KEY
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
<% content_for :head do %>
|
||||
<% if BlogPost::ShareThis.enabled? %>
|
||||
<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
|
||||
<script type="text/javascript">
|
||||
stLight.options({publisher:'<%= BlogPost::ShareThis.key %>'});
|
||||
</script>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% content_for :body_content_title, @blog_post.title %>
|
||||
|
||||
<% content_for :body_content_left do %>
|
||||
|
@ -15,6 +24,10 @@
|
|||
</p>
|
||||
<%= @blog_post.body %>
|
||||
|
||||
<% if BlogPost::ShareThis.enabled? %>
|
||||
<span class="st_sharethis" displayText="ShareThis"></span>
|
||||
<% end %>
|
||||
|
||||
<% if BlogPost.comments_allowed? %>
|
||||
<h2><%= t('.comments.title') %></h2>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue