Commit 3628263d authored by kaiyou's avatar kaiyou
Browse files

Merge branch 'master' of https://gitlab.com/mbajur/prismo

parents 26a5df83 ef322ac8
Pipeline #109 passed with stages
......@@ -18,6 +18,7 @@ module Admin
authorize @account
Accounts::SuspendJob.perform_later(@account.id)
redirect_back(
fallback_location: admin_accounts_path,
notice: 'Account sheduled for suspension'
......@@ -28,7 +29,7 @@ module Admin
@account = find_account
authorize @account
@account.update(silenced: true)
SilenceAccountService.new.call(@account)
redirect_back(
fallback_location: admin_accounts_path,
......
module Admin
class DomainBlocksController < ApplicationController
layout 'settings'
def index
authorize ActivityPub::DomainBlock
@domain_blocks = ActivityPub::DomainBlock.all
end
def new
authorize ActivityPub::DomainBlock
@domain_block = ActivityPub::DomainBlocks::Create.new
end
def create
authorize ActivityPub::DomainBlock
@domain_block = ActivityPub::DomainBlocks::Create.run(domain_block_params)
if @domain_block.valid?
redirect_to admin_domain_blocks_path, notice: 'Domain successfully blocked'
else
render :new
end
end
def destroy
domain_block = ActivityPub::DomainBlock.find(params[:id])
authorize domain_block
domain_block.destroy!
redirect_to admin_domain_blocks_path, notice: 'Domain successfully unblocked'
end
private
def domain_block_params
params.require(:activitypub_domain_block).permit(:domain, :severity)
end
end
end
......@@ -73,6 +73,15 @@ class Api::Ujs::CommentsController < Api::Ujs::BaseController
render 'comments/_comment', layout: false, locals: { comment: outcome.result.likeable }
end
def destroy
comment = find_comment
authorize comment
Comments::DeleteJob.perform_later(comment.id)
head :ok
end
private
def find_comment
......
......@@ -12,13 +12,22 @@ class Api::Ujs::StoriesController < Api::Ujs::BaseController
def scrap
story = find_story
authorize story, :scrap?
authorize story
Stories::Rescrap.run(story: story, user: current_user)
head :no_content
end
def destroy
story = find_story
authorize story
Stories::DeleteJob.perform_later(story.id)
head :ok
end
private
def find_story
......
class StaticController < ApplicationController
layout 'application'
def design; end
end
module ActivityPub
module DomainBlocks
class Create < ActiveInteraction::Base
string :domain
string :severity
interface :suspend_job, default: Accounts::SuspendJob
interface :silence_job, default: Accounts::SilenceJob
def execute
@domain_block = ActivityPub::DomainBlock.new
@domain_block.domain = domain
@domain_block.severity = severity
if domain_block.save
resolve_or_suspend_accounts
else
errors.merge!(domain_block.errors)
end
domain_block
end
private
attr_reader :domain_block
def resolve_or_suspend_accounts
accounts_for_domain.each do |account|
case domain_block.severity
when 'suspend'
suspend_job.perform_later(account.id)
when 'silence'
silence_job.perform_later(account.id)
end
end
end
def accounts_for_domain
::Account.remote.where(domain: domain)
end
end
end
end
......@@ -2,6 +2,9 @@ class Comments::Delete < ActiveInteraction::Base
object :comment
def execute
return false if comment.removed?
@account = comment.account
comment.update(
account: nil,
body: nil,
......@@ -12,6 +15,36 @@ class Comments::Delete < ActiveInteraction::Base
removed: true
)
distribute_delete_comment! if comment.local?
comment
end
private
attr_reader :account
def distribute_delete_comment!
delivery_inboxes.each do |inbox_url|
ActivityPub::DeliveryJob.perform_later(
signed_payload, account.id, inbox_url
)
end
end
def signed_payload
@signed_payload ||= begin
Oj.dump(
ActivityPub::LinkedDataSignature.new(payload).sign!(account)
)
end
end
def payload
ActivityPub::DeleteSerializer.new(comment, with_context: true).as_json
end
def delivery_inboxes
Account.inboxes.reject(&:empty?)
end
end
......@@ -2,6 +2,9 @@ class Stories::Delete < ActiveInteraction::Base
object :story
def execute
return false if story.removed?
@account = story.account
story.update!(
account: nil,
title: nil,
......@@ -14,6 +17,36 @@ class Stories::Delete < ActiveInteraction::Base
removed: true
)
distribute_delete_story! if story.local?
story
end
private
attr_reader :account
def distribute_delete_story!
delivery_inboxes.each do |inbox_url|
ActivityPub::DeliveryJob.perform_later(
signed_payload, account.id, inbox_url
)
end
end
def signed_payload
@signed_payload ||= begin
Oj.dump(
ActivityPub::LinkedDataSignature.new(payload).sign!(account)
)
end
end
def payload
ActivityPub::DeleteSerializer.new(story, with_context: true).as_json
end
def delivery_inboxes
Account.inboxes.reject(&:empty?)
end
end
......@@ -12,6 +12,8 @@
@import './n/components/box';
@import './n/components/form';
@import './n/components/label';
@import './n/components/menu';
@import './n/components/popover';
@import './helpers/shortcuts';
@import './helpers/animations';
......
@import 'components_t/box';
/**
* This injects Tailwind's base styles, which is a combination of
* Normalize.css and some additional base styles.
*
* You can see the styles here:
* https://github.com/tailwindcss/tailwindcss/blob/master/css/preflight.css
*
* If using `postcss-import`, use this import instead:
*
* @import "tailwindcss/preflight";
*/
@tailwind preflight;
/**
* This injects any component classes registered by plugins.
*
* If using `postcss-import`, use this import instead:
*
* @import "tailwindcss/components";
*/
@tailwind components;
/**
* Here you would add any of your custom component classes; stuff that you'd
* want loaded *before* the utilities so that the utilities could still
* override them.
*
* Example:
*
* .btn { ... }
* .form-input { ... }
*
* Or if using a preprocessor or `postcss-import`:
*
* @import "components/buttons";
* @import "components/forms";
*/
/**
* This injects all of Tailwind's utility classes, generated based on your
* config file.
*
* If using `postcss-import`, use this import instead:
*
* @import "tailwindcss/utilities";
*/
@tailwind utilities;
/**
* Here you would add any custom utilities you need that don't come out of the
* box with Tailwind.
*
* Example :
*
* .bg-pattern-graph-paper { ... }
* .skew-45 { ... }
*
* Or if using a preprocessor or `postcss-import`:
*
* @import "utilities/background-patterns";
* @import "utilities/skew-transforms";
*/
......@@ -29,7 +29,7 @@
text-overflow: ellipsis;
}
&:hover {
&:hover, &:active, &:focus {
background: rgba(#fff, 0.3);
color: #fff;
}
......
......@@ -156,6 +156,10 @@
animation: none;
}
}
&--removed {
opacity: 0.5;
}
}
.story-row--phone {
......
......@@ -20,7 +20,7 @@
color: n-color($textColor);
border-color: n-color($accent);
&:hover {
&:hover, &:visited, &:active, &:focus {
@include n-transition;
background-color: n-color(#{$accent}-light);
......@@ -36,7 +36,7 @@
border-color: n-color($accent);
color: n-color(#{$accent}-dark);
&:hover, &:visited {
&:hover, &:visited, &:active, &:focus {
@include n-transition;
color: n-color(#{$accent}-dark);
......
......@@ -5,7 +5,7 @@ $spaces: (
3: 0.75rem,
4: 1rem,
5: 1.25rem,
6: 1.25rem,
6: 1.5rem,
8: 2rem,
10: 2.5rem,
12: 3rem,
......@@ -113,6 +113,7 @@ $borderWidths: (
$borderRadius: (
none: 0,
2sm: .1rem,
sm: .125rem,
default: .25rem,
lg: .5rem,
......@@ -122,8 +123,8 @@ $borderRadius: (
$shadows: (
default: 0 2px 4px 0 rgba(0,0,0,0.10),
sm: 0 1px 2px rgba(0,0,0,0.05),
md: '0 4px 8px 0 rgba(0,0,0,0.12), 0 2px 4px 0 rgba(0,0,0,0.08)',
lg: '0 15px 30px 0 rgba(0,0,0,0.11), 0 5px 15px 0 rgba(0,0,0,0.08)',
md: #{0 2px 8px 0 rgba(0,0,0,0.12), 0 1px 4px 0 rgba(0,0,0,0.08)},
lg: #{0 15px 30px 0 rgba(0,0,0,0.11), 0 5px 15px 0 rgba(0,0,0,0.08)},
inner: inset 0 2px 4px 0 rgba(0,0,0,0.06),
outline: 0 0 0 3px rgba(52,144,220,0.5),
none: none,
......
......@@ -15,17 +15,14 @@
font-weight: n-font-weight(semibold);
text-decoration: none;
&:hover {
&:hover, &:visited, &:active, &:focus {
text-decoration: none;
}
&:visited {
color: n-color(white);
}
}
.btn-n-lg {
font-size: n-text-size(base);
font-size: n-text-size(xs);
height: 2rem;
line-height: 2rem;
}
......
$menu-space-base: n-space(2) * .8;
$menu-space-h: .4rem;
.menu-n {
background: n-color(white);
border-radius: n-border-radius(2sm);
list-style: none;
margin: 0;
padding: $menu-space-base;
transform: translateY(n-space(1));
z-index: 300;
box-shadow: n-shadow(md);
display: none;
&__item {
margin-top: 0;
padding: 0 $menu-space-base;
position: relative;
text-decoration: none;
a {
border-radius: n-border-radius(2sm);
color: inherit;
text-decoration: none;
display: block;
margin: 0 ($menu-space-h * -1);
padding: .2rem $menu-space-h;
}
> a.active,
> a:active,
> a:hover {
color: n-color(indigo);
background: rgba(n-color(indigo-lightest), 0.6);
}
&+.menu-n__item {
margin-top: n-space(2) * .5;
}
}
&__divider {
border-top: n-border-width(default) solid n-color(grey-lighter);
height: n-border-width(default);
margin: $menu-space-base 0;
&[data-content] {
margin: .8rem 0;
}
&::after {
background: n-color(white);
color: n-color(grey);
content: attr(data-content);
display: inline-block;
font-size: n-text-size(xs);
padding: 0 $menu-space-h;
transform: translateY(-.65rem);
}
}
&--opened {
display: inline-block;
}
}
.popover-n {
display: none;
&--opened {
display: inline-block;
}
}
@mixin enter-transform($placement, $animation) {
@if ($animation == 'perspective') {
@if ($placement == 'top') {
transform: translateY(-10px) rotateX(0);
} @else if ($placement == 'bottom') {
transform: translateY(10px) rotateX(0);
} @else if ($placement == 'left') {
transform: translateX(-10px) rotateY(0);
} @else if ($placement == 'right') {
transform: translateX(10px) rotateY(0);
}
} @else if ($animation == 'fade') {
@if ($placement == 'top') {
transform: translateY(-10px);
} @else if ($placement == 'bottom') {
transform: translateY(10px);
} @else if ($placement == 'left') {
transform: translateX(-10px);
} @else if ($placement == 'right') {
transform: translateX(10px);
}
} @else if ($animation == 'scale') {
@if ($placement == 'top') {
transform: translateY(-10px) scale(1);
} @else if ($placement == 'bottom') {
transform: translateY(10px) scale(1);
} @else if ($placement == 'left') {
transform: translateX(-10px) scale(1);
} @else if ($placement == 'right') {
transform: translateX(10px) scale(1);
}
}
}
@mixin leave-transform($placement, $animation) {
@if ($animation == 'perspective') {
@if ($placement == 'top') {
transform: translateY(0) rotateX(60deg);
} @else if ($placement == 'bottom') {
transform: translateY(0) rotateX(-60deg);
} @else if ($placement == 'left') {
transform: translateX(0) rotateY(-60deg);
} @else if ($placement == 'right') {
transform: translateX(0) rotateY(60deg);
}
} @else if ($animation == 'shift-away') {
@if ($placement == 'top') {
transform: translateY(0);
} @else if ($placement == 'bottom') {
transform: translateY(0);
} @else if ($placement == 'left') {
transform: translateX(0);
} @else if ($placement == 'right') {
transform: translateX(0);
}
} @else if ($animation == 'scale') {
@if ($placement == 'top') {
transform: translateY(0) scale(0.5);
} @else if ($placement == 'bottom') {
transform: translateY(0) scale(0.5);
} @else if ($placement == 'left') {
transform: translateX(0) scale(0.5);
} @else if ($placement == 'right') {
transform: translateX(0) scale(0.5);
}
} @else if ($animation == 'shift-toward') {
@if ($placement == 'top') {
transform: translateY(-20px);
} @else if ($placement == 'bottom') {
transform: translateY(20px);
} @else if ($placement == 'left') {
transform: translateX(-20px);
} @else if ($placement == 'right') {
transform: translateX(20px);
}
}
}
@mixin backdrop-transform-enter($placement) {
$scale: 1;
@if ($placement == 'top') {
transform: scale($scale) translate(-50%, -55%);
} @else if ($placement == 'bottom') {
transform: scale($scale) translate(-50%, -45%);
} @else if ($placement == 'left') {
transform: scale($scale) translate(-50%, -50%);
} @else if ($placement == 'right') {
transform: scale($scale) translate(-50%, -50%);
}
}
@mixin backdrop-transform-leave($placement) {
$scale: 0.2;
@if ($placement == 'top') {
transform: scale($scale) translate(-50%, -45%);
} @else if ($placement == 'bottom') {
transform: scale($scale) translate(-50%, 0);
} @else if ($placement == 'left') {
transform: scale($scale) translate(-75%, -50%);
} @else if ($placement == 'right') {
transform: scale($scale) translate(-25%, -50%);
}
}
@mixin arrow($placement, $width, $color) {
@if ($placement == 'top') {
border-top: $width solid $color;
border-right: $width solid transparent;
border-left: $width solid transparent;
} @else if ($placement == 'bottom') {
border-bottom: $width solid $color;
border-right: $width solid transparent;
border-left: $width solid transparent;
} @else if ($placement == 'left') {
border-left: $width solid $color;
border-top: $width solid transparent;