Add table of contents to about page (#11885)
Move public domain blocks information to about page
This commit is contained in:
parent
e1066cd431
commit
d930eb88b6
10 changed files with 328 additions and 215 deletions
|
@ -3,9 +3,7 @@
|
|||
class AboutController < ApplicationController
|
||||
layout 'public'
|
||||
|
||||
before_action :require_open_federation!, only: [:show, :more, :blocks]
|
||||
before_action :check_blocklist_enabled, only: [:blocks]
|
||||
before_action :authenticate_user!, only: [:blocks], if: :blocklist_account_required?
|
||||
before_action :require_open_federation!, only: [:show, :more]
|
||||
before_action :set_body_classes, only: :show
|
||||
before_action :set_instance_presenter
|
||||
before_action :set_expires_in, only: [:show, :more, :terms]
|
||||
|
@ -16,15 +14,20 @@ class AboutController < ApplicationController
|
|||
|
||||
def more
|
||||
flash.now[:notice] = I18n.t('about.instance_actor_flash') if params[:instance_actor]
|
||||
|
||||
toc_generator = TOCGenerator.new(@instance_presenter.site_extended_description)
|
||||
|
||||
@contents = toc_generator.html
|
||||
@table_of_contents = toc_generator.toc
|
||||
@blocks = DomainBlock.with_user_facing_limitations.by_severity if display_blocks?
|
||||
end
|
||||
|
||||
def terms; end
|
||||
|
||||
def blocks
|
||||
@show_rationale = Setting.show_domain_blocks_rationale == 'all'
|
||||
@show_rationale |= Setting.show_domain_blocks_rationale == 'users' && !current_user.nil? && current_user.functional?
|
||||
@blocks = DomainBlock.with_user_facing_limitations.order('(CASE severity WHEN 0 THEN 1 WHEN 1 THEN 2 WHEN 2 THEN 0 END), reject_media, domain').to_a
|
||||
end
|
||||
helper_method :display_blocks?
|
||||
helper_method :display_blocks_rationale?
|
||||
helper_method :public_fetch_mode?
|
||||
helper_method :new_user
|
||||
|
||||
private
|
||||
|
||||
|
@ -32,28 +35,14 @@ class AboutController < ApplicationController
|
|||
not_found if whitelist_mode?
|
||||
end
|
||||
|
||||
def check_blocklist_enabled
|
||||
not_found if Setting.show_domain_blocks == 'disabled'
|
||||
def display_blocks?
|
||||
Setting.show_domain_blocks == 'all' || (Setting.show_domain_blocks == 'users' && user_signed_in?)
|
||||
end
|
||||
|
||||
def blocklist_account_required?
|
||||
Setting.show_domain_blocks == 'users'
|
||||
def display_blocks_rationale?
|
||||
Setting.show_domain_blocks_rationale == 'all' || (Setting.show_domain_blocks_rationale == 'users' && user_signed_in?)
|
||||
end
|
||||
|
||||
def block_severity_text(block)
|
||||
if block.severity == 'suspend'
|
||||
I18n.t('domain_blocks.suspension')
|
||||
else
|
||||
limitations = []
|
||||
limitations << I18n.t('domain_blocks.media_block') if block.reject_media?
|
||||
limitations << I18n.t('domain_blocks.silence') if block.severity == 'silence'
|
||||
limitations.join(', ')
|
||||
end
|
||||
end
|
||||
|
||||
helper_method :block_severity_text
|
||||
helper_method :public_fetch_mode?
|
||||
|
||||
def new_user
|
||||
User.new.tap do |user|
|
||||
user.build_account
|
||||
|
@ -61,8 +50,6 @@ class AboutController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
helper_method :new_user
|
||||
|
||||
def set_instance_presenter
|
||||
@instance_presenter = InstancePresenter.new
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue