From: Thibaut Girka Date: Mon, 30 Sep 2019 10:23:57 +0000 (+0200) Subject: Merge branch 'master' into glitch-soc/merge-upstream X-Git-Url: https://git.xn--scling-oua.cat.family/?a=commitdiff_plain;h=16ff7c5627c12a0c9658e9d2fac7c48002e1b788;p=mastodon.git Merge branch 'master' into glitch-soc/merge-upstream Conflicts: - Gemfile - Gemfile.lock - app/controllers/about_controller.rb - app/controllers/auth/sessions_controller.rb --- 16ff7c5627c12a0c9658e9d2fac7c48002e1b788 diff --cc Gemfile index 2505194c8,7ed1a4e6b..45a8444fd --- a/Gemfile +++ b/Gemfile @@@ -50,8 -50,7 +50,8 @@@ gem 'fastimage gem 'goldfinger', '~> 2.1' gem 'hiredis', '~> 0.6' gem 'redis-namespace', '~> 1.5' - gem 'health_check', '~> 3.0' + gem 'health_check', git: 'https://github.com/ianheggie/health_check', ref: '0b799ead604f900ed50685e9b2d469cd2befba5b' +gem 'html2text' gem 'htmlentities', '~> 4.3' gem 'http', '~> 3.3' gem 'http_accept_language', '~> 2.1' diff --cc Gemfile.lock index 092f69119,fdf28bd10..c05b85b2a --- a/Gemfile.lock +++ b/Gemfile.lock @@@ -502,8 -506,7 +508,8 @@@ GE link_header (~> 0.0, >= 0.0.8) rdf-normalize (0.3.3) rdf (>= 2.2, < 4.0) + redcarpet (3.4.0) - redis (4.1.2) + redis (4.1.3) redis-actionpack (5.0.2) actionpack (>= 4.0, < 6) redis-rack (>= 1, < 3) @@@ -711,9 -714,8 +717,9 @@@ DEPENDENCIE fuubar (~> 2.4) goldfinger (~> 2.1) hamlit-rails (~> 0.2) - health_check (~> 3.0) + health_check! hiredis (~> 0.6) + html2text htmlentities (~> 4.3) http (~> 3.3) http_accept_language (~> 2.1) diff --cc app/controllers/about_controller.rb index 7b0438127,abd1ec0cb..5d5db937c --- a/app/controllers/about_controller.rb +++ b/app/controllers/about_controller.rb @@@ -1,12 -1,9 +1,10 @@@ # frozen_string_literal: true class AboutController < ApplicationController + before_action :set_pack layout 'public' - before_action :require_open_federation!, only: [:show, :more, :blocks] - before_action :check_blocklist_enabled, only: [:blocks] - before_action :authenticate_user!, only: [:blocks], if: :blocklist_account_required? + before_action :require_open_federation!, only: [:show, :more] before_action :set_body_classes, only: :show before_action :set_instance_presenter before_action :set_expires_in, only: [:show, :more, :terms] @@@ -62,12 -50,6 +51,10 @@@ end end - helper_method :new_user - + def set_pack + use_pack 'public' + end + def set_instance_presenter @instance_presenter = InstancePresenter.new end diff --cc app/controllers/auth/sessions_controller.rb index c2b38883b,f48b17c79..efde02ac2 --- a/app/controllers/auth/sessions_controller.rb +++ b/app/controllers/auth/sessions_controller.rb @@@ -8,7 -8,7 +8,8 @@@ class Auth::SessionsController < Devise skip_before_action :require_no_authentication, only: [:create] skip_before_action :require_functional! + prepend_before_action :set_pack + prepend_before_action :authenticate_with_two_factor, if: :two_factor_enabled?, only: [:create] before_action :set_instance_presenter, only: [:new] before_action :set_body_classes @@@ -94,19 -111,8 +112,12 @@@ render :two_factor end - def authenticate_and_respond(user) - sign_in(user) - remember_me(user) - - respond_with user, location: after_sign_in_path_for(user) - end - private + def set_pack + use_pack 'auth' + end + def set_instance_presenter @instance_presenter = InstancePresenter.new end diff --cc app/controllers/directories_controller.rb index bbfdde8af,750c835dd..adf2bd014 --- a/app/controllers/directories_controller.rb +++ b/app/controllers/directories_controller.rb @@@ -8,8 -8,9 +8,10 @@@ class DirectoriesController < Applicati before_action :set_instance_presenter before_action :set_tag, only: :show before_action :set_accounts + before_action :set_pack + skip_before_action :require_functional! + def index render :index end diff --cc app/controllers/remote_follow_controller.rb index 65dfa35db,db1604644..93a0a7476 --- a/app/controllers/remote_follow_controller.rb +++ b/app/controllers/remote_follow_controller.rb @@@ -5,9 -5,10 +5,11 @@@ class RemoteFollowController < Applicat layout 'modal' + before_action :set_pack before_action :set_body_classes + skip_before_action :require_functional! + def new @remote_follow = RemoteFollow.new(session_params) end diff --cc app/controllers/remote_interaction_controller.rb index 6b797b10f,4073e7ac3..e058d0ed5 --- a/app/controllers/remote_interaction_controller.rb +++ b/app/controllers/remote_interaction_controller.rb @@@ -9,8 -9,9 +9,10 @@@ class RemoteInteractionController < App before_action :set_interaction_type before_action :set_status before_action :set_body_classes + before_action :set_pack + skip_before_action :require_functional! + def new @remote_follow = RemoteFollow.new(session_params) end diff --cc app/javascript/mastodon/locales/ja.json index 64baed71d,ee31d3ae3..d59b2c7f2 --- a/app/javascript/mastodon/locales/ja.json +++ b/app/javascript/mastodon/locales/ja.json @@@ -267,9 -267,8 +271,9 @@@ "navigation_bar.pins": "固定したトゥート", "navigation_bar.preferences": "ユーザー設定", "navigation_bar.public_timeline": "連合タイムライン", + "navigation_bar.misc": "その他", "navigation_bar.security": "セキュリティ", - "notification.and_n_others": "and {count, plural, one {# other} other {# others}}", + "notification.and_n_others": "と、他 {count} 件", "notification.favourite": "{name}さんがあなたのトゥートをお気に入りに登録しました", "notification.follow": "{name}さんにフォローされました", "notification.mention": "{name}さんがあなたに返信しました", diff --cc app/javascript/packs/public.js index 9418188a7,ed713f335..1229a7505 --- a/app/javascript/packs/public.js +++ b/app/javascript/packs/public.js @@@ -100,16 -117,146 +100,26 @@@ function main() delegate(document, '.custom-emoji', 'mouseover', getEmojiAnimationHandler('data-original')); delegate(document, '.custom-emoji', 'mouseout', getEmojiAnimationHandler('data-static')); - }); - - delegate(document, '.webapp-btn', 'click', ({ target, button }) => { - if (button !== 0) { - return true; - } - window.location.href = target.href; - return false; - }); - - delegate(document, '.status__content__spoiler-link', 'click', function() { - const contentEl = this.parentNode.parentNode.querySelector('.e-content'); - - if (contentEl.style.display === 'block') { - contentEl.style.display = 'none'; - this.parentNode.style.marginBottom = 0; - } else { - contentEl.style.display = 'block'; - this.parentNode.style.marginBottom = null; - } - - return false; - }); - - delegate(document, '.blocks-table button.icon-button', 'click', function(e) { - e.preventDefault(); - - const classList = this.firstElementChild.classList; - classList.toggle('fa-chevron-down'); - classList.toggle('fa-chevron-up'); - this.parentElement.parentElement.nextElementSibling.classList.toggle('hidden'); - }); - - delegate(document, '.modal-button', 'click', e => { - e.preventDefault(); - - let href; - - if (e.target.nodeName !== 'A') { - href = e.target.parentNode.href; - } else { - href = e.target.href; - } - - window.open(href, 'mastodon-intent', 'width=445,height=600,resizable=no,menubar=no,status=no,scrollbars=yes'); - }); - - delegate(document, '#account_display_name', 'input', ({ target }) => { - const name = document.querySelector('.card .display-name strong'); - if (name) { - if (target.value) { - name.innerHTML = emojify(escapeTextContentForBrowser(target.value)); - } else { - name.textContent = document.querySelector('#default_account_display_name').textContent; - } - } - }); - - delegate(document, '#account_avatar', 'change', ({ target }) => { - const avatar = document.querySelector('.card .avatar img'); - const [file] = target.files || []; - const url = file ? URL.createObjectURL(file) : avatar.dataset.originalSrc; - - avatar.src = url; - }); - - const getProfileAvatarAnimationHandler = (swapTo) => { - //animate avatar gifs on the profile page when moused over - return ({ target }) => { - const swapSrc = target.getAttribute(swapTo); - //only change the img source if autoplay is off and the image src is actually different - if(target.getAttribute('data-autoplay') !== 'true' && target.src !== swapSrc) { - target.src = swapSrc; - } - }; - }; - - delegate(document, 'img#profile_page_avatar', 'mouseover', getProfileAvatarAnimationHandler('data-original')); - - delegate(document, 'img#profile_page_avatar', 'mouseout', getProfileAvatarAnimationHandler('data-static')); - - delegate(document, '#account_header', 'change', ({ target }) => { - const header = document.querySelector('.card .card__img img'); - const [file] = target.files || []; - const url = file ? URL.createObjectURL(file) : header.dataset.originalSrc; - - header.src = url; - }); - delegate(document, '#account_locked', 'change', ({ target }) => { - const lock = document.querySelector('.card .display-name i'); + delegate(document, '.blocks-table button.icon-button', 'click', function(e) { + e.preventDefault(); - if (target.checked) { - lock.style.display = 'inline'; - } else { - lock.style.display = 'none'; - } - }); - - delegate(document, '.input-copy input', 'click', ({ target }) => { - target.focus(); - target.select(); - target.setSelectionRange(0, target.value.length); - }); - - delegate(document, '.input-copy button', 'click', ({ target }) => { - const input = target.parentNode.querySelector('.input-copy__wrapper input'); - - const oldReadOnly = input.readonly; - - input.readonly = false; - input.focus(); - input.select(); - input.setSelectionRange(0, input.value.length); - - try { - if (document.execCommand('copy')) { - input.blur(); - target.parentNode.classList.add('copied'); - - setTimeout(() => { - target.parentNode.classList.remove('copied'); - }, 700); - } - } catch (err) { - console.error(err); - } - - input.readonly = oldReadOnly; + const classList = this.firstElementChild.classList; + classList.toggle('fa-chevron-down'); + classList.toggle('fa-chevron-up'); + this.parentElement.parentElement.nextElementSibling.classList.toggle('hidden'); + }); }); + + delegate(document, '.sidebar__toggle__icon', 'click', () => { + const target = document.querySelector('.sidebar ul'); + + if (target.style.display === 'block') { + target.style.display = 'none'; + } else { + target.style.display = 'block'; + } + }); } loadPolyfills().then(main).catch(error => { diff --cc app/models/status.rb index b0f610aa2,5e7474577..202434db3 --- a/app/models/status.rb +++ b/app/models/status.rb @@@ -355,12 -304,8 +355,12 @@@ class Status < ApplicationRecor Favourite.select('status_id').where(status_id: status_ids).where(account_id: account_id).each_with_object({}) { |f, h| h[f.status_id] = true } end + def bookmarks_map(status_ids, account_id) + Bookmark.select('status_id').where(status_id: status_ids).where(account_id: account_id).map { |f| [f.status_id, true] }.to_h + end + def reblogs_map(status_ids, account_id) - select('reblog_of_id').where(reblog_of_id: status_ids).where(account_id: account_id).reorder(nil).each_with_object({}) { |s, h| h[s.reblog_of_id] = true } + unscoped.select('reblog_of_id').where(reblog_of_id: status_ids).where(account_id: account_id).each_with_object({}) { |s, h| h[s.reblog_of_id] = true } end def mutes_map(conversation_ids, account_id) diff --cc app/serializers/activitypub/note_serializer.rb index f1cebbcd4,110621a28..dce506fa2 --- a/app/serializers/activitypub/note_serializer.rb +++ b/app/serializers/activitypub/note_serializer.rb @@@ -23,8 -23,9 +23,10 @@@ class ActivityPub::NoteSerializer < Act attribute :end_time, if: :poll_and_expires? attribute :closed, if: :poll_and_expired? + attribute :voters_count, if: :poll_and_voters_count? + def id + raise Mastodon::NotPermittedError, 'Local-only statuses should not be serialized' if object.local_only? && !instance_options[:allow_local_only] ActivityPub::TagManager.instance.uri_for(object) end diff --cc app/views/about/more.html.haml index 4922f0f54,7e156db61..03be3f423 --- a/app/views/about/more.html.haml +++ b/app/views/about/more.html.haml @@@ -2,9 -2,10 +2,9 @@@ = site_hostname - content_for :header_tags do - = javascript_pack_tag 'public', integrity: true, crossorigin: 'anonymous' = render partial: 'shared/og' - .grid-3 + .grid-4 .column-0 .public-account-header.public-account-header--no-bar .public-account-header__image diff --cc config/locales/ja.yml index f39e048ca,4b850a8a8..3ad4cf3e9 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@@ -705,9 -735,9 +735,10 @@@ ja all: すべて changes_saved_msg: 正常に変更されました! copy: コピー + no_batch_actions_available: 利用可能なバッチアクションはありません order_by: 並び順 save_changes: 変更を保存 + use_this: これを使う validation_errors: other: エラーが発生しました! 以下の%{count}個のエラーを確認してください html_validator: diff --cc config/routes.rb index 416bd833e,e43e201a5..49edb4602 --- a/config/routes.rb +++ b/config/routes.rb @@@ -132,11 -136,14 +136,16 @@@ Rails.application.routes.draw d end end + resources :flavours, only: [:index, :show, :update], param: :flavour + resource :delete, only: [:show, :destroy] - resource :migration, only: [:show, :update] + resource :migration, only: [:show, :create] + + namespace :migration do + resource :redirect, only: [:new, :create, :destroy] + end + resources :aliases, only: [:index, :create, :destroy] resources :sessions, only: [:destroy] resources :featured_tags, only: [:index, :create, :destroy] end