From 2cf407b2466085779e0a353e52cdd1ca69da568d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Gaya?= Date: Wed, 1 Apr 2026 16:40:34 +0200 Subject: [PATCH 1/4] Optimize showcase --- .../showcase/websites_controller.rb | 25 +++++++---- app/views/showcase/websites/_filters.html.erb | 16 +++---- .../showcase/websites/_highlight.html.erb | 42 ++++++++++--------- app/views/showcase/websites/_list.html.erb | 39 ++++++++--------- app/views/showcase/websites/feature.html.erb | 4 +- app/views/showcase/websites/index.html.erb | 2 +- app/views/showcase/websites/tag.html.erb | 4 +- 7 files changed, 73 insertions(+), 59 deletions(-) diff --git a/app/controllers/showcase/websites_controller.rb b/app/controllers/showcase/websites_controller.rb index 129d2b786..99bab4de7 100644 --- a/app/controllers/showcase/websites_controller.rb +++ b/app/controllers/showcase/websites_controller.rb @@ -2,9 +2,19 @@ class Showcase::WebsitesController < Showcase::ApplicationController def index @tags = Communication::Website::Showcase::Tag.all.ordered @features = Communication::Website::Showcase.features - @websites = Communication::Website.in_showcase - .ordered_by_production_date + @websites = Communication::Website.in_showcase.ordered_by_production_date @title = "#{@websites.count } sites créés" + respond_to do |format| + format.html { + @highlighted_websites = @websites.highlighted_in_showcase + @websites = @websites.page(params[:page]).per(100) + } + format.json { + @websites = @websites.page(params[:page]) + response.set_header('X-Total-Count', @websites.total_count.to_s) + response.set_header('X-Total-Pages', @websites.total_pages.to_s) + } + end end def show @@ -14,18 +24,17 @@ def show def tag @tag = Communication::Website::Showcase::Tag.find_by!(slug: params[:tag]) - @websites = @tag.websites.in_showcase - .ordered_by_production_date - .page(params[:page]) - .per(100) + @websites = @tag.websites.in_showcase.ordered_by_production_date + @highlighted_websites = @websites.highlighted_in_showcase + @websites = @websites.page(params[:page]).per(100) end def feature feature = params[:feature].to_sym @title = Communication::Website::Showcase.title_for_feature(feature) @websites = Communication::Website::Showcase.websites_for_feature(feature) - .in_showcase .ordered_by_production_date - .page(params[:page]) + @highlighted_websites = @websites.highlighted_in_showcase + @websites = @websites.page(params[:page]).per(100) end end diff --git a/app/views/showcase/websites/_filters.html.erb b/app/views/showcase/websites/_filters.html.erb index 7b48d8557..d8174c5a8 100644 --- a/app/views/showcase/websites/_filters.html.erb +++ b/app/views/showcase/websites/_filters.html.erb @@ -1,18 +1,20 @@

Thèmes

<% @tags.each do |tag| %> - <% next if tag.websites.none? %> - <%= link_to "#{tag} #{tag.websites.in_production.count}".html_safe, - showcase_tag_path(tag.slug), + <% tag_websites_count = tag.websites.in_showcase.count %> + <% next if tag_websites_count.zero? %> + <%= link_to "#{tag} #{tag_websites_count}".html_safe, + showcase_tag_path(tag.slug), class: 'btn btn-light rounded-pill text-decoration-none mb-2 me-1 px-lg-3 py-lg-2' %> <% end %>

Fonctionnalités

<% @features.each do |feature| %> - <% next if feature[:websites].none? %> - <%= link_to "#{feature[:name]} #{feature[:websites].count}".html_safe, - feature[:path], + <% feature_websites_count = feature[:websites].count %> + <% next if feature_websites_count.zero? %> + <%= link_to "#{feature[:name]} #{feature_websites_count}".html_safe, + feature[:path], class: 'btn btn-light rounded-pill text-decoration-none mb-2 me-1 px-lg-3 py-lg-2' %> <% end %> -
\ No newline at end of file + diff --git a/app/views/showcase/websites/_highlight.html.erb b/app/views/showcase/websites/_highlight.html.erb index 65bcb2f04..3a9f06fdc 100644 --- a/app/views/showcase/websites/_highlight.html.erb +++ b/app/views/showcase/websites/_highlight.html.erb @@ -1,24 +1,26 @@

À découvrir

- <% @websites.highlighted_in_showcase.each do |website| %> -
-
- <% if website.screenshot_full_page.attached? %> -
- <%= kamifusen_tag website.screenshot_full_page, - width: 600, - class: 'img-fluid screenshot-full-page mb-3' %> -
- <% end %> -

- <%= link_to website.original_localization.to_s, - showcase_website_path(website), - class: 'stretched-link' %> - - <%= website.in_production_at.year %> - -

-
-
+ <% @highlighted_websites.each do |website| %> + <% cache website do %> +
+
+ <% if website.screenshot_full_page.attached? %> +
+ <%= kamifusen_tag website.screenshot_full_page, + width: 600, + class: 'img-fluid screenshot-full-page mb-3' %> +
+ <% end %> +

+ <%= link_to website.original_localization.to_s, + showcase_website_path(website), + class: 'stretched-link' %> + + <%= website.in_production_at.year %> + +

+
+
+ <% end %> <% end %>
diff --git a/app/views/showcase/websites/_list.html.erb b/app/views/showcase/websites/_list.html.erb index c9863792f..4b044a29a 100644 --- a/app/views/showcase/websites/_list.html.erb +++ b/app/views/showcase/websites/_list.html.erb @@ -1,28 +1,29 @@ -<% @websites_paginated = @websites.page(params[:page]).per(100) %>

Tous les sites - <%= @websites.count %> - <%= Communication::Website.model_name.human(count: @websites.count).downcase %> + <%= @websites.total_count %> + <%= Communication::Website.model_name.human(count: @websites.total_count).downcase %>

-<% @websites_paginated.each do |website| %> -
-
-
- <%= link_to website.original_localization.to_s, - showcase_website_path(website), - class: 'stretched-link' %> - <%= kamifusen_tag website.screenshot, - width: 500, - class: 'floating-thumb' if website.screenshot.attached? %> +<% @websites.each do |website| %> + <% cache website do %> +
+
+
+ <%= link_to website.original_localization.to_s, + showcase_website_path(website), + class: 'stretched-link' %> + <%= kamifusen_tag website.screenshot, + width: 500, + class: 'floating-thumb' if website.screenshot.attached? %> +
+
<%= website.university %>
+
<%= website.showcase_tags.to_sentence %>
+
<%= website.in_production_at.year %>
-
<%= website.university %>
-
<%= website.showcase_tags.to_sentence %>
-
<%= website.in_production_at.year %>
-
-
+ + <% end %> <% end %>
-<%= paginate @websites_paginated, theme: 'bootstrap-5' %> +<%= paginate @websites, theme: 'bootstrap-5' %> diff --git a/app/views/showcase/websites/feature.html.erb b/app/views/showcase/websites/feature.html.erb index 9fca019e6..5cebae9e4 100644 --- a/app/views/showcase/websites/feature.html.erb +++ b/app/views/showcase/websites/feature.html.erb @@ -2,5 +2,5 @@

<%= @title %>

-<%= render 'highlight' %> -<%= render 'list' %> \ No newline at end of file +<%= render 'highlight' if @highlighted_websites.any? %> +<%= render 'list' %> diff --git a/app/views/showcase/websites/index.html.erb b/app/views/showcase/websites/index.html.erb index 83df35b8a..a5a9e5d94 100644 --- a/app/views/showcase/websites/index.html.erb +++ b/app/views/showcase/websites/index.html.erb @@ -3,7 +3,7 @@

<%= @title %>

<% unless params.has_key?(:page) %> - <%= render 'highlight' %> + <%= render 'highlight' if @highlighted_websites.any? %> <%= render 'filters' %> <% end %> diff --git a/app/views/showcase/websites/tag.html.erb b/app/views/showcase/websites/tag.html.erb index be7258c5e..873faa47e 100644 --- a/app/views/showcase/websites/tag.html.erb +++ b/app/views/showcase/websites/tag.html.erb @@ -2,5 +2,5 @@

<%= @tag %>

-<%= render 'highlight' %> -<%= render 'list' %> \ No newline at end of file +<%= render 'highlight' if @highlighted_websites.any? %> +<%= render 'list' %> From a92f2fcd1cb6af89ee1e771a75200c23a242953f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Gaya?= Date: Wed, 1 Apr 2026 16:45:19 +0200 Subject: [PATCH 2/4] style --- app/controllers/showcase/websites_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/showcase/websites_controller.rb b/app/controllers/showcase/websites_controller.rb index 99bab4de7..3d2b02594 100644 --- a/app/controllers/showcase/websites_controller.rb +++ b/app/controllers/showcase/websites_controller.rb @@ -2,7 +2,8 @@ class Showcase::WebsitesController < Showcase::ApplicationController def index @tags = Communication::Website::Showcase::Tag.all.ordered @features = Communication::Website::Showcase.features - @websites = Communication::Website.in_showcase.ordered_by_production_date + @websites = Communication::Website.in_showcase + .ordered_by_production_date @title = "#{@websites.count } sites créés" respond_to do |format| format.html { @@ -24,7 +25,8 @@ def show def tag @tag = Communication::Website::Showcase::Tag.find_by!(slug: params[:tag]) - @websites = @tag.websites.in_showcase.ordered_by_production_date + @websites = @tag.websites.in_showcase + .ordered_by_production_date @highlighted_websites = @websites.highlighted_in_showcase @websites = @websites.page(params[:page]).per(100) end From bfce9843aa0bc2eb9eb5e6de31fab660d6ecb855 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Wed, 1 Apr 2026 18:23:49 +0200 Subject: [PATCH 3/4] margin --- app/views/showcase/websites/_highlight.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/showcase/websites/_highlight.html.erb b/app/views/showcase/websites/_highlight.html.erb index 3a9f06fdc..611873f83 100644 --- a/app/views/showcase/websites/_highlight.html.erb +++ b/app/views/showcase/websites/_highlight.html.erb @@ -3,7 +3,7 @@ <% @highlighted_websites.each do |website| %> <% cache website do %>
-
+
<% if website.screenshot_full_page.attached? %>
<%= kamifusen_tag website.screenshot_full_page, From 2a717c94294432273122256f26b1029444e20802 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Wed, 1 Apr 2026 18:29:34 +0200 Subject: [PATCH 4/4] Public footer --- app/views/layouts/public.html.erb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/views/layouts/public.html.erb b/app/views/layouts/public.html.erb index e92960daa..56ef8bb91 100644 --- a/app/views/layouts/public.html.erb +++ b/app/views/layouts/public.html.erb @@ -11,15 +11,19 @@
<%= yield %>
+