Méta données rajoutées, utiles pour le référencement

recurrent
echarp 8 years ago
parent f140d7c7bd
commit 69f89f5b04
  1. 11
      Gemfile
  2. 5
      Gemfile.lock
  3. 26
      app/controllers/events_controller.rb
  4. 10
      app/views/layouts/application.html.haml

@ -49,7 +49,8 @@ gem 'spring', group: :development
gem 'haml-rails'
gem 'compass-rails'
gem 'modernizr-rails'
gem 'activeadmin', github: 'gregbell/active_admin'
# Patch older browsers so they do understand html5
gem 'webshims-rails'
gem 'devise'
@ -59,7 +60,9 @@ gem 'rails-i18n'
gem 'i18n-active_record',
git: 'git://github.com/svenfuchs/i18n-active_record.git',
require: 'i18n/active_record'
# A superb font to use as icons
gem 'font-awesome-rails'
# Validate mails submitted
gem 'email_validator'
# To display a patched diff for event descriptions
gem 'differ'
@ -67,6 +70,9 @@ gem 'differ'
# The central piece of this application: the month calendar view
gem 'simple_calendar'
# A generic library to administrate the tool
gem 'activeadmin', github: 'gregbell/active_admin'
# Markdown display
gem 'redcarpet'
@ -80,6 +86,9 @@ gem 'openlayers-rails'
gem 'tinymce-rails'
gem 'tinymce-rails-langs'
# SEO optimisations
gem 'meta-tags'
group :development do
gem 'guard-livereload'
gem 'guard-bundler'

@ -83,7 +83,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.7.1)
compass (0.12.6)
compass (0.12.7)
chunky_png (~> 1.2)
fssm (>= 0.2.7)
sass (~> 3.2.19)
@ -173,6 +173,8 @@ GEM
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
meta-tags (2.0.0)
actionpack (>= 3.0.0)
method_source (0.8.2)
mime-types (1.25.1)
minitest (5.4.0)
@ -311,6 +313,7 @@ DEPENDENCIES
jbuilder (~> 2.0)
jquery-rails
jquery-turbolinks
meta-tags
modernizr-rails
mysql2
openlayers-rails

@ -23,6 +23,19 @@ class EventsController < ApplicationController
end
@events = @events.month start_date.change day: 1
end
set_meta_tags description: t('layouts.application.subtitle'),
keywords: @events.pluck(:tags)
.join(' ')
.split
.group_by { |i| i }
.reject { |k, v| v.size < 2 }
.collect { |k, v| k },
DC: {
title: t('layouts.application.title'),
subject: t('layouts.application.subtitle'),
date: start_date.to_s
}
}
format.rss {
@ -113,6 +126,19 @@ class EventsController < ApplicationController
@event = Event.moderated
end
@event = @event.find params[:id]
set_meta_tags title: @event.title,
description: @event.description,
keywords: @event.tags,
DC: {
title: @event.title,
date: @event.start_time.to_s
},
geo: {
region: @event.related_region,
placename: @event.city,
position: "#{@event.related_city.try :latitude};#{@event.related_city.try :longitude}"
}
end
# Never trust parameters from the scary internet, only allow the white list through.

@ -2,19 +2,11 @@
/[if IE]
%html.no-js(lang="#{I18n.locale}")
%head
%title= content_for?(:title) ? yield(:title) : t('.title')
= display_meta_tags site: t('.title')
%meta(http-equiv='Content-Type' content='text/html; charset=utf-8')
%meta(name='viewport' content='width=device-width, initial-scale=1.0')
%meta(name='description' content='Agende du Libre. Free Software Calendar')
%meta(name='author' content='Emmanuel Charpentier')
%meta(name='robots' content='index, follow')
%meta(name='keywords' content='calendar, agenda, date')
%meta(name='dcterms.title' content='Free Calendar' lang='en')
%meta(name='dcterms.title' content='Agenda du Libre' lang='fr')
%meta(name='dcterms.subject' content='agenda')
= favicon_link_tag '/favicon.ico'
= auto_discovery_link_tag :rss, { controller: '/events', format: :rss }

Loading…
Cancel
Save