Commit c6dc9c48aca2acb22993f35bb89833c378eaed66

Authored by Daniela Feitosa
1 parent f1dd48d2

Added meta tags for OpenGraph and Twitter

(ActionItem2610)
app/helpers/layout_helper.rb
... ... @@ -90,5 +90,8 @@ module LayoutHelper
90 90 end
91 91 end
92 92  
  93 + def meta_description_tag(article=nil)
  94 + article ? truncate(strip_tags(article.body.to_s), :length => 200) : environment.name
  95 + end
93 96 end
94 97  
... ...
app/views/layouts/application-ng.rhtml
... ... @@ -6,6 +6,27 @@
6 6 <!--<meta http-equiv="refresh" content="1"/>-->
7 7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
8 8 <meta name="description" content="<%= @environment.name %>" />
  9 +
  10 + <!-- Twitter Card -->
  11 + <meta name="twitter:card" value="summary">
  12 + <meta name="twitter:title" content="<%= h page_title %>">
  13 + <meta name="twitter:description" content="<%= meta_description_tag(@page) %>">
  14 + <meta name="twitter:image" content="<%= @page.body_images_paths.first.to_s if @page %>">
  15 +
  16 + <!-- Open Graph -->
  17 + <meta property="og:type" content="<%= @page ? 'article' : 'website' %>">
  18 + <meta property="og:url" content="<%= @page ? url_for(@page.url) : @environment.top_url %>">
  19 + <meta property="og:title" content="<%= h page_title %>">
  20 + <meta property="og:site_name" content="<%= profile ? profile.name : @environment.name %>">
  21 + <meta property="og:description" content="<%= @page ? truncate(strip_tags(@page.body.to_s), :length => 200) : @environment.name %>">
  22 +
  23 + <% if @page %>
  24 + <meta property="article:published_time" content="<%= show_date(@page.published_at) %>">
  25 + <% @page.body_images_paths.each do |img| %>
  26 + <meta property="og:image" content="<%= img.to_s %>">
  27 + <% end %>
  28 + <% end %>
  29 +
9 30 <link rel="shortcut icon" href="<%= image_path(theme_favicon) %>" type="image/x-icon" />
10 31 <%= noosfero_javascript %>
11 32 <%= noosfero_stylesheets %>
... ...