You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
962 B

  1. # frozen_string_literal: true
  2. class DirectoriesController < ApplicationController
  3. layout 'public'
  4. before_action :authenticate_user!, if: :whitelist_mode?
  5. before_action :require_enabled!
  6. before_action :set_instance_presenter
  7. before_action :set_tag, only: :show
  8. before_action :set_accounts
  9. skip_before_action :require_functional!
  10. def index
  11. render :index
  12. end
  13. def show
  14. render :index
  15. end
  16. private
  17. def require_enabled!
  18. return not_found unless Setting.profile_directory
  19. end
  20. def set_tag
  21. @tag = Tag.discoverable.find_normalized!(params[:id])
  22. end
  23. def set_accounts
  24. @accounts = Account.local.discoverable.by_recent_status.page(params[:page]).per(20).tap do |query|
  25. query.merge!(Account.tagged_with(@tag.id)) if @tag
  26. query.merge!(Account.not_excluded_by_account(current_account)) if current_account
  27. end
  28. end
  29. def set_instance_presenter
  30. @instance_presenter = InstancePresenter.new
  31. end
  32. end