From 3127a9fcbd8e4993329a860ae4d02acabd149fa6 Mon Sep 17 00:00:00 2001 From: echarp Date: Tue, 4 Feb 2020 17:56:45 +0100 Subject: [PATCH] The tag page now displays a map, and related organisations --- app/assets/stylesheets/maps.sass | 2 +- app/controllers/tags_controller.rb | 2 +- app/views/maps/_events.html.haml | 2 +- app/views/maps/_tag.html.haml | 20 +++++++++++++ app/views/tags/_aside.html.haml | 46 ++++++++++++++++++++++++++++++ app/views/tags/show.html.haml | 34 ++-------------------- config/locales/views/de.yml | 2 ++ config/locales/views/en.yml | 2 ++ config/locales/views/fr.yml | 2 ++ config/locales/views/nl.yml | 2 ++ config/locales/views/pt-BR.yml | 2 ++ 11 files changed, 82 insertions(+), 34 deletions(-) create mode 100644 app/views/maps/_tag.html.haml create mode 100644 app/views/tags/_aside.html.haml diff --git a/app/assets/stylesheets/maps.sass b/app/assets/stylesheets/maps.sass index 22b0fd07..509eb250 100644 --- a/app/assets/stylesheets/maps.sass +++ b/app/assets/stylesheets/maps.sass @@ -4,7 +4,7 @@ * /* Popup are better displayed with this: */ max-width: initial - ul.feeds li + ul li a display: inline-block .awesome-marker diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index e5b3d8d8..34769bc6 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -1,7 +1,6 @@ # Manage event and organisation tags class TagsController < InheritedResources::Base has_scope :region, :locality, :daylimit - has_scope :period, type: :hash, using: %i[year week] has_scope :tag, as: :id def index @@ -22,6 +21,7 @@ class TagsController < InheritedResources::Base def show @events_future = apply_scopes Event.moderated.future @events_past = apply_scopes Event.moderated.past + @orgas = apply_scopes Orga.moderated.active respond_to do |format| format.html diff --git a/app/views/maps/_events.html.haml b/app/views/maps/_events.html.haml index de45e1ec..8380b272 100644 --- a/app/views/maps/_events.html.haml +++ b/app/views/maps/_events.html.haml @@ -1,6 +1,6 @@ = render '/regions/filter' -%ul.list.feeds#map +%ul.list.events#map %li = link_to maps_path format: :json do .awesome-marker.awesome-marker-icon-blue diff --git a/app/views/maps/_tag.html.haml b/app/views/maps/_tag.html.haml new file mode 100644 index 00000000..294e6614 --- /dev/null +++ b/app/views/maps/_tag.html.haml @@ -0,0 +1,20 @@ +%ul.list#map + %li + = link_to maps_path tag: params[:id], format: :json do + .awesome-marker.awesome-marker-icon-blue + %i.icon-white.fa.fa-calendar + - if params[:future] == 'false' + = Event.model_name.human + - else + = t '.future' + + - cs = %w[blue red darkred orange green darkgreen purple darkpuple cadetblue] + - idx = 1 + - Kind.all.each do |kind| + %li + = link_to map_path kind.name, tag: params[:id], format: :json do + .awesome-marker{ class: "awesome-marker-icon-#{cs[idx % cs.length]}" } + %i.icon-white.fa{ class: "fa-#{kind.icon}" } + = Kind.human_attribute_name "name_#{kind.name}" + - idx += 1 + diff --git a/app/views/tags/_aside.html.haml b/app/views/tags/_aside.html.haml new file mode 100644 index 00000000..4aba9a1a --- /dev/null +++ b/app/views/tags/_aside.html.haml @@ -0,0 +1,46 @@ +%aside + - if @orgas.present? + %h2 + = link_to orgas_path do + %em.fa.fa-users + = Orga.model_name.human.pluralize + %ul.fa-ul + - @orgas.each do |orga| + %li + = link_to orga do + - if orga.kind + %em.fa.fa-li{ class: "fa-#{orga.kind.icon}", + title: Kind.human_attribute_name("name_#{orga.kind.name}") } + = orga.name + = render partial: '/orgas/favicon', locals: { orga: orga } + + %h2 + %em.fa.fa-link + = t '.links' + + %ul.fa-ul + %li + = link_to tags_path, class: :back do + %em.fa.fa-li.fa-arrow-left + = Event.human_attribute_name :tags + %li + = link_to events_path tag: params[:id] do + %em.fa.fa-li.fa-calendar + Agenda + %li + = link_to events_path format: :rss, tag: params[:id] do + %em.fa.fa-li.fa-rss + RSS + %li + = link_to events_path format: :ics, tag: params[:id] do + %em.fa.fa-li.fa-th-list + iCal + %li + = link_to maps_path tag: params[:id] do + %em.fa.fa-li.fa-map-marker + OpenStreetMap + %li + = link_to maps_path format: :json, tag: params[:id] do + %em.fa.fa-li.fa-dot-circle + GeoJSON + diff --git a/app/views/tags/show.html.haml b/app/views/tags/show.html.haml index a267c652..b0123096 100644 --- a/app/views/tags/show.html.haml +++ b/app/views/tags/show.html.haml @@ -1,5 +1,3 @@ -= render partial: '/tags/context', locals: { tags: params[:id] } - %h2 %em.fa.fa-tag = title params[:id] @@ -7,36 +5,10 @@ %em.fa.fa-forward = t '.count', count: @events_future.count -%aside - %h2 - %em.fa.fa-link - = t '.links' +- unless params[:iframe] + = render '/maps/tag' - %ul.fa-ul - %li - = link_to tags_path, class: :back do - %em.fa.fa-li.fa-arrow-left - = Event.human_attribute_name :tags - %li - = link_to events_path tag: params[:id] do - %em.fa.fa-li.fa-calendar - Agenda - %li - = link_to events_path format: :rss, tag: params[:id] do - %em.fa.fa-li.fa-rss - RSS - %li - = link_to events_path format: :ics, tag: params[:id] do - %em.fa.fa-li.fa-th-list - iCal - %li - = link_to maps_path tag: params[:id] do - %em.fa.fa-li.fa-map-marker - OpenStreetMap - %li - = link_to maps_path format: :json, tag: params[:id] do - %em.fa.fa-li.fa-dot-circle - GeoJSON += render 'aside' - @events_future.order('start_time asc').each do |event| %article.event{ class: event.tag_list } diff --git a/config/locales/views/de.yml b/config/locales/views/de.yml index c42e21be..baf68662 100644 --- a/config/locales/views/de.yml +++ b/config/locales/views/de.yml @@ -263,6 +263,8 @@ erneut zu übermitteln." title: Karte der Veranstaltungen und Organisationen events: future: Kommende Veranstaltung + tag: + future: Kommende Veranstaltung users: sign_in: title: Identifizierung diff --git a/config/locales/views/en.yml b/config/locales/views/en.yml index fb1a8892..6042e051 100644 --- a/config/locales/views/en.yml +++ b/config/locales/views/en.yml @@ -251,6 +251,8 @@ description." title: Events and organisations map events: future: Coming event + tag: + future: Future users: sign_in: title: Authentication diff --git a/config/locales/views/fr.yml b/config/locales/views/fr.yml index 10cbd34a..42b06165 100644 --- a/config/locales/views/fr.yml +++ b/config/locales/views/fr.yml @@ -270,6 +270,8 @@ description plus complète." title: Carte des événements et organisations events: future: Événement à venir + tag: + future: Événement à venir users: sign_in: title: Identification diff --git a/config/locales/views/nl.yml b/config/locales/views/nl.yml index b812120e..37408b09 100644 --- a/config/locales/views/nl.yml +++ b/config/locales/views/nl.yml @@ -265,6 +265,8 @@ vollediger beschrijving." title: Evenementen en organisaties kaart events: future: Aankomende evenement + tag: + future: Aankomende evenement users: sign_in: title: Identificatie diff --git a/config/locales/views/pt-BR.yml b/config/locales/views/pt-BR.yml index 3d635e36..0c327c78 100644 --- a/config/locales/views/pt-BR.yml +++ b/config/locales/views/pt-BR.yml @@ -244,6 +244,8 @@ descrição mais completa." title: Mapa de eventos e organizações events: future: Evento Futuro + tag: + future: Evento Futuro users: sign_in: title: Autenticação