xmllistevents.php ajouté

This commit is contained in:
echarp 2014-07-19 09:03:08 +02:00
parent 2c6080abc0
commit e75f29860b
3 changed files with 27 additions and 0 deletions

View File

@ -46,6 +46,10 @@ class EventsController < ApplicationController
format.ics {
@events = @events.where('start_time > ?', 360.days.ago).order :id
}
format.xml {
@events = @events.order :id
}
end
end

View File

@ -0,0 +1,21 @@
xml.instruct!
xml.events do
for event in @events
xml.event do
xml.title event.title
xml.start_time event.start_time.strftime '%Y/%m/%d %T'
xml.end_time event.end_time.strftime '%Y/%m/%d %T'
xml.city event.city
xml.region event.related_region
xml.locality event.locality
xml.tags event.tags
xml.contact event.contact
xml.adlurl event_url event
@event = event
content = render file: '/events/show.html', locals: { rss: true }
xml.description { xml.cdata! content }
end
end
end

View File

@ -23,6 +23,8 @@ Rails.application.routes.draw do
resources :tags, only: [ :index, :show ]
resources :maps, only: [:index]
# A mechanism to list "all" events
get '(:format)listevents.php', to: 'events#index'
# Respond to rss and ical calls
get ':format.php' => 'events#index'