From b1946a1189a2ee8cebb46455a0af824374949526 Mon Sep 17 00:00:00 2001 From: Yannis Jaquet Date: Sun, 3 Sep 2023 13:09:01 +0200 Subject: [PATCH] Improve headlines (#277) * Convert headline markdown to html on cup show page * Improve Headline layout --- app/controllers/headlines_controller.rb | 2 +- app/views/cups/_headline.html.erb | 2 +- app/views/headlines/_headline.html.erb | 31 ++++++++++--------------- app/views/headlines/index.html.erb | 4 ++-- app/views/headlines/show.html.erb | 2 +- app/views/layouts/_navigation.html.erb | 2 +- config/locales/models/headlines.en.yml | 4 ++++ config/locales/models/headlines.fr.yml | 4 ++++ 8 files changed, 26 insertions(+), 25 deletions(-) diff --git a/app/controllers/headlines_controller.rb b/app/controllers/headlines_controller.rb index 20e79e5a..348bab48 100644 --- a/app/controllers/headlines_controller.rb +++ b/app/controllers/headlines_controller.rb @@ -7,7 +7,7 @@ class HeadlinesController < ApplicationController respond_to :html def index - respond_with @headlines.order(created_at: :desc) + @headlines = @headlines.order(created_at: :desc) end def show diff --git a/app/views/cups/_headline.html.erb b/app/views/cups/_headline.html.erb index d1b3886a..c9d52b99 100644 --- a/app/views/cups/_headline.html.erb +++ b/app/views/cups/_headline.html.erb @@ -2,7 +2,7 @@

<%= headline.title %>

- <%== headline.content %> + <%= md_to_html(headline.content) %>
<%= link_to cup_headlines_path(@cup), class: "font-medium text-red-600 hover:text-red-500" do %> diff --git a/app/views/headlines/_headline.html.erb b/app/views/headlines/_headline.html.erb index 88650b01..bd1bc07c 100644 --- a/app/views/headlines/_headline.html.erb +++ b/app/views/headlines/_headline.html.erb @@ -1,21 +1,14 @@ -
  • -
    -
    -
    -

    - <%= link_to(cup_headline_path(@current_cup, headline)) do %> - <%= headline.title %> - <% end %> -

    -

    - <%= headline.created_at.to_fs :day_month_year %> -

    -
    -
    -
    -
    - <%= md_to_html(headline.content) %> -
    +
    +
    +

    + <%= Headline.human_attribute_name(:created_at) %> + <%= l(headline.created_at.to_date, format: :day_month_year) %> +

    +

    + <%= headline.title %> +

    +
    + <%= md_to_html(headline.content) %>
    -
  • +
    diff --git a/app/views/headlines/index.html.erb b/app/views/headlines/index.html.erb index ab163cd3..f1dae123 100644 --- a/app/views/headlines/index.html.erb +++ b/app/views/headlines/index.html.erb @@ -11,12 +11,12 @@
    - + diff --git a/app/views/headlines/show.html.erb b/app/views/headlines/show.html.erb index a533ee1e..b5620700 100644 --- a/app/views/headlines/show.html.erb +++ b/app/views/headlines/show.html.erb @@ -1,6 +1,6 @@ <% @title ||= @headline.title; title @title %>
    -
    +

    <%= @title %> diff --git a/app/views/layouts/_navigation.html.erb b/app/views/layouts/_navigation.html.erb index 77492e1f..c953cf6d 100644 --- a/app/views/layouts/_navigation.html.erb +++ b/app/views/layouts/_navigation.html.erb @@ -74,7 +74,7 @@ render(NavigationDropdownComponent.new( name: "locale", text: I18n.locale.to_s.upcase, - css_class: "hidden lg:block text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium", + css_class: "hidden sm:block text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium", links: I18n.available_locales.map { |locale| {text: locale.to_s.upcase, url: {locale: locale}} } )) %> diff --git a/config/locales/models/headlines.en.yml b/config/locales/models/headlines.en.yml index 1e71e85a..99704a13 100644 --- a/config/locales/models/headlines.en.yml +++ b/config/locales/models/headlines.en.yml @@ -1,5 +1,9 @@ --- en: + activerecord: + attributes: + headline: + created_at: Published headlines: index: no_news: No headlines yet… diff --git a/config/locales/models/headlines.fr.yml b/config/locales/models/headlines.fr.yml index 3acc5606..b7fd9c6d 100644 --- a/config/locales/models/headlines.fr.yml +++ b/config/locales/models/headlines.fr.yml @@ -1,5 +1,9 @@ --- fr: + activerecord: + attributes: + headline: + created_at: Publié headlines: index: no_news: Pas de nouvelles pour l'instant…