Skip to content
This repository
Browse code

Merge pull request #108 from msevestre/master

Correct Issue #106. Logo for open graph protocol with facebook
  • Loading branch information...
commit 21b9f40cf4666d690ff7bcb8e1fe98d28e7431eb 2 parents e9e6890 + 85d3812
Jean-Philippe Boily authored
5 app/helpers/monologue/application_helper.rb
@@ -48,6 +48,11 @@ def facebook_icon
48 48 social_icon("facebook", Monologue.facebook_url, Monologue.facebook_url)
49 49 end
50 50
  51 + def absolute_image_url(url)
  52 + return url if url.starts_with? "http"
  53 + request.protocol + request.host + url
  54 + end
  55 +
51 56 # TODO: That should be move in TagHelper if I manage to get that loaded
52 57 def tag_url(tag)
53 58 "#{Monologue::Engine.routes.url_helpers.root_path}tags/#{tag.name.downcase}"
5 app/views/layouts/monologue/application/_fb_open_graph.html.erb
... ... @@ -1,4 +1,7 @@
1 1 <meta property="og:title" content="<%= monologue_accurate_title %>"/>
2 2 <meta property="og:type" content="<%= controller.action_name == "show" ? "article" : "blog" %>"/>
3 3 <meta property="og:url" content="http://<%= request.host_with_port %><%= request.path.gsub("//","/") %>"/>
4   -<meta property="og:site_name" content="<%= Monologue.site_name %>"/>
  4 +<meta property="og:site_name" content="<%= Monologue.site_name %>"/>
  5 +<% if Monologue.facebook_logo%>
  6 + <meta property="og:image" content="<%= absolute_image_url(image_path(Monologue.facebook_logo)) %>" />
  7 +<% end %>
1  lib/monologue.rb
@@ -15,6 +15,7 @@ module Monologue
15 15
16 16 :facebook_like_locale,
17 17 :facebook_url,
  18 + :facebook_logo, #used in the open graph protocol to display an image when a post is liked
18 19
19 20 :google_plus_account_url,
20 21 :google_plusone_locale,
1  spec/dummy/config/initializers/monologue.rb
@@ -27,6 +27,7 @@
27 27 #SOCIAL
28 28 Monologue.twitter_username = "jipiboily"
29 29 Monologue.facebook_url = "https://www.facebook.com/jipiboily"
  30 +Monologue.facebook_logo = 'logo.png'
30 31 Monologue.google_plus_account_url = "https://plus.google.com/u/1/115273180419164295760/posts"
31 32 Monologue.linkedin_url = "http://www.linkedin.com/in/jipiboily"
32 33 Monologue.github_username = "jipiboily"
12 spec/helpers/application_helper_spec.rb
@@ -11,6 +11,18 @@
11 11 end
12 12 end
13 13
  14 + describe "resolving the absolute image url" do
  15 + it "should create the fully qualified url for a relative url" do
  16 + controller.request.host = 'www.domain.com'
  17 + helper.absolute_image_url('/image.png').should eq "http://www.domain.com/image.png"
  18 + end
  19 +
  20 + it "should returns the url for an absolute url" do
  21 + url ='https://mydomain.com/image.png'
  22 + helper.absolute_image_url(url).should eq url
  23 + end
  24 + end
  25 +
14 26 describe "creating the sidebar section for a title and a block" do
15 27 before(:each) do
16 28 @content = "this is the content"

0 comments on commit 21b9f40

Please sign in to comment.
Something went wrong with that request. Please try again.