Skip to content
This repository has been archived by the owner on Aug 2, 2020. It is now read-only.

Commit

Permalink
Add admin setting to enable blocks list in nodeinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
rhaamo committed Jul 12, 2019
1 parent 8422009 commit 28c71c5
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/controllers/admin/dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/admin/settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class SettingsController < BaseController
preview_sensitive_media
custom_css
profile_directory
nodeinfo_show_blocks
).freeze

BOOLEAN_SETTINGS = %w(
Expand All @@ -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(
Expand Down
4 changes: 4 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 4 additions & 0 deletions app/models/form/admin_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Form::AdminSettings
preview_sensitive_media
custom_css
profile_directory
nodeinfo_show_blocks
thumbnail
hero
mascot
Expand All @@ -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(
Expand Down Expand Up @@ -142,6 +144,8 @@ def typecast_value(key, value)
:custom_css=,
:profile_directory,
:profile_directory=,
:nodeinfo_show_blocks,
:nodeinfo_show_blocks=,
to: Setting
)
end
1 change: 1 addition & 0 deletions app/serializers/initial_state_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 3 additions & 2 deletions app/serializers/node_info_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,17 @@ def openRegistrations
end

def metadata
{
md = {
nodeName: instance_presenter.site_title,
nodeDescription: instance_presenter.site_description,
nodeTerms: instance_presenter.site_terms,
siteContactEmail: instance_presenter.site_contact_email,
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
Expand Down
3 changes: 3 additions & 0 deletions app/views/admin/settings/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 28c71c5

Please sign in to comment.