From: kibigo! Date: Wed, 11 Oct 2017 17:43:10 +0000 (-0700) Subject: Merge upstream 2.0ish #165 X-Git-Url: https://git.xn--scling-oua.cat.family/?a=commitdiff_plain;h=8d6b9ba4946b5b159af0fbd130637a226a286796;p=mastodon.git Merge upstream 2.0ish #165 --- 8d6b9ba4946b5b159af0fbd130637a226a286796 diff --cc app/javascript/mastodon/components/column_header.js index e0042b055,e4fa8fa7a..c47296a51 --- a/app/javascript/mastodon/components/column_header.js +++ b/app/javascript/mastodon/components/column_header.js @@@ -173,34 -135,17 +173,34 @@@ export default class ColumnHeader exten return (
-

+

{title} -
{backButton} + { notifCleaning ? ( + + ) : null} {collapseButton}

+ { notifCleaning ? ( +
+
+ {(notifCleaningActive || animatingNCD) ? () : null } +
+
+ ) : null} + -
+
{(!collapsed || animating) && collapsedContent}
diff --cc app/javascript/mastodon/features/compose/components/search_results.js index cae4ca412,8350d20a5..a3e68643f --- a/app/javascript/mastodon/features/compose/components/search_results.js +++ b/app/javascript/mastodon/features/compose/components/search_results.js @@@ -2,8 -2,8 +2,8 @@@ import React from 'react' import ImmutablePropTypes from 'react-immutable-proptypes'; import { FormattedMessage } from 'react-intl'; import AccountContainer from '../../../containers/account_container'; -import StatusContainer from '../../../containers/status_container'; +import StatusContainer from '../../../../glitch/components/status/container'; - import Link from 'react-router-dom/Link'; + import { Link } from 'react-router-dom'; import ImmutablePureComponent from 'react-immutable-pure-component'; export default class SearchResults extends ImmutablePureComponent { diff --cc app/javascript/mastodon/features/compose/index.js index f0bce1e40,6166fce3c..9068648bd --- a/app/javascript/mastodon/features/compose/index.js +++ b/app/javascript/mastodon/features/compose/index.js @@@ -5,9 -5,7 +5,9 @@@ import PropTypes from 'prop-types' import ImmutablePropTypes from 'react-immutable-proptypes'; import { connect } from 'react-redux'; import { mountCompose, unmountCompose } from '../../actions/compose'; +import { openModal } from '../../actions/modal'; +import { changeLocalSetting } from '../../../glitch/actions/local_settings'; - import Link from 'react-router-dom/Link'; + import { Link } from 'react-router-dom'; import { injectIntl, defineMessages } from 'react-intl'; import SearchContainer from './containers/search_container'; import Motion from 'react-motion/lib/Motion'; diff --cc app/javascript/mastodon/features/status/components/detailed_status.js index 232eccf70,4fd1c2ec0..816f83e45 --- a/app/javascript/mastodon/features/status/components/detailed_status.js +++ b/app/javascript/mastodon/features/status/components/detailed_status.js @@@ -3,11 -3,10 +3,11 @@@ import PropTypes from 'prop-types' import ImmutablePropTypes from 'react-immutable-proptypes'; import Avatar from '../../../components/avatar'; import DisplayName from '../../../components/display_name'; -import StatusContent from '../../../components/status_content'; -import MediaGallery from '../../../components/media_gallery'; +import StatusContent from '../../../../glitch/components/status/content'; +import StatusGallery from '../../../../glitch/components/status/gallery'; +import StatusPlayer from '../../../../glitch/components/status/player'; import AttachmentList from '../../../components/attachment_list'; - import Link from 'react-router-dom/Link'; + import { Link } from 'react-router-dom'; import { FormattedDate, FormattedNumber } from 'react-intl'; import CardContainer from '../containers/card_container'; import ImmutablePureComponent from 'react-immutable-pure-component'; diff --cc app/javascript/mastodon/features/status/index.js index fc45d5f21,eed8ea260..fff5f529c --- a/app/javascript/mastodon/features/status/index.js +++ b/app/javascript/mastodon/features/status/index.js @@@ -183,30 -284,33 +286,34 @@@ export default class Status extends Imm -
+
{ancestors} - - - + +
+ + + +
+
{descendants}
diff --cc app/javascript/mastodon/features/ui/components/column_link.js index 62aab9a23,5425219c4..b845d1895 --- a/app/javascript/mastodon/features/ui/components/column_link.js +++ b/app/javascript/mastodon/features/ui/components/column_link.js @@@ -1,8 -1,8 +1,8 @@@ import React from 'react'; import PropTypes from 'prop-types'; - import Link from 'react-router-dom/Link'; + import { Link } from 'react-router-dom'; -const ColumnLink = ({ icon, text, to, href, method }) => { +const ColumnLink = ({ icon, text, to, onClick, href, method }) => { if (href) { return ( diff --cc app/javascript/mastodon/features/ui/index.js index 73bd23432,70e451373..14a5f6224 --- a/app/javascript/mastodon/features/ui/index.js +++ b/app/javascript/mastodon/features/ui/index.js @@@ -41,13 -41,10 +42,14 @@@ import { HotKeys } from 'react-hotkeys' // Dummy import, to make sure that ends up in the application bundle. // Without this it ends up in ~8 very commonly used bundles. -import '../../components/status'; +import '../../../glitch/components/status'; const mapStateToProps = state => ({ + systemFontUi: state.getIn(['meta', 'system_font_ui']), + layout: state.getIn(['local_settings', 'layout']), + isWide: state.getIn(['local_settings', 'stretch']), + navbarUnder: state.getIn(['local_settings', 'navbar_under']), + me: state.getIn(['meta', 'me']), isComposing: state.getIn(['compose', 'is_composing']), }); @@@ -62,11 -85,8 +90,12 @@@ export default class UI extends React.C static propTypes = { dispatch: PropTypes.func.isRequired, children: PropTypes.node, + layout: PropTypes.string, + isWide: PropTypes.bool, + systemFontUi: PropTypes.bool, + navbarUnder: PropTypes.bool, isComposing: PropTypes.bool, + me: PropTypes.string, location: PropTypes.object, }; @@@ -207,64 -318,68 +328,86 @@@ render () { const { width, draggingOver } = this.state; - const { children } = this.props; + const { children, layout, isWide, navbarUnder } = this.props; + + const columnsClass = layout => { + switch (layout) { + case 'single': + return 'single-column'; + case 'multiple': + return 'multi-columns'; + default: + return 'auto-columns'; + } + }; + + const className = classNames('ui', columnsClass(layout), { + 'wide': isWide, + 'system-font': this.props.systemFontUi, + 'navbar-under': navbarUnder, + }); + const handlers = { + new: this.handleHotkeyNew, + search: this.handleHotkeySearch, + forceNew: this.handleHotkeyForceNew, + focusColumn: this.handleHotkeyFocusColumn, + back: this.handleHotkeyBack, + goToHome: this.handleHotkeyGoToHome, + goToNotifications: this.handleHotkeyGoToNotifications, + goToLocal: this.handleHotkeyGoToLocal, + goToFederated: this.handleHotkeyGoToFederated, + goToStart: this.handleHotkeyGoToStart, + goToFavourites: this.handleHotkeyGoToFavourites, + goToPinned: this.handleHotkeyGoToPinned, + goToProfile: this.handleHotkeyGoToProfile, + goToBlocked: this.handleHotkeyGoToBlocked, + goToMuted: this.handleHotkeyGoToMuted, + }; + return ( -
- {navbarUnder ? null : ()} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {navbarUnder ? () : null} - - - -
+ -
- ++
++ {navbarUnder ? null : ()} + - ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ++ {navbarUnder ? () : null} + + + +
+ ); } diff --cc app/javascript/mastodon/reducers/notifications.js index ecce8dcb6,cccf00a1f..48850ab01 --- a/app/javascript/mastodon/reducers/notifications.js +++ b/app/javascript/mastodon/reducers/notifications.js @@@ -8,14 -8,11 +8,17 @@@ import NOTIFICATIONS_EXPAND_FAIL, NOTIFICATIONS_CLEAR, NOTIFICATIONS_SCROLL_TOP, + NOTIFICATIONS_DELETE_MARKED_REQUEST, + NOTIFICATIONS_DELETE_MARKED_SUCCESS, + NOTIFICATION_MARK_FOR_DELETE, + NOTIFICATIONS_DELETE_MARKED_FAIL, + NOTIFICATIONS_ENTER_CLEARING_MODE, + NOTIFICATIONS_MARK_ALL_FOR_DELETE, } from '../actions/notifications'; - import { ACCOUNT_BLOCK_SUCCESS } from '../actions/accounts'; + import { + ACCOUNT_BLOCK_SUCCESS, + ACCOUNT_MUTE_SUCCESS, + } from '../actions/accounts'; import { TIMELINE_DELETE } from '../actions/timelines'; import { Map as ImmutableMap, List as ImmutableList } from 'immutable'; diff --cc app/javascript/mastodon/reducers/settings.js index 1bdee7356,a9f3f9529..0c0dae388 --- a/app/javascript/mastodon/reducers/settings.js +++ b/app/javascript/mastodon/reducers/settings.js @@@ -5,9 -6,12 +6,13 @@@ import { Map as ImmutableMap, fromJS } import uuid from '../uuid'; const initialState = ImmutableMap({ + saved: true, + onboarded: false, + layout: 'auto', + skinTone: 1, + home: ImmutableMap({ shows: ImmutableMap({ reblog: true, diff --cc app/javascript/styles/components.scss index 2f02af098,b6da70c91..8ecc0b91b --- a/app/javascript/styles/components.scss +++ b/app/javascript/styles/components.scss @@@ -591,33 -584,30 +630,49 @@@ } .status__prepend-icon-wrapper { - left: -26px; - position: absolute; + float: left; + margin: 0 10px 0 -58px; + width: 48px; + text-align: right; +} + +.notif-cleaning { + .status, .notification-follow { + padding-right: ($dismiss-overlay-width + 0.5rem); + } +} + +.notification-follow { + position: relative; + + // same like Status + border-bottom: 1px solid lighten($ui-base-color, 8%); + + .account { + border-bottom: 0 none; + } } + .focusable { + &:focus { + outline: 0; + background: lighten($ui-base-color, 4%); + + &.status-direct { + background: lighten($ui-base-color, 12%); + } + + .detailed-status, + .detailed-status__action-bar { + background: lighten($ui-base-color, 8%); + } + } + } + .status { padding: 8px 10px; - padding-left: 68px; position: relative; + height: auto; min-height: 48px; border-bottom: 1px solid lighten($ui-base-color, 8%); cursor: default; @@@ -1199,8 -1076,25 +1265,16 @@@ } } + .muted { + .emojione { + opacity: 0.5; + } + } + -.status__display-name, -.reply-indicator__display-name, -.detailed-status__display-name, -.account__display-name { - &:hover strong { - text-decoration: underline; - } -} - .account__display-name strong { display: block; + overflow: hidden; + text-overflow: ellipsis; } .detailed-status__application, diff --cc app/models/media_attachment.rb index 65ff893a8,60380198b..f6c8879c5 --- a/app/models/media_attachment.rb +++ b/app/models/media_attachment.rb @@@ -157,9 -139,13 +160,13 @@@ class MediaAttachment < ApplicationReco end end + def prepare_description + self.description = description.strip[0...420] unless description.nil? + end + def set_type_and_extension - self.type = VIDEO_MIME_TYPES.include?(file_content_type) ? :video : :image - extension = appropriate_extension + self.type = VIDEO_MIME_TYPES.include?(file_content_type) ? :video : AUDIO_MIME_TYPES.include?(file_content_type) ? :audio : :image + extension = AUDIO_MIME_TYPES.include?(file_content_type) ? '.mp4' : appropriate_extension basename = Paperclip::Interpolations.basename(file, :original) file.instance_write :file_name, [basename, extension].delete_if(&:blank?).join('.') end diff --cc app/models/mute.rb index 0d597a275,6e64848c7..bcd3d247c --- a/app/models/mute.rb +++ b/app/models/mute.rb @@@ -3,12 -3,11 +3,12 @@@ # # Table name: mutes # - # id :integer not null, primary key - # account_id :integer not null - # target_account_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null -# account_id :integer not null -# id :integer not null, primary key -# target_account_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null ++# account_id :integer not null ++# id :integer not null, primary key ++# target_account_id :integer not null +# hide_notifications :boolean default(TRUE), not null # class Mute < ApplicationRecord diff --cc app/services/mute_service.rb index 56cbebd5d,132369484..a9a02937e --- a/app/services/mute_service.rb +++ b/app/services/mute_service.rb @@@ -1,9 -1,10 +1,10 @@@ # frozen_string_literal: true class MuteService < BaseService - def call(account, target_account) + def call(account, target_account, notifications: nil) return if account.id == target_account.id - FeedManager.instance.clear_from_timeline(account, target_account) - mute = account.mute!(target_account) + account.mute!(target_account, notifications: notifications) + BlockWorker.perform_async(account.id, target_account.id) + mute end end diff --cc app/views/layouts/error.html.haml index 8b260c619,37359b89b..d0eae4434 --- a/app/views/layouts/error.html.haml +++ b/app/views/layouts/error.html.haml @@@ -3,12 -3,12 +3,12 @@@ %head %meta{ content: 'text/html; charset=UTF-8', 'http-equiv' => 'Content-Type' }/ %meta{ charset: 'utf-8' }/ - %title= safe_join([yield(:page_title), title], ' - ') + %title= safe_join([yield(:page_title), Setting.default_settings['site_title']], ' - ') %meta{ content: 'width=device-width,initial-scale=1', name: 'viewport' }/ = stylesheet_pack_tag 'common', media: 'all' - = stylesheet_pack_tag Setting.default_settings['theme'], media: 'all' + = stylesheet_pack_tag 'application', integrity: true, media: 'all' %body.error .dialog - %img{ alt: title, src: '/oops.gif' }/ + %img{ alt: Setting.default_settings['site_title'], src: '/oops.gif' }/ %div %h1= yield :content diff --cc config/application.rb index db53b8c84,4860a08a1..4e8a5875d --- a/config/application.rb +++ b/config/application.rb @@@ -9,7 -9,7 +9,8 @@@ Bundler.require(*Rails.groups require_relative '../app/lib/exceptions' require_relative '../lib/paperclip/gif_transcoder' require_relative '../lib/paperclip/video_transcoder' +require_relative '../lib/paperclip/audio_transcoder' + require_relative '../lib/mastodon/snowflake' require_relative '../lib/mastodon/version' Dotenv::Railtie.load diff --cc config/environments/production.rb index dc1ce5ed6,5705ffcfe..e0ee393c1 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@@ -90,18 -90,10 +90,13 @@@ Rails.application.configure d config.action_mailer.delivery_method = ENV.fetch('SMTP_DELIVERY_METHOD', 'smtp').to_sym - config.to_prepare do - StatsD.backend = StatsD::Instrument::Backends::NullBackend.new if ENV['STATSD_ADDR'].blank? - Sidekiq::Logging.logger.level = Logger::WARN - end - config.action_dispatch.default_headers = { - 'Server' => 'Mastodon', - 'X-Frame-Options' => 'DENY', - 'X-Content-Type-Options' => 'nosniff', - 'X-XSS-Protection' => '1; mode=block', + 'Server' => 'Mastodon', + 'X-Frame-Options' => 'DENY', + 'X-Content-Type-Options' => 'nosniff', + 'X-XSS-Protection' => '1; mode=block', + 'Content-Security-Policy' => "frame-ancestors 'none'; object-src 'none'; script-src 'self' https://dev-static.glitch.social 'unsafe-inline'; base-uri 'none';" , + 'Referrer-Policy' => 'no-referrer, strict-origin-when-cross-origin', + 'Strict-Transport-Security' => 'max-age=63072000; includeSubDomains; preload' } end diff --cc config/routes.rb index 2c41c24e9,5a6351f77..9ed081e50 --- a/config/routes.rb +++ b/config/routes.rb @@@ -193,14 -204,9 +204,13 @@@ Rails.application.routes.draw d get '/search', to: 'search#index', as: :search resources :follows, only: [:create] - resources :media, only: [:create] - resources :apps, only: [:create] + resources :media, only: [:create, :update] resources :blocks, only: [:index] - resources :mutes, only: [:index] + resources :mutes, only: [:index] do + collection do + get 'details' + end + end resources :favourites, only: [:index] resources :reports, only: [:index, :create] diff --cc config/webpack/loaders/babel.js index 989a87dcf,e17d2fa70..770c89aa7 --- a/config/webpack/loaders/babel.js +++ b/config/webpack/loaders/babel.js @@@ -4,15 -4,10 +4,11 @@@ const env = process.env.NODE_ENV || 'de module.exports = { test: /\.js$/, - // include react-intl because transform-react-remove-prop-types needs to apply to it - exclude: { - test: /node_modules/, - exclude: /react-intl[\/\\](?!locale-data)/, - }, + exclude: /node_modules/, loader: 'babel-loader', options: { - forceEnv: env, + forceEnv: process.env.NODE_ENV || 'development', + sourceRoot: 'app/javascript', cacheDirectory: env === 'development' ? false : resolve(__dirname, '..', '..', '..', 'tmp', 'cache', 'babel-loader'), }, }; diff --cc config/webpack/shared.js index 99f4dec1a,cd642a28a..e3a1fc379 --- a/config/webpack/shared.js +++ b/config/webpack/shared.js @@@ -50,10 -48,14 +50,17 @@@ module.exports = plugins: [ new webpack.EnvironmentPlugin(JSON.parse(JSON.stringify(env))), + new webpack.NormalModuleReplacementPlugin( + /^history\//, (resource) => { + // temporary fix for https://github.com/ReactTraining/react-router/issues/5576 + // to reduce bundle size + resource.request = resource.request.replace(/^history/, 'history/es'); + } + ), - new ExtractTextPlugin(env.NODE_ENV === 'production' ? '[name]-[hash].css' : '[name].css'), + new ExtractTextPlugin({ + filename: env.NODE_ENV === 'production' ? '[name]-[hash].css' : '[name].css', + allChunks: true, + }), new ManifestPlugin({ publicPath: output.publicPath, writeToFileEmit: true, diff --cc db/schema.rb index 6b73ebb94,f9722ccda..128f51ee7 --- a/db/schema.rb +++ b/db/schema.rb @@@ -176,11 -196,10 +196,11 @@@ ActiveRecord::Schema.define(version: 20 end create_table "mutes", force: :cascade do |t| - t.bigint "account_id", null: false - t.bigint "target_account_id", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.boolean "hide_notifications", default: true, null: false + t.bigint "account_id", null: false + t.bigint "target_account_id", null: false t.index ["account_id", "target_account_id"], name: "index_mutes_on_account_id_and_target_account_id", unique: true end