diff options
-rw-r--r-- | app/models/blog_post.rb | 17 | ||||
-rw-r--r-- | app/views/blog/posts/show.html.erb | 13 |
2 files changed, 30 insertions, 0 deletions
diff --git a/app/models/blog_post.rb b/app/models/blog_post.rb index ad31778..0470cf7 100644 --- a/app/models/blog_post.rb +++ b/app/models/blog_post.rb @@ -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 diff --git a/app/views/blog/posts/show.html.erb b/app/views/blog/posts/show.html.erb index 163b6b3..ed2c082 100644 --- a/app/views/blog/posts/show.html.erb +++ b/app/views/blog/posts/show.html.erb @@ -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> |