From 4f42238c294f92dbd87db3d83f9514344fcd1f8a Mon Sep 17 00:00:00 2001 From: "chr v1.x" Date: Fri, 15 Jun 2018 02:15:15 -0700 Subject: [PATCH 1/8] Put "Media Only" option in column settings instead of content area headline (#7801) * Action/reducer for changing column settings takes a path and a value instead of a javascript object * Settings menu version and column headline version working simultaneously * remove column headline entirely * remove css for headlines that aren't possible now * Remove commented out code from unfruitful attempt at this feature * Give direct timeline its own column settings bc it doesn't have a media only option * Fix typo in public timeline code that was preventing per-column settings from working properly * Fix codeclimate issues * Missing semicolons * Use redux state to set onlyMedia, let that do the update instead of a callback. Consequently, unpinned setting works without history modification * Unused import --- app/javascript/mastodon/actions/columns.js | 5 +- .../components/column_settings.js | 6 ++ .../components/section_headline.js | 59 ------------------- .../containers/column_settings_container.js | 29 ++++++--- .../features/community_timeline/index.js | 41 +++++-------- .../components/column_settings.js | 35 +++++++++++ .../containers/column_settings_container.js | 2 +- .../containers/column_settings_container.js | 29 ++++++--- .../features/public_timeline/index.js | 44 +++++++------- app/javascript/mastodon/reducers/settings.js | 6 +- .../styles/mastodon/components.scss | 2 - 11 files changed, 125 insertions(+), 133 deletions(-) delete mode 100644 app/javascript/mastodon/features/community_timeline/components/section_headline.js create mode 100644 app/javascript/mastodon/features/direct_timeline/components/column_settings.js diff --git a/app/javascript/mastodon/actions/columns.js b/app/javascript/mastodon/actions/columns.js index f550e6c48d..9b87415fb8 100644 --- a/app/javascript/mastodon/actions/columns.js +++ b/app/javascript/mastodon/actions/columns.js @@ -40,12 +40,13 @@ export function moveColumn(uuid, direction) { }; }; -export function changeColumnParams(uuid, params) { +export function changeColumnParams(uuid, path, value) { return dispatch => { dispatch({ type: COLUMN_PARAMS_CHANGE, uuid, - params, + path, + value, }); dispatch(saveSettings()); diff --git a/app/javascript/mastodon/features/community_timeline/components/column_settings.js b/app/javascript/mastodon/features/community_timeline/components/column_settings.js index a992b27bbd..3a1d19aa81 100644 --- a/app/javascript/mastodon/features/community_timeline/components/column_settings.js +++ b/app/javascript/mastodon/features/community_timeline/components/column_settings.js @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import SettingText from '../../../components/setting_text'; +import SettingToggle from '../../notifications/components/setting_toggle'; const messages = defineMessages({ filter_regex: { id: 'home.column_settings.filter_regex', defaultMessage: 'Filter out by regular expressions' }, @@ -16,6 +17,7 @@ export default class ColumnSettings extends React.PureComponent { settings: ImmutablePropTypes.map.isRequired, onChange: PropTypes.func.isRequired, intl: PropTypes.object.isRequired, + columnId: PropTypes.string, }; render () { @@ -23,6 +25,10 @@ export default class ColumnSettings extends React.PureComponent { return (
+
+ } /> +
+
diff --git a/app/javascript/mastodon/features/community_timeline/components/section_headline.js b/app/javascript/mastodon/features/community_timeline/components/section_headline.js deleted file mode 100644 index c7176d04b8..0000000000 --- a/app/javascript/mastodon/features/community_timeline/components/section_headline.js +++ /dev/null @@ -1,59 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component, Fragment } from 'react'; -import { FormattedMessage } from 'react-intl'; -import { NavLink } from 'react-router-dom'; - -export default class SectionHeadline extends Component { - - static propTypes = { - timelineId: PropTypes.string.isRequired, - to: PropTypes.string.isRequired, - pinned: PropTypes.bool.isRequired, - onlyMedia: PropTypes.bool.isRequired, - onClick: PropTypes.func, - }; - - shouldComponentUpdate (nextProps) { - return ( - this.props.onlyMedia !== nextProps.onlyMedia || - this.props.pinned !== nextProps.pinned || - this.props.to !== nextProps.to || - this.props.timelineId !== nextProps.timelineId - ); - } - - handleClick = e => { - const { onClick } = this.props; - - if (typeof onClick === 'function') { - e.preventDefault(); - - onClick.call(this, e); - } - } - - render () { - const { timelineId, to, pinned, onlyMedia } = this.props; - - return ( -
- {pinned ? ( - - - - - - - - - ) : ( - - - - - )} -
- ); - } - -} diff --git a/app/javascript/mastodon/features/community_timeline/containers/column_settings_container.js b/app/javascript/mastodon/features/community_timeline/containers/column_settings_container.js index f3489b4095..405064c3fc 100644 --- a/app/javascript/mastodon/features/community_timeline/containers/column_settings_container.js +++ b/app/javascript/mastodon/features/community_timeline/containers/column_settings_container.js @@ -1,17 +1,28 @@ import { connect } from 'react-redux'; import ColumnSettings from '../components/column_settings'; import { changeSetting } from '../../../actions/settings'; +import { changeColumnParams } from '../../../actions/columns'; -const mapStateToProps = state => ({ - settings: state.getIn(['settings', 'community']), -}); +const mapStateToProps = (state, { columnId }) => { + const uuid = columnId; + const columns = state.getIn(['settings', 'columns']); + const index = columns.findIndex(c => c.get('uuid') === uuid); -const mapDispatchToProps = dispatch => ({ + return { + settings: (uuid && index >= 0) ? columns.get(index).get('params') : state.getIn(['settings', 'community']), + }; +}; - onChange (key, checked) { - dispatch(changeSetting(['community', ...key], checked)); - }, - -}); +const mapDispatchToProps = (dispatch, { columnId }) => { + return { + onChange (key, checked) { + if (columnId) { + dispatch(changeColumnParams(columnId, key, checked)); + } else { + dispatch(changeSetting(['community', ...key], checked)); + } + }, + }; +}; export default connect(mapStateToProps, mapDispatchToProps)(ColumnSettings); diff --git a/app/javascript/mastodon/features/community_timeline/index.js b/app/javascript/mastodon/features/community_timeline/index.js index d375edbd51..eb9ad97a2b 100644 --- a/app/javascript/mastodon/features/community_timeline/index.js +++ b/app/javascript/mastodon/features/community_timeline/index.js @@ -6,23 +6,33 @@ import StatusListContainer from '../ui/containers/status_list_container'; import Column from '../../components/column'; import ColumnHeader from '../../components/column_header'; import { expandCommunityTimeline } from '../../actions/timelines'; -import { addColumn, removeColumn, moveColumn, changeColumnParams } from '../../actions/columns'; +import { addColumn, removeColumn, moveColumn } from '../../actions/columns'; import ColumnSettingsContainer from './containers/column_settings_container'; -import SectionHeadline from './components/section_headline'; import { connectCommunityStream } from '../../actions/streaming'; const messages = defineMessages({ title: { id: 'column.community', defaultMessage: 'Local timeline' }, }); -const mapStateToProps = (state, { onlyMedia }) => ({ - hasUnread: state.getIn(['timelines', `community${onlyMedia ? ':media' : ''}`, 'unread']) > 0, -}); +const mapStateToProps = (state, { onlyMedia, columnId }) => { + const uuid = columnId; + const columns = state.getIn(['settings', 'columns']); + const index = columns.findIndex(c => c.get('uuid') === uuid); + + return { + hasUnread: state.getIn(['timelines', `community${onlyMedia ? ':media' : ''}`, 'unread']) > 0, + onlyMedia: (columnId && index >= 0) ? columns.get(index).getIn(['params', 'other', 'onlyMedia']) : state.getIn(['settings', 'community', 'other', 'onlyMedia']), + }; +}; @connect(mapStateToProps) @injectIntl export default class CommunityTimeline extends React.PureComponent { + static contextTypes = { + router: PropTypes.object, + }; + static defaultProps = { onlyMedia: false, }; @@ -89,27 +99,10 @@ export default class CommunityTimeline extends React.PureComponent { dispatch(expandCommunityTimeline({ maxId, onlyMedia })); } - handleHeadlineLinkClick = e => { - const { columnId, dispatch } = this.props; - const onlyMedia = /\/media$/.test(e.currentTarget.href); - - dispatch(changeColumnParams(columnId, { other: { onlyMedia } })); - } - render () { const { intl, hasUnread, columnId, multiColumn, onlyMedia } = this.props; const pinned = !!columnId; - const headline = ( - - ); - return ( - + + + +
+ +
+
+ ); + } + +} diff --git a/app/javascript/mastodon/features/direct_timeline/containers/column_settings_container.js b/app/javascript/mastodon/features/direct_timeline/containers/column_settings_container.js index 1833f69e5c..38054ce9eb 100644 --- a/app/javascript/mastodon/features/direct_timeline/containers/column_settings_container.js +++ b/app/javascript/mastodon/features/direct_timeline/containers/column_settings_container.js @@ -1,5 +1,5 @@ import { connect } from 'react-redux'; -import ColumnSettings from '../../community_timeline/components/column_settings'; +import ColumnSettings from '../components/column_settings'; import { changeSetting } from '../../../actions/settings'; const mapStateToProps = state => ({ diff --git a/app/javascript/mastodon/features/public_timeline/containers/column_settings_container.js b/app/javascript/mastodon/features/public_timeline/containers/column_settings_container.js index 203e1da926..c56caa59e7 100644 --- a/app/javascript/mastodon/features/public_timeline/containers/column_settings_container.js +++ b/app/javascript/mastodon/features/public_timeline/containers/column_settings_container.js @@ -1,17 +1,28 @@ import { connect } from 'react-redux'; import ColumnSettings from '../../community_timeline/components/column_settings'; import { changeSetting } from '../../../actions/settings'; +import { changeColumnParams } from '../../../actions/columns'; -const mapStateToProps = state => ({ - settings: state.getIn(['settings', 'public']), -}); +const mapStateToProps = (state, { columnId }) => { + const uuid = columnId; + const columns = state.getIn(['settings', 'columns']); + const index = columns.findIndex(c => c.get('uuid') === uuid); -const mapDispatchToProps = dispatch => ({ + return { + settings: (uuid && index >= 0) ? columns.get(index).get('params') : state.getIn(['settings', 'public']), + }; +}; - onChange (key, checked) { - dispatch(changeSetting(['public', ...key], checked)); - }, - -}); +const mapDispatchToProps = (dispatch, { columnId }) => { + return { + onChange (key, checked) { + if (columnId) { + dispatch(changeColumnParams(columnId, key, checked)); + } else { + dispatch(changeSetting(['public', ...key], checked)); + } + }, + }; +}; export default connect(mapStateToProps, mapDispatchToProps)(ColumnSettings); diff --git a/app/javascript/mastodon/features/public_timeline/index.js b/app/javascript/mastodon/features/public_timeline/index.js index 341af582ae..2d5bb3baf7 100644 --- a/app/javascript/mastodon/features/public_timeline/index.js +++ b/app/javascript/mastodon/features/public_timeline/index.js @@ -6,23 +6,33 @@ import StatusListContainer from '../ui/containers/status_list_container'; import Column from '../../components/column'; import ColumnHeader from '../../components/column_header'; import { expandPublicTimeline } from '../../actions/timelines'; -import { addColumn, removeColumn, moveColumn, changeColumnParams } from '../../actions/columns'; +import { addColumn, removeColumn, moveColumn } from '../../actions/columns'; import ColumnSettingsContainer from './containers/column_settings_container'; -import SectionHeadline from '../community_timeline/components/section_headline'; import { connectPublicStream } from '../../actions/streaming'; const messages = defineMessages({ title: { id: 'column.public', defaultMessage: 'Federated timeline' }, }); -const mapStateToProps = (state, { onlyMedia }) => ({ - hasUnread: state.getIn(['timelines', `public${onlyMedia ? ':media' : ''}`, 'unread']) > 0, -}); +const mapStateToProps = (state, { onlyMedia, columnId }) => { + const uuid = columnId; + const columns = state.getIn(['settings', 'columns']); + const index = columns.findIndex(c => c.get('uuid') === uuid); + + return { + hasUnread: state.getIn(['timelines', `public${onlyMedia ? ':media' : ''}`, 'unread']) > 0, + onlyMedia: (columnId && index >= 0) ? columns.get(index).getIn(['params', 'other', 'onlyMedia']) : state.getIn(['settings', 'public', 'other', 'onlyMedia']), + }; +}; @connect(mapStateToProps) @injectIntl export default class PublicTimeline extends React.PureComponent { + static contextTypes = { + router: PropTypes.object, + }; + static defaultProps = { onlyMedia: false, }; @@ -89,27 +99,17 @@ export default class PublicTimeline extends React.PureComponent { dispatch(expandPublicTimeline({ maxId, onlyMedia })); } - handleHeadlineLinkClick = e => { - const { columnId, dispatch } = this.props; - const onlyMedia = /\/media$/.test(e.currentTarget.href); - - dispatch(changeColumnParams(columnId, { other: { onlyMedia } })); + handleSettingChanged = (key, checked) => { + const { columnId } = this.props; + if (!columnId && key[0] === 'other' && key[1] === 'onlyMedia') { + this.context.router.history.replace(`/timelines/public${checked ? '/media' : ''}`); + } } render () { const { intl, columnId, hasUnread, multiColumn, onlyMedia } = this.props; const pinned = !!columnId; - const headline = ( - - ); - return ( - + { .set('saved', false); }; -const changeColumnParams = (state, uuid, params) => { +const changeColumnParams = (state, uuid, path, value) => { const columns = state.get('columns'); const index = columns.findIndex(item => item.get('uuid') === uuid); - const newColumns = columns.update(index, column => column.update('params', () => fromJS(params))); + const newColumns = columns.update(index, column => column.updateIn(['params', ...path], () => value)); return state .set('columns', newColumns) @@ -127,7 +127,7 @@ export default function settings(state = initialState, action) { case COLUMN_MOVE: return moveColumn(state, action.uuid, action.direction); case COLUMN_PARAMS_CHANGE: - return changeColumnParams(state, action.uuid, action.params); + return changeColumnParams(state, action.uuid, action.path, action.value); case EMOJI_USE: return updateFrequentEmojis(state, action.emoji); case SETTING_SAVE: diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index 42eebb05c3..0a75a64dd1 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -4806,8 +4806,6 @@ a.status-card { } } -.community-timeline__section-headline, -.public-timeline__section-headline, .account__section-headline { background: darken($ui-base-color, 4%); border-bottom: 1px solid lighten($ui-base-color, 8%); From 1cc775200eab449c90e1ebb463ee19ee76c2935b Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 15 Jun 2018 15:51:37 +0200 Subject: [PATCH 2/8] Add "find friends", "invite people", and more to getting started footer (#7803) - Find friends from Twitter (bridge) - Invite people (when invites enabled) - Security (change e-mail/password) - Developers (create OAuth apps/tokens) --- app/javascript/mastodon/features/getting_started/index.js | 6 +++++- app/javascript/mastodon/initial_state.js | 1 + app/serializers/initial_state_serializer.rb | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/javascript/mastodon/features/getting_started/index.js b/app/javascript/mastodon/features/getting_started/index.js index 115dfd2b97..0df2d8bbfe 100644 --- a/app/javascript/mastodon/features/getting_started/index.js +++ b/app/javascript/mastodon/features/getting_started/index.js @@ -7,7 +7,7 @@ import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePureComponent from 'react-immutable-pure-component'; -import { me } from '../../initial_state'; +import { me, invitesEnabled } from '../../initial_state'; import { fetchFollowRequests } from '../../actions/accounts'; import { List as ImmutableList } from 'immutable'; import { Link } from 'react-router-dom'; @@ -135,9 +135,13 @@ export default class GettingStarted extends ImmutablePureComponent {
    +
  • ·
  • + {invitesEnabled &&
  • ·
  • } {multiColumn &&
  • ·
  • } +
  • ·
  • ·
  • ·
  • +
  • ·
  • ·
diff --git a/app/javascript/mastodon/initial_state.js b/app/javascript/mastodon/initial_state.js index df310e7e13..807262fd7b 100644 --- a/app/javascript/mastodon/initial_state.js +++ b/app/javascript/mastodon/initial_state.js @@ -11,5 +11,6 @@ export const boostModal = getMeta('boost_modal'); export const deleteModal = getMeta('delete_modal'); export const me = getMeta('me'); export const searchEnabled = getMeta('search_enabled'); +export const invitesEnabled = getMeta('invites_enabled'); export default initialState; diff --git a/app/serializers/initial_state_serializer.rb b/app/serializers/initial_state_serializer.rb index 6c9fba2f5b..42d0e4bf32 100644 --- a/app/serializers/initial_state_serializer.rb +++ b/app/serializers/initial_state_serializer.rb @@ -14,6 +14,7 @@ class InitialStateSerializer < ActiveModel::Serializer domain: Rails.configuration.x.local_domain, admin: object.admin&.id&.to_s, search_enabled: Chewy.enabled?, + invites_enabled: Setting.min_invite_role == 'user', } if object.current_account From c3b3594305f4480b02177f4f90d134eb63c8f873 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 15 Jun 2018 15:51:51 +0200 Subject: [PATCH 3/8] Remove placeholder text for media-only toots (#7806) Ref: cfa9b6e13ab3c434f3901df6f614d0aa94a3d1ed This breaks compatibility with pre-2.3.0 Mastodon and older software, but at the time of writing the network is >80% above that version. Compatibility broken only for toots with no text. --- app/services/post_status_service.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index d072e581d5..a5a21c3592 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -22,7 +22,6 @@ class PostStatusService < BaseService media = validate_media!(options[:media_ids]) status = nil text = options.delete(:spoiler_text) if text.blank? && options[:spoiler_text].present? - text = '.' if text.blank? && media.present? ApplicationRecord.transaction do status = account.statuses.create!(text: text, From 33dd9bf36d7cb7c94f76520357879d1a913c4ccb Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 15 Jun 2018 18:00:03 +0200 Subject: [PATCH 4/8] Fix vertical alignment of navigation bar (#7807) --- app/javascript/styles/mastodon/components.scss | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index 0a75a64dd1..9ec25c5723 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -1494,6 +1494,7 @@ a.account__display-name { .navigation-bar { padding: 10px; display: flex; + align-items: center; flex-shrink: 0; cursor: default; color: $darker-text-color; @@ -1531,6 +1532,8 @@ a.account__display-name { .navigation-bar__profile { flex: 1 1 auto; margin-left: 8px; + line-height: 20px; + margin-top: -1px; overflow: hidden; } From ca85658975dd6c85fbe5cc725698fe3a34d1234e Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 15 Jun 2018 18:00:23 +0200 Subject: [PATCH 5/8] Add autofollow option to invites (#7805) * Add autofollow option to invites * Trigger CodeClimate rebuild --- .../auth/registrations_controller.rb | 7 ++- app/controllers/invites_controller.rb | 4 +- app/javascript/styles/mastodon/accounts.scss | 51 +++++++++++++++---- app/models/invite.rb | 1 + app/services/bootstrap_timeline_service.rb | 18 +++++-- app/views/auth/registrations/new.html.haml | 5 ++ app/views/authorize_follows/_card.html.haml | 14 ++++- app/views/invites/_form.html.haml | 3 ++ config/locales/en.yml | 1 + config/locales/simple_form.en.yml | 2 + ...0180615122121_add_autofollow_to_invites.rb | 17 +++++++ db/schema.rb | 3 +- 12 files changed, 108 insertions(+), 18 deletions(-) create mode 100644 db/migrate/20180615122121_add_autofollow_to_invites.rb diff --git a/app/controllers/auth/registrations_controller.rb b/app/controllers/auth/registrations_controller.rb index 417e2b63bd..c095411c12 100644 --- a/app/controllers/auth/registrations_controller.rb +++ b/app/controllers/auth/registrations_controller.rb @@ -3,6 +3,7 @@ class Auth::RegistrationsController < Devise::RegistrationsController layout :determine_layout + before_action :set_invite, only: [:new, :create] before_action :check_enabled_registrations, only: [:new, :create] before_action :configure_sign_up_params, only: [:create] before_action :set_sessions, only: [:edit, :update] @@ -51,7 +52,7 @@ class Auth::RegistrationsController < Devise::RegistrationsController end def allowed_registrations? - Setting.open_registrations || (invite_code.present? && Invite.find_by(code: invite_code)&.valid_for_use?) + Setting.open_registrations || @invite&.valid_for_use? end def invite_code @@ -68,6 +69,10 @@ class Auth::RegistrationsController < Devise::RegistrationsController @instance_presenter = InstancePresenter.new end + def set_invite + @invite = invite_code.present? ? Invite.find_by(code: invite_code) : nil + end + def determine_layout %w(edit update).include?(action_name) ? 'admin' : 'auth' end diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rb index 26ef99b7e0..5c30313f49 100644 --- a/app/controllers/invites_controller.rb +++ b/app/controllers/invites_controller.rb @@ -11,7 +11,7 @@ class InvitesController < ApplicationController authorize :invite, :create? @invites = invites - @invite = Invite.new(expires_in: 1.day.to_i) + @invite = Invite.new end def create @@ -42,6 +42,6 @@ class InvitesController < ApplicationController end def resource_params - params.require(:invite).permit(:max_uses, :expires_in) + params.require(:invite).permit(:max_uses, :expires_in, :autofollow) end end diff --git a/app/javascript/styles/mastodon/accounts.scss b/app/javascript/styles/mastodon/accounts.scss index 3ccce383b0..14dc5dd621 100644 --- a/app/javascript/styles/mastodon/accounts.scss +++ b/app/javascript/styles/mastodon/accounts.scss @@ -458,23 +458,31 @@ } .account-card { - padding: 14px 10px; - background: $simple-background-color; border-radius: 4px; text-align: left; box-shadow: 0 0 15px rgba($base-shadow-color, 0.2); + background: $simple-background-color; - .detailed-status__display-name { + &__header { + background-size: cover; + background-position: center center; + height: 90px; + border-radius: 4px 4px 0 0; + } + + & > .detailed-status__display-name { display: block; overflow: hidden; - margin-bottom: 15px; + display: flex; + align-items: center; + padding: 10px; &:last-child { margin-bottom: 0; } - & > div { - float: left; + & > div:first-child { + flex: 0 0 auto; margin-right: 10px; width: 48px; height: 48px; @@ -483,9 +491,11 @@ .avatar { display: block; border-radius: 4px; + margin: 0; } .display-name { + flex: 1 0 auto; display: block; max-width: 100%; overflow: hidden; @@ -493,6 +503,10 @@ text-overflow: ellipsis; cursor: default; + & > .detailed-status__display-name { + margin-bottom: 0; + } + strong { font-weight: 500; color: $ui-base-color; @@ -519,9 +533,28 @@ } } - .account__header__content { - font-size: 14px; - color: $inverted-text-color; + .counter { + box-sizing: border-box; + flex: 0 0 auto; + color: $light-text-color; + padding: 0 10px; + cursor: default; + text-align: center; + position: relative; + line-height: 24px; + + .counter-label { + font-size: 12px; + display: block; + text-transform: uppercase; + } + + .counter-number { + font-weight: 500; + font-size: 16px; + color: $inverted-text-color; + font-family: 'mastodon-font-display', sans-serif; + } } } diff --git a/app/models/invite.rb b/app/models/invite.rb index 2250e588e1..d0cc427c45 100644 --- a/app/models/invite.rb +++ b/app/models/invite.rb @@ -11,6 +11,7 @@ # uses :integer default(0), not null # created_at :datetime not null # updated_at :datetime not null +# autofollow :boolean default(FALSE), not null # class Invite < ApplicationRecord diff --git a/app/services/bootstrap_timeline_service.rb b/app/services/bootstrap_timeline_service.rb index c01e25824f..db2c83e5d1 100644 --- a/app/services/bootstrap_timeline_service.rb +++ b/app/services/bootstrap_timeline_service.rb @@ -2,13 +2,25 @@ class BootstrapTimelineService < BaseService def call(source_account) - bootstrap_timeline_accounts.each do |target_account| - FollowService.new.call(source_account, target_account) - end + @source_account = source_account + + autofollow_inviter! + autofollow_bootstrap_timeline_accounts! end private + def autofollow_inviter! + return unless @source_account&.user&.invite&.autofollow? + FollowService.new.call(@source_account, @source_account.user.invite.user.account) + end + + def autofollow_bootstrap_timeline_accounts! + bootstrap_timeline_accounts.each do |target_account| + FollowService.new.call(@source_account, target_account) + end + end + def bootstrap_timeline_accounts return @bootstrap_timeline_accounts if defined?(@bootstrap_timeline_accounts) diff --git a/app/views/auth/registrations/new.html.haml b/app/views/auth/registrations/new.html.haml index 2d4c0f5ac6..0fac8e10da 100644 --- a/app/views/auth/registrations/new.html.haml +++ b/app/views/auth/registrations/new.html.haml @@ -7,6 +7,11 @@ = simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| = render 'shared/error_messages', object: resource + - if @invite.present? && @invite.autofollow? + .fields-group{ style: 'margin-bottom: 30px' } + %p.hint{ style: 'text-align: center' }= t('invites.invited_by') + = render 'authorize_follows/card', account: @invite.user.account + = f.simple_fields_for :account do |ff| .input-with-append = ff.input :username, autofocus: true, placeholder: t('simple_form.labels.defaults.username'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.username'), :autocomplete => 'off' } diff --git a/app/views/authorize_follows/_card.html.haml b/app/views/authorize_follows/_card.html.haml index 9abcfd37e1..edc03131f4 100644 --- a/app/views/authorize_follows/_card.html.haml +++ b/app/views/authorize_follows/_card.html.haml @@ -1,4 +1,5 @@ .account-card + .account-card__header{ style: "background-image: url(#{account.header.url(:original)})" } .detailed-status__display-name %div = image_tag account.avatar.url(:original), alt: '', width: 48, height: 48, class: 'avatar' @@ -9,5 +10,14 @@ %strong.emojify= display_name(account, custom_emojify: true) %span @#{account.acct} - - if account.note? - .account__header__content.emojify= Formatter.instance.simplified_format(account) + .counter + %span.counter-number= number_to_human account.statuses_count, strip_insignificant_zeros: true + %span.counter-label= t('accounts.posts') + + .counter + %span.counter-number= number_to_human account.following_count, strip_insignificant_zeros: true + %span.counter-label= t('accounts.following') + + .counter + %span.counter-number= number_to_human account.followers_count, strip_insignificant_zeros: true + %span.counter-label= t('accounts.followers') diff --git a/app/views/invites/_form.html.haml b/app/views/invites/_form.html.haml index 3f0871f47f..42a107bb2c 100644 --- a/app/views/invites/_form.html.haml +++ b/app/views/invites/_form.html.haml @@ -5,5 +5,8 @@ = f.input :max_uses, wrapper: :with_label, collection: [1, 5, 10, 25, 50, 100], label_method: lambda { |num| I18n.t('invites.max_uses', count: num) }, prompt: I18n.t('invites.max_uses_prompt') = f.input :expires_in, wrapper: :with_label, collection: [30.minutes, 1.hour, 6.hours, 12.hours, 1.day, 1.week].map(&:to_i), label_method: lambda { |i| I18n.t("invites.expires_in.#{i}") }, prompt: I18n.t('invites.expires_in_prompt') + .fields-group + = f.input :autofollow, wrapper: :with_label + .actions = f.button :button, t('invites.generate'), type: :submit diff --git a/config/locales/en.yml b/config/locales/en.yml index d128f92f3d..46875d2ecb 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -514,6 +514,7 @@ en: '86400': 1 day expires_in_prompt: Never generate: Generate + invited_by: 'You were invited by:' max_uses: one: 1 use other: "%{count} uses" diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index 85597e9a78..247a792187 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -3,6 +3,7 @@ en: simple_form: hints: defaults: + autofollow: People who sign up through the invite will automatically follow you avatar: PNG, GIF or JPG. At most 2MB. Will be downscaled to 400x400px bot: This account mainly performs automated actions and might not be monitored digest: Only sent after a long period of inactivity and only if you have received any personal messages in your absence @@ -30,6 +31,7 @@ en: name: Label value: Content defaults: + autofollow: Invite to follow your account avatar: Avatar bot: This is a bot account confirm_new_password: Confirm new password diff --git a/db/migrate/20180615122121_add_autofollow_to_invites.rb b/db/migrate/20180615122121_add_autofollow_to_invites.rb new file mode 100644 index 0000000000..850b1d693e --- /dev/null +++ b/db/migrate/20180615122121_add_autofollow_to_invites.rb @@ -0,0 +1,17 @@ +require Rails.root.join('lib', 'mastodon', 'migration_helpers') + +class AddAutofollowToInvites < ActiveRecord::Migration[5.2] + include Mastodon::MigrationHelpers + + disable_ddl_transaction! + + def change + safety_assured do + add_column_with_default :invites, :autofollow, :bool, default: false, allow_null: false + end + end + + def down + remove_column :invites, :autofollow + end +end diff --git a/db/schema.rb b/db/schema.rb index 6564193a81..4c39de26a6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2018_06_09_104432) do +ActiveRecord::Schema.define(version: 2018_06_15_122121) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -219,6 +219,7 @@ ActiveRecord::Schema.define(version: 2018_06_09_104432) do t.integer "uses", default: 0, null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.boolean "autofollow", default: false, null: false t.index ["code"], name: "index_invites_on_code", unique: true t.index ["user_id"], name: "index_invites_on_user_id" end From 53f0452b70445831664431ef7720d8ec2d361656 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 15 Jun 2018 19:46:25 +0200 Subject: [PATCH 6/8] Remove rack-timeout (#7809) Timeout considered harmful due to leaving the app in a broken state, including unreaped database connections --- Gemfile | 1 - Gemfile.lock | 2 -- config/initializers/timeout.rb | 6 ------ 3 files changed, 9 deletions(-) delete mode 100644 config/initializers/timeout.rb diff --git a/Gemfile b/Gemfile index cab4c41399..7a6e1568d2 100644 --- a/Gemfile +++ b/Gemfile @@ -66,7 +66,6 @@ gem 'pundit', '~> 1.1' gem 'premailer-rails' gem 'rack-attack', '~> 5.2' gem 'rack-cors', '~> 1.0', require: 'rack/cors' -gem 'rack-timeout', '~> 0.4' gem 'rails-i18n', '~> 5.1' gem 'rails-settings-cached', '~> 0.6' gem 'redis', '~> 4.0', require: ['redis', 'redis/connection/hiredis'] diff --git a/Gemfile.lock b/Gemfile.lock index f7a377d457..fd4452f7d5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -425,7 +425,6 @@ GEM rack rack-test (1.0.0) rack (>= 1.0, < 3) - rack-timeout (0.4.2) rails (5.2.0) actioncable (= 5.2.0) actionmailer (= 5.2.0) @@ -726,7 +725,6 @@ DEPENDENCIES pundit (~> 1.1) rack-attack (~> 5.2) rack-cors (~> 1.0) - rack-timeout (~> 0.4) rails (~> 5.2.0) rails-controller-testing (~> 1.0) rails-i18n (~> 5.1) diff --git a/config/initializers/timeout.rb b/config/initializers/timeout.rb deleted file mode 100644 index de87fd906c..0000000000 --- a/config/initializers/timeout.rb +++ /dev/null @@ -1,6 +0,0 @@ -Rack::Timeout::Logger.disable -Rack::Timeout.service_timeout = false - -if Rails.env.production? - Rack::Timeout.service_timeout = 90 -end From 09147186b79f80cf3ef3aa8ba7e6e5e032faa255 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 15 Jun 2018 19:49:32 +0200 Subject: [PATCH 7/8] Fix regression where CW is focused on reply (#7811) --- .../mastodon/features/compose/components/compose_form.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/javascript/mastodon/features/compose/components/compose_form.js b/app/javascript/mastodon/features/compose/components/compose_form.js index 83f2f4d342..6eb01123e4 100644 --- a/app/javascript/mastodon/features/compose/components/compose_form.js +++ b/app/javascript/mastodon/features/compose/components/compose_form.js @@ -127,9 +127,7 @@ export default class ComposeForm extends ImmutablePureComponent { this.autosuggestTextarea.textarea.focus(); } else if(prevProps.is_submitting && !this.props.is_submitting) { this.autosuggestTextarea.textarea.focus(); - } - - if (this.props.spoiler !== prevProps.spoiler) { + } else if (this.props.spoiler !== prevProps.spoiler) { if (this.props.spoiler) { this.spoilerText.focus(); } else { From 0df91c7b1e05952ebbfc552915e995d55af0a403 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 15 Jun 2018 20:21:47 +0200 Subject: [PATCH 8/8] Add dat, dweb, ipfs, ipns, ssb, gopher protocols to URL extractor (#7810) * Add dat:// and gopher:// to URL extractor Fix #6072 * Fix comment indent * Add dweb, ipfs, ipns, ssb --- config/initializers/twitter_regex.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/twitter_regex.rb b/config/initializers/twitter_regex.rb index 7fa828300b..c227f92d3e 100644 --- a/config/initializers/twitter_regex.rb +++ b/config/initializers/twitter_regex.rb @@ -30,7 +30,7 @@ module Twitter ( # $1 total match (#{REGEXEN[:valid_url_preceding_chars]}) # $2 Preceeding chracter ( # $3 URL - (https?:\/\/)? # $4 Protocol (optional) + ((https?|dat|dweb|ipfs|ipns|ssb|gopher):\/\/)? # $4 Protocol (optional) (#{REGEXEN[:valid_domain]}) # $5 Domain(s) (?::(#{REGEXEN[:valid_port_number]}))? # $6 Port number (optional) (/#{REGEXEN[:valid_url_path]}*)? # $7 URL Path and anchor