mirror of
https://0xacab.org/sutty/sutty
synced 2025-02-24 14:11:49 +00:00
Merge branch 'issue-13096' into panel.sutty.nl
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
commit
d54563a3a1
11 changed files with 105 additions and 10 deletions
|
@ -384,6 +384,8 @@ $bezier: cubic-bezier(0.75, 0, 0.25, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.word-break-all { word-break: break-all !important; }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Modificadores de Bootstrap que no tienen versión responsive.
|
* Modificadores de Bootstrap que no tienen versión responsive.
|
||||||
*/
|
*/
|
||||||
|
@ -406,6 +408,8 @@ $bezier: cubic-bezier(0.75, 0, 0.25, 1);
|
||||||
.text-#{$grid-breakpoint}-right { text-align: right !important; }
|
.text-#{$grid-breakpoint}-right { text-align: right !important; }
|
||||||
.text-#{$grid-breakpoint}-center { text-align: center !important; }
|
.text-#{$grid-breakpoint}-center { text-align: center !important; }
|
||||||
|
|
||||||
|
.word-break-#{$grid-breakpoint}-all { word-break: break-all !important; }
|
||||||
|
|
||||||
// posición
|
// posición
|
||||||
@each $position in $positions {
|
@each $position in $positions {
|
||||||
.position-#{$grid-breakpoint}-#{$position} { position: $position !important; }
|
.position-#{$grid-breakpoint}-#{$position} { position: $position !important; }
|
||||||
|
|
|
@ -91,6 +91,10 @@ class ApplicationController < ActionController::Base
|
||||||
breadcrumb 'stats.index', root_path, match: :exact
|
breadcrumb 'stats.index', root_path, match: :exact
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def site
|
||||||
|
@site ||= find_site
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def configure_permitted_parameters
|
def configure_permitted_parameters
|
||||||
|
|
41
app/controllers/build_stats_controller.rb
Normal file
41
app/controllers/build_stats_controller.rb
Normal 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
|
|
@ -159,10 +159,6 @@ class PostsController < ApplicationController
|
||||||
end.transform_keys(&:to_sym)
|
end.transform_keys(&:to_sym)
|
||||||
end
|
end
|
||||||
|
|
||||||
def site
|
|
||||||
@site ||= find_site
|
|
||||||
end
|
|
||||||
|
|
||||||
def post
|
def post
|
||||||
@post ||= site.posts(lang: locale).find(params[:post_id] || params[:id])
|
@post ||= site.posts(lang: locale).find(params[:post_id] || params[:id])
|
||||||
end
|
end
|
||||||
|
|
|
@ -85,20 +85,22 @@ class DeployDistributedPress < Deploy
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
# @return [Array]
|
||||||
def gateway_urls
|
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] ]
|
[ protocol[:link], protocol[:gateway] ]
|
||||||
end.flatten.compact.select do |link|
|
end&.flatten&.compact&.select do |link|
|
||||||
link.include? '://'
|
link.include? '://'
|
||||||
end
|
end || []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @return [Array]
|
||||||
def protocol_urls
|
def protocol_urls
|
||||||
remote_info.dig(:distributed_press, :protocols).select do |_, enabled|
|
remote_info.dig(:distributed_press, :protocols)&.select do |_, enabled|
|
||||||
enabled
|
enabled
|
||||||
end.map do |protocol, _|
|
end&.map do |protocol, _|
|
||||||
"#{protocol}://#{site.hostname}"
|
"#{protocol}://#{site.hostname}"
|
||||||
end
|
end || []
|
||||||
end
|
end
|
||||||
|
|
||||||
# El cliente de la API
|
# El cliente de la API
|
||||||
|
|
3
app/models/site_build_stat.rb
Normal file
3
app/models/site_build_stat.rb
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
SiteBuildStat = Struct.new(:site)
|
16
app/policies/site_build_stat_policy.rb
Normal file
16
app/policies/site_build_stat_policy.rb
Normal 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
|
21
app/views/build_stats/index.haml
Normal file
21
app/views/build_stats/index.haml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
%main.row
|
||||||
|
%aside.menu.col-md-3
|
||||||
|
%h1= @site.title
|
||||||
|
%p.lead= @site.description
|
||||||
|
.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]
|
|
@ -696,3 +696,6 @@ en:
|
||||||
queries:
|
queries:
|
||||||
show:
|
show:
|
||||||
empty: '(empty)'
|
empty: '(empty)'
|
||||||
|
build_stats:
|
||||||
|
index:
|
||||||
|
title: "Publications"
|
||||||
|
|
|
@ -704,3 +704,6 @@ es:
|
||||||
queries:
|
queries:
|
||||||
show:
|
show:
|
||||||
empty: '(vacío)'
|
empty: '(vacío)'
|
||||||
|
build_stats:
|
||||||
|
index:
|
||||||
|
title: "Publicaciones"
|
||||||
|
|
|
@ -75,5 +75,7 @@ Rails.application.routes.draw do
|
||||||
get :'stats/host', to: 'stats#host'
|
get :'stats/host', to: 'stats#host'
|
||||||
get :'stats/uris', to: 'stats#uris'
|
get :'stats/uris', to: 'stats#uris'
|
||||||
get :'stats/resources', to: 'stats#resources'
|
get :'stats/resources', to: 'stats#resources'
|
||||||
|
|
||||||
|
resources :build_stats, only: %i[index]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue