]> cat aescling's git repositories - mastodon.git/commitdiff
Merge branch 'master' into glitch-soc/merge-upstream
authorThibaut Girka <thib@sitedethib.com>
Sun, 3 May 2020 19:20:42 +0000 (21:20 +0200)
committerThibaut Girka <thib@sitedethib.com>
Sun, 3 May 2020 19:23:49 +0000 (21:23 +0200)
Conflicts:
- `app/controllers/statuses_controller.rb`:
  Upstream disabled the embed controller for reblogs.
  Not a real conflict, but glitch-soc has an extra line to deal
  with its theming system.
  Ported upstream changes.
- `app/javascript/packs/public.js`:
  Upstream made changes to get rid of most inline CSS, this changes
  javascript for public pages, which in glitch are split between
  different files. Ported those changes.
- `app/models/status.rb`:
  Upstream changed the block check in `Status#permitted_for` to
  include domain-block checks. Not a real conflict with glitch-soc,
  but our scope is slightly different, as our scope for
  unauthenticated access do not include instance-local toots.
  Ported upstream changes.
- `app/serializers/rest/instance_serializer.rb`:
  Not a real conflict, upstream added a new field to the instance
  serializer, the conflict is one line above since we added more of
  that.
  Ported upstream changes.
- `app/views/settings/profiles/show.html.haml`:
  Upstream got rid of most inline CSS and moved hidden elements
  to data attributes in the process, in fields were we have
  different values.
  Ported upstream changes while keeping our glitch-specific
  values.
- `app/views/statuses/_simple_status.html.haml`:
  Upstream got rid of inline CSS on an HAML line we treat
  differently, stripping empty text nodes.
  Ported upstream changes to the style attribute, keeping
  the empty text node stripping behavior.

29 files changed:
1  2 
Gemfile
Gemfile.lock
app/controllers/accounts_controller.rb
app/controllers/api/v1/statuses_controller.rb
app/controllers/remote_interaction_controller.rb
app/controllers/statuses_controller.rb
app/javascript/core/settings.js
app/javascript/flavours/glitch/packs/public.js
app/javascript/packs/public.js
app/javascript/styles/mastodon/admin.scss
app/javascript/styles/mastodon/components.scss
app/models/account.rb
app/models/media_attachment.rb
app/models/status.rb
app/serializers/rest/instance_serializer.rb
app/views/admin/pending_accounts/index.html.haml
app/views/admin/reports/show.html.haml
app/views/admin/statuses/index.html.haml
app/views/admin/tags/index.html.haml
app/views/directories/index.html.haml
app/views/layouts/application.html.haml
app/views/layouts/embedded.html.haml
app/views/public_timelines/show.html.haml
app/views/settings/preferences/appearance/show.html.haml
app/views/settings/profiles/show.html.haml
app/views/statuses/_simple_status.html.haml
db/schema.rb
spec/models/status_spec.rb
yarn.lock

diff --cc Gemfile
Simple merge
diff --cc Gemfile.lock
Simple merge
index 588063d0103bc210f8ef56d683b415e70c2f1dd4,d362b97dc6916c60df197e12c734f7188c06c218..a1b7f432041a4b15e572a2a205f1ffb06f312115
@@@ -48,8 -46,7 +48,8 @@@ class StatusesController < ApplicationC
    end
  
    def embed
-     return not_found if @status.hidden?
 +    use_pack 'embed'
+     return not_found if @status.hidden? || @status.reblog?
  
      expires_in 180, public: true
      response.headers['X-Frame-Options'] = 'ALLOWALL'
index e02c91cc764f8b76f5a77121cd8512aac83d115c,0000000000000000000000000000000000000000..9fe03f90c2c37a957ed3ffa7e70f53fb7b04a0c8
mode 100644,000000..100644
--- /dev/null
@@@ -1,74 -1,0 +1,74 @@@
-       name.textContent = document.querySelector('#default_account_display_name').textContent;
 +//  This file will be loaded on settings pages, regardless of theme.
 +
 +import escapeTextContentForBrowser from 'escape-html';
 +const { delegate } = require('@rails/ujs');
 +import emojify from '../mastodon/features/emoji/emoji';
 +
 +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 = name.textContent = target.dataset.default;
 +    }
 +  }
 +});
 +
 +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;
 +});
 +
 +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');
 +
 +  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;
 +});
index e5a567205d64486f3e47bf744c69206e2f6b9c01,0000000000000000000000000000000000000000..58febcf5b182b18b195a06dc3a46c03b97ace4b7
mode 100644,000000..100644
--- /dev/null
@@@ -1,140 -1,0 +1,138 @@@
-       const contentEl = this.parentNode.parentNode.querySelector('.e-content');
 +import loadPolyfills from 'flavours/glitch/util/load_polyfills';
 +import ready from 'flavours/glitch/util/ready';
 +import loadKeyboardExtensions from 'flavours/glitch/util/load_keyboard_extensions';
 +
 +function main() {
 +  const IntlMessageFormat = require('intl-messageformat').default;
 +  const { timeAgoString } = require('flavours/glitch/components/relative_timestamp');
 +  const { delegate } = require('@rails/ujs');
 +  const emojify = require('flavours/glitch/util/emoji').default;
 +  const { getLocale } = require('locales');
 +  const { messages } = getLocale();
 +  const React = require('react');
 +  const ReactDOM = require('react-dom');
 +  const Rellax = require('rellax');
 +  const { createBrowserHistory } = require('history');
 +
 +  const scrollToDetailedStatus = () => {
 +    const history = createBrowserHistory();
 +    const detailedStatuses = document.querySelectorAll('.public-layout .detailed-status');
 +    const location = history.location;
 +
 +    if (detailedStatuses.length === 1 && (!location.state || !location.state.scrolledToDetailedStatus)) {
 +      detailedStatuses[0].scrollIntoView();
 +      history.replace(location.pathname, { ...location.state, scrolledToDetailedStatus: true });
 +    }
 +  };
 +
 +  const getEmojiAnimationHandler = (swapTo) => {
 +    return ({ target }) => {
 +      target.src = target.getAttribute(swapTo);
 +    };
 +  };
 +
 +  ready(() => {
 +    const locale = document.documentElement.lang;
 +
 +    const dateTimeFormat = new Intl.DateTimeFormat(locale, {
 +      year: 'numeric',
 +      month: 'long',
 +      day: 'numeric',
 +      hour: 'numeric',
 +      minute: 'numeric',
 +    });
 +
 +    [].forEach.call(document.querySelectorAll('.emojify'), (content) => {
 +      content.innerHTML = emojify(content.innerHTML);
 +    });
 +
 +    [].forEach.call(document.querySelectorAll('time.formatted'), (content) => {
 +      const datetime = new Date(content.getAttribute('datetime'));
 +      const formattedDate = dateTimeFormat.format(datetime);
 +
 +      content.title = formattedDate;
 +      content.textContent = formattedDate;
 +    });
 +
 +    [].forEach.call(document.querySelectorAll('time.time-ago'), (content) => {
 +      const datetime = new Date(content.getAttribute('datetime'));
 +      const now      = new Date();
 +
 +      content.title = dateTimeFormat.format(datetime);
 +      content.textContent = timeAgoString({
 +        formatMessage: ({ id, defaultMessage }, values) => (new IntlMessageFormat(messages[id] || defaultMessage, locale)).format(values),
 +        formatDate: (date, options) => (new Intl.DateTimeFormat(locale, options)).format(date),
 +      }, datetime, now, now.getFullYear(), content.getAttribute('datetime').includes('T'));
 +    });
 +
 +    const reactComponents = document.querySelectorAll('[data-component]');
 +    if (reactComponents.length > 0) {
 +      import(/* webpackChunkName: "containers/media_container" */ 'flavours/glitch/containers/media_container')
 +        .then(({ default: MediaContainer }) => {
 +          [].forEach.call(reactComponents, (component) => {
 +            [].forEach.call(component.children, (child) => {
 +              component.removeChild(child);
 +            });
 +          });
 +
 +          const content = document.createElement('div');
 +
 +          ReactDOM.render(<MediaContainer locale={locale} components={reactComponents} />, content);
 +          document.body.appendChild(content);
 +          scrollToDetailedStatus();
 +        })
 +        .catch(error => {
 +          console.error(error);
 +          scrollToDetailedStatus();
 +        });
 +    } else {
 +      scrollToDetailedStatus();
 +    }
 +
 +    const parallaxComponents = document.querySelectorAll('.parallax');
 +
 +    if (parallaxComponents.length > 0 ) {
 +      new Rellax('.parallax', { speed: -1 });
 +    }
 +
 +    delegate(document, '.custom-emoji', 'mouseover', getEmojiAnimationHandler('data-original'));
 +    delegate(document, '.custom-emoji', 'mouseout', getEmojiAnimationHandler('data-static'));
 +
 +    delegate(document, '.status__content__spoiler-link', 'click', function() {
-       if (contentEl.style.display === 'block') {
-         contentEl.style.display = 'none';
-         this.parentNode.style.marginBottom = 0;
++      const statusEl = this.parentNode.parentNode;
 +
-         contentEl.style.display = 'block';
-         this.parentNode.style.marginBottom = null;
++      if (statusEl.dataset.spoiler === 'expanded') {
++        statusEl.dataset.spoiler = 'folded';
 +        this.textContent = (new IntlMessageFormat(messages['status.show_more'] || 'Show more', locale)).format();
 +      } else {
-       const contentEl = spoilerLink.parentNode.parentNode.querySelector('.e-content');
-       const message = (contentEl.style.display === 'block') ? (messages['status.show_less'] || 'Show less') : (messages['status.show_more'] || 'Show more');
++        statusEl.dataset.spoiler = 'expanded';
 +        this.textContent = (new IntlMessageFormat(messages['status.show_less'] || 'Show less', locale)).format();
 +      }
 +
 +      return false;
 +    });
 +
 +    [].forEach.call(document.querySelectorAll('.status__content__spoiler-link'), (spoilerLink) => {
++      const statusEl = spoilerLink.parentNode.parentNode;
++      const message = (statusEl.dataset.spoiler === 'expanded') ? (messages['status.show_less'] || 'Show less') : (messages['status.show_more'] || 'Show more');
 +      spoilerLink.textContent = (new IntlMessageFormat(message, locale)).format();
 +    });
 +  });
 +
 +  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)
 +  .then(loadKeyboardExtensions)
 +  .catch(error => {
 +    console.error(error);
 +  });
Simple merge
Simple merge
Simple merge
index 31e77770d48efbd044c4adfdfadcfdb05a5bc0e8,a938ff032563a285f96437aa2d144c43c0208074..34fa00912587f71d0a7ba79136db59059f5fd973
@@@ -403,8 -349,8 +399,8 @@@ class Status < ApplicationRecor
        visibility = [:public, :unlisted]
  
        if account.nil?
 -        where(visibility: visibility)
 +        where(visibility: visibility).not_local_only
-       elsif target_account.blocking?(account) # get rid of blocked peeps
+       elsif target_account.blocking?(account) || (account.domain.present? && target_account.domain_blocking?(account.domain)) # get rid of blocked peeps
          none
        elsif account.id == target_account.id # author can see own stuff
          all
index e913f0c64fd0dccaad5940c4e496a153224f7586,b388e448e3622a45a6d4a0ca1dfc980480d4ab37..54e7c450caa7d605b16485a7445b80edca875357
@@@ -4,8 -4,8 +4,8 @@@ class REST::InstanceSerializer < Active
    include RoutingHelper
  
    attributes :uri, :title, :short_description, :description, :email,
 -             :version, :urls, :stats, :thumbnail,
 +             :version, :urls, :stats, :thumbnail, :max_toot_chars, :poll_limits,
-              :languages, :registrations, :approval_required
+              :languages, :registrations, :approval_required, :invites_enabled
  
    has_one :contact_account, serializer: REST::AccountSerializer
  
Simple merge
Simple merge
Simple merge
index 5453177fdbea22f0e8def72c4e81c6698f9b09de,10fff406e6dd7f1ce2592e641dfd7cd29bfeff07..5fc865814a0a1112a194911b437ab4a610013e87
@@@ -5,12 -5,15 +5,12 @@@
    = button_tag t('generic.save_changes'), class: 'button', form: 'edit_user'
  
  = simple_form_for current_user, url: settings_preferences_appearance_path, html: { method: :put, id: 'edit_user' } do |f|
 -  .fields-row
 -    .fields-group.fields-row__column.fields-row__column-6
 -      = f.input :locale, collection: I18n.available_locales, wrapper: :with_label, include_blank: false, label_method: lambda { |locale| human_locale(locale) }, selected: I18n.locale, hint: false
 -    .fields-group.fields-row__column.fields-row__column-6
 -      = f.input :setting_theme, collection: Themes.instance.names, label_method: lambda { |theme| I18n.t("themes.#{theme}", default: theme) }, wrapper: :with_label, include_blank: false, hint: false
 +  .fields-group
 +    = f.input :locale, collection: I18n.available_locales, wrapper: :with_label, include_blank: false, label_method: lambda { |locale| human_locale(locale) }, selected: I18n.locale, hint: false
  
    - unless I18n.locale == :en
-     .flash-message{ style: "text-align: unset; color: unset" }
-       #{t 'appearance.localization.body'} #{content_tag(:a, t('appearance.localization.guide_link_text'), href: t('appearance.localization.guide_link'), target: "_blank", rel: "noopener", style: "text-decoration: underline")}
+     .flash-message.translation-prompt
+       #{t 'appearance.localization.body'} #{content_tag(:a, t('appearance.localization.guide_link_text'), href: t('appearance.localization.guide_link'), target: "_blank", rel: "noopener")}
  
    %h4= t 'appearance.advanced_web_interface'
  
index 841c01fd7b6dbb6d3078bb5fc791feb5e0d6eeb6,4885878f0f3ec2bc7a8b5e972f0a53754a92a250..6061e9cfdf89639aa0dff684ee3abfeb5dff8cd8
@@@ -9,8 -9,8 +9,8 @@@
  
    .fields-row
      .fields-row__column.fields-group.fields-row__column-6
-       = f.input :display_name, wrapper: :with_label, input_html: { maxlength: Account::MAX_DISPLAY_NAME_LENGTH }, hint: false
 -      = f.input :display_name, wrapper: :with_label, input_html: { maxlength: 30, data: { default: @account.username } }, hint: false
 -      = f.input :note, wrapper: :with_label, input_html: { maxlength: 500 }, hint: false
++      = f.input :display_name, wrapper: :with_label, input_html: { maxlength: Account::MAX_DISPLAY_NAME_LENGTH, data: { default: @account.username } }, hint: false
 +      = f.input :note, wrapper: :with_label, input_html: { maxlength: Account::MAX_NOTE_LENGTH }, hint: false
  
    .fields-row
      .fields-row__column.fields-row__column-6
index 8a418a1d5cb63918290dbf8d6e4052d1b60e5b6e,ff09ab2eec297e082b555619c3ecec0b5844212b..f959056cdc6b1163dd0c2db2b1710b7b6d2b0cb2
            %span.display-name__account
              = acct(status.account)
              = fa_icon('lock') if status.account.locked?
-   .status__content.emojify<
+   .status__content.emojify{ :data => ({ spoiler: current_account&.user&.setting_expand_spoilers ? 'expanded' : 'folded' } if status.spoiler_text?) }<
      - if status.spoiler_text?
-       %p{ :style => ('margin-bottom: 0' unless current_account&.user&.setting_expand_spoilers) }<
+       %p<
          %span.p-summary> #{Formatter.instance.format_spoiler(status, autoplay: autoplay)}&nbsp;
          %button.status__content__spoiler-link= t('statuses.show_more')
-     .e-content{ style: "display: #{!current_account&.user&.setting_expand_spoilers && status.spoiler_text? ? 'none' : 'block'}; direction: #{rtl_status?(status) ? 'rtl' : 'ltr'}" }<
 -    .e-content{ dir: rtl_status?(status) ? 'rtl' : 'ltr' }
++    .e-content{ dir: rtl_status?(status) ? 'rtl' : 'ltr' }<
        = Formatter.instance.format(status, custom_emojify: true, autoplay: autoplay)
        - if status.preloadable_poll
          = react_component :poll, disabled: true, poll: ActiveModelSerializers::SerializableResource.new(status.preloadable_poll, serializer: REST::PollSerializer, scope: current_user, scope_name: :current_user).as_json do
diff --cc db/schema.rb
Simple merge
Simple merge
diff --cc yarn.lock
Simple merge