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.

43 lines
1.2 KiB

  1. class AccountsController < ApplicationController
  2. layout 'public'
  3. before_action :set_account
  4. before_action :set_link_headers
  5. def show
  6. respond_to do |format|
  7. format.html do
  8. @statuses = @account.statuses.order('id desc').with_includes.with_counters.paginate(page: params[:page], per_page: 10)
  9. end
  10. format.atom do
  11. @entries = @account.stream_entries.order('id desc').with_includes.paginate_by_max_id(20, params[:max_id] || nil)
  12. end
  13. end
  14. end
  15. def followers
  16. @followers = @account.followers.order('follows.created_at desc').paginate(page: params[:page], per_page: 6)
  17. end
  18. def following
  19. @following = @account.following.order('follows.created_at desc').paginate(page: params[:page], per_page: 6)
  20. end
  21. private
  22. def set_account
  23. @account = Account.find_local!(params[:username])
  24. end
  25. def set_link_headers
  26. response.headers['Link'] = LinkHeader.new([
  27. [webfinger_account_url, [['rel', 'lrdd'], ['type', 'application/xrd+xml']]],
  28. [account_url(@account, format: 'atom'), [['rel', 'alternate'], ['type', 'application/atom+xml']]]
  29. ])
  30. end
  31. def webfinger_account_url
  32. webfinger_url(resource: "acct:#{@account.acct}@#{Rails.configuration.x.local_domain}")
  33. end
  34. end