From 2048398aa7cd61d1ed04d4f5d2ea8697f45bf524 Mon Sep 17 00:00:00 2001 From: echarp Date: Fri, 26 Apr 2019 11:13:53 +0200 Subject: [PATCH] Tag cloud threshold is displayed on the screen --- app/assets/stylesheets/tags.sass | 10 +++++++--- app/controllers/tags_controller.rb | 3 ++- app/views/tags/index.html.haml | 6 +++++- config/application.rb | 2 ++ config/locales/views/en.yml | 1 + config/locales/views/fr.yml | 1 + 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/tags.sass b/app/assets/stylesheets/tags.sass index 29caeac9..c681f98f 100644 --- a/app/assets/stylesheets/tags.sass +++ b/app/assets/stylesheets/tags.sass @@ -51,6 +51,10 @@ ul.ui-autocomplete li margin: 0 background-color: #F0F8FF -body.tags .event[class*='libre-en-fete-'] em.city:before - content: image-url(lef-small) - margin-right: 0.5em +body.tags + .event[class*='libre-en-fete-'] em.city:before + content: image-url(lef-small) + margin-right: 0.5em + .info + float: right + margin-right: 10% diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index de835530..e5b3d8d8 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -5,7 +5,8 @@ class TagsController < InheritedResources::Base has_scope :tag, as: :id def index - @tags = ActsAsTaggableOn::Tag.where('taggings_count > 3') + @tags = ActsAsTaggableOn::Tag.where('taggings_count > ?', + Rails.configuration.cloud_threshold) if params[:term] # Used to autocomplete tags @tags = @tags.select(:id, :name, 'name AS label') diff --git a/app/views/tags/index.html.haml b/app/views/tags/index.html.haml index b4e911a0..8220f965 100644 --- a/app/views/tags/index.html.haml +++ b/app/views/tags/index.html.haml @@ -2,5 +2,9 @@ %em.fa.fa-tags = title t '.title' -- tag_cloud @tags, %w(css1 css2 css3 css4) do |tag, css_class| +- tag_cloud @tags.order(:name), %w[css1 css2 css3 css4] do |tag, css_class| = link_to tag.name, { action: :show, id: tag.name }, class: css_class + +%p.info + %em.fa.fa-info-circle + = t '.threshold', threshold: Rails.configuration.cloud_threshold diff --git a/config/application.rb b/config/application.rb index c323c7c8..d30c5547 100644 --- a/config/application.rb +++ b/config/application.rb @@ -50,5 +50,7 @@ module AgendaDuLibreRails config.action_controller.per_form_csrf_tokens = false config.active_record.sqlite3.represent_boolean_as_integer = true + + config.cloud_threshold = 3 end end diff --git a/config/locales/views/en.yml b/config/locales/views/en.yml index dcb4fd13..dcd40c8e 100644 --- a/config/locales/views/en.yml +++ b/config/locales/views/en.yml @@ -151,6 +151,7 @@ it more readable or agreable." tags: index: title: Tags + threshold: used more than %{threshold} times show: title: Tag links: See also diff --git a/config/locales/views/fr.yml b/config/locales/views/fr.yml index b0cbe72b..e22797e4 100644 --- a/config/locales/views/fr.yml +++ b/config/locales/views/fr.yml @@ -164,6 +164,7 @@ l’événement pour la rendre plus complète, plus lisible ou plus attrayante." tags: index: title: Mots-clés + threshold: utilisés plus de %{threshold} fois show: title: Mot-clé links: Voir aussi