Add profile directory to web UI (#11688)
* Add profile directory to web UI * Add a line of bio to the directory
This commit is contained in:
parent
7802ebd5f3
commit
cb447b28c4
25 changed files with 715 additions and 159 deletions
30
app/controllers/api/v1/directories_controller.rb
Normal file
30
app/controllers/api/v1/directories_controller.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::DirectoriesController < Api::BaseController
|
||||
before_action :require_enabled!
|
||||
before_action :set_accounts
|
||||
|
||||
def show
|
||||
render json: @accounts, each_serializer: REST::AccountSerializer
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def require_enabled!
|
||||
return not_found unless Setting.profile_directory
|
||||
end
|
||||
|
||||
def set_accounts
|
||||
@accounts = accounts_scope.offset(params[:offset]).limit(limit_param(DEFAULT_ACCOUNTS_LIMIT))
|
||||
end
|
||||
|
||||
def accounts_scope
|
||||
Account.discoverable.tap do |scope|
|
||||
scope.merge!(Account.local) if truthy_param?(:local)
|
||||
scope.merge!(Account.by_recent_status) if params[:order].blank? || params[:order] == 'active'
|
||||
scope.merge!(Account.order(id: :desc)) if params[:order] == 'new'
|
||||
scope.merge!(Account.not_excluded_by_account(current_account)) if current_account
|
||||
scope.merge!(Account.not_domain_blocked_by_account(current_account)) if current_account && !truthy_param?(:local)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -7,7 +7,6 @@ class DirectoriesController < ApplicationController
|
|||
before_action :require_enabled!
|
||||
before_action :set_instance_presenter
|
||||
before_action :set_tag, only: :show
|
||||
before_action :set_tags
|
||||
before_action :set_accounts
|
||||
|
||||
def index
|
||||
|
@ -28,13 +27,10 @@ class DirectoriesController < ApplicationController
|
|||
@tag = Tag.discoverable.find_normalized!(params[:id])
|
||||
end
|
||||
|
||||
def set_tags
|
||||
@tags = Tag.discoverable.limit(30).reject { |tag| tag.cached_sample_accounts.empty? }
|
||||
end
|
||||
|
||||
def set_accounts
|
||||
@accounts = Account.discoverable.by_recent_status.page(params[:page]).per(40).tap do |query|
|
||||
@accounts = Account.local.discoverable.by_recent_status.page(params[:page]).per(15).tap do |query|
|
||||
query.merge!(Account.tagged_with(@tag.id)) if @tag
|
||||
query.merge!(Account.not_excluded_by_account(current_account)) if current_account
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue