Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hashtag filter to profiles #9755

Merged
merged 5 commits into from
Feb 4, 2019
Merged

Add hashtag filter to profiles #9755

merged 5 commits into from
Feb 4, 2019

Conversation

Gargron
Copy link
Member

@Gargron Gargron commented Jan 8, 2019

screenshot_2019-02-03 admin admin localhost 3000

Allow browsing a profile by a specific hashtag. Useful for artists.

Public profile change: GET /@:username/tagged/:hashtag
REST API change: GET /api/v1/accounts/:id/statuses?tagged=:hashtag


TODO:

  • Public profile page route
  • REST API
  • List of browserable hashtags in sidebar on public profile

@Gargron Gargron added api REST API, Streaming API, Web Push API work in progress Not to be merged, currently being worked on labels Jan 8, 2019
@MirceaKitsune
Copy link

Will this also work for the search bar? For instance you could use #sometag@username@domain to only list posts containing that tag from the user in cause. Additionally just #sometag@domain would be a very welcome syntax, allowing you to search for a tag on a specific instance only.

@Gargron Gargron added the ui Front-end, design label Feb 3, 2019
GET /@:username/tagged/:hashtag
GET /api/v1/accounts/:id/statuses?tagged=:hashtag
@Gargron Gargron force-pushed the feature-profile-hashtags branch 3 times, most recently from 2b72637 to eb6672e Compare February 4, 2019 00:41
@Gargron Gargron removed the work in progress Not to be merged, currently being worked on label Feb 4, 2019
@@ -78,12 +79,15 @@ def no_replies_scope
Status.without_replies
end

def hashtag_scope
Status.tagged_with(Tag.find_by(name: params[:tag].downcase)&.id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what the project's preference is, but I've been seeing a lot of people move from #[] to #fetch() since it tells the reader a lot more about the intent. For example, in this method we EXPECT :tag to be a key, thus params.fetch(:tag), but if we didn't params.fetch(:tag, nil) and of course we get all the niceness of #fetch's other default api: fetch(:key) {dynamicvalue}.

Either way, seems like what you want here could also be expressed as: Status.tagged_with(Tag.where(name: params[:tag]).pluck(:id).first), though if tagged_with allows an array you can just drop .first.

@Gargron Gargron merged commit 364f2ff into master Feb 4, 2019
@Gargron Gargron deleted the feature-profile-hashtags branch February 4, 2019 03:26
hiyuki2578 pushed a commit to ProjectMyosotis/mastodon that referenced this pull request Oct 2, 2019
* 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
messenjahofchrist pushed a commit to Origin-Creative/mastodon that referenced this pull request Jul 30, 2021
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api REST API, Streaming API, Web Push API ui Front-end, design
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants