agenda-libre-ruby/app/views/events/index.rss.builder

58 lines
1.9 KiB
Plaintext
Raw Normal View History

2013-12-29 20:42:00 +01:00
xml.instruct!
2014-08-17 15:43:04 +02:00
xml.rdf :RDF,
'xmlns:rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
'xmlns' => 'http://purl.org/rss/1.0/',
'xmlns:dc' => 'http://purl.org/dc/elements/1.1/',
'xmlns:sy' => 'http://purl.org/rss/1.0/modules/syndication/',
'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
2013-12-29 20:42:00 +01:00
xml.channel 'rdf:about' => root_url do
2014-08-17 15:43:04 +02:00
title = t 'layouts.application.title'
if params[:region].present? && params[:region] != 'all'
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'
2014-08-17 15:43:04 +02:00
xml.dc :creator, root_url
2013-12-29 20:42:00 +01:00
xml.items do
xml.rdf :Seq do
2014-08-17 15:43:04 +02:00
@events.each do |event|
xml.rdf :li, 'rdf:resource' => event_url(event)
2013-12-29 20:42:00 +01:00
end
end
end
end
2014-08-17 15:43:04 +02:00
@events.each do |event|
2013-12-29 20:42:00 +01:00
xml.item 'rdf:about' => event_url(event) do
2014-08-17 15:43:04 +02:00
title = event.city
title += ": #{event.title}"
xml.title title + ", le #{l event.start_time.to_date, format: :long}"
2013-12-29 20:42:00 +01:00
xml.link event_url event
2014-08-17 15:43:04 +02:00
domain = root_url.gsub(/www/, '').gsub(/http.?:../, '').gsub(/:.*/, '')
xml.dc :identifier, "#{event.id}@#{domain}"
xml.dc :date, event.start_time.iso8601
2014-08-17 15:43:04 +02:00
if event.related_city && event.related_city.latitude &&
event.related_city.longitude
xml.georss :point,
event.related_city.latitude,
2014-08-17 15:53:54 +02:00
' ',
event.related_city.longitude
2014-08-17 15:43:04 +02:00
end
2013-12-29 20:42:00 +01:00
@event = event
content = render file: '/events/show.html', locals: { rss: true }
2013-12-29 20:42:00 +01:00
xml.description strip_tags content
xml.content(:encoded) { xml.cdata! content }
2013-12-29 20:42:00 +01:00
end
end
end