Accès aux flux rss par région

This commit is contained in:
echarp 2014-01-02 00:21:49 +01:00
parent 97d285e497
commit bd2dca40c8
14 changed files with 70 additions and 23 deletions

View File

@ -66,7 +66,7 @@ main
margin: 10px 5px 5px 5px margin: 10px 5px 5px 5px
letter-spacing: 2px letter-spacing: 2px
h2 h2
margin: 52px 0px 18px margin: 52px 0px 20px
h3 h3
margin: 1.1em 0 1em margin: 1.1em 0 1em
font-size: 1.2em font-size: 1.2em
@ -85,7 +85,7 @@ main
margin: 10px 20px margin: 10px 20px
footer.bottom nav footer.bottom nav
margin: 18px auto -3px margin: 26px auto -3px
font-size: smaller font-size: smaller
a + a:before a + a:before
color: black color: black

View File

@ -30,9 +30,6 @@ table.calendar + h2
table.calendar table.calendar
width: 90% width: 90%
margin: 0 auto
padding: 0
border-spacing: 2px
tr tr
th th
padding-bottom: 0.35em padding-bottom: 0.35em
@ -78,14 +75,15 @@ table.calendar
ul ul
clear: left clear: left
margin-top: 0
margin-left: 0 margin-left: 0
padding-left: 15px padding-left: 15px
margin-bottom: 5px
list-style-type: circle list-style-type: circle
li li
color: #444 color: #444
margin: 0 margin: 0
padding: 0 padding: 0
margin-bottom: 5px
.event .event
font-size: smaller font-size: smaller
@ -101,7 +99,7 @@ table.calendar
.formats .formats
width: 90% width: 90%
margin: 10px auto margin: 11px auto 28px
font-size: smaller font-size: smaller
text-align: right text-align: right

View File

@ -1,17 +1,20 @@
@import "compass" @import "compass"
table table
margin: 1em auto margin: auto
padding: 1em border-spacing: 2px
border-spacing: 0
th th
padding: 0.3em 0.6em padding: 0.3em 0.6em
table.list
&.list
width: 30%
tr:nth-child(odd)
background-color: #D1EAFF
tr:nth-child(even)
background-color: #C9E2F5
td td
text-align: left padding: 0.2em
//tr:nth-child(even) td
// border-bottom: solid thin #ddf
//tr:nth-child(odd) td
// border-bottom: solid thin #fdd
.view_link:link, .edit_link:link, .delete_link:link .view_link:link, .edit_link:link, .delete_link:link
font-size: 0 font-size: 0

View File

@ -21,7 +21,7 @@ class EventsController < InheritedResources::Base
} }
format.rss { format.rss {
@events = @events.where('start_time >= now()').order(start_time: :asc).limit(25) @events = @events.future.limit(25)
} }
end end
end end

View File

@ -0,0 +1,5 @@
class RegionsController < InheritedResources::Base
def index
@regions = Region.all
end
end

View File

@ -5,13 +5,18 @@ class Event < ActiveRecord::Base
default_scope { where moderated: 1 } default_scope { where moderated: 1 }
scope :future, -> {
where('start_time >= now() and end_time <= ?', Date.today + 30)
.order(:start_time)
}
scope :year, -> year { scope :year, -> year {
where "end_time >= ? and start_time < ?", where "end_time >= ? and start_time < ?",
"#{year}-1-1", "#{year.to_i+1}-1-1" "#{year}-1-1", "#{year.to_i+1}-1-1"
} }
scope :month, -> year, month { scope :month, -> year, month {
where "end_time >= ? and start_time < ?", where 'end_time >= ? and start_time <= ?',
"#{year}-#{month.to_i-1}-1", "#{year}-#{month.to_i+2}-1" "#{year}-#{month.to_i-1}-23",
"#{month == '12' ? year.to_i+1 : year}-#{month == '12' ? 1 : month.to_i+1}-7"
} }
scope :region, -> region { where region: region } scope :region, -> region { where region: region }
scope :tag, -> tag { where "tags like ?", "%#{tag}%" } scope :tag, -> tag { where "tags like ?", "%#{tag}%" }

View File

@ -1,3 +1,5 @@
class Region < ActiveRecord::Base class Region < ActiveRecord::Base
has_many :lugs, foreign_key: :region has_many :lugs, foreign_key: :region
default_scope order(:name)
end end

View File

@ -38,5 +38,7 @@
.formats .formats
=t '.calendar_in' =t '.calendar_in'
= link_to 'rss', events_url(:rss) = link_to('rss', events_url(:rss))+','
, iCal ou calendrier Google = link_to 'iCal', events_url(:rss)
ou
= link_to 'calendrier Google', events_url(:rss)

View File

@ -24,7 +24,7 @@ xml.tag! 'rdf:RDF', 'xmlns:rdf' => "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
for event in @events for event in @events
xml.item 'rdf:about' => event_url(event) do xml.item 'rdf:about' => event_url(event) do
xml.title "#{event.city}: #{event.title}, #{l event.start_time.to_date, format: :long}" xml.title "#{event.city}: #{event.title}, le #{l event.start_time.to_date, format: :long}"
xml.link event_url event xml.link event_url event
xml.tag! 'dc:identifier', "#{event.id}@agendadulibre.org" xml.tag! 'dc:identifier', "#{event.id}@agendadulibre.org"
xml.tag! 'dc:date', event.start_time xml.tag! 'dc:date', event.start_time

View File

@ -59,7 +59,7 @@
%footer.bottom %footer.bottom
%nav %nav
= link_to t('.propose'), new_event_path = link_to t('.propose'), new_event_path
= link_to t('.rss'), events_url(:rss) = link_to t('.rss'), regions_url
= link_to t('.ical'), users_url = link_to t('.ical'), users_url
= link_to t('.map'), users_url = link_to t('.map'), users_url
= link_to t('.tags'), users_url = link_to t('.tags'), users_url

View File

@ -0,0 +1,25 @@
%h2=t '.title'
%p Chaque flux RSS liste les évènements pour les 30 prochains jours en cours dans une région donnée. En vous abonnant à un flux régional, vous recevrez des informations sur les évènements de votre région à portée locale, mais également les évènements à portée nationale comme les RMLL.
%table.list
%tr
%td=t :all, scope: 'activerecord.attributes.region.name_values'
%td= link_to :rss, events_path(format: :rss, region: :all)
- @regions.each do |region|
%tr
%td= region.name
%td= link_to :rss, events_path(format: :rss, region: region.id)
:markdown
Quelques fonctionnalités intéressantes des flux RSS :
* Vous pouvez limiter les évènements d'un flux RSS à un certain tag, en
passant le paramètre `tag`. Cela permet par exemple de récupérer un flux RSS
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/rss.php?tag=toulibre`.
* Vous pouvez modifier la limite aux 30 prochains jours des flux RSS en
utilisant le paramètre `daylimit`.
Exemple: `http://www.agendadulibre.org/rss.php?region=6&daylimit=42`

View File

@ -4,4 +4,4 @@
# Mime::Type.register "text/richtext", :rtf # Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone # Mime::Type.register_alias "text/html", :iphone
#Mime::Type.register "text/xml", :rss Mime::Type.register "text/xml", :rss

View File

@ -50,6 +50,9 @@ fr:
url: URL url: URL
contact: Contact contact: Contact
submitter: Soumetteur submitter: Soumetteur
region:
name_values:
all: Toutes les régions
helpers: helpers:
submit: submit:
@ -102,3 +105,6 @@ fr:
form: form:
save: Valider save: Valider
visualise: Visualiser visualise: Visualiser
regions:
index:
title: Liste des flux RSS

View File

@ -1,4 +1,5 @@
AgendaDuLibreRails::Application.routes.draw do AgendaDuLibreRails::Application.routes.draw do
resources :regions, only: :index
resources :events resources :events
resources :users resources :users