]> cat aescling's git repositories - mastodon.git/blob - app/controllers/about_controller.rb
Add table of contents to about page (#11885)
[mastodon.git] / app / controllers / about_controller.rb
1 # frozen_string_literal: true
2
3 class AboutController < ApplicationController
4 layout 'public'
5
6 before_action :require_open_federation!, only: [:show, :more]
7 before_action :set_body_classes, only: :show
8 before_action :set_instance_presenter
9 before_action :set_expires_in, only: [:show, :more, :terms]
10
11 skip_before_action :require_functional!, only: [:more, :terms]
12
13 def show; end
14
15 def more
16 flash.now[:notice] = I18n.t('about.instance_actor_flash') if params[:instance_actor]
17
18 toc_generator = TOCGenerator.new(@instance_presenter.site_extended_description)
19
20 @contents = toc_generator.html
21 @table_of_contents = toc_generator.toc
22 @blocks = DomainBlock.with_user_facing_limitations.by_severity if display_blocks?
23 end
24
25 def terms; end
26
27 helper_method :display_blocks?
28 helper_method :display_blocks_rationale?
29 helper_method :public_fetch_mode?
30 helper_method :new_user
31
32 private
33
34 def require_open_federation!
35 not_found if whitelist_mode?
36 end
37
38 def display_blocks?
39 Setting.show_domain_blocks == 'all' || (Setting.show_domain_blocks == 'users' && user_signed_in?)
40 end
41
42 def display_blocks_rationale?
43 Setting.show_domain_blocks_rationale == 'all' || (Setting.show_domain_blocks_rationale == 'users' && user_signed_in?)
44 end
45
46 def new_user
47 User.new.tap do |user|
48 user.build_account
49 user.build_invite_request
50 end
51 end
52
53 def set_instance_presenter
54 @instance_presenter = InstancePresenter.new
55 end
56
57 def set_body_classes
58 @hide_navbar = true
59 end
60
61 def set_expires_in
62 expires_in 0, public: true
63 end
64 end
This page took 0.097047 seconds and 5 git commands to generate.