Files
compiler-explorer/views
Matt Godbolt (bot acct) 0cd84e0c3a Add OpenSearch shortcut for shortlinks (ce <id> in the address bar) (#8836)
## What

Adds
[OpenSearch](https://developer.mozilla.org/en-US/docs/Web/XML/Guides/OpenSearch)
support so browsers can register a `ce` keyword. Once registered, typing
`ce <shortlink>` in the address bar redirects to `/z/<shortlink>`.

## How

- **`views/opensearch.pug`** — an OpenSearch 1.1 description document.
- **`/search.xml` route** (`lib/app/server-config.ts`) — mirrors the
existing `/sitemap.xml` route; serves the doc with `Content-Type:
application/opensearchdescription+xml`.
- **`views/meta.pug`** — advertises it via `<link rel="search">` on the
main page (omitted on embed pages, where OpenSearch discovery doesn't
apply).

The search URL template (`…/z/{searchTerms}`) is built from the request
(`{protocol}://{host}{httpRoot}`, the same pattern as
`lib/storage/base.ts`), and the favicon uses the env-resolved
`staticRoot`/`faviconFilename`, so it's correct across
prod/beta/staging/local.

## Activation note

This is opt-in *discovery*, not automatic activation — browsers register
the engine after visiting the site, and the user typically activates the
`ce` keyword once (Chrome: Settings → Search engines → Site search;
Firefox surfaces it in the address bar). Chrome's auto-discovery is also
gated on a secure context, so this is best validated on an HTTPS
environment (e.g. staging/beta) rather than a plain-HTTP dev box.

## Testing

Verified against a local instance:
- `GET /search.xml` → `200`, correct content-type, well-formed XML,
`{searchTerms}` placeholder preserved, `<Url template>` absolute and
host-derived.
- `<link rel="search">` present on `/`, absent on `/e`.
- favicon URL resolves.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: mattgodbolt-molty <mattgodbolt-molty@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 12:01:51 +01:00
..
2025-10-14 13:51:16 +02:00
2019-09-06 19:39:31 -04:00
2022-11-13 10:35:39 -06:00