5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-27 08:46:22 +00:00

Merge branch 'issue-15109-1' of https://0xacab.org/sutty/sutty into production.panel.sutty.nl

This commit is contained in:
Sutty 2024-03-21 21:17:07 +00:00
commit cc7a4b5892
8 changed files with 103 additions and 44 deletions

View file

@ -34,6 +34,22 @@ $sizes: (
@import "bootstrap"; @import "bootstrap";
@import "editor"; @import "editor";
@each $color, $rgb in $theme-colors {
.#{$color} {
color: var(--#{$color});
&:focus {
color: var(--#{$color});
}
::-moz-selection,
::selection {
background: var(--#{$color});
color: white;
}
}
}
.editor { .editor {
.editor-content { .editor-content {
figure { figure {

View file

@ -11,9 +11,12 @@ class ModerationQueueController < ApplicationController
# Cola de moderación viendo todo el sitio # Cola de moderación viendo todo el sitio
def index def index
authorize ModerationQueue.new(site)
breadcrumb site.title, site_posts_path(site) breadcrumb site.title, site_posts_path(site)
breadcrumb I18n.t('moderation_queue.index.title'), '' breadcrumb I18n.t('moderation_queue.index.title'), ''
site.moderation_checked!
# @todo cambiar el estado por query # @todo cambiar el estado por query
@activity_pubs = site.activity_pubs @activity_pubs = site.activity_pubs
@instance_moderations = rubanok_process(site.instance_moderations, with: InstanceModerationProcessor) @instance_moderations = rubanok_process(site.instance_moderations, with: InstanceModerationProcessor)

View file

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

View file

@ -19,6 +19,29 @@ class Site
before_save :generate_private_key_pem!, unless: :private_key_pem? before_save :generate_private_key_pem!, unless: :private_key_pem?
def moderation_enabled?
deploy_social_inbox.present?
end
def deploy_social_inbox
@deploy_social_inbox ||= deploys.find_by(type: 'DeploySocialDistributedPress')
end
def moderation_checked!
deploy_social_inbox.touch
end
# @return [Bool]
def moderation_needed?
return false unless moderation_enabled?
last_activity_pub = activity_pubs.order(updated_at: :desc).first&.updated_at
return false if last_activity_pub.blank?
last_activity_pub > deploy_social_inbox.updated_at
end
# @return [SocialInbox] # @return [SocialInbox]
def social_inbox def social_inbox
@social_inbox ||= SocialInbox.new(site: self) @social_inbox ||= SocialInbox.new(site: self)

View file

@ -0,0 +1,9 @@
# frozen_string_literal: true
# Si la cola de moderación está activada y le usuarie tiene permisos de
# usuarie.
ModerationQueuePolicy = Struct.new(:usuarie, :moderation_queue) do
def index?
moderation_queue.site.moderation_enabled? && moderation_queue.site.usuarie?(usuarie)
end
end

View file

@ -7,11 +7,11 @@
%main.row %main.row
%aside.menu.col-lg-3 %aside.menu.col-lg-3
= render 'sites/header', site: @site .mb-3
= render 'sites/header', site: @site
= render 'sites/status', site: @site = render 'sites/status', site: @site
= render 'sites/build', site: @site, class: 'btn-block'
= render 'sites/build', site: @site, class: 'btn-block mb-3' = render 'sites/moderation_queue', site: @site, class: 'btn-block'
%h3= t('posts.new') %h3= t('posts.new')
%table.table.table-sm.mb-3 %table.table.table-sm.mb-3

View file

@ -0,0 +1,9 @@
- if policy(ModerationQueue.new(site)).index?
- moderation_needed = site.moderation_needed?
- local_assigns[:class] = "btn btn-secondary #{local_assigns[:class]}"
= link_to site_moderation_queue_path(site), class: local_assigns[:class], title: (t('.moderation_needed') if moderation_needed) do
= t('moderation_queue.index.title')
- if moderation_needed
%span.primary &#x23FA;
%span.sr-only= t('.moderation_needed')

View file

@ -15,43 +15,39 @@
%tbody %tbody
- @sites.each do |site| - @sites.each do |site|
- next unless site.jekyll? - next unless site.jekyll?
- rol = current_usuarie.rol_for_site(site) %tr
-# %td
TODO: Solo les usuaries cachean porque tenemos que separar %h2
les botones por permisos. - if policy(site).show?
- cache_if (rol.usuarie? && !rol.temporal), [site, I18n.locale] do = link_to site.title, site_posts_path(site, locale: site.default_locale)
%tr
%td
%h2
- if policy(site).show?
= link_to site.title, site_posts_path(site, locale: site.default_locale)
- else
= site.title
%p.lead= site.description
%br
= link_to t('.visit'), site.url, class: 'btn btn-secondary'
- if rol.temporal
= button_to t('sites.invitations.accept'),
site_usuaries_accept_invitation_path(site),
method: :patch,
title: t('help.sites.invitations.accept'),
class: 'btn btn-secondary'
= button_to t('sites.invitations.reject'),
site_usuaries_reject_invitation_path(site),
method: :patch,
title: t('help.sites.invitations.reject'),
class: 'btn btn-secondary'
- else - else
- if policy(site).show? = site.title
= render 'layouts/btn_with_tooltip', %p.lead= site.description
tooltip: t('help.sites.edit_posts'), %br
type: 'success', = link_to t('.visit'), site.url, class: 'btn btn-secondary'
link: site_path(site), - if current_usuarie.rol_for_site(site).temporal?
text: t('sites.posts') = render 'components/btn_base',
- if policy(SiteUsuarie.new(site, current_usuarie)).index? text: t('sites.invitations.accept'),
= render 'layouts/btn_with_tooltip', path: site_usuaries_accept_invitation_path(site),
tooltip: t('usuaries.index.help.self'), title: t('help.sites.invitations.accept'),
text: t('usuaries.index.title'), class: 'btn-secondary'
type: 'info', = render 'components/btn_base',
link: site_usuaries_path(site) text: t('sites.invitations.reject'),
= render 'sites/build', site: site path: site_usuaries_reject_invitation_path(site),
title: t('help.sites.invitations.reject'),
class: 'btn-secondary'
- else
- if policy(site).show?
= render 'layouts/btn_with_tooltip',
tooltip: t('help.sites.edit_posts'),
type: 'success',
link: site_path(site),
text: t('sites.posts')
= render 'sites/build', site: site
= render 'sites/moderation_queue', site: site
- if policy(SiteUsuarie.new(site, current_usuarie)).index?
= render 'layouts/btn_with_tooltip',
tooltip: t('usuaries.index.help.self'),
text: t('usuaries.index.title'),
type: 'info',
link: site_usuaries_path(site)