Browse Source

Le flux rss utilise la vue html pour constituer la description des événements

recurrent
echarp 8 years ago
parent
commit
c0059b6846
  1. 3
      app/assets/stylesheets/events.css.sass
  2. 2
      app/models/region.rb
  3. 28
      app/views/events/index.rss.builder
  4. 18
      app/views/events/show.html.haml
  5. 2
      config/initializers/mime_types.rb

3
app/assets/stylesheets/events.css.sass

@ -47,6 +47,9 @@ table.calendar
color: #544f32
font-size: 0.8em
margin-top: -1px
.event
a:link, a:visited
color: #8F4900
&.future
border-color: rgb(150, 207, 255)
background-color: #C6E5FF

2
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

28
app/views/events/index.rss.builder

@ -28,31 +28,11 @@ xml.tag! 'rdf:RDF', 'xmlns:rdf' => "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xml.link event_url event
xml.tag! 'dc:identifier', "#{event.id}@agendadulibre.org"
xml.tag! 'dc:date', event.start_time
xml.tag! 'georss:point', City.find_all_by_majname(event.city.upcase).collect { |c| "#{c.latitude} #{c.longitude}" }.first
city = City.find_by_majname event.city.gsub('-', ' ').upcase
xml.tag! 'georss:point', "#{city.latitude} #{city.longitude}" rescue nil
content = "<h2><em>#{event.city}</em>: #{event.title}</h2>
<h3>Date et lieu</h3>"
if event.same_day?
content += "
<p>Le #{l event.start_time.to_date, format: :long},
de #{l event.start_time, format: :hours} à #{l event.end_time, format: :hours}.</p>
<p>À <em>#{link_to event.city, 'http://fr.wikipedia.org/wiki/'+event.city}</em>,
#{link_to event.region.name, 'http://fr.wikipedia.org/wiki/'+event.region.name}</p>"
else
content += "
<p>Du #{l event.start_time, format: :at} au #{l event.end_time, format: :at}.</p>"
end
content += "
<h3>Description</h3>
#{event.description}
<h3>Informations</h3>
<p>Site Web: <a href=\"#{event.url}\">#{event.url}</a></p>
<p>Contact: #{mail_to event.contact.gsub('@', ' CHEZ ').gsub('.', ' POINT '), event.contact.gsub('@', ' CHEZ ').gsub('.', ' POINT ')}</p>
"
if (event.tags && event.tags.present?)
content += "<p>Tags: #{event.tags.split.collect { |tag| link_to tag, events_url(tag: tag) }.join(', ')}</p>"
end
@event = event
content = render file: '/events/show.html', locals: { rss: true }
xml.description strip_tags(content)
xml.tag! 'content:encoded', content

18
app/views/events/show.html.haml

@ -1,6 +1,6 @@
%p#notice= notice
- if request.format == 'text/html'
%p#notice= notice
- if @event.id
#lug-list
%h1=t '.lug-list'
- if @event.region
@ -14,13 +14,11 @@
= link_to t('.add_to_calendar'), root_url
%h2
%em
= @event.city
\:
%em= @event.city
\:
= @event.title
%h3
Date et lieu
%h3 Date et lieu
%p
- if @event.same_day?
@ -34,8 +32,7 @@
%p
À
%em
= link_to(@event.city, "http://fr.wikipedia.org/wiki/#{@event.city}") + ','
%em= link_to(@event.city, "http://fr.wikipedia.org/wiki/#{@event.city}") + ','
= link_to @event.region.name, "http://fr.wikipedia.org/wiki/#{@event.region.name}" rescue nil
%h3 Description
@ -52,5 +49,4 @@
- if (@event.tags && @event.tags.present?)
%p
Tags:
- @event.tags.split.each do |tag|
= link_to tag, events_url(tag: tag)
=raw @event.tags.split.collect { |tag| link_to tag, events_url(tag: tag) }.join(', ')

2
config/initializers/mime_types.rb

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

Loading…
Cancel
Save