Skip to content

Commit

Permalink
adds social media meta tags for proposals
Browse files Browse the repository at this point in the history
  • Loading branch information
xuanxu committed Sep 18, 2015
1 parent fcdfe23 commit d6c38b1
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/views/layouts/application.html.erb
Expand Up @@ -14,6 +14,7 @@
rel: "apple-touch-icon",
sizes: "200x200",
type: "image/png" %>
<%= content_for :social_media_meta_tags %>
<!--[if lt IE 9]>
<%= javascript_include_tag "respond" %>
<![endif]-->
Expand Down
6 changes: 6 additions & 0 deletions app/views/proposals/show.html.erb
@@ -1,3 +1,9 @@
<% provide :social_media_meta_tags do %>
<%= render "shared/social_media_meta_tags",
url: proposal_url(@proposal),
title: @proposal.title,
description: @proposal.summary %>
<% end %>
<% cache [locale_and_user_status(@proposal), @proposal, @proposal.author, Flag.flagged?(current_user, @proposal), @proposal_votes] do %>
<section class="proposal-show">
<div id="<%= dom_id(@proposal) %>" class="row">
Expand Down
16 changes: 16 additions & 0 deletions app/views/shared/_social_media_meta_tags.html.erb
@@ -0,0 +1,16 @@
<!-- Twitter -->
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@abriendomadrid" />
<meta name="twitter:title" content="<%= title %>" />
<meta name="twitter:description" content="<%= description %>" />
<meta name="twitter:image" content="https://decide.madrid.es/social-media-icon.png" />
<!-- Facebook OG -->
<meta id="ogtitle" property="og:title" content="<%= title %>"/>
<meta property="article:publisher" content="http://decide.madrid.es"/>
<meta property="article:author" content="https://www.facebook.com/Ayuntamiento-de-Madrid-770904446353931"/>
<meta property="og:type" content="article"/>
<meta id="ogurl" property="og:url" content="<%= url %>"/>
<meta id="ogimage" property="og:image" content="https://decide.madrid.es/social-media-icon.png"/>
<meta property="og:site_name" content="Madrid Participación"/>
<meta id="ogdescription" property="og:description" content="<%= description %>"/>
<meta property="fb:app_id" content="1662598980652932"/>
Binary file added public/social-media-icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions spec/features/proposals_spec.rb
Expand Up @@ -53,6 +53,14 @@
end
end

scenario 'Social Media Cards' do
proposal = create(:proposal)

visit proposal_path(proposal)
expect(page.html).to include "<meta name=\"twitter:title\" content=\"#{proposal.title}\" />"
expect(page.html).to include "<meta id=\"ogtitle\" property=\"og:title\" content=\"#{proposal.title}\"/>"
end

scenario 'Create' do
author = create(:user)
login_as(author)
Expand Down

0 comments on commit d6c38b1

Please sign in to comment.