✨ Add Firefox search engine support #46

Open
ossfx43d8146f wants to merge 1 commit from ossfx43d8146f/v2-web:feat/43-opensearch-query-search into master
First-time contributor

Closes #43

Problem

Firefox and other compliant browsers could not install the site as a search engine because there was no OpenSearch description or search-engine autodiscovery link.

The application also had no shareable search URL state: it ignored query parameters on startup and did not update the address bar after submitting a search. External browser search therefore could not open the site directly with results.

Root cause

  • The repository did not contain an OpenSearch XML document, and src/index.html did not expose <link rel="search"> autodiscovery.
  • The initial search input value in AppHeader.vue was always an empty string.
  • App.vue did not parse the URL during startup and its search method only updated local component state before opening the SSE API stream.

Solution

  • Read the initial query on startup from q, with query accepted as a compatibility fallback, and canonicalize the address bar to q.
  • Automatically run the initial search when a supported query parameter is present.
  • Pass the initial query into the search input so the form, address bar and results stay in sync.
  • Update the URL with history.replaceState after search submission, avoiding extra history entries and without adding a router dependency.
  • Add src/public/opensearch.xml, which Vite copies to the site root, and reference it from src/index.html.
  • Point the OpenSearch URL template to https://playsearch.kaki87.net/?q={searchTerms} and include the Firefox moz:SearchForm.

URL contract

  • https://playsearch.kaki87.net/?q=firefox opens the page and immediately searches for firefox.
  • Existing links using ?query=firefox also run the search and are normalized to ?q=firefox.
  • Visits without a supported query parameter keep the existing empty initial state and do not call the search API.

Files changed

  • src/components/App.vue: parse initial query, synchronize URL state, and trigger startup search.
  • src/components/AppHeader.vue: initialize the input from the route-derived query.
  • src/index.html: expose the OpenSearch description to browsers.
  • src/public/opensearch.xml: define the browser search plugin and Firefox search form.

Verification

  • yarn install --frozen-lockfile --ignore-scripts: success; dependencies already up to date. Existing peer/dependency warnings were unchanged.
  • yarn build: success; 121 modules transformed. The only warnings were the existing browser externalization notices for launchdarkly-eventsource Node built-ins.
  • git diff --check upstream/master...HEAD: passed with no whitespace errors.
  • Parsed both src/public/opensearch.xml and dist/opensearch.xml as XML and verified the search template and Firefox search form.
  • Browser smoke test served the final local production build from dist and intercepted the production SSE endpoint in the browser with deterministic data:
    • /?q=firefox populated the input, requested query=firefox, rendered the result, preserved the URL, and exposed the OpenSearch link.
    • Submitting browser requested query=browser and updated both the input and URL to ?q=browser.
    • /?query=legacy-query requested legacy-query and normalized the URL to ?q=legacy-query.
    • Intercepted API queries were exactly firefox, browser, and legacy-query.
    • No page errors or unhandled promise rejections were observed.

The project has no automated test npm script, so the production build plus the browser/SSE smoke test were used as the local equivalent.

Compatibility and risk

  • Frontend-only change; no API payload or result data structure changes.
  • No new npm dependency.
  • URL query behavior is additive; normal visits without query parameters remain unchanged.
  • replaceState updates the current history entry instead of creating a redirect or additional history entry.
Closes #43 ## Problem Firefox and other compliant browsers could not install the site as a search engine because there was no OpenSearch description or search-engine autodiscovery link. The application also had no shareable search URL state: it ignored query parameters on startup and did not update the address bar after submitting a search. External browser search therefore could not open the site directly with results. ## Root cause - The repository did not contain an OpenSearch XML document, and `src/index.html` did not expose `<link rel="search">` autodiscovery. - The initial search input value in `AppHeader.vue` was always an empty string. - `App.vue` did not parse the URL during startup and its search method only updated local component state before opening the SSE API stream. ## Solution - Read the initial query on startup from `q`, with `query` accepted as a compatibility fallback, and canonicalize the address bar to `q`. - Automatically run the initial search when a supported query parameter is present. - Pass the initial query into the search input so the form, address bar and results stay in sync. - Update the URL with `history.replaceState` after search submission, avoiding extra history entries and without adding a router dependency. - Add `src/public/opensearch.xml`, which Vite copies to the site root, and reference it from `src/index.html`. - Point the OpenSearch URL template to `https://playsearch.kaki87.net/?q={searchTerms}` and include the Firefox `moz:SearchForm`. ## URL contract - `https://playsearch.kaki87.net/?q=firefox` opens the page and immediately searches for `firefox`. - Existing links using `?query=firefox` also run the search and are normalized to `?q=firefox`. - Visits without a supported query parameter keep the existing empty initial state and do not call the search API. ## Files changed - `src/components/App.vue`: parse initial query, synchronize URL state, and trigger startup search. - `src/components/AppHeader.vue`: initialize the input from the route-derived query. - `src/index.html`: expose the OpenSearch description to browsers. - `src/public/opensearch.xml`: define the browser search plugin and Firefox search form. ## Verification - `yarn install --frozen-lockfile --ignore-scripts`: success; dependencies already up to date. Existing peer/dependency warnings were unchanged. - `yarn build`: success; 121 modules transformed. The only warnings were the existing browser externalization notices for `launchdarkly-eventsource` Node built-ins. - `git diff --check upstream/master...HEAD`: passed with no whitespace errors. - Parsed both `src/public/opensearch.xml` and `dist/opensearch.xml` as XML and verified the search template and Firefox search form. - Browser smoke test served the final local production build from `dist` and intercepted the production SSE endpoint in the browser with deterministic data: - `/?q=firefox` populated the input, requested `query=firefox`, rendered the result, preserved the URL, and exposed the OpenSearch link. - Submitting `browser` requested `query=browser` and updated both the input and URL to `?q=browser`. - `/?query=legacy-query` requested `legacy-query` and normalized the URL to `?q=legacy-query`. - Intercepted API queries were exactly `firefox`, `browser`, and `legacy-query`. - No page errors or unhandled promise rejections were observed. The project has no automated `test` npm script, so the production build plus the browser/SSE smoke test were used as the local equivalent. ## Compatibility and risk - Frontend-only change; no API payload or result data structure changes. - No new npm dependency. - URL query behavior is additive; normal visits without query parameters remain unchanged. - `replaceState` updates the current history entry instead of creating a redirect or additional history entry.
ossfx43d8146f added 1 commit 2026-11-20 01:28:22 +01:00
Closes #43

- read the initial search query from q, with query as a compatibility fallback
- start that search on page load and keep q in the URL after submit
- expose an OpenSearch description so Firefox and compatible browsers can install the site as a search engine
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'feat/43-opensearch-query-search:ossfx43d8146f-feat/43-opensearch-query-search'
git checkout 'ossfx43d8146f-feat/43-opensearch-query-search'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git checkout 'master'
git merge --no-ff 'ossfx43d8146f-feat/43-opensearch-query-search'
git checkout 'ossfx43d8146f-feat/43-opensearch-query-search'
git rebase 'master'
git checkout 'master'
git merge --ff-only 'ossfx43d8146f-feat/43-opensearch-query-search'
git checkout 'ossfx43d8146f-feat/43-opensearch-query-search'
git rebase 'master'
git checkout 'master'
git merge --no-ff 'ossfx43d8146f-feat/43-opensearch-query-search'
git checkout 'master'
git merge --squash 'ossfx43d8146f-feat/43-opensearch-query-search'
git checkout 'master'
git merge --ff-only 'ossfx43d8146f-feat/43-opensearch-query-search'
git checkout 'master'
git merge 'ossfx43d8146f-feat/43-opensearch-query-search'
git push origin 'master'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: playsearch.kaki87.net/v2-web#46
No description provided.