public_timelines_controller.rb 842 B

12345678910111213141516171819202122232425262728293031323334
  1. # frozen_string_literal: true
  2. class PublicTimelinesController < ApplicationController
  3. layout 'public'
  4. before_action :check_enabled
  5. before_action :set_body_classes
  6. before_action :set_instance_presenter
  7. def show
  8. respond_to do |format|
  9. format.html do
  10. @initial_state_json = ActiveModelSerializers::SerializableResource.new(
  11. InitialStatePresenter.new(settings: { known_fediverse: Setting.show_known_fediverse_at_about_page }, token: current_session&.token),
  12. serializer: InitialStateSerializer
  13. ).to_json
  14. end
  15. end
  16. end
  17. private
  18. def check_enabled
  19. raise ActiveRecord::RecordNotFound unless Setting.timeline_preview
  20. end
  21. def set_body_classes
  22. @body_classes = 'with-modals'
  23. end
  24. def set_instance_presenter
  25. @instance_presenter = InstancePresenter.new
  26. end
  27. end