From 28c71c502ca2a573dffc8d17bc1bfab064c9f388 Mon Sep 17 00:00:00 2001 From: Dashie Date: Sat, 13 Jul 2019 01:26:40 +0200 Subject: [PATCH] Add admin setting to enable blocks list in nodeinfo --- app/controllers/admin/dashboard_controller.rb | 1 + app/controllers/admin/settings_controller.rb | 2 ++ app/helpers/application_helper.rb | 4 ++++ app/models/form/admin_settings.rb | 4 ++++ app/serializers/initial_state_serializer.rb | 1 + app/serializers/node_info_serializer.rb | 5 +++-- app/views/admin/settings/edit.html.haml | 3 +++ config/locales/en.yml | 3 +++ config/settings.yml | 1 + 9 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb index 8a6f250c9..37971196c 100644 --- a/app/controllers/admin/dashboard_controller.rb +++ b/app/controllers/admin/dashboard_controller.rb @@ -32,6 +32,7 @@ def index @trending_hashtags = TrendingTags.get(7) @profile_directory = Setting.profile_directory @timeline_preview = Setting.timeline_preview + @nodeinfo_show_blocks = Setting.nodeinfo_show_blocks end private diff --git a/app/controllers/admin/settings_controller.rb b/app/controllers/admin/settings_controller.rb index d6f506011..1f7528c5d 100644 --- a/app/controllers/admin/settings_controller.rb +++ b/app/controllers/admin/settings_controller.rb @@ -29,6 +29,7 @@ class SettingsController < BaseController preview_sensitive_media custom_css profile_directory + nodeinfo_show_blocks ).freeze BOOLEAN_SETTINGS = %w( @@ -41,6 +42,7 @@ class SettingsController < BaseController show_known_fediverse_at_about_page preview_sensitive_media profile_directory + nodeinfo_show_blocks ).freeze UPLOAD_SETTINGS = %w( diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 779e8febb..e2ed753ca 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -31,6 +31,10 @@ def closed_registrations? Setting.registrations_mode == 'none' end + def nodeinfo_show_blocks + Setting.nodeinfo_show_blocks + end + def available_sign_up_path if closed_registrations? 'https://joinmastodon.org/#getting-started' diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb index b258f9ee3..eac1db267 100644 --- a/app/models/form/admin_settings.rb +++ b/app/models/form/admin_settings.rb @@ -27,6 +27,7 @@ class Form::AdminSettings preview_sensitive_media custom_css profile_directory + nodeinfo_show_blocks thumbnail hero mascot @@ -41,6 +42,7 @@ class Form::AdminSettings show_known_fediverse_at_about_page preview_sensitive_media profile_directory + nodeinfo_show_blocks ).freeze UPLOAD_KEYS = %i( @@ -142,6 +144,8 @@ def typecast_value(key, value) :custom_css=, :profile_directory, :profile_directory=, + :nodeinfo_show_blocks, + :nodeinfo_show_blocks=, to: Setting ) end diff --git a/app/serializers/initial_state_serializer.rb b/app/serializers/initial_state_serializer.rb index 97c5670c1..58339ae4c 100644 --- a/app/serializers/initial_state_serializer.rb +++ b/app/serializers/initial_state_serializer.rb @@ -20,6 +20,7 @@ def meta invites_enabled: Setting.min_invite_role == 'user', mascot: instance_presenter.mascot&.file&.url, profile_directory: Setting.profile_directory, + nodeinfo_show_blocks: Setting.nodeinfo_show_blocks, max_toot_chars: instance_presenter.max_toot_chars, max_bio_chars: instance_presenter.max_bio_chars } diff --git a/app/serializers/node_info_serializer.rb b/app/serializers/node_info_serializer.rb index 56f8820f6..3537eb0be 100644 --- a/app/serializers/node_info_serializer.rb +++ b/app/serializers/node_info_serializer.rb @@ -46,7 +46,7 @@ def openRegistrations end def metadata - { + md = { nodeName: instance_presenter.site_title, nodeDescription: instance_presenter.site_description, nodeTerms: instance_presenter.site_terms, @@ -54,8 +54,9 @@ def metadata domain_count: instance_presenter.domain_count, features: features, invitesEnabled: Setting.min_invite_role != 'admin', - federation: federation, } + md[:federation] = federation if Setting.nodeinfo_show_blocks + md end def features diff --git a/app/views/admin/settings/edit.html.haml b/app/views/admin/settings/edit.html.haml index b5dd5e3c4..b5cbd12de 100644 --- a/app/views/admin/settings/edit.html.haml +++ b/app/views/admin/settings/edit.html.haml @@ -72,6 +72,9 @@ .fields-group = f.input :profile_directory, as: :boolean, wrapper: :with_label, label: t('admin.settings.profile_directory.title'), hint: t('admin.settings.profile_directory.desc_html') + .fields-group + = f.input :nodeinfo_show_blocks, as: :boolean, wrapper: :with_label, label: t('admin.settings.nodeinfo_show_blocks.title'), hint: t('admin.settings.nodeinfo_show_blocks.desc_html') + %hr.spacer/ .fields-group diff --git a/config/locales/en.yml b/config/locales/en.yml index bfd098f52..cfb1d853c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -420,6 +420,9 @@ en: profile_directory: desc_html: Allow users to be discoverable title: Enable profile directory + nodeinfo_show_blocks: + desc_html: List instance suspends, silence and rejects in nodeinfo + title: Enable showing blocks in nodeinfo 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 19dd3c328..8f97066db 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -13,6 +13,7 @@ defaults: &defaults max_bio_chars: 500 max_toot_chars: 500 profile_directory: true + nodeinfo_show_blocks: false closed_registrations_message: '' open_deletion: true min_invite_role: 'admin'