From e75f29860b3878faa806b467d4327a92d6829480 Mon Sep 17 00:00:00 2001 From: echarp Date: Sat, 19 Jul 2014 09:03:08 +0200 Subject: [PATCH] =?UTF-8?q?xmllistevents.php=20ajout=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/events_controller.rb | 4 ++++ app/views/events/index.xml.builder | 21 +++++++++++++++++++++ config/routes.rb | 2 ++ 3 files changed, 27 insertions(+) create mode 100644 app/views/events/index.xml.builder diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index a8cfcb6d..ad21f280 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -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 diff --git a/app/views/events/index.xml.builder b/app/views/events/index.xml.builder new file mode 100644 index 00000000..cdb3cd8e --- /dev/null +++ b/app/views/events/index.xml.builder @@ -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 diff --git a/config/routes.rb b/config/routes.rb index d0e1ba52..9d73e0f0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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'