Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump puma from 5.6.5 to 6.1.1 #1977

Open
wants to merge 24 commits into
base: handon-production
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
45fa13a
[Change] 日本語検索に関する最適化
highemerly May 29, 2022
cf9a0de
[Change] 投票投稿時のWeb/API上のパラメータを修正
highemerly Sep 13, 2019
15b6715
[Add] Announcement機能をマージ
highemerly Mar 30, 2022
7497339
[Change] .gitignoreに独自関連機能関連ファイルを追加
highemerly Nov 30, 2019
fc24cf2
[Add] サイトテーマにInstanceTickerを対応
highemerly Jan 26, 2020
d475e91
[Change] タイムライン取得上限値を400から1200に変更
highemerly Jan 28, 2020
8f4da13
[Add] 独自CSSを mods/handon.scss として組み込み
highemerly Jan 28, 2020
7f35573
[Change] アカウント登録申請理由に関する表現を変更
highemerly Feb 16, 2020
619a49c
[Change] トレンドタグの選出条件を緩くした
highemerly Mar 30, 2022
3fea4ae
プロフィール絵文字を追加 (best-friends/mastodon)
highemerly May 8, 2021
8eb3ec4
[Add] HTL上にDMを表示しないオプションを追加(かつデフォルトに設定)
highemerly May 11, 2022
f99b637
Rails6のautoload周りの仕様がよく分からないので暫定対処
highemerly May 9, 2021
17cef94
[Change] 動画・画像のアップロード制限を緩和
highemerly Mar 30, 2022
7afbba7
[Add] スタイルを追加・整理
highemerly Mar 2, 2022
6352288
[Change] はんドン独自機能と既存機能のコンパチをなんとかした
highemerly Nov 6, 2022
cd469bf
[Change] 4.0.x のUIを改善するため独自修正を行った
highemerly Nov 17, 2022
4772e32
[Fix] InstanceTickerに暫定対処
highemerly Nov 17, 2022
8002070
[Add] Logo dataを追加
highemerly Nov 17, 2022
d8bb2bb
[add] カスタム絵文字のスタンプ機能を復活
highemerly Nov 19, 2022
9b9ee23
[Fix] スマホ画面の投稿ボタン表示制御の見直し
highemerly Nov 20, 2022
728b10a
[Fix] 独自実装のバグを修正
highemerly Nov 21, 2022
6cbfc68
instancetickerのホスト名変更に対応
highemerly Jan 22, 2023
74087eb
Update CSP for cloudflare
highemerly Jan 22, 2023
1c4315a
Bump puma from 5.6.5 to 6.1.1
dependabot[bot] Mar 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@ yarn-debug.log

# Ignore Docker option files
docker-compose.override.yml

# Add by highemerly
public/announcements.json
public/server-info.html
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ruby '>= 2.6.0', '< 3.1.0'
gem 'pkg-config', '~> 1.4'
gem 'rexml', '~> 3.2'

gem 'puma', '~> 5.6'
gem 'puma', '~> 6.1'
gem 'rails', '~> 6.1.7'
gem 'sprockets', '~> 3.7.2'
gem 'thor', '~> 1.2'
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ GEM
pry-rails (0.3.9)
pry (>= 0.10.4)
public_suffix (5.0.0)
puma (5.6.5)
puma (6.1.1)
nio4r (~> 2.0)
pundit (2.2.0)
activesupport (>= 3.0.0)
Expand Down Expand Up @@ -810,7 +810,7 @@ DEPENDENCIES
private_address_check (~> 0.5)
pry-byebug (~> 3.10)
pry-rails (~> 0.3)
puma (~> 5.6)
puma (~> 6.1)
pundit (~> 2.2)
rack (~> 2.2.4)
rack-attack (~> 6.6)
Expand Down
27 changes: 9 additions & 18 deletions app/chewy/statuses_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,21 @@ class StatusesIndex < Chewy::Index
include FormattingHelper

settings index: { refresh_interval: '30s' }, analysis: {
filter: {
english_stop: {
type: 'stop',
stopwords: '_english_',
},
english_stemmer: {
type: 'stemmer',
language: 'english',
},
english_possessive_stemmer: {
type: 'stemmer',
language: 'possessive_english',
tokenizer: {
kuromoji_user_dict: {
type: 'kuromoji_tokenizer',
user_dictionary: 'userdic.txt',
},
},
analyzer: {
content: {
tokenizer: 'uax_url_email',
type: 'custom',
tokenizer: 'kuromoji_user_dict',
filter: %w(
english_possessive_stemmer
lowercase
asciifolding
kuromoji_baseform
kuromoji_stemmer
cjk_width
english_stop
english_stemmer
lowercase
),
},
},
Expand Down
1 change: 1 addition & 0 deletions app/controllers/settings/preferences_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def user_settings_params
:setting_advanced_layout,
:setting_use_blurhash,
:setting_use_pending_items,
:setting_hidden_direct,
:setting_trends,
:setting_crop_images,
:setting_always_send_emails,
Expand Down
9 changes: 8 additions & 1 deletion app/javascript/mastodon/actions/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,11 @@ export function fetchComposeSuggestions(token) {
return (dispatch, getState) => {
switch (token[0]) {
case ':':
fetchComposeSuggestionsEmojis(dispatch, getState, token);
if (token[1] == '@') {
fetchComposeSuggestionsAccounts(dispatch, getState, token.substr(1, token.length));
} else {
fetchComposeSuggestionsEmojis(dispatch, getState, token);
}
break;
case '#':
fetchComposeSuggestionsTags(dispatch, getState, token);
Expand Down Expand Up @@ -569,6 +573,9 @@ export function selectComposeSuggestion(position, token, suggestion, path) {
} else if (suggestion.type === 'account') {
completion = getState().getIn(['accounts', suggestion.id, 'acct']);
startPosition = position;
if (token[0] == ':') {
completion = `@${completion}:`;
}
}

// We don't want to replace hashtags that vary only in case due to accessibility, but we need to fire off an event so that
Expand Down
8 changes: 7 additions & 1 deletion app/javascript/mastodon/components/display_name.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,14 @@ export default class DisplayName extends React.PureComponent {
acct = `${acct}@${localDomain}`;
}

let suffixClassName = 'display-name__account';

if (acct.indexOf('@') === -1) {
suffixClassName = suffixClassName + ' handon-local-account';
}

displayName = <bdi><strong className='display-name__html' dangerouslySetInnerHTML={{ __html: account.get('display_name_html') }} /></bdi>;
suffix = <span className='display-name__account'>@{acct}</span>;
suffix = <span className={suffixClassName}>@{acct}</span>;
} else {
displayName = <bdi><strong className='display-name__html'><Skeleton width='10ch' /></strong></bdi>;
suffix = <span className='display-name__account'><Skeleton width='7ch' /></span>;
Expand Down
5 changes: 1 addition & 4 deletions app/javascript/mastodon/components/logo.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import React from 'react';

const Logo = () => (
<svg viewBox='0 0 261 66' className='logo' role='img'>
<title>Mastodon</title>
<use xlinkHref='#logo-symbol-wordmark' />
</svg>
<img src='/handon-header.png' width='165px' />
);

export default Logo;
1 change: 1 addition & 0 deletions app/javascript/mastodon/components/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ class Status extends ImmutablePureComponent {
{prepend}

<div className={classNames('status', `status-${status.get('visibility')}`, { 'status-reply': !!status.get('in_reply_to_id'), muted: this.props.muted })} data-id={status.get('id')}>
<div className='status__expand' onClick={this.handleClick} role='presentation' />
<div className='status__info'>
<a onClick={this.handleClick} href={`/@${status.getIn(['account', 'acct'])}\/${status.get('id')}`} className='status__relative-time' target='_blank' rel='noopener noreferrer'>
<span className='status__visibility-icon'><Icon id={visibilityIcon.icon} title={visibilityIcon.text} /></span>
Expand Down
120 changes: 120 additions & 0 deletions app/javascript/mastodon/features/compose/components/announcements.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import Immutable from 'immutable';
import { Link } from 'react-router-dom';
import axios from 'axios';
import classnames from 'classnames';

class Announcement extends React.PureComponent {

static propTypes = {
item: ImmutablePropTypes.map,
}

render() {
const { item } = this.props;

const contents = [];
contents.push(<div key='body' className='announcements2__body'>{item.get('body')}</div>);
if (item.get('icon')) {
contents.push(
<div key='icon' className='announcements2__icon'>
<img src={item.get('icon')} alt='' />
</div>
);
}

const href = item.get('href');

const classname = classnames({
'announcements2__item': true,
'announcements2__item--clickable': !!href,
});

if (!href) {
return (<div className={classname}>{contents}</div>);
} else if (href.startsWith('/web/')) {
return (<Link to={item.get('href').slice(4)} className={classname}>{contents}</Link>);
} else {
return (<a href={item.get('href')} target='_blank' className={classname}>{contents}</a>);
}
}

}

export default class Announcements extends React.PureComponent {

state = {
items: Announcements.cache || Immutable.Map(),
}

static isCacheControlled = false
static lastDate = null
static cache = null

constructor () {
super();
this.refresh();
}

componentWillUnmount() {
this.cancelPolling();
}

setPolling = () => {
this.timer = setTimeout(this.refresh, 2 * 60 * 1000);
}

cancelPolling = () => {
if (this.timer !== null) {
clearTimeout(this.timer);
this.timer = null;
}
}

deleteServiceWorkerCache = () => {
// files in /system/ will be cached by SW
if (self.caches) {
return caches.open('mastodon-system')
.then(cache => cache.delete(window.origin + '/system/announcements.json'))
.catch(() => {});
} else {
return Promise.resolve();
}
}

refresh = () => {
this.timer = null;

axios.get('/announcements.json', {
headers: {
'If-Modified-Since': !Announcements.isCacheControlled && Announcements.lastDate || '',
},
})
.then(resp => {
Announcements.isCacheControlled = !!resp.headers['cache-control'];
Announcements.lastDate = resp.headers['last-modified'];
return resp;
})
.then(resp => this.setState({ items: Announcements.cache = Immutable.fromJS(resp.data) || {} }))
.catch(err => err.response.status !== 304 && console.warn(err))
.then(this.deleteServiceWorkerCache)
.then(this.setPolling)
.catch(err => err && console.warn(err));
}

render() {
const { items } = this.state;

return (
<ul className='announcements2'>
{items.entrySeq().map(([key, item]) =>
(<li key={key}>
<Announcement item={item} />
</li>)
)}
</ul>
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,16 @@ class PollForm extends ImmutablePureComponent {
</ul>

<div className='poll__footer'>
<button type='button' disabled={options.size >= 4} className='button button-secondary' onClick={this.handleAddOption}><Icon id='plus' /> <FormattedMessage {...messages.add_option} /></button>
<button type='button' disabled={options.size >= 16} className='button button-secondary' onClick={this.handleAddOption}><Icon id='plus' /> <FormattedMessage {...messages.add_option} /></button>

{/* eslint-disable-next-line jsx-a11y/no-onchange */}
<select value={expiresIn} onChange={this.handleSelectDuration}>
<option value={60}>{intl.formatMessage(messages.minutes, { number: 1 })}</option>
<option value={300}>{intl.formatMessage(messages.minutes, { number: 5 })}</option>
<option value={600}>{intl.formatMessage(messages.minutes, { number: 10 })}</option>
<option value={1800}>{intl.formatMessage(messages.minutes, { number: 30 })}</option>
<option value={3600}>{intl.formatMessage(messages.hours, { number: 1 })}</option>
<option value={7200}>{intl.formatMessage(messages.hours, { number: 2 })}</option>
<option value={21600}>{intl.formatMessage(messages.hours, { number: 6 })}</option>
<option value={86400}>{intl.formatMessage(messages.days, { number: 1 })}</option>
<option value={259200}>{intl.formatMessage(messages.days, { number: 3 })}</option>
Expand Down
5 changes: 3 additions & 2 deletions app/javascript/mastodon/features/compose/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { openModal } from 'mastodon/actions/modal';
import elephantUIPlane from '../../../images/elephant_ui_plane.svg';
import { mascot } from '../../initial_state';
import Icon from 'mastodon/components/icon';
import Announcements from './components/announcements';
import { logOut } from 'mastodon/utils/log_out';
import Column from 'mastodon/components/column';
import { Helmet } from 'react-helmet';
Expand Down Expand Up @@ -116,7 +117,7 @@ class Compose extends React.PureComponent {
<NavigationContainer onClose={this.onBlur} />

<ComposeFormContainer />

<Announcements />
<div className='drawer__inner__mastodon'>
<img alt='' draggable='false' src={mascot || elephantUIPlane} />
</div>
Expand All @@ -130,7 +131,7 @@ class Compose extends React.PureComponent {
)}
</Motion>
</div>
</div>
</div>
);
}

Expand Down
25 changes: 19 additions & 6 deletions app/javascript/mastodon/features/emoji/emoji.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ const emojiFilename = (filename) => {

const domParser = new DOMParser();

const emojifyTextNode = (node, customEmojis) => {
const emojifyTextNode = (node, customEmojis, natural) => {
let str = node.textContent;
let contentNaturalFlag = natural;
let contentEmojiFlag = false;

const fragment = new DocumentFragment();

Expand All @@ -31,10 +33,12 @@ const emojifyTextNode = (node, customEmojis) => {

if (customEmojis === null) {
while (i < str.length && !(match = trie.search(str.slice(i)))) {
contentNaturalFlag = true;
i += str.codePointAt(i) < 65536 ? 1 : 2;
}
} else {
while (i < str.length && str[i] !== ':' && !(match = trie.search(str.slice(i)))) {
contentNaturalFlag = true;
i += str.codePointAt(i) < 65536 ? 1 : 2;
}
}
Expand All @@ -51,7 +55,9 @@ const emojifyTextNode = (node, customEmojis) => {
// if you want additional emoji handler, add statements below which set replacement and return true.
if (shortname in customEmojis) {
const filename = autoPlayGif ? customEmojis[shortname].url : customEmojis[shortname].static_url;
replacement = `<img draggable="false" class="emojione custom-emoji" alt="${shortname}" title="${shortname}" src="${filename}" data-original="${customEmojis[shortname].url}" data-static="${customEmojis[shortname].static_url}" />`;
const classname = contentEmojiFlag ? 'emojione custom-emoji' : 'emojione custom-emoji handon-emojione-first'
contentEmojiFlag = true;
replacement = `<img draggable="false" class="${classname}" alt="${shortname}" title="${shortname}" src="${filename}" data-original="${customEmojis[shortname].url}" data-static="${customEmojis[shortname].static_url}" />`;
return true;
}
return false;
Expand All @@ -77,30 +83,37 @@ const emojifyTextNode = (node, customEmojis) => {

fragment.append(document.createTextNode(str));
node.parentElement.replaceChild(fragment, node);
return contentNaturalFlag;
};

const emojifyNode = (node, customEmojis) => {
const emojifyNode = (node, customEmojis, contentNaturalFlag) => {
for (const child of node.childNodes) {
switch(child.nodeType) {
case Node.TEXT_NODE:
emojifyTextNode(child, customEmojis);
contentNaturalFlag = emojifyTextNode(child, customEmojis, contentNaturalFlag);
break;
case Node.ELEMENT_NODE:
if (!child.classList.contains('invisible'))
emojifyNode(child, customEmojis);
contentNaturalFlag = emojifyNode(child, customEmojis, contentNaturalFlag);
break;
}
}
return contentNaturalFlag;
};

const emojify = (str, customEmojis = {}) => {
let contentNatural;
const wrapper = document.createElement('div');
wrapper.innerHTML = str;

if (!Object.keys(customEmojis).length)
customEmojis = null;

emojifyNode(wrapper, customEmojis);
contentNatural = emojifyNode(wrapper, customEmojis, false);

if (!contentNatural) {
wrapper.innerHTML = '<span class="handon-emoji-only-content">' + wrapper.innerHTML + '</span>';
}

return wrapper.innerHTML;
};
Expand Down
Loading