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

Support default filters #129

Closed
ericholscher opened this issue Feb 8, 2023 · 0 comments · Fixed by #132
Closed

Support default filters #129

ericholscher opened this issue Feb 8, 2023 · 0 comments · Fixed by #132
Assignees

Comments

@ericholscher
Copy link
Member

It would be very useful to have the ability to have a default search query that users get when they open. This would be configurable at the integration point for the extension, perhaps adding a config option:

rtd_sphinx_search_default_filters = 'subprojects:docs'

The use case here is:

  • I am a project on RTD that has subprojects
  • We want users to be able to search across all the subprojects easily
  • When they launch search, it should already have subprojects:<slug> prepended to the search in some fashion
@ericholscher ericholscher moved this to In progress in 📍Roadmap Feb 28, 2023
@ericholscher ericholscher moved this from In progress to Planned in 📍Roadmap Feb 28, 2023
@stsewd stsewd mentioned this issue Mar 9, 2023
@ericholscher ericholscher moved this from Planned to In progress in 📍Roadmap Mar 14, 2023
@stsewd stsewd moved this from In progress to Needs review in 📍Roadmap Mar 15, 2023
stsewd added a commit that referenced this issue Mar 27, 2023
- Added 2 new options: rtd_sphinx_search_default_filter and rtd_sphinx_search_filters.
- The options are passed as a JSON object to be read by our JS code.
- The default filter defaults to the current project and version (extracted from the RTD env vars)
- Filters are implemented as check boxes, we only support one filter at a time (when a filter is selected, we uncheck all others)

How to test locally:

- Run your local version of RTD
- To allow cross site requests, add `|/api/v3/search` at https://github.com/readthedocs/readthedocs.org/blob/b574f4b0dad34ccba8595cee72246d3473f8a2e5/readthedocs/settings/base.py#L769-L781
- Change the `rtd_dummy_data.json` file
  - `'proxied_api_host': 'http://devthedocs.org'`
  -  Set the project and version to a project that you have locally
- Change the value of `rtd_sphinx_search_default_filter = "project:superproject/latest"` to the slug of a project you have locally
- Build the docs:

```
cd docs
make clean html
```

- Open the _build/index.html file.

### showcase

[showcase.webm](https://user-images.githubusercontent.com/4975310/225148123-7811d477-3a91-4eea-b9fb-b8cb1cbf0d6a.webm)


Closes #129
Closes #130
Closes #131
@github-project-automation github-project-automation bot moved this from Needs review to Done in 📍Roadmap Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants