about summary refs log tree commit diff
path: root/app/controllers/accounts_controller.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-02-04 04:25:59 +0100
committerGitHub <noreply@github.com>2019-02-04 04:25:59 +0100
commit364f2ff9aa2b4bf601d68a12bce758aeb5530467 (patch)
tree6e47b26ef9148d3b88dd9748460d8cf51beac748 /app/controllers/accounts_controller.rb
parentd14c276e58f0f223b0e4889d342a948c961081b2 (diff)
Add featured hashtags to profiles (#9755)
* Add hashtag filter to profiles

GET /@:username/tagged/:hashtag
GET /api/v1/accounts/:id/statuses?tagged=:hashtag

* Display featured hashtags on public profile

* Use separate model for featured tags

* Update featured hashtag counters on-write

* Limit featured tags to 10
Diffstat (limited to 'app/controllers/accounts_controller.rb')
-rw-r--r--app/controllers/accounts_controller.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb
index f788a9078..6e3a23073 100644
--- a/app/controllers/accounts_controller.rb
+++ b/app/controllers/accounts_controller.rb
@@ -57,6 +57,7 @@ class AccountsController < ApplicationController
 
   def filtered_statuses
     default_statuses.tap do |statuses|
+      statuses.merge!(hashtag_scope)    if tag_requested?
       statuses.merge!(only_media_scope) if media_requested?
       statuses.merge!(no_replies_scope) unless replies_requested?
     end
@@ -78,12 +79,15 @@ class AccountsController < ApplicationController
     Status.without_replies
   end
 
+  def hashtag_scope
+    Status.tagged_with(Tag.find_by(name: params[:tag].downcase)&.id)
+  end
+
   def set_account
     @account = Account.find_local!(params[:username])
   end
 
   def older_url
-    ::Rails.logger.info("older: max_id #{@statuses.last.id}, url #{pagination_url(max_id: @statuses.last.id)}")
     pagination_url(max_id: @statuses.last.id)
   end
 
@@ -92,7 +96,9 @@ class AccountsController < ApplicationController
   end
 
   def pagination_url(max_id: nil, min_id: nil)
-    if media_requested?
+    if tag_requested?
+      short_account_tag_url(@account, params[:tag], max_id: max_id, min_id: min_id)
+    elsif media_requested?
       short_account_media_url(@account, max_id: max_id, min_id: min_id)
     elsif replies_requested?
       short_account_with_replies_url(@account, max_id: max_id, min_id: min_id)
@@ -109,6 +115,10 @@ class AccountsController < ApplicationController
     request.path.ends_with?('/with_replies')
   end
 
+  def tag_requested?
+    request.path.ends_with?("/tagged/#{params[:tag]}")
+  end
+
   def filtered_status_page(params)
     if params[:min_id].present?
       filtered_statuses.paginate_by_min_id(PAGE_SIZE, params[:min_id]).reverse