Merge commit 'f378f10404
' into kb_migration
This commit is contained in:
commit
edb2a5dcf3
153 changed files with 1225 additions and 1025 deletions
|
@ -71,7 +71,7 @@ module Admin
|
|||
end
|
||||
|
||||
def resource_params
|
||||
params.require(:webhook).permit(:url, events: [])
|
||||
params.require(:webhook).permit(:url, :template, events: [])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -121,10 +121,10 @@ class DropdownMenu extends PureComponent {
|
|||
return <li key={`sep-${i}`} className='dropdown-menu__separator' />;
|
||||
}
|
||||
|
||||
const { text, href = '#', target = '_blank', method } = option;
|
||||
const { text, href = '#', target = '_blank', method, dangerous } = option;
|
||||
|
||||
return (
|
||||
<li className='dropdown-menu__item' key={`${text}-${i}`}>
|
||||
<li className={classNames('dropdown-menu__item', { 'dropdown-menu__item--dangerous': dangerous })} key={`${text}-${i}`}>
|
||||
<a href={href} target={target} data-method={method} rel='noopener noreferrer' role='button' tabIndex={0} ref={i === 0 ? this.setFocusRef : null} onClick={this.handleClick} onKeyPress={this.handleItemKeyPress} data-index={i}>
|
||||
{text}
|
||||
</a>
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
import PropTypes from 'prop-types';
|
||||
import { PureComponent } from 'react';
|
||||
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
|
||||
export default class LoadMore extends PureComponent {
|
||||
|
||||
static propTypes = {
|
||||
onClick: PropTypes.func,
|
||||
disabled: PropTypes.bool,
|
||||
visible: PropTypes.bool,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
visible: true,
|
||||
};
|
||||
|
||||
render() {
|
||||
const { disabled, visible } = this.props;
|
||||
|
||||
return (
|
||||
<button type='button' className='load-more' disabled={disabled || !visible} style={{ visibility: visible ? 'visible' : 'hidden' }} onClick={this.props.onClick}>
|
||||
<FormattedMessage id='status.load_more' defaultMessage='Load more' />
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
24
app/javascript/mastodon/components/load_more.tsx
Normal file
24
app/javascript/mastodon/components/load_more.tsx
Normal file
|
@ -0,0 +1,24 @@
|
|||
import { FormattedMessage } from 'react-intl';
|
||||
|
||||
interface Props {
|
||||
onClick: (event: React.MouseEvent) => void;
|
||||
disabled?: boolean;
|
||||
visible?: boolean;
|
||||
}
|
||||
export const LoadMore: React.FC<Props> = ({
|
||||
onClick,
|
||||
disabled,
|
||||
visible = true,
|
||||
}) => {
|
||||
return (
|
||||
<button
|
||||
type='button'
|
||||
className='load-more'
|
||||
disabled={disabled || !visible}
|
||||
style={{ visibility: visible ? 'visible' : 'hidden' }}
|
||||
onClick={onClick}
|
||||
>
|
||||
<FormattedMessage id='status.load_more' defaultMessage='Load more' />
|
||||
</button>
|
||||
);
|
||||
};
|
|
@ -15,7 +15,7 @@ import IntersectionObserverArticleContainer from '../containers/intersection_obs
|
|||
import { attachFullscreenListener, detachFullscreenListener, isFullscreen } from '../features/ui/util/fullscreen';
|
||||
import IntersectionObserverWrapper from '../features/ui/util/intersection_observer_wrapper';
|
||||
|
||||
import LoadMore from './load_more';
|
||||
import { LoadMore } from './load_more';
|
||||
import LoadPending from './load_pending';
|
||||
import LoadingIndicator from './loading_indicator';
|
||||
|
||||
|
|
|
@ -304,8 +304,8 @@ class StatusActionBar extends ImmutablePureComponent {
|
|||
|
||||
if (writtenByMe) {
|
||||
menu.push({ text: intl.formatMessage(messages.edit), action: this.handleEditClick });
|
||||
menu.push({ text: intl.formatMessage(messages.delete), action: this.handleDeleteClick });
|
||||
menu.push({ text: intl.formatMessage(messages.redraft), action: this.handleRedraftClick });
|
||||
menu.push({ text: intl.formatMessage(messages.delete), action: this.handleDeleteClick, dangerous: true });
|
||||
menu.push({ text: intl.formatMessage(messages.redraft), action: this.handleRedraftClick, dangerous: true });
|
||||
} else {
|
||||
menu.push({ text: intl.formatMessage(messages.mention, { name: account.get('username') }), action: this.handleMentionClick });
|
||||
menu.push({ text: intl.formatMessage(messages.direct, { name: account.get('username') }), action: this.handleDirectClick });
|
||||
|
@ -314,22 +314,22 @@ class StatusActionBar extends ImmutablePureComponent {
|
|||
if (relationship && relationship.get('muting')) {
|
||||
menu.push({ text: intl.formatMessage(messages.unmute, { name: account.get('username') }), action: this.handleMuteClick });
|
||||
} else {
|
||||
menu.push({ text: intl.formatMessage(messages.mute, { name: account.get('username') }), action: this.handleMuteClick });
|
||||
menu.push({ text: intl.formatMessage(messages.mute, { name: account.get('username') }), action: this.handleMuteClick, dangerous: true });
|
||||
}
|
||||
|
||||
if (relationship && relationship.get('blocking')) {
|
||||
menu.push({ text: intl.formatMessage(messages.unblock, { name: account.get('username') }), action: this.handleBlockClick });
|
||||
} else {
|
||||
menu.push({ text: intl.formatMessage(messages.block, { name: account.get('username') }), action: this.handleBlockClick });
|
||||
menu.push({ text: intl.formatMessage(messages.block, { name: account.get('username') }), action: this.handleBlockClick, dangerous: true });
|
||||
}
|
||||
|
||||
if (!this.props.onFilter) {
|
||||
menu.push(null);
|
||||
menu.push({ text: intl.formatMessage(messages.filter), action: this.handleFilterClick });
|
||||
menu.push({ text: intl.formatMessage(messages.filter), action: this.handleFilterClick, dangerous: true });
|
||||
menu.push(null);
|
||||
}
|
||||
|
||||
menu.push({ text: intl.formatMessage(messages.report, { name: account.get('username') }), action: this.handleReport });
|
||||
menu.push({ text: intl.formatMessage(messages.report, { name: account.get('username') }), action: this.handleReport, dangerous: true });
|
||||
|
||||
if (account.get('acct') !== account.get('username')) {
|
||||
const domain = account.get('acct').split('@')[1];
|
||||
|
@ -339,7 +339,7 @@ class StatusActionBar extends ImmutablePureComponent {
|
|||
if (relationship && relationship.get('domain_blocking')) {
|
||||
menu.push({ text: intl.formatMessage(messages.unblockDomain, { domain }), action: this.handleUnblockDomain });
|
||||
} else {
|
||||
menu.push({ text: intl.formatMessage(messages.blockDomain, { domain }), action: this.handleBlockDomain });
|
||||
menu.push({ text: intl.formatMessage(messages.blockDomain, { domain }), action: this.handleBlockDomain, dangerous: true });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -335,16 +335,16 @@ class Header extends ImmutablePureComponent {
|
|||
if (account.getIn(['relationship', 'muting'])) {
|
||||
menu.push({ text: intl.formatMessage(messages.unmute, { name: account.get('username') }), action: this.props.onMute });
|
||||
} else {
|
||||
menu.push({ text: intl.formatMessage(messages.mute, { name: account.get('username') }), action: this.props.onMute });
|
||||
menu.push({ text: intl.formatMessage(messages.mute, { name: account.get('username') }), action: this.props.onMute, dangerous: true });
|
||||
}
|
||||
|
||||
if (account.getIn(['relationship', 'blocking'])) {
|
||||
menu.push({ text: intl.formatMessage(messages.unblock, { name: account.get('username') }), action: this.props.onBlock });
|
||||
} else {
|
||||
menu.push({ text: intl.formatMessage(messages.block, { name: account.get('username') }), action: this.props.onBlock });
|
||||
menu.push({ text: intl.formatMessage(messages.block, { name: account.get('username') }), action: this.props.onBlock, dangerous: true });
|
||||
}
|
||||
|
||||
menu.push({ text: intl.formatMessage(messages.report, { name: account.get('username') }), action: this.props.onReport });
|
||||
menu.push({ text: intl.formatMessage(messages.report, { name: account.get('username') }), action: this.props.onReport, dangerous: true });
|
||||
}
|
||||
|
||||
if (signedIn && isRemote) {
|
||||
|
@ -353,7 +353,7 @@ class Header extends ImmutablePureComponent {
|
|||
if (account.getIn(['relationship', 'domain_blocking'])) {
|
||||
menu.push({ text: intl.formatMessage(messages.unblockDomain, { domain: remoteDomain }), action: this.props.onUnblockDomain });
|
||||
} else {
|
||||
menu.push({ text: intl.formatMessage(messages.blockDomain, { domain: remoteDomain }), action: this.props.onBlockDomain });
|
||||
menu.push({ text: intl.formatMessage(messages.blockDomain, { domain: remoteDomain }), action: this.props.onBlockDomain, dangerous: true });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import { connect } from 'react-redux';
|
|||
import { lookupAccount, fetchAccount } from 'mastodon/actions/accounts';
|
||||
import { openModal } from 'mastodon/actions/modal';
|
||||
import ColumnBackButton from 'mastodon/components/column_back_button';
|
||||
import LoadMore from 'mastodon/components/load_more';
|
||||
import { LoadMore } from 'mastodon/components/load_more';
|
||||
import LoadingIndicator from 'mastodon/components/loading_indicator';
|
||||
import ScrollContainer from 'mastodon/containers/scroll_container';
|
||||
import BundleColumnError from 'mastodon/features/ui/components/bundle_column_error';
|
||||
|
|
|
@ -6,7 +6,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
|
|||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||
|
||||
import { Icon } from 'mastodon/components/icon';
|
||||
import LoadMore from 'mastodon/components/load_more';
|
||||
import { LoadMore } from 'mastodon/components/load_more';
|
||||
|
||||
import { ImmutableHashtag as Hashtag } from '../../../components/hashtag';
|
||||
import AccountContainer from '../../../containers/account_container';
|
||||
|
|
|
@ -13,7 +13,7 @@ import { addColumn, removeColumn, moveColumn, changeColumnParams } from 'mastodo
|
|||
import { fetchDirectory, expandDirectory } from 'mastodon/actions/directory';
|
||||
import Column from 'mastodon/components/column';
|
||||
import ColumnHeader from 'mastodon/components/column_header';
|
||||
import LoadMore from 'mastodon/components/load_more';
|
||||
import { LoadMore } from 'mastodon/components/load_more';
|
||||
import LoadingIndicator from 'mastodon/components/loading_indicator';
|
||||
import { RadioButton } from 'mastodon/components/radio_button';
|
||||
import ScrollContainer from 'mastodon/containers/scroll_container';
|
||||
|
|
|
@ -11,7 +11,7 @@ import { connect } from 'react-redux';
|
|||
|
||||
import { expandSearch } from 'mastodon/actions/search';
|
||||
import { ImmutableHashtag as Hashtag } from 'mastodon/components/hashtag';
|
||||
import LoadMore from 'mastodon/components/load_more';
|
||||
import { LoadMore } from 'mastodon/components/load_more';
|
||||
import LoadingIndicator from 'mastodon/components/loading_indicator';
|
||||
import Account from 'mastodon/containers/account_container';
|
||||
import Status from 'mastodon/containers/status_container';
|
||||
|
|
|
@ -16,6 +16,8 @@ const messages = defineMessages({
|
|||
dislike_description: { id: 'report.reasons.dislike_description', defaultMessage: 'It is not something you want to see' },
|
||||
spam: { id: 'report.reasons.spam', defaultMessage: 'It\'s spam' },
|
||||
spam_description: { id: 'report.reasons.spam_description', defaultMessage: 'Malicious links, fake engagement, or repetitive replies' },
|
||||
legal: { id: 'report.reasons.legal', defaultMessage: 'It\'s illegal' },
|
||||
legal_description: { id: 'report.reasons.legal_description', defaultMessage: 'You believe it violates the law of your or the server\'s country' },
|
||||
violation: { id: 'report.reasons.violation', defaultMessage: 'It violates server rules' },
|
||||
violation_description: { id: 'report.reasons.violation_description', defaultMessage: 'You are aware that it breaks specific rules' },
|
||||
other: { id: 'report.reasons.other', defaultMessage: 'It\'s something else' },
|
||||
|
@ -69,11 +71,13 @@ class Category extends PureComponent {
|
|||
const options = rules.size > 0 ? [
|
||||
'dislike',
|
||||
'spam',
|
||||
'legal',
|
||||
'violation',
|
||||
'other',
|
||||
] : [
|
||||
'dislike',
|
||||
'spam',
|
||||
'legal',
|
||||
'other',
|
||||
];
|
||||
|
||||
|
|
|
@ -239,8 +239,8 @@ class ActionBar extends PureComponent {
|
|||
menu.push({ text: intl.formatMessage(mutingConversation ? messages.unmuteConversation : messages.muteConversation), action: this.handleConversationMuteClick });
|
||||
menu.push(null);
|
||||
menu.push({ text: intl.formatMessage(messages.edit), action: this.handleEditClick });
|
||||
menu.push({ text: intl.formatMessage(messages.delete), action: this.handleDeleteClick });
|
||||
menu.push({ text: intl.formatMessage(messages.redraft), action: this.handleRedraftClick });
|
||||
menu.push({ text: intl.formatMessage(messages.delete), action: this.handleDeleteClick, dangerous: true });
|
||||
menu.push({ text: intl.formatMessage(messages.redraft), action: this.handleRedraftClick, dangerous: true });
|
||||
} else {
|
||||
menu.push({ text: intl.formatMessage(messages.mention, { name: status.getIn(['account', 'username']) }), action: this.handleMentionClick });
|
||||
menu.push(null);
|
||||
|
@ -248,16 +248,16 @@ class ActionBar extends PureComponent {
|
|||
if (relationship && relationship.get('muting')) {
|
||||
menu.push({ text: intl.formatMessage(messages.unmute, { name: account.get('username') }), action: this.handleMuteClick });
|
||||
} else {
|
||||
menu.push({ text: intl.formatMessage(messages.mute, { name: account.get('username') }), action: this.handleMuteClick });
|
||||
menu.push({ text: intl.formatMessage(messages.mute, { name: account.get('username') }), action: this.handleMuteClick, dangerous: true });
|
||||
}
|
||||
|
||||
if (relationship && relationship.get('blocking')) {
|
||||
menu.push({ text: intl.formatMessage(messages.unblock, { name: account.get('username') }), action: this.handleBlockClick });
|
||||
} else {
|
||||
menu.push({ text: intl.formatMessage(messages.block, { name: account.get('username') }), action: this.handleBlockClick });
|
||||
menu.push({ text: intl.formatMessage(messages.block, { name: account.get('username') }), action: this.handleBlockClick, dangerous: true });
|
||||
}
|
||||
|
||||
menu.push({ text: intl.formatMessage(messages.report, { name: status.getIn(['account', 'username']) }), action: this.handleReport });
|
||||
menu.push({ text: intl.formatMessage(messages.report, { name: status.getIn(['account', 'username']) }), action: this.handleReport, dangerous: true });
|
||||
|
||||
if (account.get('acct') !== account.get('username')) {
|
||||
const domain = account.get('acct').split('@')[1];
|
||||
|
@ -267,7 +267,7 @@ class ActionBar extends PureComponent {
|
|||
if (relationship && relationship.get('domain_blocking')) {
|
||||
menu.push({ text: intl.formatMessage(messages.unblockDomain, { domain }), action: this.handleUnblockDomain });
|
||||
} else {
|
||||
menu.push({ text: intl.formatMessage(messages.blockDomain, { domain }), action: this.handleBlockDomain });
|
||||
menu.push({ text: intl.formatMessage(messages.blockDomain, { domain }), action: this.handleBlockDomain, dangerous: true });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -548,6 +548,8 @@
|
|||
"report.placeholder": "Additional comments",
|
||||
"report.reasons.dislike": "I don't like it",
|
||||
"report.reasons.dislike_description": "It is not something you want to see",
|
||||
"report.reasons.legal": "It's illegal",
|
||||
"report.reasons.legal_description": "You believe it violates the law of your or the server's country",
|
||||
"report.reasons.other": "It's something else",
|
||||
"report.reasons.other_description": "The issue does not fit into other categories",
|
||||
"report.reasons.spam": "It's spam",
|
||||
|
|
|
@ -1656,105 +1656,6 @@ a .account__avatar {
|
|||
gap: 4px;
|
||||
}
|
||||
|
||||
.account__disclaimer {
|
||||
padding: 10px;
|
||||
border-top: 1px solid lighten($ui-base-color, 8%);
|
||||
color: $dark-text-color;
|
||||
|
||||
strong {
|
||||
font-weight: 500;
|
||||
|
||||
@each $lang in $cjk-langs {
|
||||
&:lang(#{$lang}) {
|
||||
font-weight: 700;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
a {
|
||||
font-weight: 500;
|
||||
color: inherit;
|
||||
text-decoration: underline;
|
||||
|
||||
&:hover,
|
||||
&:focus,
|
||||
&:active {
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.account__action-bar {
|
||||
border-top: 1px solid lighten($ui-base-color, 8%);
|
||||
border-bottom: 1px solid lighten($ui-base-color, 8%);
|
||||
line-height: 36px;
|
||||
overflow: hidden;
|
||||
flex: 0 0 auto;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.account__action-bar-dropdown {
|
||||
padding: 10px;
|
||||
|
||||
.icon-button {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.dropdown--active {
|
||||
.dropdown__content.dropdown__right {
|
||||
inset-inline-start: 6px;
|
||||
inset-inline-end: initial;
|
||||
}
|
||||
|
||||
&::after {
|
||||
bottom: initial;
|
||||
margin-inline-start: 11px;
|
||||
margin-top: -7px;
|
||||
inset-inline-end: initial;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.account__action-bar-links {
|
||||
display: flex;
|
||||
flex: 1 1 auto;
|
||||
line-height: 18px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.account__action-bar__tab {
|
||||
text-decoration: none;
|
||||
overflow: hidden;
|
||||
flex: 0 1 100%;
|
||||
border-inline-end: 1px solid lighten($ui-base-color, 8%);
|
||||
padding: 10px 0;
|
||||
border-bottom: 4px solid transparent;
|
||||
|
||||
&.active {
|
||||
border-bottom: 4px solid $ui-highlight-color;
|
||||
}
|
||||
|
||||
& > span {
|
||||
display: block;
|
||||
text-transform: uppercase;
|
||||
font-size: 11px;
|
||||
color: $darker-text-color;
|
||||
}
|
||||
|
||||
strong {
|
||||
display: block;
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
color: $primary-text-color;
|
||||
|
||||
@each $lang in $cjk-langs {
|
||||
&:lang(#{$lang}) {
|
||||
font-weight: 700;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.account-authorize {
|
||||
padding: 14px 10px;
|
||||
|
||||
|
@ -2106,36 +2007,18 @@ a.account__display-name {
|
|||
}
|
||||
|
||||
.dropdown-animation {
|
||||
animation: dropdown 300ms cubic-bezier(0.1, 0.7, 0.1, 1);
|
||||
animation: dropdown 150ms cubic-bezier(0.1, 0.7, 0.1, 1);
|
||||
|
||||
@keyframes dropdown {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: scaleX(0.85) scaleY(0.75);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: scaleX(1) scaleY(1);
|
||||
}
|
||||
}
|
||||
|
||||
&.top {
|
||||
transform-origin: bottom;
|
||||
}
|
||||
|
||||
&.right {
|
||||
transform-origin: left;
|
||||
}
|
||||
|
||||
&.bottom {
|
||||
transform-origin: top;
|
||||
}
|
||||
|
||||
&.left {
|
||||
transform-origin: right;
|
||||
}
|
||||
|
||||
.reduce-motion & {
|
||||
animation: none;
|
||||
}
|
||||
|
@ -2151,16 +2034,17 @@ a.account__display-name {
|
|||
}
|
||||
|
||||
.dropdown-menu__separator {
|
||||
border-bottom: 1px solid darken($ui-secondary-color, 8%);
|
||||
margin: 5px 7px 6px;
|
||||
border-bottom: 1px solid var(--dropdown-border-color);
|
||||
margin: 5px 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.dropdown-menu {
|
||||
background: $ui-secondary-color;
|
||||
padding: 4px 0;
|
||||
background: var(--dropdown-background-color);
|
||||
border: 1px solid var(--dropdown-border-color);
|
||||
padding: 4px;
|
||||
border-radius: 4px;
|
||||
box-shadow: 2px 4px 15px rgba($base-shadow-color, 0.4);
|
||||
box-shadow: var(--dropdown-shadow);
|
||||
z-index: 9999;
|
||||
|
||||
&__text-button {
|
||||
|
@ -2181,12 +2065,13 @@ a.account__display-name {
|
|||
|
||||
&__container {
|
||||
&__header {
|
||||
border-bottom: 1px solid darken($ui-secondary-color, 8%);
|
||||
padding: 4px 14px;
|
||||
padding-bottom: 8px;
|
||||
border-bottom: 1px solid var(--dropdown-border-color);
|
||||
padding: 10px 14px;
|
||||
padding-bottom: 14px;
|
||||
margin-bottom: 4px;
|
||||
font-size: 13px;
|
||||
line-height: 18px;
|
||||
color: $inverted-text-color;
|
||||
color: $darker-text-color;
|
||||
}
|
||||
|
||||
&__list {
|
||||
|
@ -2223,103 +2108,43 @@ a.account__display-name {
|
|||
}
|
||||
}
|
||||
|
||||
.dropdown-menu__arrow {
|
||||
position: absolute;
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
display: block;
|
||||
width: 14px;
|
||||
height: 5px;
|
||||
background-color: $ui-secondary-color;
|
||||
mask-image: url("data:image/svg+xml;utf8,<svg width='14' height='5' xmlns='http://www.w3.org/2000/svg'><path d='M7 0L0 5h14L7 0z' fill='white'/></svg>");
|
||||
}
|
||||
|
||||
&.top {
|
||||
bottom: -5px;
|
||||
|
||||
&::before {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
}
|
||||
|
||||
&.right {
|
||||
inset-inline-start: -9px;
|
||||
|
||||
&::before {
|
||||
transform: rotate(-90deg);
|
||||
}
|
||||
}
|
||||
|
||||
&.bottom {
|
||||
top: -5px;
|
||||
}
|
||||
|
||||
&.left {
|
||||
inset-inline-end: -9px;
|
||||
|
||||
&::before {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.dropdown-menu__item {
|
||||
font-size: 13px;
|
||||
line-height: 18px;
|
||||
font-weight: 500;
|
||||
display: block;
|
||||
color: $inverted-text-color;
|
||||
|
||||
&--dangerous {
|
||||
color: $error-value-color;
|
||||
}
|
||||
|
||||
a,
|
||||
button {
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
line-height: inherit;
|
||||
font: inherit;
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 4px 14px;
|
||||
padding: 10px 14px;
|
||||
border: 0;
|
||||
margin: 0;
|
||||
background: transparent;
|
||||
box-sizing: border-box;
|
||||
text-decoration: none;
|
||||
background: $ui-secondary-color;
|
||||
color: inherit;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
text-align: inherit;
|
||||
border-radius: 4px;
|
||||
|
||||
&:focus,
|
||||
&:hover,
|
||||
&:active {
|
||||
background: $ui-highlight-color;
|
||||
color: $secondary-text-color;
|
||||
background: var(--dropdown-border-color);
|
||||
outline: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.dropdown-menu__item--text {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
padding: 4px 14px;
|
||||
}
|
||||
|
||||
.dropdown-menu__item.edited-timestamp__history__item {
|
||||
border-bottom: 1px solid darken($ui-secondary-color, 8%);
|
||||
|
||||
&:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
&.dropdown-menu__item--text,
|
||||
a,
|
||||
button {
|
||||
padding: 8px 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.inline-account {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
|
@ -2335,62 +2160,6 @@ a.account__display-name {
|
|||
}
|
||||
}
|
||||
|
||||
.dropdown--active .dropdown__content {
|
||||
display: block;
|
||||
line-height: 18px;
|
||||
max-width: 311px;
|
||||
inset-inline-end: 0;
|
||||
text-align: start;
|
||||
z-index: 9999;
|
||||
|
||||
& > ul {
|
||||
list-style: none;
|
||||
background: $ui-secondary-color;
|
||||
padding: 4px 0;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 0 15px rgba($base-shadow-color, 0.4);
|
||||
min-width: 140px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
&.dropdown__right {
|
||||
inset-inline-end: 0;
|
||||
}
|
||||
|
||||
&.dropdown__left {
|
||||
& > ul {
|
||||
inset-inline-start: -98px;
|
||||
}
|
||||
}
|
||||
|
||||
& > ul > li > a {
|
||||
font-size: 13px;
|
||||
line-height: 18px;
|
||||
display: block;
|
||||
padding: 4px 14px;
|
||||
box-sizing: border-box;
|
||||
text-decoration: none;
|
||||
background: $ui-secondary-color;
|
||||
color: $inverted-text-color;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
|
||||
&:focus {
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: $ui-highlight-color;
|
||||
color: $secondary-text-color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.dropdown__icon {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.columns-area {
|
||||
display: flex;
|
||||
flex: 1 1 auto;
|
||||
|
@ -3168,10 +2937,10 @@ $ui-header-height: 55px;
|
|||
.compose-form__highlightable {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
flex: 0 1 auto;
|
||||
border-radius: 4px;
|
||||
transition: box-shadow 300ms linear;
|
||||
min-height: 0;
|
||||
|
||||
&.active {
|
||||
transition: none;
|
||||
|
@ -3213,7 +2982,6 @@ $ui-header-height: 55px;
|
|||
|
||||
.compose-form {
|
||||
flex: 1;
|
||||
overflow-y: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 310px;
|
||||
|
|
|
@ -62,3 +62,10 @@ $no-gap-breakpoint: 1175px;
|
|||
$font-sans-serif: 'mastodon-font-sans-serif' !default;
|
||||
$font-display: 'mastodon-font-display' !default;
|
||||
$font-monospace: 'mastodon-font-monospace' !default;
|
||||
|
||||
:root {
|
||||
--dropdown-border-color: #{lighten($ui-base-color, 12%)};
|
||||
--dropdown-background-color: #{lighten($ui-base-color, 4%)};
|
||||
--dropdown-shadow: 0 20px 25px -5px #{rgba($base-shadow-color, 0.25)},
|
||||
0 8px 10px -6px #{rgba($base-shadow-color, 0.25)};
|
||||
}
|
||||
|
|
|
@ -7,15 +7,15 @@ class LinkDetailsExtractor
|
|||
# Some publications wrap their JSON-LD data in their <script> tags
|
||||
# in commented-out CDATA blocks, they need to be removed before
|
||||
# attempting to parse JSON
|
||||
CDATA_JUNK_PATTERN = %r{^[\s]*(
|
||||
(/\*[\s]*<!\[CDATA\[[\s]*\*/) # Block comment style opening
|
||||
CDATA_JUNK_PATTERN = %r{^\s*(
|
||||
(/\*\s*<!\[CDATA\[\s*\*/) # Block comment style opening
|
||||
|
|
||||
(//[\s]*<!\[CDATA\[) # Single-line comment style opening
|
||||
(//\s*<!\[CDATA\[) # Single-line comment style opening
|
||||
|
|
||||
(/\*[\s]*\]\]>[\s]*\*/) # Block comment style closing
|
||||
(/\*\s*\]\]>\s*\*/) # Block comment style closing
|
||||
|
|
||||
(//[\s]*\]\]>) # Single-line comment style closing
|
||||
)[\s]*$}x
|
||||
(//\s*\]\]>) # Single-line comment style closing
|
||||
)\s*$}x
|
||||
|
||||
class StructuredData
|
||||
SUPPORTED_TYPES = %w(
|
||||
|
@ -204,7 +204,7 @@ class LinkDetailsExtractor
|
|||
def host_to_url(str)
|
||||
return if str.blank?
|
||||
|
||||
str.start_with?(/https?:\/\//) ? str : "http://#{str}"
|
||||
str.start_with?(%r{https?://}) ? str : "http://#{str}"
|
||||
end
|
||||
|
||||
def valid_url_or_nil(str, same_origin_only: false)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
class PlainTextFormatter
|
||||
include ActionView::Helpers::TextHelper
|
||||
|
||||
NEWLINE_TAGS_RE = /(<br \/>|<br>|<\/p>)+/
|
||||
NEWLINE_TAGS_RE = %r{(<br />|<br>|</p>)+}
|
||||
|
||||
attr_reader :text, :local
|
||||
|
||||
|
|
|
@ -7,18 +7,18 @@ class TagManager
|
|||
include RoutingHelper
|
||||
|
||||
def web_domain?(domain)
|
||||
domain.nil? || domain.gsub(/[\/]/, '').casecmp(Rails.configuration.x.web_domain).zero?
|
||||
domain.nil? || domain.delete('/').casecmp(Rails.configuration.x.web_domain).zero?
|
||||
end
|
||||
|
||||
def local_domain?(domain)
|
||||
domain.nil? || domain.gsub(/[\/]/, '').casecmp(Rails.configuration.x.local_domain).zero?
|
||||
domain.nil? || domain.delete('/').casecmp(Rails.configuration.x.local_domain).zero?
|
||||
end
|
||||
|
||||
def normalize_domain(domain)
|
||||
return if domain.nil?
|
||||
|
||||
uri = Addressable::URI.new
|
||||
uri.host = domain.gsub(/[\/]/, '')
|
||||
uri.host = domain.delete('/')
|
||||
uri.normalized_host
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ class TextFormatter
|
|||
include ERB::Util
|
||||
include RoutingHelper
|
||||
|
||||
URL_PREFIX_REGEX = /\A(https?:\/\/(www\.)?|xmpp:)/
|
||||
URL_PREFIX_REGEX = %r{\A(https?://(www\.)?|xmpp:)}
|
||||
|
||||
DEFAULT_REL = %w(nofollow noopener noreferrer).freeze
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ class WebfingerResource
|
|||
case resource
|
||||
when /\Ahttps?/i
|
||||
username_from_url
|
||||
when /\@/
|
||||
when /@/
|
||||
username_from_acct
|
||||
else
|
||||
raise InvalidRequest
|
||||
|
|
67
app/lib/webhooks/payload_renderer.rb
Normal file
67
app/lib/webhooks/payload_renderer.rb
Normal file
|
@ -0,0 +1,67 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Webhooks::PayloadRenderer
|
||||
class DocumentTraverser
|
||||
INT_REGEX = /[0-9]+/
|
||||
|
||||
def initialize(document)
|
||||
@document = document.with_indifferent_access
|
||||
end
|
||||
|
||||
def get(path)
|
||||
value = @document.dig(*parse_path(path))
|
||||
string = Oj.dump(value)
|
||||
|
||||
# We want to make sure people can use the variable inside
|
||||
# other strings, so it can't be wrapped in quotes.
|
||||
if value.is_a?(String)
|
||||
string[1...-1]
|
||||
else
|
||||
string
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def parse_path(path)
|
||||
path.split('.').filter_map do |segment|
|
||||
if segment.match(INT_REGEX)
|
||||
segment.to_i
|
||||
else
|
||||
segment.presence
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class TemplateParser < Parslet::Parser
|
||||
rule(:dot) { str('.') }
|
||||
rule(:digit) { match('[0-9]') }
|
||||
rule(:property_name) { match('[a-z_]').repeat(1) }
|
||||
rule(:array_index) { digit.repeat(1) }
|
||||
rule(:segment) { (property_name | array_index) }
|
||||
rule(:path) { property_name >> (dot >> segment).repeat }
|
||||
rule(:variable) { (str('}}').absent? >> path).repeat.as(:variable) }
|
||||
rule(:expression) { str('{{') >> variable >> str('}}') }
|
||||
rule(:text) { (str('{{').absent? >> any).repeat(1) }
|
||||
rule(:text_with_expressions) { (text.as(:text) | expression).repeat.as(:text) }
|
||||
root(:text_with_expressions)
|
||||
end
|
||||
|
||||
EXPRESSION_REGEXP = /
|
||||
\{\{
|
||||
[a-z_]+
|
||||
(\.
|
||||
([a-z_]+|[0-9]+)
|
||||
)*
|
||||
\}\}
|
||||
/iox
|
||||
|
||||
def initialize(json)
|
||||
@document = DocumentTraverser.new(Oj.load(json))
|
||||
end
|
||||
|
||||
def render(template)
|
||||
template.gsub(EXPRESSION_REGEXP) { |match| @document.get(match[2...-2]) }
|
||||
end
|
||||
end
|
|
@ -66,9 +66,9 @@ class Account < ApplicationRecord
|
|||
trust_level
|
||||
)
|
||||
|
||||
USERNAME_RE = /[a-z0-9_]+([a-z0-9_\.-]+[a-z0-9_]+)?/i
|
||||
MENTION_RE = /(?<=^|[^\/[:word:]])@((#{USERNAME_RE})(?:@[[:word:]\.\-]+[[:word:]]+)?)/i
|
||||
URL_PREFIX_RE = /\Ahttp(s?):\/\/[^\/]+/
|
||||
USERNAME_RE = /[a-z0-9_]+([a-z0-9_.-]+[a-z0-9_]+)?/i
|
||||
MENTION_RE = %r{(?<=^|[^/[:word:]])@((#{USERNAME_RE})(?:@[[:word:].-]+[[:word:]]+)?)}i
|
||||
URL_PREFIX_RE = %r{\Ahttp(s?)://[^/]+}
|
||||
USERNAME_ONLY_RE = /\A#{USERNAME_RE}\z/i
|
||||
|
||||
include Attachmentable
|
||||
|
|
|
@ -35,7 +35,7 @@ class DomainAllow < ApplicationRecord
|
|||
def rule_for(domain)
|
||||
return if domain.blank?
|
||||
|
||||
uri = Addressable::URI.new.tap { |u| u.host = domain.gsub(/[\/]/, '') }
|
||||
uri = Addressable::URI.new.tap { |u| u.host = domain.delete('/') }
|
||||
|
||||
find_by(domain: uri.normalized_host)
|
||||
end
|
||||
|
|
|
@ -119,7 +119,7 @@ class DomainBlock < ApplicationRecord
|
|||
def rule_for(domain)
|
||||
return if domain.blank?
|
||||
|
||||
uri = Addressable::URI.new.tap { |u| u.host = domain.strip.gsub(/[\/]/, '') }
|
||||
uri = Addressable::URI.new.tap { |u| u.host = domain.strip.delete('/') }
|
||||
segments = uri.normalized_host.split('.')
|
||||
variants = segments.map.with_index { |_, i| segments[i..-1].join('.') }
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ class Report < ApplicationRecord
|
|||
enum category: {
|
||||
other: 0,
|
||||
spam: 1_000,
|
||||
legal: 1_500,
|
||||
violation: 2_000,
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ class SiteUpload < ApplicationRecord
|
|||
|
||||
has_attached_file :file, styles: ->(file) { STYLES[file.instance.var.to_sym] }, convert_options: { all: '-coalesce +profile "!icc,*" +set modify-date +set create-date' }, processors: [:lazy_thumbnail, :blurhash_transcoder, :type_corrector]
|
||||
|
||||
validates_attachment_content_type :file, content_type: /\Aimage\/.*\z/
|
||||
validates_attachment_content_type :file, content_type: %r{\Aimage/.*\z}
|
||||
validates :file, presence: true
|
||||
validates :var, presence: true, uniqueness: true
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class Tag < ApplicationRecord
|
|||
HASHTAG_LAST_SEQUENCE = '([[:word:]_]*[[:alpha:]][[:word:]_]*)'
|
||||
HASHTAG_NAME_PAT = "#{HASHTAG_FIRST_SEQUENCE}|#{HASHTAG_LAST_SEQUENCE}"
|
||||
|
||||
HASHTAG_RE = /(?:^|[^\/\)\w])#(#{HASHTAG_NAME_PAT})/i
|
||||
HASHTAG_RE = %r{(?:^|[^/)\w])#(#{HASHTAG_NAME_PAT})}i
|
||||
HASHTAG_NAME_RE = /\A(#{HASHTAG_NAME_PAT})\z/i
|
||||
HASHTAG_INVALID_CHARS_RE = /[^[:alnum:]#{HASHTAG_SEPARATORS}]/
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
# enabled :boolean default(TRUE), not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# template :text
|
||||
#
|
||||
|
||||
class Webhook < ApplicationRecord
|
||||
|
@ -30,6 +31,7 @@ class Webhook < ApplicationRecord
|
|||
validates :events, presence: true
|
||||
|
||||
validate :validate_events
|
||||
validate :validate_template
|
||||
|
||||
before_validation :strip_events
|
||||
before_validation :generate_secret
|
||||
|
@ -49,7 +51,18 @@ class Webhook < ApplicationRecord
|
|||
private
|
||||
|
||||
def validate_events
|
||||
errors.add(:events, :invalid) if events.any? { |e| !EVENTS.include?(e) }
|
||||
errors.add(:events, :invalid) if events.any? { |e| EVENTS.exclude?(e) }
|
||||
end
|
||||
|
||||
def validate_template
|
||||
return if template.blank?
|
||||
|
||||
begin
|
||||
parser = Webhooks::PayloadRenderer::TemplateParser.new
|
||||
parser.parse(template)
|
||||
rescue Parslet::ParseFailed
|
||||
errors.add(:template, :invalid)
|
||||
end
|
||||
end
|
||||
|
||||
def strip_events
|
||||
|
|
|
@ -77,8 +77,8 @@ class BackupService < BaseService
|
|||
path = m.file&.path
|
||||
next unless path
|
||||
|
||||
path = path.gsub(/\A.*\/system\//, '')
|
||||
path = path.gsub(/\A\/+/, '')
|
||||
path = path.gsub(%r{\A.*/system/}, '')
|
||||
path = path.gsub(%r{\A/+}, '')
|
||||
download_to_zip(zipfile, m.file, path)
|
||||
end
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ class FetchLinkCardService < BaseService
|
|||
URL_PATTERN = %r{
|
||||
(#{Twitter::TwitterText::Regex[:valid_url_preceding_chars]}) # $1 preceding chars
|
||||
( # $2 URL
|
||||
(https?:\/\/) # $3 Protocol (required)
|
||||
(https?://) # $3 Protocol (required)
|
||||
(#{Twitter::TwitterText::Regex[:valid_domain]}) # $4 Domain(s)
|
||||
(?::(#{Twitter::TwitterText::Regex[:valid_port_number]}))? # $5 Port number (optional)
|
||||
(/#{Twitter::TwitterText::Regex[:valid_url_path]}*)? # $6 URL Path and anchor
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class FetchOEmbedService
|
||||
ENDPOINT_CACHE_EXPIRES_IN = 24.hours.freeze
|
||||
URL_REGEX = /(=(http[s]?(%3A|:)(\/\/|%2F%2F)))([^&]*)/i
|
||||
URL_REGEX = %r{(=(https?(%3A|:)(//|%2F%2F)))([^&]*)}i
|
||||
|
||||
attr_reader :url, :options, :format, :endpoint_url
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ class SearchService < BaseService
|
|||
end
|
||||
|
||||
def url_query?
|
||||
@resolve && /\Ahttps?:\/\//.match?(@query)
|
||||
@resolve && %r{\Ahttps?://}.match?(@query)
|
||||
end
|
||||
|
||||
def url_resource_results
|
||||
|
|
|
@ -7,5 +7,8 @@
|
|||
.fields-group
|
||||
= f.input :events, collection: Webhook::EVENTS, wrapper: :with_block_label, include_blank: false, as: :check_boxes, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li'
|
||||
|
||||
.fields-group
|
||||
= f.input :template, wrapper: :with_block_label, input_html: { placeholder: '{ "content": "Hello {{object.username}}" }' }
|
||||
|
||||
.actions
|
||||
= f.button :button, @webhook.new_record? ? t('admin.webhooks.add_new') : t('generic.save_changes'), type: :submit
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
= t('admin.webhooks.title')
|
||||
|
||||
- content_for :heading do
|
||||
%h2
|
||||
%small
|
||||
= fa_icon 'inbox'
|
||||
= t('admin.webhooks.webhook')
|
||||
= @webhook.url
|
||||
|
||||
- content_for :heading_actions do
|
||||
= link_to t('admin.webhooks.edit'), edit_admin_webhook_path, class: 'button' if can?(:update, @webhook)
|
||||
.content__heading__row
|
||||
%h2
|
||||
%small
|
||||
= fa_icon 'inbox'
|
||||
= t('admin.webhooks.webhook')
|
||||
= @webhook.url
|
||||
.content__heading__actions
|
||||
= link_to t('admin.webhooks.edit'), edit_admin_webhook_path, class: 'button' if can?(:update, @webhook)
|
||||
|
||||
.table-wrapper
|
||||
%table.table.horizontal-table
|
||||
|
|
|
@ -8,7 +8,7 @@ class Webhooks::DeliveryWorker
|
|||
|
||||
def perform(webhook_id, body)
|
||||
@webhook = Webhook.find(webhook_id)
|
||||
@body = body
|
||||
@body = @webhook.template.blank? ? body : Webhooks::PayloadRenderer.new(body).render(@webhook.template)
|
||||
@response = nil
|
||||
|
||||
perform_request
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue