Meilleure génération rss

This commit is contained in:
echarp 2014-08-17 15:43:04 +02:00
parent b5fd79e4e0
commit e90e4d9f0c
3 changed files with 53 additions and 31 deletions

View File

@ -1,8 +1,8 @@
source 'https://rubygems.org' source 'https://rubygems.org'
gem 'rails', '~> 4.1.0.rc1' gem 'rails'
# Use SCSS for stylesheets # Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.1' gem 'sass-rails'
# Use Uglifier as compressor for JavaScript assets # Use Uglifier as compressor for JavaScript assets
gem 'uglifier' gem 'uglifier'

View File

@ -60,8 +60,8 @@ GEM
arel (5.0.1.20140414130214) arel (5.0.1.20140414130214)
ast (2.0.0) ast (2.0.0)
bcrypt (3.1.7) bcrypt (3.1.7)
bourbon (3.2.3) bourbon (4.0.2)
sass (~> 3.2) sass (~> 3.3)
thor thor
brakeman (2.6.1) brakeman (2.6.1)
erubis (~> 2.6) erubis (~> 2.6)
@ -86,10 +86,18 @@ GEM
coffee-script-source coffee-script-source
execjs execjs
coffee-script-source (1.7.1) coffee-script-source (1.7.1)
compass (0.12.7) compass (1.0.0)
chunky_png (~> 1.2) chunky_png (~> 1.2)
fssm (>= 0.2.7) compass-core (~> 1.0.0)
sass (~> 3.2.19) compass-import-once (~> 1.0.5)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
sass (>= 3.3.13, < 3.5)
compass-core (1.0.0)
multi_json (~> 1.0)
sass (>= 3.3.0, < 3.5)
compass-import-once (1.0.5)
sass (>= 3.2, < 3.5)
compass-rails (2.0.0) compass-rails (2.0.0)
compass (>= 0.12.2) compass (>= 0.12.2)
devise (3.3.0) devise (3.3.0)
@ -115,7 +123,6 @@ GEM
formatador (0.2.5) formatador (0.2.5)
formtastic (2.3.0.rc4) formtastic (2.3.0.rc4)
actionpack (>= 3.0) actionpack (>= 3.0)
fssm (0.2.10)
guard (2.6.1) guard (2.6.1)
formatador (>= 0.2.4) formatador (>= 0.2.4)
listen (~> 2.7) listen (~> 2.7)
@ -196,7 +203,7 @@ GEM
activerecord (>= 3.0) activerecord (>= 3.0)
polyglot (0.3.5) polyglot (0.3.5)
powerpack (0.0.9) powerpack (0.0.9)
pry (0.10.0) pry (0.10.1)
coderay (~> 1.1.0) coderay (~> 1.1.0)
method_source (~> 0.8.1) method_source (~> 0.8.1)
slop (~> 3.4) slop (~> 3.4)
@ -251,11 +258,10 @@ GEM
sexp_processor (~> 4.0) sexp_processor (~> 4.0)
ruby_parser (3.5.0) ruby_parser (3.5.0)
sexp_processor (~> 4.1) sexp_processor (~> 4.1)
sass (3.2.19) sass (3.3.14)
sass-rails (4.0.2) sass-rails (4.0.1)
railties (>= 4.0.0, < 5.0) railties (>= 4.0.0, < 5.0)
sass (~> 3.2.0) sass (>= 3.1.10)
sprockets (~> 2.8, <= 2.11.0)
sprockets-rails (~> 2.0.0) sprockets-rails (~> 2.0.0)
sdoc (0.4.1) sdoc (0.4.1)
json (~> 1.7, >= 1.7.7) json (~> 1.7, >= 1.7.7)
@ -270,7 +276,7 @@ GEM
tilt (>= 1.3.3, < 2.1) tilt (>= 1.3.3, < 2.1)
slop (3.6.0) slop (3.6.0)
spring (1.1.3) spring (1.1.3)
sprockets (2.11.0) sprockets (2.12.1)
hike (~> 1.2) hike (~> 1.2)
multi_json (~> 1.0) multi_json (~> 1.0)
rack (~> 1.0) rack (~> 1.0)
@ -339,10 +345,10 @@ DEPENDENCIES
modernizr-rails modernizr-rails
mysql2 mysql2
quiet_assets quiet_assets
rails (~> 4.1.0.rc1) rails
rails-i18n rails-i18n
redcarpet redcarpet
sass-rails (~> 4.0.1) sass-rails
sdoc (~> 0.4.0) sdoc (~> 0.4.0)
select2-rails select2-rails
simple_calendar simple_calendar

View File

@ -1,34 +1,50 @@
xml.instruct! xml.instruct!
xml.rdf :RDF, 'xmlns:rdf' => "http://www.w3.org/1999/02/22-rdf-syntax-ns#", xml.rdf :RDF,
'xmlns' => "http://purl.org/rss/1.0/", 'xmlns:dc' => "http://purl.org/dc/elements/1.1/", 'xmlns:rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
'xmlns:sy' => "http://purl.org/rss/1.0/modules/syndication/", 'xmlns' => 'http://purl.org/rss/1.0/',
'xmlns:admin' => "http://webns.net/mvcb/", 'xmlns:cc' => "http://web.resource.org/cc/", 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/',
'xmlns:content' => "http://purl.org/rss/1.0/modules/content/", 'xmlns:sy' => 'http://purl.org/rss/1.0/modules/syndication/',
'xmlns:georss' => "http://www.georss.org/georss" do 'xmlns:admin' => 'http://webns.net/mvcb/',
'xmlns:cc' => 'http://web.resource.org/cc/',
'xmlns:content' => 'http://purl.org/rss/1.0/modules/content/',
'xmlns:georss' => 'http://www.georss.org/georss' do
xml.channel 'rdf:about' => root_url do xml.channel 'rdf:about' => root_url do
xml.title "Agenda du Libre [ #{params[:region].present? && params[:region] != 'all' ? Region.find(params[:region]).name : t('.all_regions')} ]" title = t 'layouts.application.title'
xml.description 'Agenda des événements autour du Logiciel Libre' if params[:region].present? && params[:region] != 'all'
xml.link 'http://www.agendadulibre.org' region = Region.find(params[:region]).name
title += " [#{region}]"
end
xml.title title
xml.description t 'layouts.application.subtitle'
xml.link root_url
xml.dc :language, 'fr' xml.dc :language, 'fr'
xml.dc :creator, 'AgendaDuLibre.org' xml.dc :creator, root_url
xml.items do xml.items do
xml.rdf :Seq do xml.rdf :Seq do
for event in @events @events.each do |event|
xml.rdf :li, 'rdf:resource' => event_url(event) xml.rdf :li, 'rdf:resource' => event_url(event)
end end
end end
end end
end end
for event in @events @events.each do |event|
xml.item 'rdf:about' => event_url(event) do xml.item 'rdf:about' => event_url(event) do
xml.title "#{event.city}: #{event.title}, le #{l event.start_time.to_date, format: :long}" title = event.city
title += ": #{event.title}"
xml.title title + ", le #{l event.start_time.to_date, format: :long}"
xml.link event_url event xml.link event_url event
xml.dc :identifier, "#{event.id}@agendadulibre.org" domain = root_url.gsub(/www/, '').gsub(/http.?:../, '').gsub(/:.*/, '')
xml.dc :identifier, "#{event.id}@#{domain}"
xml.dc :date, event.start_time.iso8601 xml.dc :date, event.start_time.iso8601
xml.georss :point, "#{event.related_city.latitude} #{event.related_city.longitude}" rescue nil if event.related_city && event.related_city.latitude &&
event.related_city.longitude
xml.georss :point,
"#{event.related_city.latitude}
#{event.related_city.longitude}"
end
@event = event @event = event
content = render file: '/events/show.html', locals: { rss: true } content = render file: '/events/show.html', locals: { rss: true }