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

Put a search box on the site homepage which targets /-/search #2

Closed
simonw opened this issue Mar 8, 2020 · 9 comments
Closed

Put a search box on the site homepage which targets /-/search #2

simonw opened this issue Mar 8, 2020 · 9 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@simonw
Copy link
Owner

simonw commented Mar 8, 2020

This search box should only appear if there is at least one searchable table.

@simonw simonw added the enhancement New feature or request label Mar 8, 2020
@simonw
Copy link
Owner Author

simonw commented Mar 8, 2020

For the moment I can do this with a custom index.html template which over-rides the {% block description_source_license %} to first show a search box:

https://github.com/simonw/datasette/blob/7508477a96492caa1893c52411405656c50d30f9/datasette/templates/index.html

I'll also need to set a custom template variable that indicates if the datasette should be searchable or not.

I'm going to think about ways to make Datasette templates more customizable by plugins in a way that lets them co-operate easily with each other.

@simonw
Copy link
Owner Author

simonw commented Mar 8, 2020

simonw/datasette#690 is where I'm thinking about better plugin UI customization hooks.

simonw added a commit that referenced this issue Mar 8, 2020
@simonw
Copy link
Owner Author

simonw commented Mar 8, 2020

The custom index.html template isn't working and I'm not sure why.

I've deployed master to FARA to try it out there: https://fara.datasettes.com/-/search?q=manafort

@simonw simonw closed this as completed in cbc4505 Mar 8, 2020
@simonw
Copy link
Owner Author

simonw commented Mar 8, 2020

Test failed in CI even though it passes on my laptop: https://circleci.com/gh/simonw/datasette-search-all/4 - that search form isn't reliably appearing on the homepage.

@simonw simonw reopened this Mar 8, 2020
@simonw simonw added the bug Something isn't working label Mar 8, 2020
@simonw
Copy link
Owner Author

simonw commented Mar 8, 2020

Aha! The tests on my laptop fail against Datasette 0.37.1 (installed from pip) but pass against my own checkout of Datasette master (installed with pip install -e ~/.../datasette).

@simonw
Copy link
Owner Author

simonw commented Mar 8, 2020

... which is weird because none of the changes between 0.37.1 and current master have anything to do with template rendering: simonw/datasette@0.37.1...f7f31a

Maybe this is a bug that only exhibits itself against Datasette installed from PyPI as opposed to Datasette installed with pip install -e?

I'll try against a checkout of the 0.37.1 tag:

cd ~/.../datasette
git checkout 0.37.1
pip install -e .
cd ~/.../datasette-search-all
pytest

Tests fail with this. And datasette --version confirms this is datasette, version 0.37.1.

@simonw
Copy link
Owner Author

simonw commented Mar 8, 2020

Maybe it's related to this bug - simonw/datasette#689 - "template_context broken in >=0.35"

@simonw
Copy link
Owner Author

simonw commented Mar 8, 2020

Running pytest against the plugin against a pip install -e installation of the Datasette 0.35 branch also results in failed tests.

@simonw
Copy link
Owner Author

simonw commented Mar 8, 2020

... and now I'm back to a checkout of master and the tests are still failing. This seems to be a weird intermittent bug. I don't think it's really about the Datasette version at all. Need to investigate further.

Core problem appears to be that index.html is not being loaded reliably from the plugin template directory as it should be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant