diff --git a/app/assets/stylesheets/digest.css.sass b/app/assets/stylesheets/digest.css.sass index 310a78e7..277431d3 100644 --- a/app/assets/stylesheets/digest.css.sass +++ b/app/assets/stylesheets/digest.css.sass @@ -12,6 +12,11 @@ body.digests main font-size: larger text-align: left + // Some hack so the display is similar to the one on dlfp + .description, .second_part + p + white-space: pre-line + textarea width: 40em height: 20em diff --git a/app/controllers/digests_controller.rb b/app/controllers/digests_controller.rb index d519a99b..d34f0773 100644 --- a/app/controllers/digests_controller.rb +++ b/app/controllers/digests_controller.rb @@ -10,7 +10,7 @@ class DigestsController < ApplicationController before_action :set_events, only: [:show] def show - render params[:id] + render :markdown end private diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index cdd706c0..f76f00fe 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -1,7 +1,8 @@ # Manage event tags class TagsController < InheritedResources::Base - has_scope :region, :locality, :tag, :daylimit + has_scope :region, :locality, :daylimit has_scope :period, type: :hash, using: [:year, :week] + has_scope :tag, as: :id def index @tags = apply_scopes(Event.moderated) @@ -18,7 +19,7 @@ class TagsController < InheritedResources::Base end def show - @events_future = apply_scopes(Event).moderated.future.tag params[:id] - @events_past = apply_scopes(Event).moderated.past.tag params[:id] + @events_future = apply_scopes(Event).moderated.future + @events_past = apply_scopes(Event).moderated.past end end diff --git a/app/views/digests/markdown.html.haml b/app/views/digests/markdown.html.haml index 2df1275d..97f36e81 100644 --- a/app/views/digests/markdown.html.haml +++ b/app/views/digests/markdown.html.haml @@ -1,36 +1,39 @@ -- title = "Agenda du Libre pour la semaine #{@week.cweek} de l'année #{@week.year}" +- title = t '.title', week: @week.cweek, year: @week.year - description = capture_haml do - - @events.group_by { |evt| evt.start_time.to_date }.sort.each do |day, evts| - = l(day, format: :long).capitalize - \----- + = t '.week', begin: @week.beginning_of_week.day, end: @week.end_of_week.day, + month: t('date.month_names')[@week.month], year: @week.year, + count: @events.count + \ - - evts.each do |event| - * [[#{event.city}] #{event.title}](#{event_url event}) - \ + - @events.group_by { |evt| evt.start_time.to_date }.sort.each do |day, evts| + = '* ' + t('date.day_names')[day.wday].capitalize + ':' + = evts.collect { |event| "[#{event.city}] [#{event.title}](#{event_url event})" }.join '; ' - second_part = capture_haml do = title \===== - - @events.sort_by { |e| e.start_time }.each do |event| + = t '.week', begin: @week.beginning_of_week.day, end: @week.end_of_week.day, + month: t('date.month_names')[@week.month], year: @week.year, + count: @events.count + \ + - @events.sort_by(&:start_time).each do |event| - @event = event - [#{event.city}] [#{event.title}](#{event_url event}) - \----- - - %p= display_date - %p= event.full_address - - > #{strip_tags(@event.description).remove(/\n.*/)} - + \## [#{event.city}] [#{event.title}](#{event_url event}) + = display_date + = event.full_address + - strip_tags(@event.description).split(/\r\n/)[0..3].reject { |p| p.blank? }.each do |p| + > #{p} \ - * #{link_to @event.url, @event.url} - * #{@event.tags.split.collect { |tag| "[#{tag}](#{tag_url tag})" }.join ', '} + * #{Event.human_attribute_name :url}: #{link_to @event.url, @event.url} + * #{Event.human_attribute_name :tags}: #{@event.tags.split.collect { |tag| "[#{tag}](#{tag_url tag})" }.join ', '} \ %h1= title -:markdown - #{description} +%description + :markdown + #{description} %hr @@ -46,8 +49,9 @@ %hr -:markdown - #{second_part} +.second_part + :markdown + #{second_part} %hr diff --git a/config/locales/views/fr.yml b/config/locales/views/fr.yml index 97f70b59..fe032190 100644 --- a/config/locales/views/fr.yml +++ b/config/locales/views/fr.yml @@ -282,6 +282,10 @@ description plus complète." ko: Non destroy: ok: L'organisation a bien été supprimée + digests: + markdown: + title: Agenda du Libre pour la semaine %{week} de l'année %{year} + week: Semaine du %{begin} au %{end} %{month} %{year}. %{count} événements. devise: sessions: diff --git a/test/controllers/maps_controller_test.rb b/test/controllers/maps_controller_test.rb index d0293a27..53293739 100644 --- a/test/controllers/maps_controller_test.rb +++ b/test/controllers/maps_controller_test.rb @@ -2,6 +2,7 @@ require 'test_helper' # Test the geocoding life cycle class MapsControllerTest < ActionController::TestCase + include Devise::TestHelpers test 'should get index' do get :index assert_response :success