diff --git a/app/assets/stylesheets/tags.css.sass b/app/assets/stylesheets/tags.css.sass
new file mode 100644
index 00000000..f19cf8cc
--- /dev/null
+++ b/app/assets/stylesheets/tags.css.sass
@@ -0,0 +1,23 @@
+.tag
+ vertical-align: middle
+ sub
+ font-size: 8px
+
+ &.size_1
+ font-size: 60%
+ letter-spacing: -1px
+ &.size_2
+ font-size: 80%
+ letter-spacing: -1px
+ &.size_3
+ font-size: 100%
+ &.size_4
+ font-size: 120%
+ &.size_5
+ font-size: 180%
+ &.size_6
+ font-size: 200%
+ &.size_7
+ font-size: 220%
+ &.size_8
+ font-size: 240%
diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb
index 836a2335..aa43e0c5 100644
--- a/app/controllers/events_controller.rb
+++ b/app/controllers/events_controller.rb
@@ -19,7 +19,7 @@ class EventsController < InheritedResources::Base
}
format.rss {
- @events = @events.future
+ @events = @events.future_30
@events = @events.limit params[:daylimit] if params[:daylimit]
}
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb
new file mode 100644
index 00000000..6ce417e1
--- /dev/null
+++ b/app/controllers/tags_controller.rb
@@ -0,0 +1,17 @@
+class TagsController < InheritedResources::Base
+ def index
+ @tags = Event
+ .pluck(:tags)
+ .join(' ')
+ .split
+ .group_by { |i| i }
+ .reject { |k, v| v.size < 2 }
+ .collect { |k, v| [k, v.size()] }
+ .sort
+ end
+
+ def show
+ @eventsFuture = Event.future.tag params[:id]
+ @eventsPast = Event.past.tag params[:id]
+ end
+end
diff --git a/app/models/event.rb b/app/models/event.rb
index 8a31df01..55651638 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -5,7 +5,9 @@ class Event < ActiveRecord::Base
default_scope { where moderated: 1 }
- scope :future, -> {
+ scope :past, -> { where('end_time < now()').order(start_time: :desc) }
+ scope :future, -> { where('end_time >= now()').order(start_time: :asc) }
+ scope :future_30, -> {
where('start_time >= now() and end_time <= ?', Date.today + 30)
.order(:start_time)
}
diff --git a/app/views/events/index.html.haml b/app/views/events/index.html.haml
index ce6a96e9..07815c6f 100644
--- a/app/views/events/index.html.haml
+++ b/app/views/events/index.html.haml
@@ -38,7 +38,7 @@
.formats
=t '.calendar_in'
- = link_to('rss', events_url(:rss))+','
- = link_to 'iCal', events_url(:rss)
+ = link_to('rss', events_url(:rss, tag: params[:tag]))+','
+ = link_to 'iCal', events_url(:rss, tag: params[:tag])
ou
- = link_to 'calendrier Google', events_url(:rss)
+ = link_to 'calendrier Google', events_url(:rss, tag: params[:tag])
diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml
index 52674f25..1744ec5a 100644
--- a/app/views/layouts/application.html.haml
+++ b/app/views/layouts/application.html.haml
@@ -62,7 +62,7 @@
= link_to t('.rss'), regions_url
= link_to t('.ical'), icallist_regions_url
= link_to t('.map'), users_url
- = link_to t('.tags'), users_url
+ = link_to t('.tags'), tags_url
= link_to t('.infos'), users_url
= link_to t('.stats'), stats_regions_url
= link_to t('.contact'), users_url
diff --git a/app/views/tags/index.html.haml b/app/views/tags/index.html.haml
new file mode 100644
index 00000000..34c93938
--- /dev/null
+++ b/app/views/tags/index.html.haml
@@ -0,0 +1,11 @@
+%h2=t '.title'
+
+- @tags.each do |tag|
+ %span.tag(class="size_#{Math.log2(tag[1]).to_i}")
+ = link_to tag[0], tag_url(tag[0])
+ %sub<>
+ = link_to :rss, events_url(format: :rss, tag: tag[0])
+ \/
+ = link_to :ical, events_url(format: :ics, tag: tag[0])
+
+%p Seuls les tags portants sur plus d'un évènement sont affichés dans cette liste.
diff --git a/app/views/tags/show.html.haml b/app/views/tags/show.html.haml
new file mode 100644
index 00000000..dfc9c733
--- /dev/null
+++ b/app/views/tags/show.html.haml
@@ -0,0 +1,35 @@
+%h2
+ =t '.title'
+ %em= params[:id]
+
+%p=raw t '.future', count: @eventsFuture.count
+%ul
+ - @eventsFuture.each do |event|
+ %li
+ %div= link_to event.title, event
+ - if event.same_day?
+ le
+ =l event.start_time.to_date, format: :long
+ - else
+ du
+ =l event.start_time.to_date, format: :long
+ au
+ =l event.end_time.to_date, format: :long
+ à
+ = event.city
+
+%p=raw t '.past', count: @eventsPast.count
+%ul
+ - @eventsPast.each do |event|
+ %li
+ %div= link_to event.title, event
+ - if event.same_day?
+ le
+ =l event.start_time.to_date, format: :long
+ - else
+ du
+ =l event.start_time.to_date, format: :long
+ au
+ =l event.end_time.to_date, format: :long
+ à
+ = event.city
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index a78fd1ea..894c5935 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -120,3 +120,16 @@ fr:
city: Statistiques par ville
dates: Statistiques par date
web: Statistiques Web
+ tags:
+ index:
+ title: Tags
+ show:
+ title: Les évènements
+ future:
+ zero:
+ one: "Prochainement, %{count} évènement:"
+ other: "Prochainement, %{count} évènements:"
+ past:
+ zero:
+ one: "Dans le passé, %{count} évènement:"
+ other: "Dans le passé, %{count} évènements:"
diff --git a/config/routes.rb b/config/routes.rb
index f6ef7d04..bf0f8092 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -5,6 +5,7 @@ AgendaDuLibreRails::Application.routes.draw do
end
resources :events
resources :users
+ resources :tags, only: [ :index, :show ]
get 'ical.php' => 'events#index', format: :ics
get ':format.php' => 'events#index'