diff --git a/app/controllers/showcase/home_controller.rb b/app/controllers/showcase/websites_controller.rb similarity index 78% rename from app/controllers/showcase/home_controller.rb rename to app/controllers/showcase/websites_controller.rb index c6326481b876099f81430232cd2744878ebe9578..0ad75544a6c620b02a8a142888e7da46433b782f 100644 --- a/app/controllers/showcase/home_controller.rb +++ b/app/controllers/showcase/websites_controller.rb @@ -1,4 +1,4 @@ -class Showcase::HomeController < Showcase::ApplicationController +class Showcase::WebsitesController < Showcase::ApplicationController def index @tags = Communication::Website::Showcase::Tag.all.ordered @features = Communication::Website::Showcase.features @@ -6,6 +6,11 @@ class Showcase::HomeController < Showcase::ApplicationController .page(params[:page]) end + def show + @website = Communication::Website.find(params[:id]) + raise_404_unless(@website.in_showcase && @website.in_production) + end + def tag @tag = Communication::Website::Showcase::Tag.find_by!(slug: params[:tag]) @websites = @tag.websites.in_showcase diff --git a/app/views/showcase/home/index.html.erb b/app/views/showcase/home/index.html.erb deleted file mode 100644 index 26435bc92e0ec1d9a2366256494ca0efaf89fca1..0000000000000000000000000000000000000000 --- a/app/views/showcase/home/index.html.erb +++ /dev/null @@ -1,25 +0,0 @@ -<% content_for :title, 'Showcase' %> - -<h1>Showcase</h1> - -<div class="my-5"> - <p class="small text-uppercase">Thèmes</p> - <% @tags.each do |tag| %> - <% next if tag.websites.none? %> - <%= link_to "#{tag} <span class=\"badge bg-light text-dark rounded-pill\">#{tag.websites.in_production.count}</span>".html_safe, - showcase_tag_path(tag.slug), - class: 'btn btn-outline-light text-dark rounded-pill mb-2 me-2 px-4 py-3' %> - <% end %> -</div> - -<div class="my-5"> - <p class="small text-uppercase">Fonctionnalités</p> - <% @features.each do |feature| %> - <% next if feature[:websites].none? %> - <%= link_to "#{feature[:name]} <span class=\"badge bg-light text-dark rounded-pill\">#{feature[:websites].count}</span>".html_safe, - feature[:path], - class: 'btn btn-outline-light text-dark rounded-pill mb-2 me-2 px-4 py-3' %> - <% end %> -</div> - -<%= render 'list' %> diff --git a/app/views/showcase/home/_list.html.erb b/app/views/showcase/websites/_list.html.erb similarity index 79% rename from app/views/showcase/home/_list.html.erb rename to app/views/showcase/websites/_list.html.erb index 47a312c6c7bb68e25bdce079922239d10ea36df0..adc1f97a6cf7e874ffa41874dc90f756e8dd2acb 100644 --- a/app/views/showcase/home/_list.html.erb +++ b/app/views/showcase/websites/_list.html.erb @@ -1,3 +1,6 @@ +<% +current_year = nil +%> <p class="text-end"> <%= @websites.total_count %> <%= Communication::Website.model_name.human(count: @websites.total_count).downcase %> @@ -5,17 +8,27 @@ <div class="row"> <% @websites.each do |website| %> + <% + year = website.created_at.year + if current_year != year + current_year = year + %> + <div class="col-12"> + <h2><%= year %></h2> + <hr> + </div> + <% end %> <div class="col-lg-6"> <article class="mb-5 pb-5"> <% if website.screenshot.attached? %> - <%= link_to website.url, target: :_blank, class: 'no-icon' do %> + <%= link_to showcase_website_path(website) do %> <%= kamifusen_tag website.screenshot, class: 'img-fluid rounded mb-3' %> <% end %> <% end %> <div class="row"> <div class="col-lg-10"> - <h2 class="h4"><%= website.original_localization.to_s %></h2> + <h3 class="h4"><%= link_to website.original_localization.to_s, showcase_website_path(website) %></h3> <div class="small mb-1"> <i class="bi bi-compass-fill me-1"></i> <%= contact_link website.url, :website %> diff --git a/app/views/showcase/home/feature.html.erb b/app/views/showcase/websites/feature.html.erb similarity index 100% rename from app/views/showcase/home/feature.html.erb rename to app/views/showcase/websites/feature.html.erb diff --git a/app/views/showcase/websites/index.html.erb b/app/views/showcase/websites/index.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..c81d7d47737f8be3b78c78adce0f099ec328cba5 --- /dev/null +++ b/app/views/showcase/websites/index.html.erb @@ -0,0 +1,27 @@ +<% content_for :title, 'Showcase' %> + +<h1>Showcase</h1> + +<% unless params.has_key?(:page) %> + <div class="my-5"> + <p class="small text-uppercase">Thèmes</p> + <% @tags.each do |tag| %> + <% next if tag.websites.none? %> + <%= link_to "#{tag} <span class=\"badge bg-light text-dark rounded-pill\">#{tag.websites.in_production.count}</span>".html_safe, + showcase_tag_path(tag.slug), + class: 'btn btn-outline-light text-dark rounded-pill mb-1 me-1 px-lg-3 py-lg-2' %> + <% end %> + </div> + + <div class="my-5"> + <p class="small text-uppercase">Fonctionnalités</p> + <% @features.each do |feature| %> + <% next if feature[:websites].none? %> + <%= link_to "#{feature[:name]} <span class=\"badge bg-light text-dark rounded-pill\">#{feature[:websites].count}</span>".html_safe, + feature[:path], + class: 'btn btn-outline-light text-dark rounded-pill mb-1 me-1 px-lg-3 py-lg-2' %> + <% end %> + </div> +<% end %> + +<%= render 'list' %> diff --git a/app/views/showcase/websites/show.html.erb b/app/views/showcase/websites/show.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..36adba94663813ac00e43e99c960b7cb87c1fef2 --- /dev/null +++ b/app/views/showcase/websites/show.html.erb @@ -0,0 +1,34 @@ +<% content_for :title, @website %> + +<h1><%= @website %></h1> + +<div class="row mt-5"> + <div class="col-lg-6"> + <% if @website.screenshot.attached? %> + <%= kamifusen_tag @website.screenshot, + class: 'img-fluid rounded mb-3' %> + <% end %> + </div> + <div class="col-lg-6"> + <div class="mb-4"> + <i class="bi bi-compass-fill me-1"></i> + <%= contact_link @website.url, :website %> + </div> + <div class="mb-4"> + <i class="bi bi-github me-1"></i> + <%= contact_link @website.repository_url, :github %> + </div> + <div class="mb-4"> + <% @website.showcase_tags.each do |tag| %> + <%= link_to tag, + showcase_tag_path(tag.slug), + class: 'btn btn-sm btn-outline-light text-dark rounded-pill' %> + <% end %> + </div> + <% if @website.university.logo.attached? %> + <%= image_tag @website.university.logo, + width: 200, + class: 'img-fluid p-3' %> + <% end %> + </div> +</div> \ No newline at end of file diff --git a/app/views/showcase/home/tag.html.erb b/app/views/showcase/websites/tag.html.erb similarity index 100% rename from app/views/showcase/home/tag.html.erb rename to app/views/showcase/websites/tag.html.erb diff --git a/config/routes.rb b/config/routes.rb index 7f9f910c46a111e72e9145bb755829e2b5d7aa8d..9666e0a99d9a5a27700b2c781bb88a0d1e94f887 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,12 +1,13 @@ Rails.application.routes.draw do constraints host: ENV['OSUNY_SHOWCASE'] do - get ':feature' => 'showcase/home#feature', + get ':feature' => 'showcase/websites#feature', as: :showcase_feature, constraints: { feature: /actualites|agenda|portfolio/ } - get ':tag' => 'showcase/home#tag', as: :showcase_tag - get '/' => 'showcase/home#index' + get ':tag' => 'showcase/websites#tag', as: :showcase_tag + get '/' => 'showcase/websites#index' + get 'websites/:id' => 'showcase/websites#show', as: :showcase_website end constraints host: ENV['OSUNY_TRANSPARENCY'] do get '/' => 'transparency/home#index'