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

Enable search via URL hash, and update browser history when searching #1

Merged
merged 1 commit into from
Jul 10, 2024

Conversation

orrc
Copy link
Contributor

@orrc orrc commented Jul 9, 2024

Hi there!

As a long-term user of the Beolingus dictionary, I was sad to learn today that it has been taken offline.

However, I was happy to find that they recommended this simple, modern and speedy open source project as a replacement. Thank you!

I have always accessed Beolingus via a browser search shortcut (e.g. https://dict.tu-chemnitz.de/dings.cgi?…&query=%s). But with this web app, I noticed that it's not possible to pass in the search term via the URL, so I can't create a similar shortcut.

Therefore I added the ability to specify a search term via URL hash (e.g. https://example.com/#q=beispiel) — specifically using a URL hash rather than a query parameter, so that the search term doesn't get sent to the server hosting this webapp.

Furthermore, I update the URL hash when the input field changes, so you can follow your browser history of searched words. To make that history and navigation a bit nicer, the search term is also now appended to the page title.

Hopefully this seems useful, and you're open to PRs!
If so, I could also add a note about this functionality on the index page to help users. Though it should also become clear that the URL updates when users start entering search terms.

Screenshot:
image

…rch.

This lets you link directly to a URL like `example.com/#q=beispiel` and
the search will occur automatically.

If you update the search value, this will be reflected in the URL, and
an entry pushed onto the browser history stack, enabling you to navigate
back and forth between searches.

To improve browser navigation and history, the search term is also now
appended to the page title.
@haukex haukex merged commit 276b379 into haukex:main Jul 10, 2024
@haukex
Copy link
Owner

haukex commented Jul 10, 2024

Very nice, thank you very much! I added a small tweak in f622bc7 .

@orrc
Copy link
Contributor Author

orrc commented Jul 10, 2024

Amazing, thanks very much! ❤️

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.

2 participants