Browse Source

Nuage de tags en place

recurrent
echarp 8 years ago
parent
commit
f9cc4e012c
  1. 23
      app/assets/stylesheets/tags.css.sass
  2. 2
      app/controllers/events_controller.rb
  3. 17
      app/controllers/tags_controller.rb
  4. 4
      app/models/event.rb
  5. 6
      app/views/events/index.html.haml
  6. 2
      app/views/layouts/application.html.haml
  7. 11
      app/views/tags/index.html.haml
  8. 35
      app/views/tags/show.html.haml
  9. 13
      config/locales/fr.yml
  10. 1
      config/routes.rb

23
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%

2
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]
}

17
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

4
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)
}

6
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])

2
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

11
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.

35
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

13
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: "<strong>Prochainement</strong>, %{count} évènement:"
other: "<strong>Prochainement</strong>, %{count} évènements:"
past:
zero:
one: "<strong>Dans le passé</strong>, %{count} évènement:"
other: "<strong>Dans le passé</strong>, %{count} évènements:"

1
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'

Loading…
Cancel
Save