From 0e73eb6c419e379227d84872adb97e746186679d Mon Sep 17 00:00:00 2001 From: echarp Date: Sat, 16 Aug 2014 16:04:42 +0200 Subject: [PATCH] Some small optimisation --- Gemfile.lock | 6 ++--- app/controllers/tags_controller.rb | 6 ++--- app/views/events/index.html.haml | 2 +- app/views/regions/_selector.haml | 37 +++++++++++++++--------------- app/views/tags/index.html.haml | 2 +- config/locales/fr.yml | 1 + 6 files changed, 28 insertions(+), 26 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index c4481685..de17ccf7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -252,11 +252,11 @@ GEM ruby_parser (3.5.0) sexp_processor (~> 4.1) sass (3.2.19) - sass-rails (4.0.3) + sass-rails (4.0.2) railties (>= 4.0.0, < 5.0) sass (~> 3.2.0) sprockets (~> 2.8, <= 2.11.0) - sprockets-rails (~> 2.0) + sprockets-rails (~> 2.0.0) sdoc (0.4.1) json (~> 1.7, >= 1.7.7) rdoc (~> 4.0) @@ -275,7 +275,7 @@ GEM multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sprockets-rails (2.1.3) + sprockets-rails (2.0.1) actionpack (>= 3.0) activesupport (>= 3.0) sprockets (~> 2.8) diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 212662ab..a9c269b2 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -2,10 +2,10 @@ class TagsController < InheritedResources::Base def index @tags = Event - .pluck(:tags) - .join(' ').split.group_by { |i| i } - .reject { |_k, v| v.size < 2 } + .pluck(:tags).map { |e| e.split }.flatten + .group_by { |i| i } .map { |k, v| [k, v.size] } + .reject { |_k, v| v < 2 } .sort respond_to do |format| diff --git a/app/views/events/index.html.haml b/app/views/events/index.html.haml index 8c05ec6b..70f9d280 100644 --- a/app/views/events/index.html.haml +++ b/app/views/events/index.html.haml @@ -1,7 +1,7 @@ -# Seems necessary, for the time being, to ensure calendar is changing days correctly - Time.zone = 'Paris' -%nav.region_selector= render '/regions/selector' += render '/regions/selector' = render '/lugs/search' diff --git a/app/views/regions/_selector.haml b/app/views/regions/_selector.haml index 3161d5ce..6f0539c9 100644 --- a/app/views/regions/_selector.haml +++ b/app/views/regions/_selector.haml @@ -1,24 +1,25 @@ --# Display the currently selected region -%h3 - - if params[:region] - = Region.find params[:region] - %em.fa.fa-chevron-down - - else - %span.placeholder - =t '.all_regions' +%nav.region_selector + -# Display the currently selected region + %h3 + - if params[:region] + = Region.find params[:region] %em.fa.fa-chevron-down + - else + %span.placeholder + =t '.all_regions' + %em.fa.fa-chevron-down --# Choose a region to filter events with -%ul - %li - = link_to t('.all_regions'), region: nil, - start_date: params[:start_date], - year: params[:year], - tag: params[:tag] - - - Region.all.each do |region| + -# Choose a region to filter events with + %ul %li - = link_to region, region: region.id, + = link_to t('.all_regions'), region: nil, start_date: params[:start_date], year: params[:year], tag: params[:tag] + + - Region.all.each do |region| + %li + = link_to region, region: region.id, + start_date: params[:start_date], + year: params[:year], + tag: params[:tag] diff --git a/app/views/tags/index.html.haml b/app/views/tags/index.html.haml index efdbf085..07566730 100644 --- a/app/views/tags/index.html.haml +++ b/app/views/tags/index.html.haml @@ -10,4 +10,4 @@ \/ = 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. +%p=t '.limited' diff --git a/config/locales/fr.yml b/config/locales/fr.yml index b0eb64c9..5a232c0d 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -198,6 +198,7 @@ Exemple: `%{daylimit}`" tags: index: title: Tags + limited: Seuls les tags portants sur plus d'un évènement sont affichés dans cette liste. show: title: Les événements future: