Nuage de tags en place
This commit is contained in:
parent
c18425c4ca
commit
f9cc4e012c
23
app/assets/stylesheets/tags.css.sass
Normal file
23
app/assets/stylesheets/tags.css.sass
Normal file
@ -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%
|
@ -19,7 +19,7 @@ class EventsController < InheritedResources::Base
|
|||||||
}
|
}
|
||||||
|
|
||||||
format.rss {
|
format.rss {
|
||||||
@events = @events.future
|
@events = @events.future_30
|
||||||
@events = @events.limit params[:daylimit] if params[:daylimit]
|
@events = @events.limit params[:daylimit] if params[:daylimit]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
17
app/controllers/tags_controller.rb
Normal file
17
app/controllers/tags_controller.rb
Normal file
@ -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
|
@ -5,7 +5,9 @@ class Event < ActiveRecord::Base
|
|||||||
|
|
||||||
default_scope { where moderated: 1 }
|
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)
|
where('start_time >= now() and end_time <= ?', Date.today + 30)
|
||||||
.order(:start_time)
|
.order(:start_time)
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
.formats
|
.formats
|
||||||
=t '.calendar_in'
|
=t '.calendar_in'
|
||||||
= link_to('rss', events_url(:rss))+','
|
= link_to('rss', events_url(:rss, tag: params[:tag]))+','
|
||||||
= link_to 'iCal', events_url(:rss)
|
= link_to 'iCal', events_url(:rss, tag: params[:tag])
|
||||||
ou
|
ou
|
||||||
= link_to 'calendrier Google', events_url(:rss)
|
= link_to 'calendrier Google', events_url(:rss, tag: params[:tag])
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
= link_to t('.rss'), regions_url
|
= link_to t('.rss'), regions_url
|
||||||
= link_to t('.ical'), icallist_regions_url
|
= link_to t('.ical'), icallist_regions_url
|
||||||
= link_to t('.map'), users_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('.infos'), users_url
|
||||||
= link_to t('.stats'), stats_regions_url
|
= link_to t('.stats'), stats_regions_url
|
||||||
= link_to t('.contact'), users_url
|
= link_to t('.contact'), users_url
|
||||||
|
11
app/views/tags/index.html.haml
Normal file
11
app/views/tags/index.html.haml
Normal file
@ -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
Normal file
35
app/views/tags/show.html.haml
Normal file
@ -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
|
@ -120,3 +120,16 @@ fr:
|
|||||||
city: Statistiques par ville
|
city: Statistiques par ville
|
||||||
dates: Statistiques par date
|
dates: Statistiques par date
|
||||||
web: Statistiques Web
|
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:"
|
||||||
|
@ -5,6 +5,7 @@ AgendaDuLibreRails::Application.routes.draw do
|
|||||||
end
|
end
|
||||||
resources :events
|
resources :events
|
||||||
resources :users
|
resources :users
|
||||||
|
resources :tags, only: [ :index, :show ]
|
||||||
|
|
||||||
get 'ical.php' => 'events#index', format: :ics
|
get 'ical.php' => 'events#index', format: :ics
|
||||||
get ':format.php' => 'events#index'
|
get ':format.php' => 'events#index'
|
||||||
|
Loading…
Reference in New Issue
Block a user