5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-16 18:26:21 +00:00

Merge branch 'issue-13096' into 'rails'

feat: lista de links #13096

See merge request sutty/sutty!162
This commit is contained in:
fauno 2023-05-13 14:34:32 +00:00
commit 7deca064c8
14 changed files with 111 additions and 14 deletions

View file

@ -383,6 +383,9 @@ $bezier: cubic-bezier(0.75, 0, 0.25, 1);
}
}
.word-break-all { word-break: break-all !important; }
.hyphens { hyphens: auto; }
/*
* Modificadores de Bootstrap que no tienen versión responsive.
*/
@ -405,6 +408,8 @@ $bezier: cubic-bezier(0.75, 0, 0.25, 1);
.text-#{$grid-breakpoint}-right { text-align: right !important; }
.text-#{$grid-breakpoint}-center { text-align: center !important; }
.word-break-#{$grid-breakpoint}-all { word-break: break-all !important; }
// posición
@each $position in $positions {
.position-#{$grid-breakpoint}-#{$position} { position: $position !important; }

View file

@ -91,6 +91,10 @@ class ApplicationController < ActionController::Base
breadcrumb 'stats.index', root_path, match: :exact
end
def site
@site ||= find_site
end
protected
def configure_permitted_parameters

View file

@ -0,0 +1,41 @@
# frozen_string_literal: true
# La lista de estados de compilación, por ahora solo mostramos el último
# estado.
class BuildStatsController < ApplicationController
include ActionView::Helpers::NumberHelper
include ActionView::Helpers::DateHelper
before_action :authenticate_usuarie!
breadcrumb -> { current_usuarie.email }, :edit_usuarie_registration_path
breadcrumb 'sites.index', :sites_path, match: :exact
breadcrumb -> { site.title }, -> { site_posts_path(site, locale: locale) }, match: :exact
def index
authorize SiteBuildStat.new(site)
breadcrumb I18n.t('build_stats.index.title'), ''
@headers = %w[type url seconds size].map do |header|
t("deploy_mailer.deployed.th.#{header}")
end
@table = site.deployment_list.map do |deploy|
type = deploy.class.name.underscore
urls = deploy.respond_to?(:urls) ? deploy.urls : [deploy.url].compact
urls = [nil] if urls.empty?
build_stat = deploy.build_stats.where(status: true).last
seconds = build_stat&.seconds || 0
{
title: t("deploy_mailer.deployed.#{type}.title"),
urls: urls,
seconds: {
human: distance_of_time_in_words(seconds),
machine: "PT#{seconds}S"
},
size: number_to_human_size(build_stat&.bytes || 0, precision: 2)
}
end
end
end

View file

@ -159,10 +159,6 @@ class PostsController < ApplicationController
end.transform_keys(&:to_sym)
end
def site
@site ||= find_site
end
def post
@post ||= site.posts(lang: locale).find(params[:post_id] || params[:id])
end

View file

@ -85,12 +85,13 @@ class DeployDistributedPress < Deploy
private
# @return [Array]
def gateway_urls
remote_info.dig(:distributed_press, :links).values.map do |protocol|
remote_info.dig(:distributed_press, :links)&.values&.map do |protocol|
[ protocol[:link], protocol[:gateway] ]
end.flatten.compact.select do |link|
end&.flatten&.compact&.select do |link|
link.include? '://'
end
end || []
end
# El cliente de la API

View file

@ -0,0 +1,3 @@
# frozen_string_literal: true
SiteBuildStat = Struct.new(:site)

View file

@ -0,0 +1,16 @@
# frozen_string_literal: true
# Quiénes pueden ver estados de compilación de un sitio
class SiteBuildStatPolicy
attr_reader :site_build_stat, :usuarie
def initialize(usuarie, site_build_stat)
@usuarie = usuarie
@site_build_stat = site_build_stat
end
# Todes les usuaries e invitades de este sitio
def index?
site_build_stat.site.usuarie?(usuarie) || site_build_stat.site.invitade?(usuarie)
end
end

View file

@ -0,0 +1,20 @@
%main.row
%aside.menu.col-md-3
= render 'sites/header', site: @site
.col
%h1= t('.title')
%table.table
%thead
%tr
- @headers.each do |header|
%th{ scope: 'col' }= header
%tbody
- @table.each do |row|
- row[:urls].each do |url|
%tr
%th{ scope: 'row' }= row[:title]
%td= link_to_if url.present?, url, url, class: 'word-break-all'
%td
%time{ datetime: row[:seconds][:machine] }= row[:seconds][:human]
%td= row[:size]

View file

@ -1,7 +1,7 @@
%main.row
%aside.menu.col-md-3
%h1= @site.title
%p.lead= @site.description
= render 'sites/header', site: @site
- cache_if @usuarie, [@site, I18n.locale] do
= render 'sites/status', site: @site

View file

@ -0,0 +1,3 @@
.hyphens{ lang: site.default_locale }
%h1= site.title
%p.lead= site.description

View file

@ -16,4 +16,4 @@
- link = true
= render 'bootstrap/alert' do
= link_to_if link, message.html_safe, site.url, class: 'alert-link'
= link_to_if link, message.html_safe, site_build_stats_path(site), class: 'alert-link'

View file

@ -364,9 +364,9 @@ en:
static_file_migration: 'File migration'
find_and_replace: 'Search and replace'
status:
building: "Your site is building, please wait <time datetime=\"PT%{seconds}S\">%{average_time}</time> to refresh this page..."
building: "Your site is building, refresh this page in <time datetime=\"PT%{seconds}S\">%{average_time}</time>."
not_published_yet: "Your site is being published for the first time, please wait up to 1 minute..."
available: "Your site is available! Click here to visit it."
available: "Your site is available! Click here to find all the different ways to visit it."
index:
title: 'My Sites'
pull: 'Upgrade'
@ -700,3 +700,6 @@ en:
queries:
show:
empty: '(empty)'
build_stats:
index:
title: "Publications"

View file

@ -369,9 +369,9 @@ es:
static_file_migration: 'Migración de archivos'
find_and_replace: 'Búsqueda y reemplazo'
status:
building: "Tu sitio se está publicando, por favor espera <time datetime=\"PT%{seconds}S\">%{average_time}</time> para recargar esta página..."
building: "Tu sitio se está publicando, recargá esta página en <time datetime=\"PT%{seconds}S\">%{average_time}</time>."
not_published_yet: "Tu sitio se está publicando por primera vez, por favor espera hasta un minuto..."
available: "¡Tu sitio está disponible! Cliquea aquí para visitarlo."
available: "¡Tu sitio está disponible! Cliqueá aquí para encontrar todas las formas en que podés visitarlo."
index:
title: 'Mis sitios'
pull: 'Actualizar'
@ -708,3 +708,6 @@ es:
queries:
show:
empty: '(vacío)'
build_stats:
index:
title: "Publicaciones"

View file

@ -75,5 +75,7 @@ Rails.application.routes.draw do
get :'stats/host', to: 'stats#host'
get :'stats/uris', to: 'stats#uris'
get :'stats/resources', to: 'stats#resources'
resources :build_stats, only: %i[index]
end
end