From cdb101340a20183a82889f811d9311c370c855e5 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 29 Jun 2018 15:34:36 +0200 Subject: Keyword/phrase filtering (#7905) * Add keyword filtering GET|POST /api/v1/filters GET|PUT|DELETE /api/v1/filters/:id - Irreversible filters can drop toots from home or notifications - Other filters can hide toots through the client app - Filters use a phrase valid in particular contexts, expiration * Make sure expired filters don't get applied client-side * Add missing API methods * Remove "regex filter" from column settings * Add tests * Add test for FeedManager * Add CustomFilter test * Add UI for managing filters * Add streaming API event to allow syncing filters * Fix tests --- config/locales/en.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'config/locales/en.yml') diff --git a/config/locales/en.yml b/config/locales/en.yml index 01e5dd2f8..5cb81ebe9 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -474,6 +474,22 @@ en: follows: You follow mutes: You mute storage: Media storage + filters: + contexts: + home: Home timeline + notifications: Notifications + public: Public timelines + thread: Conversations + edit: + title: Edit filter + errors: + invalid_context: None or invalid context supplied + invalid_irreversible: Irreversible filtering only works with home or notifications context + index: + delete: Delete + title: Filters + new: + title: Add new filter followers: domain: Domain explanation_html: If you want to ensure the privacy of your statuses, you must be aware of who is following you. Your private statuses are delivered to all instances where you have followers. You may wish to review them, and remove followers if you do not trust your privacy to be respected by the staff or software of those instances. -- cgit From 2092d5c0ad099e8f60eb001ee0cd647fc759aefc Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 1 Jul 2018 04:12:34 +0200 Subject: Improve embeds (#7919) * Make embeds cacheable by reverse proxy * Make follow button on embeds open remote follow modal Instead of web+mastodon://, also, turn the button blue, and add a sign up prompt to the remote follow modal --- app/controllers/remote_follow_controller.rb | 1 + app/controllers/statuses_controller.rb | 5 +++++ app/javascript/packs/public.js | 2 +- app/javascript/styles/mastodon/accounts.scss | 1 + app/javascript/styles/mastodon/stream_entries.scss | 13 +++++++++---- app/views/remote_follow/new.html.haml | 2 ++ app/views/stream_entries/_detailed_status.html.haml | 2 +- config/locales/en.yml | 1 + 8 files changed, 21 insertions(+), 6 deletions(-) (limited to 'config/locales/en.yml') diff --git a/app/controllers/remote_follow_controller.rb b/app/controllers/remote_follow_controller.rb index 3b988e08d..cd61fd763 100644 --- a/app/controllers/remote_follow_controller.rb +++ b/app/controllers/remote_follow_controller.rb @@ -5,6 +5,7 @@ class RemoteFollowController < ApplicationController before_action :set_account before_action :gone, if: :suspended_account? + before_action :set_body_classes def new @remote_follow = RemoteFollow.new(session_params) diff --git a/app/controllers/statuses_controller.rb b/app/controllers/statuses_controller.rb index 645995c2a..b85341822 100644 --- a/app/controllers/statuses_controller.rb +++ b/app/controllers/statuses_controller.rb @@ -46,7 +46,12 @@ class StatusesController < ApplicationController end def embed + raise ActiveRecord::RecordNotFound if @status.hidden? + + skip_session! + expires_in 180, public: true response.headers['X-Frame-Options'] = 'ALLOWALL' + render 'stream_entries/embed', layout: 'embedded' end diff --git a/app/javascript/packs/public.js b/app/javascript/packs/public.js index d5e5b7fe0..cc2fed3f1 100644 --- a/app/javascript/packs/public.js +++ b/app/javascript/packs/public.js @@ -64,7 +64,7 @@ function main() { [].forEach.call(document.querySelectorAll('.logo-button'), (content) => { content.addEventListener('click', (e) => { e.preventDefault(); - window.open(e.target.href, 'mastodon-intent', 'width=400,height=400,resizable=no,menubar=no,status=no,scrollbars=yes'); + window.open(e.target.href, 'mastodon-intent', 'width=445,height=600,resizable=no,menubar=no,status=no,scrollbars=yes'); }); }); diff --git a/app/javascript/styles/mastodon/accounts.scss b/app/javascript/styles/mastodon/accounts.scss index 14dc5dd62..8033e6418 100644 --- a/app/javascript/styles/mastodon/accounts.scss +++ b/app/javascript/styles/mastodon/accounts.scss @@ -464,6 +464,7 @@ background: $simple-background-color; &__header { + background: $base-shadow-color; background-size: cover; background-position: center center; height: 90px; diff --git a/app/javascript/styles/mastodon/stream_entries.scss b/app/javascript/styles/mastodon/stream_entries.scss index 281cbaf83..369bb4479 100644 --- a/app/javascript/styles/mastodon/stream_entries.scss +++ b/app/javascript/styles/mastodon/stream_entries.scss @@ -324,6 +324,9 @@ .button.button-secondary.logo-button { flex: 0 auto; font-size: 14px; + background: $ui-highlight-color; + color: $primary-text-color; + border: 0; svg { width: 20px; @@ -332,19 +335,21 @@ margin-right: 5px; path:first-child { - fill: $ui-primary-color; + fill: $primary-text-color; } path:last-child { - fill: $simple-background-color; + fill: $ui-highlight-color; } } &:active, &:focus, &:hover { - svg path:first-child { - fill: lighten($ui-primary-color, 4%); + background: lighten($ui-highlight-color, 10%); + + svg path:last-child { + fill: lighten($ui-highlight-color, 10%); } } } diff --git a/app/views/remote_follow/new.html.haml b/app/views/remote_follow/new.html.haml index fc5c4da20..3273c318c 100644 --- a/app/views/remote_follow/new.html.haml +++ b/app/views/remote_follow/new.html.haml @@ -11,3 +11,5 @@ .actions = f.button :button, t('remote_follow.proceed'), type: :submit + + %p.hint.subtle-hint= t('remote_follow.no_account_html', sign_up_path: open_registrations? ? new_user_registration_path : 'https://joinmastodon.org') diff --git a/app/views/stream_entries/_detailed_status.html.haml b/app/views/stream_entries/_detailed_status.html.haml index c0f1e4f0f..de844818f 100644 --- a/app/views/stream_entries/_detailed_status.html.haml +++ b/app/views/stream_entries/_detailed_status.html.haml @@ -8,7 +8,7 @@ %span= acct(status.account) - if embedded_view? - = link_to "web+mastodon://follow?uri=#{status.account.local_username_and_domain}", class: 'button button-secondary logo-button', target: '_new' do + = link_to account_remote_follow_path(status.account), class: 'button button-secondary logo-button', target: '_new' do = render file: Rails.root.join('app', 'javascript', 'images', 'logo.svg') = t('accounts.follow') diff --git a/config/locales/en.yml b/config/locales/en.yml index 5cb81ebe9..8ab652045 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -615,6 +615,7 @@ en: remote_follow: acct: Enter your username@domain you want to follow from missing_resource: Could not find the required redirect URL for your account + no_account_html: Don't have an account? You can sign up here proceed: Proceed to follow prompt: 'You are going to follow:' remote_unfollow: -- cgit From f89c595ea070d2017adb868fb5e311e198d8e990 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 6 Jul 2018 02:15:56 +0200 Subject: Add admin setting to enable OG previews for sensitive media (#7962) --- app/controllers/admin/settings_controller.rb | 2 ++ app/models/form/admin_settings.rb | 2 ++ app/views/admin/settings/edit.html.haml | 6 ++++++ app/views/stream_entries/_og_image.html.haml | 2 +- config/locales/en.yml | 3 +++ config/settings.yml | 1 + 6 files changed, 15 insertions(+), 1 deletion(-) (limited to 'config/locales/en.yml') diff --git a/app/controllers/admin/settings_controller.rb b/app/controllers/admin/settings_controller.rb index ce3208209..75d00326c 100644 --- a/app/controllers/admin/settings_controller.rb +++ b/app/controllers/admin/settings_controller.rb @@ -21,6 +21,7 @@ module Admin activity_api_enabled peers_api_enabled show_known_fediverse_at_about_page + preview_sensitive_media ).freeze BOOLEAN_SETTINGS = %w( @@ -31,6 +32,7 @@ module Admin activity_api_enabled peers_api_enabled show_known_fediverse_at_about_page + preview_sensitive_media ).freeze UPLOAD_SETTINGS = %w( diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb index 32922e7f1..723480bdd 100644 --- a/app/models/form/admin_settings.rb +++ b/app/models/form/admin_settings.rb @@ -36,6 +36,8 @@ class Form::AdminSettings :peers_api_enabled=, :show_known_fediverse_at_about_page, :show_known_fediverse_at_about_page=, + :preview_sensitive_media, + :preview_sensitive_media=, to: Setting ) end diff --git a/app/views/admin/settings/edit.html.haml b/app/views/admin/settings/edit.html.haml index 08d05d738..f5c5deca8 100644 --- a/app/views/admin/settings/edit.html.haml +++ b/app/views/admin/settings/edit.html.haml @@ -2,6 +2,9 @@ = t('admin.settings.title') = simple_form_for @admin_settings, url: admin_settings_path, html: { method: :patch } do |f| + .actions.actions--top + = f.button :button, t('generic.save_changes'), type: :submit + .fields-group = f.input :site_title, placeholder: t('admin.settings.site_title') = f.input :site_description, wrapper: :with_block_label, as: :text, label: t('admin.settings.site_description.title'), hint: t('admin.settings.site_description.desc_html'), input_html: { rows: 8 } @@ -58,5 +61,8 @@ .fields-group = f.input :peers_api_enabled, as: :boolean, wrapper: :with_label, label: t('admin.settings.peers_api_enabled.title'), hint: t('admin.settings.peers_api_enabled.desc_html') + .fields-group + = f.input :preview_sensitive_media, as: :boolean, wrapper: :with_label, label: t('admin.settings.preview_sensitive_media.title'), hint: t('admin.settings.preview_sensitive_media.desc_html') + .actions = f.button :button, t('generic.save_changes'), type: :submit diff --git a/app/views/stream_entries/_og_image.html.haml b/app/views/stream_entries/_og_image.html.haml index 40530f567..e1b977da3 100644 --- a/app/views/stream_entries/_og_image.html.haml +++ b/app/views/stream_entries/_og_image.html.haml @@ -1,4 +1,4 @@ -- if activity.is_a?(Status) && activity.non_sensitive_with_media? +- if activity.is_a?(Status) && (activity.non_sensitive_with_media? || (activity.with_media? && Setting.preview_sensitive_media)) - player_card = false - activity.media_attachments.each do |media| - if media.image? diff --git a/config/locales/en.yml b/config/locales/en.yml index 8ab652045..a03b12a39 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -316,6 +316,9 @@ en: peers_api_enabled: desc_html: Domain names this instance has encountered in the fediverse title: Publish list of discovered instances + preview_sensitive_media: + desc_html: Link previews on other websites will display a thumbnail even if the media is marked as sensitive + title: Show sensitive media in OpenGraph previews registrations: closed_message: desc_html: Displayed on frontpage when registrations are closed. You can use HTML tags diff --git a/config/settings.yml b/config/settings.yml index 3581d10a2..190f6afcd 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -26,6 +26,7 @@ defaults: &defaults delete_modal: true auto_play_gif: false display_sensitive_media: false + preview_sensitive_media: false reduce_motion: false system_font_ui: false noindex: false -- cgit