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

[WIP] feat: search content and users #375

Open
wants to merge 35 commits into
base: main
Choose a base branch
from

Conversation

awietz
Copy link
Contributor

@awietz awietz commented Jul 8, 2024

This pull request add the option to search for questions and answers, in addition to users.

The home "Users" tab has been renamed to "Search".

The search result now contains users, questions and answers, matching the entered search query, using a LIKE statement.

Questions and answers are only searched, when the search query is at least 3 characters long. Otherwise, only users are searched.

Only the first 10 users are returned in the search result (like before).

Only the first 10 questions and answers are returned in the search result.

When nothing is entered in the search field, a set of famous users are displayed instead (just like before).

search-result

QUESTIONS

  • Right now only the answer to a question is clickable as a link. Shouldn't it be the entire content element in the search results (question and answer)?
  • The answer to a question changes the background on hover. Should that be changed, in the search results, so the entire element changes background color instead, as it's also the entire element that is clickable?
  • Each question offers a lot of functions (such as like, etc.). Should these also work / we available in the arch results?

TODO

  • Sanitise search input (leading and trailing whitespace, ``` and other parsed characters...)
  • When query starts with @, only search for users (maybe later in another PR)
  • Layout for search results (mainly questions)
  • Tests

@nunomaduro
Copy link
Member

It's looking great; share some screenshots when you can.

Copy link
Collaborator

@CamKem CamKem left a comment

Choose a reason for hiding this comment

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

Looks great so far!
I added a couple of suggestions you may like to look at.

resources/views/livewire/home/search.blade.php Outdated Show resolved Hide resolved
resources/views/livewire/home/search.blade.php Outdated Show resolved Hide resolved
* main: (111 commits)
  fix: add titles to buttons for accessibility screen readers and mobile use.
  Update CHANGELOG.md
  feat: Add dynamic title to app layout
  fix: update assertion message in UsersTest.php
  refactor: Remove unused comment method in Show component
  fix: Update link to question page in comment button
  fix: update title tag in head.blade.php
  fix: add wire:ignore.self to prevent Livewire from updating the parent div
  fix: order followers list by latest follower ID in Livewire test
  fix: order following list by latest follower ID in Livewire test
  docs: updates changelog
  fix: update followers query to order by latest follower ID
  fix: update followers query to order by latest follower ID
  fix: update followers query to order by latest follower ID
  fix: update icons following discussions on telegram.
  fix: change icons in the feed menu
  fix: remove the title from the app layout.
  fix: remove titles from the feeds
  Update CHANGELOG.md
  fix: handle condition where a file is selected & the input is opened & cancelled, triggering onchange event
  ...
* main: (51 commits)
  nah
  lazy
  Bump dependencies
  Shows parents
  refactor: Adjust show-more.js to include a buffer for maxHeight comparison
  typo
  refactor: Remove button from code elements if exist in copy-code.js
  refactor: Add lazy loading for images in copy-code.js
  Update CHANGELOG.md
  Update CHANGELOG.md
  refactor
  refactor: Remove storage prefix from avatar URLs in User model
  undo
  refactor: Update UserTest to use Gravatar email for avatar URLs in EditTest
  refactor: Update UserTest to use Storage::disk('public')->url() for avatar URLs
  refactor: Update UpdateUserAvatar job to handle file deletion on Windows OS
  refactor: Update User model's getAvatarUrlAttribute method to use null for avatar URLs
  refactor: Update avatar URLs in User model to remove unnecessary storage prefix
  refactor: Update User model's getAvatarUrlAttribute method to use Storage::disk('public')->url() for avatar URLs
  refactor: Remove unnecessary storage prefix in User model's purge method
  ...
@awietz
Copy link
Contributor Author

awietz commented Jul 14, 2024

I have a few questions listed above, I would like to get feedback on.
I guess when they are answered, the feature can be finished and I can write tests covering all the changes.

@awietz awietz requested a review from CamKem July 14, 2024 13:53
Copy link
Collaborator

@CamKem CamKem left a comment

Choose a reason for hiding this comment

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

Code looks really good. Just a name change of that blade file.

In terms of the styling, I'm not sure on the outline being present above the shared updates too... What do you guys think @MrPunyapal & @nunomaduro

Screenshot 2024-07-15 at 8 27 54 AM

Copy link
Collaborator

@CamKem CamKem Jul 14, 2024

Choose a reason for hiding this comment

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

I would name this component "user-card" - a more general name.

@awietz
Copy link
Contributor Author

awietz commented Jul 15, 2024

On the welcome page there is a users search field, teasing "Lots of interesting profiles".
That should probably remain unchanged, right?

Since the same component is used twice, there would be a little work left for me there.

@MrPunyapal
Copy link
Collaborator

As per Nuno I think default behaviour should be same and if someone searches it should bring Posts with users 🤔

* main: (43 commits)
  chore: updates changelog
  chore: fixes types
  chore: bumps dependencies
  Prevent navigating away
  Add title
  Use heroicon instead
  Move placeholder to view file
  fix: copying new lines from code
  Update CHANGELOG.md
  Replace more icons
  Replace more icons
  Replace icons with heroicons
  Adjust height and opacity
  Add line below parent
  Add question placeholder
  Remove phpstan-ignore-line
  wip
  Add corresponding model property
  Fix phpstan errors
  feat(code-copy): remove unused import
  ...

# Conflicts:
#	resources/views/livewire/home/users.blade.php
* main: (37 commits)
  Refactor link edit button in links index view
  Refactor link edit button in links index view
  chore: Update flash message wrapper z-index in show.blade.php
  removed edit icon SVG component
  Refactor link edit button in links index view
  Refactor: removed unwanted code from index
  Refactor link edit button in links index view
  feat: Add dispatch to open and close modal in link edit component
  fix modal link edit form notification z-index
  add link edit tests
  add refresh links/index
  add doc block to edit method
  fix conflict in index
  handle link edit dispatch
  add link edit dispatch in index
  add event to links edit form cancel button
  inject model instance in edit link method
  remove link model property
  remove DownloadUserAvatar event on link updated
  Add edit form cancel event
  ...
* main:
  Update CHANGELOG.md
  refactor: SQL readability
  refactor: typo
  refactor: improve trending questions feed sorting
  refactor: update trending score calculation in TrendingTest
  refactor: improve trending questions feed sorting
  Refactor TrendingQuestionsFeed builder method to improve sorting
  refactor: improve trending questions feed sorting
  feat: Improve trending questions feed by filtering out questions with less than 2 likes
  Update CHANGELOG.md
  Refactor TrendingQuestionsFeed to remove unused import
  feat: Update answer_created_at field in TrendingTest
  Refactor TrendingQuestionsFeed to order by trending score
  MySQL compatibility hint
  Refactor TrendingTest to order trending questions by trending score
  Refactor TrendingQuestionsFeed builder method to order by trending score
  Refactor flash message handling in show.blade.php
* main:
  Add support for twitter x.com urls

# Conflicts:
#	app/Livewire/Home/Search.php
* main: (73 commits)
  chore: adjusts tests
  fix: if other content, return empty string
  fix: add '...' when the image added doesn't exist
  feat(images): updated terms
  chore: adds missing test
  chore: forces documentation
  feat(images): add disk into the parser
  feat(images): add bail condition & remove multi-file select
  adds telegram route
  test(images): add unit test for MaxUploads rule
  test(images): parser removes images that done exist
  test(images): handle hydration issue when wire:navigate happens
  test(images): add test for each validation rule
  feat(images): fix validation & error message handling
  formatting
  chore: pint
  test(images): test for validation uploading non image file
  chore: pint
  feat(images): add test for VerifiedOnly rule
  feat(images): code refactor
  ...
awietz added 12 commits July 21, 2024 20:31
* main:
  Increases show more
  docs: updates changelog
  fix: allows displays upload image to verified accounts
  chore: style
* main: (139 commits)
  docs: changelog
  chore: fixes autoloading on tests
  feat(trending) make trending algo tunable; strftime() fix
  refactor: fix tests and added one more test
  refactor: add tests for two-factor authentication form
  refactor: adds todo from TrendingTest
  reverts
  docs: updates changelog
  More tests
  feat(trending): refactor
  make the trending algo tunable and add num. of comments to inputs
  feat: Improve UI for link actions in the links index view
  chore: updates changelog
  chore: bumps dependencies
  fixes trending
  feat: Add load more button to trending questions feed
  feat: Add lazy loading for trending questions feed images
  refactor: revert unique
  refactor: revert unique
  chore: Refactor two-factor authentication form layout
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants