WordPress / openverse-frontend

The gateway to the Openverse. Openverse is a search tool for CC-licensed and public domain content across the internet.
https://wordpress.org/openverse
MIT License
72 stars 64 forks source link

Redirect /search/ page to the Openverse homepage #596

Closed obulat closed 2 years ago

obulat commented 2 years ago

Problem

Currently, when you go to https://wordpress.org/openverse/search/, you see an image page that confusingly states that you got no results for " ", and a Load more button. The page is not linked from anywhere, so you can only get there if you type in the exact address.

Screen Shot 2022-01-12 at 6 43 32 PM

Description

It is better for user experience to redirect this page to the home page (https://wordpress.org/openverse/), so that even if the user gets to the /search/ address, they are not confused with incorrect text and impossible actions.

Alternatives

We could design a special page for this address, but considering that it is not linked from anywhere, it doesn't seem to be a good use of time and resources.

Implementation

zackkrida commented 2 years ago

Keep in mind that this will be the endpoint of the 'all' results view in the redesign. And also that we use this endpoint for the links on the 'sources' page, for example 'Animal Diversity' links to https://wordpress.org/openverse/search?source=animaldiversity

Perhaps when this endpoint is hit without any filters or a search term applied, we should redirect to the homepage.

kb-0311 commented 2 years ago

One possible solution I was thinking about is - because the address needs to be typed and it is not linked to anywhere, because the openverse search page here, does not accept null query

https://wordpress.org/openverse/ Screenshot (8671)

However. if you search for null query from the search bar instead of the address here , after searching for a non-null value first the page redirects to the previously filled non-null query value

https://wordpress.org/openverse/search/?q=aRandomTestToDemonstrateNullValues

Directly input a null value in the query from the address manually and you will see the same error

https://wordpress.org/openverse/search/?q=

So I guess the issue might be here - opensorce-frontend/src/store/search.js here the null value query is not defined-

    // Ensure that q filter always comes first
    const params = { q: state.query.q.trim() }
    // Handle mature filter separately
    const filterKeys = Object.keys(state.query).filter(
      (key) => !['q', 'mature'].includes(key)
    )
    filterKeys.forEach((key) => {
      if (state.query[key].length) {
        params[key] = state.query[key]
      }
    })
    if (state.query.mature === true) {
      params.mature = true
    }
    return params
  },

So maybe if I define a route for null query we can solve this problem in a more creative way maybe set the query to 'I like to test routes' if it is null. or something like this

kb-0311 commented 2 years ago

I am not sure . how would we redirect the search route with null query to the home page though? if that is the solution you want to implement.

As in I am unable to find the files where this URL change can be made

sarayourfriend commented 2 years ago

@kb-0311 I think you'd need to use the redirect function present on the nuxt context passed to asyncData to redirect to the homepage when /search/ is reached with no query params: https://nuxtjs.org/docs/concepts/context-helpers#redirecting-users--accessing-the-store