From 60dfb82c003d688538a49a9477bef4d7803260cb Mon Sep 17 00:00:00 2001 From: echarp Date: Sat, 4 Jan 2014 11:34:50 +0100 Subject: [PATCH] Les calendriers au format ical sont en place --- Gemfile | 2 ++ Gemfile.lock | 9 ++++-- app/controllers/events_controller.rb | 4 +++ app/controllers/regions_controller.rb | 2 +- app/models/region.rb | 2 +- app/views/events/index.ics.erb | 19 ++++++++++++ app/views/layouts/application.html.haml | 2 +- app/views/regions/icallist.html.haml | 40 +++++++++++++++++++++++++ config/application.rb | 2 ++ config/locales/fr.yml | 2 ++ config/routes.rb | 5 +++- 11 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 app/views/events/index.ics.erb create mode 100644 app/views/regions/icallist.html.haml diff --git a/Gemfile b/Gemfile index d5adae23..412a230a 100644 --- a/Gemfile +++ b/Gemfile @@ -58,4 +58,6 @@ group :development do gem 'guard-livereload' gem 'guard-bundler' gem 'guard-minitest' + gem 'quiet_assets' + gem 'webrick', '>= 1.3.1' end diff --git a/Gemfile.lock b/Gemfile.lock index ce254c53..83e71fd4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -90,7 +90,7 @@ GEM eventmachine (1.0.3) execjs (2.0.2) ffi (1.9.3) - font-awesome-rails (4.0.3.0) + font-awesome-rails (4.0.3.1) railties (>= 3.2, < 5.0) formatador (0.2.4) formtastic (2.3.0.rc2) @@ -128,7 +128,7 @@ GEM inherited_resources (1.4.1) has_scope (~> 0.6.0.rc) responders (~> 1.0.0.rc) - jbuilder (2.0.1) + jbuilder (2.0.2) activesupport (>= 3.0.0) multi_json (>= 1.2.0) jquery-rails (3.0.4) @@ -164,6 +164,8 @@ GEM coderay (~> 1.0) method_source (~> 0.8) slop (~> 3.4) + quiet_assets (1.0.2) + railties (>= 3.1, < 5.0) rack (1.5.2) rack-test (0.6.2) rack (>= 1.0) @@ -230,6 +232,7 @@ GEM json (>= 1.8.0) warden (1.2.3) rack (>= 1.0) + webrick (1.3.1) PLATFORMS ruby @@ -249,6 +252,7 @@ DEPENDENCIES jquery-rails jquery-turbolinks mysql2 + quiet_assets rails rails-i18n redcarpet @@ -257,3 +261,4 @@ DEPENDENCIES simple_calendar! turbolinks uglifier + webrick (>= 1.3.1) diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 937f8df6..836a2335 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -22,6 +22,10 @@ class EventsController < InheritedResources::Base @events = @events.future @events = @events.limit params[:daylimit] if params[:daylimit] } + + format.ics { + @events = @events.where('start_time > ?', 360.days.ago).order :id + } end end diff --git a/app/controllers/regions_controller.rb b/app/controllers/regions_controller.rb index 4635f6df..61df8756 100644 --- a/app/controllers/regions_controller.rb +++ b/app/controllers/regions_controller.rb @@ -1,5 +1,5 @@ class RegionsController < InheritedResources::Base - def index + def icallist @regions = Region.all end end diff --git a/app/models/region.rb b/app/models/region.rb index 442af21c..04b34c8b 100644 --- a/app/models/region.rb +++ b/app/models/region.rb @@ -1,5 +1,5 @@ class Region < ActiveRecord::Base has_many :lugs, foreign_key: :region - default_scope { order(:name) } + default_scope { order :name } end diff --git a/app/views/events/index.ics.erb b/app/views/events/index.ics.erb new file mode 100644 index 00000000..3f8716bd --- /dev/null +++ b/app/views/events/index.ics.erb @@ -0,0 +1,19 @@ +BEGIN:VCALENDAR +VERSION:2.0 +PRODID:-//AgendaDuLibre.org +X-WR-CALNAME:Agenda du Libre +X-WR-TIMEZONE:Europe/Paris +CALSCALE:GREGORIAN +X-WR-CALDESC:L'Agenda des évènements autour du Libre +<% @events.each do |event| %> +BEGIN:VEVENT +DTSTART;TZID=Europe/Paris:<%= event.start_time.strftime '%Y%m%dT%H%M%S' %> +DTEND;TZID=Europe/Paris:<%= event.end_time.strftime '%Y%m%dT%H%M%S' %> +UID:<%= event.id %>@agendadulibre.org +SUMMARY:<%= event.title %> +URL:<%= event_url event %> +DESCRIPTION:Un évènement de l'Agenda du Libre +LOCATION:<%= event.city.gsub('-', ' ') %> +END:VEVENT +<% end %> +END:VCALENDAR diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index b5de2738..b4e7415d 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -60,7 +60,7 @@ %nav = link_to t('.propose'), new_event_path = link_to t('.rss'), regions_url - = link_to t('.ical'), users_url + = link_to t('.ical'), icallist_regions_url = link_to t('.map'), users_url = link_to t('.tags'), users_url = link_to t('.infos'), users_url diff --git a/app/views/regions/icallist.html.haml b/app/views/regions/icallist.html.haml new file mode 100644 index 00000000..4c272ad5 --- /dev/null +++ b/app/views/regions/icallist.html.haml @@ -0,0 +1,40 @@ +%h2=t '.title' + +:markdown + Chaque calendrier iCal liste les évènements pour les 30 jours à venir dans une région donnée. En vous inscrivant au calendrier de votre région, vous verrez apparaître les évènements de votre région à portée locale, ainsi que tous les évènements à portée nationale, comme les RMLL. Le lien *webcal* permet d'ajouter un calendrier dans votre logiciel favori, tandis que le lien *google* permet d'ajouter un calendrier à votre agenda Google. + +%table.list + %tr + -#http://www.google.com/calendar/render?cid=http://www.agendadulibre.org/ical.php?region%3Dall + %td=t :all, scope: 'activerecord.attributes.region.name_values' + %td= link_to :webcal, events_path(protocol: :webcal, format: :ics, region: :all, only_path: false) + %td= link_to :google, "http://www.google.com/calendar/render?cid=#{events_url(format: :ics, region: :all)}" + + - @regions.each do |region| + %tr + %td= region.name + %td= link_to :webcal, events_path(protocol: :webcal, format: :ics, region: region.id, only_path: false) + %td= link_to :google, "http://www.google.com/calendar/render?cid=#{events_url(format: :ics, region: region.id)}" + +:markdown + Ce calendrier a été testé avec succès avec: + + * [Mozilla Sunbird](http://www.mozilla.org/projects/calendar/sunbird.html), l'application Calendrier indépendante de Mozilla. + Pour ajouter l'Agenda du Libre, allez dans *File* puis *Subscribe to Remote Calendars*. Indiquer qu'il s'agit d'un calendrier distant en sélectionnant *Remote*. À l'étape suivante, sélectionnez *WebDAV*, et indiquer l'URL du calendrier que vous trouverez ci-dessous. À l'étape qui suit, donner un nom à ce calendrier, puis validez. + * L'[extension Calendar](http://www.mozilla.org/projects/calendar/download.html) pour Mozilla Firefox. + Pour ajouter l'Agenda du Libre, allez dans *Fichier* puis *S'abonner à un calendrier distant*. Dans la fenêtre qui s'ouvre, entrez un nom pour le calendrier, ainsi que l'URL de celui-ci, disponible dans la liste ci-dessus. + * [KOrganizer](http://korganizer.kde.org/), le calendrier de KDE + * [Evolution](http://www.gnome.org/projects/evolution/) (versions 2.0.4 et 2.2.x). + * vCalendar, [un plugin](http://claws.sylpheed.org/plugins.php) pour [Sylpheed Claws](http://claws.sylpheed.org/). Chargez le module par le menu Configuration/Modules, puis avec un clic droit sur le dossier vCalender, choisissez "S'inscrire à un Webcal". + * [GNU Emacs](http://www.gnu.org/software/emacs/emacs.html), à l'aide de l'extension [icalendar.el](http://de.geocities.com/ulf_jasper/lisp/icalendar.el.txt) + + Les applications suivantes peuvent sans doute fonctionner: + + * Une [extension Calendar](http://www.mozilla.org/projects/calendar/download.html) pour Thunderbird. + + N'hésitez pas à [nous faire part](devel AT agendadulibre.org) de vos succès et de vos échecs avec d'autres logiciels. + + Quelques fonctionnalités additionnelles des calendriers iCal : + + * Vous pouvez limiter les évènements d'un calendrier iCal à un certain tag, en passant le paramètre `tag`. Cela permet par exemple de récupérer un calendrier iCal des évènements organisés uniquement par votre association, à partir du moment où vous pensez à marquer tous vos évènements avec un tag précis. + Exemple: `http://www.agendadulibre.org/ical.php?tag=toulibre`. diff --git a/config/application.rb b/config/application.rb index e6cbe268..a1ef9f9e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -22,5 +22,7 @@ module AgendaDuLibreRails config.i18n.default_locale = :fr I18n.config.enforce_available_locales = true + + #config.quiet_assets = false end end diff --git a/config/locales/fr.yml b/config/locales/fr.yml index fde0f889..65911a3f 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -108,3 +108,5 @@ fr: regions: index: title: Liste des flux RSS + icallist: + title: Liste des calendriers iCal diff --git a/config/routes.rb b/config/routes.rb index 0ee1bd28..dc884bec 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,8 +1,11 @@ AgendaDuLibreRails::Application.routes.draw do - resources :regions, only: :index + resources :regions, only: [ :index ] do + get 'icallist', on: :collection + end resources :events resources :users + get 'ical.php' => 'events#index', format: :ics get ':format.php' => 'events#index' devise_for :admin_users, ActiveAdmin::Devise.config