Skip to content

Add hashtag filter to profiles#9755

Merged
Gargron merged 5 commits intomasterfrom
feature-profile-hashtags
Feb 4, 2019
Merged

Add hashtag filter to profiles#9755
Gargron merged 5 commits intomasterfrom
feature-profile-hashtags

Conversation

@Gargron
Copy link
Copy Markdown
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
@Gargron Gargron force-pushed the feature-profile-hashtags branch from 8d1c9d1 to 062b2c9 Compare January 8, 2019 10:41
@MirceaKitsune
Copy link
Copy Markdown

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 force-pushed the feature-profile-hashtags branch from 062b2c9 to 8fe2c37 Compare February 3, 2019 04:16
@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 force-pushed the feature-profile-hashtags branch from eb6672e to 425a876 Compare February 4, 2019 00:43
@Gargron Gargron removed the work in progress Not to be merged, currently being worked on label Feb 4, 2019
end

def hashtag_scope
Status.tagged_with(Tag.find_by(name: params[:tag].downcase)&.id)
Copy link
Copy Markdown
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.

Comment thread app/controllers/settings/featured_tags_controller.rb Outdated
Comment thread app/controllers/settings/featured_tags_controller.rb Outdated
Comment thread app/controllers/settings/featured_tags_controller.rb Outdated
Comment thread app/controllers/settings/featured_tags_controller.rb Outdated
Comment thread app/models/featured_tag.rb Outdated
Comment thread db/migrate/20190203180359_create_featured_tags.rb
@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.

3 participants