Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/assets/stylesheets/showcase.sass
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@

// Admin
@import 'admin/design-system/*'
@import 'admin/components/pagination'
@import 'admin/components/pagination'

@import 'showcase/style'
9 changes: 9 additions & 0 deletions app/assets/stylesheets/showcase/style.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.screenshot-full-page
aspect-ratio: 3/4
object-fit: cover
object-position: top
h1
margin-bottom: 6rem
h2
margin-bottom: 2rem
margin-top: 6rem
2 changes: 2 additions & 0 deletions app/controllers/showcase/websites_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ def index
@websites = Communication::Website.in_showcase
.ordered_by_production_date
.page(params[:page])
.per(100)
end

def show
Expand All @@ -17,6 +18,7 @@ def tag
@websites = @tag.websites.in_showcase
.ordered_by_production_date
.page(params[:page])
.per(100)
end

def feature
Expand Down
15 changes: 12 additions & 3 deletions app/models/communication/website/with_screenshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,27 @@ module Communication::Website::WithScreenshot

included do
has_one_attached :screenshot
has_one_attached :screenshot_full_page
end

def screenshot!
return if url.blank?
screenshot_url = Screenshot.capture(url)
make_screenshot!
make_screenshot!(full_page: true)
end

protected

def make_screenshot!(full_page: false)
name = full_page ? "screenshot_full_page" : "screenshot"
screenshot_url = Screenshot.capture(url, full_page: full_page)
blob = ActiveStorage::Utils.blob_from_url(
screenshot_url,
filename: 'screenshot.png',
filename: "#{name}.png",
content_type: 'image/png'
)
return if blob.nil?
attachment_change = ActiveStorage::Attached::Changes::CreateOne.new("screenshot", self, blob)
attachment_change = ActiveStorage::Attached::Changes::CreateOne.new(name, self, blob)
attachment_change.save
end
end
1 change: 1 addition & 0 deletions app/models/communication/website/with_showcase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ module Communication::Website::WithShowcase
association_foreign_key: :communication_website_showcase_tag_id

scope :in_showcase, -> { in_production.where(in_showcase: true) }
scope :highlighted_in_showcase, -> { in_production.where(highlighted_in_showcase: true) }
end
end
3 changes: 2 additions & 1 deletion app/services/screenshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ class Screenshot
# }
# }
# }
def self.capture(url)
def self.capture(url, full_page:)
response = HTTParty.get(PRO_API, {
query: {
url: url,
screenshot: true,
fullPage: full_page,
meta: false,
waitForTimeout: 1500,
headers: { 'accept-language': 'fr;q=0.9, en;q=0.8' },
Expand Down
2 changes: 1 addition & 1 deletion app/views/showcase/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</head>
<body>
<nav class="navbar navbar-light">
<div class="container justify-content-center">
<div class="container-fluid">
<a class="navbar-brand" href="/">
<%= image_tag 'osuny-black.svg',
class: 'img-fluid py-4',
Expand Down
19 changes: 19 additions & 0 deletions app/views/showcase/websites/_filters.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<h2>Filtres</h2>
<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-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-2 me-1 px-lg-3 py-lg-2' %>
<% end %>
</div>
22 changes: 22 additions & 0 deletions app/views/showcase/websites/_highlight.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<h2>À découvrir</h2>
<div class="row g-5">
<% @websites.highlighted_in_showcase.each do |website| %>
<div class="col-md-6 col-xl-4">
<article class="position-relative">
<% if website.screenshot_full_page.attached? %>
<%= kamifusen_tag website.screenshot_full_page,
class: 'img-fluid screenshot-full-page mb-3' %>
<% end %>
<p>
<%= link_to website.original_localization.to_s,
showcase_website_path(website),
class: 'stretched-link' %>
<span class="float-end">
<%= website.in_production_at.year %>
</span>
</p>
</article>
</div>
<% end %>
</div>
<%= paginate @websites %>
56 changes: 22 additions & 34 deletions app/views/showcase/websites/_list.html.erb
Original file line number Diff line number Diff line change
@@ -1,36 +1,24 @@
<%
current_year = nil
%>
<p class="text-end">
<%= @websites.total_count %>
<%= Communication::Website.model_name.human(count: @websites.total_count).downcase %>
</p>

<div class="row g-5">
<% @websites.each do |website| %>
<%
year = website.in_production_at.year
if current_year != year
current_year = year
%>
<div class="col-12">
<h2><%= year %></h2>
<hr>
</div>
<% end %>
<div class="col-md-6 col-xl-4">
<article class="position-relative">
<% if website.screenshot.attached? %>
<%= kamifusen_tag website.screenshot,
class: 'img-fluid rounded mb-3' %>
<% end %>
<h3 class="fs-6 mt-1">
<%= link_to website.original_localization.to_s,
showcase_website_path(website),
class: 'stretched-link' %>
</h3>
</article>
</div>
<% end %>
<h2>
Tous les sites
<span class="float-end">
<%= @websites.total_count %>
<%= Communication::Website.model_name.human(count: @websites.total_count).downcase %>
</span>
</h2>
<div class="table-responsive">
<table class="table">
<tbody>
<% @websites.each do |website| %>
<tr class="position-relative">
<td><%= link_to website.original_localization.to_s,
showcase_website_path(website),
class: 'stretched-link' %></td>
<td><%= website.university %></td>
<td><%= website.showcase_tags.to_sentence %></td>
<td class="text-end"><%= website.in_production_at.year %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<%= paginate @websites %>
1 change: 1 addition & 0 deletions app/views/showcase/websites/feature.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

<h1><%= @title %></h1>

<%= render 'highlight' %>
<%= render 'list' %>
25 changes: 4 additions & 21 deletions app/views/showcase/websites/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,27 +1,10 @@
<% content_for :title, 'Showcase' %>
<% content_for :title, 'Sites créés' %>

<h1>Showcase</h1>
<h1>Sites créés</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-2 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-2 me-1 px-lg-3 py-lg-2' %>
<% end %>
</div>
<%= render 'highlight' %>
<%= render 'filters' %>
<% end %>

<%= render 'list' %>
6 changes: 3 additions & 3 deletions app/views/showcase/websites/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

<div class="row g-5 mt-5">
<div class="col-lg-6">
<% if @website.screenshot.attached? %>
<%= kamifusen_tag @website.screenshot,
class: 'img-fluid rounded mb-3' %>
<% if @website.screenshot_full_page.attached? %>
<%= kamifusen_tag @website.screenshot_full_page,
class: 'img-fluid mb-3' %>
<% end %>
</div>
<div class="col-lg-6">
Expand Down
1 change: 1 addition & 0 deletions app/views/showcase/websites/tag.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

<h1><%= @tag %></h1>

<%= render 'highlight' %>
<%= render 'list' %>
Loading