diff --git a/app/controllers/showcase/websites_controller.rb b/app/controllers/showcase/websites_controller.rb index 129d2b786..3d2b02594 100644 --- a/app/controllers/showcase/websites_controller.rb +++ b/app/controllers/showcase/websites_controller.rb @@ -5,6 +5,17 @@ def index @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 @@ -16,16 +27,16 @@ 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) + @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/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 %>
+ 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..611873f83 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' %>