This is an automated email from the ASF dual-hosted git repository.
tballison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git
The following commit(s) were added to refs/heads/main by this push:
new 7478ffd2df TIKA-4743 improve search and navigation on site (#2845)
7478ffd2df is described below
commit 7478ffd2df31c240a39829b20c769e141026aed8
Author: Tim Allison <[email protected]>
AuthorDate: Fri May 29 14:00:29 2026 -0400
TIKA-4743 improve search and navigation on site (#2845)
---
.../release-guides/release-artifacts.adoc | 2 +-
docs/publish-docs.sh | 43 +++++++-
docs/supplemental-ui/css/search.css | 82 --------------
docs/supplemental-ui/js/search.js | 119 ---------------------
docs/supplemental-ui/partials/footer-scripts.hbs | 1 -
docs/supplemental-ui/partials/head-scripts.hbs | 1 -
docs/supplemental-ui/partials/header-content.hbs | 17 ++-
docs/supplemental-ui/partials/toolbar.hbs | 4 +-
8 files changed, 50 insertions(+), 219 deletions(-)
diff --git
a/docs/modules/ROOT/pages/maintainers/release-guides/release-artifacts.adoc
b/docs/modules/ROOT/pages/maintainers/release-guides/release-artifacts.adoc
index 8059875491..073757fed8 100644
--- a/docs/modules/ROOT/pages/maintainers/release-guides/release-artifacts.adoc
+++ b/docs/modules/ROOT/pages/maintainers/release-guides/release-artifacts.adoc
@@ -230,4 +230,4 @@ The `release-tika-server` job builds from
`tika-server-standard-<v>.zip`
* xref:maintainers/release-guides/tika.adoc[Releasing Apache Tika]
* xref:maintainers/release-guides/docker.adoc[Releasing Tika Docker Images]
-* xref:maintainers/release-guides/site-updates.adoc[Updating the Website After
a Release]
+* xref:maintainers/site.adoc[Updating the Website After a Release]
diff --git a/docs/publish-docs.sh b/docs/publish-docs.sh
index fcbed4e995..e7e353506c 100755
--- a/docs/publish-docs.sh
+++ b/docs/publish-docs.sh
@@ -28,6 +28,31 @@ set -euo pipefail
cd "$(dirname "$0")"
PUBLISH_DIR="${1:?usage: publish-docs.sh <tika-site-publish-dir>}"
+
+# Guard the 'rm -rf' below: the publish dir must already exist (it's a
+# tika-site checkout, not something we create) and not be a dangerously
+# short/root path that a typo could expand to.
+if [[ ! -d "${PUBLISH_DIR}" ]]; then
+ echo "PUBLISH_DIR '${PUBLISH_DIR}' is not an existing directory." >&2
+ echo "Point it at a tika-site 'publish/' checkout." >&2
+ exit 1
+fi
+PUBLISH_DIR="$(cd "${PUBLISH_DIR}" && pwd -P)"
+if [[ "${#PUBLISH_DIR}" -lt 4 || "${PUBLISH_DIR}" != *"/"* ]]; then
+ echo "Refusing to operate on suspiciously short PUBLISH_DIR
'${PUBLISH_DIR}'." >&2
+ exit 1
+fi
+# Confirm this looks like a tika-site 'publish/' dir: the documented argument
+# is always <tika-site-checkout>/publish, and the downstream 'svn add' step
+# hardcodes that name for the things written here (publish/docs, publish/_,
+# publish/search-index.js). Refusing a non-'publish' basename catches a
+# wrong-but-valid checkout before we 'rm -rf' inside it.
+if [[ "$(basename "${PUBLISH_DIR}")" != "publish" ]]; then
+ echo "PUBLISH_DIR '${PUBLISH_DIR}' does not look like a tika-site publish
dir" >&2
+ echo "(expected its name to be 'publish'). Refusing to modify it." >&2
+ exit 1
+fi
+
DOCS_DIR="${PUBLISH_DIR}/docs"
if [[ ! -d target/site ]]; then
@@ -40,12 +65,24 @@ mkdir -p "${DOCS_DIR}"
# Strip the 'tika/' component dir prefix so URLs are /docs/X.Y.Z/...
cp -r target/site/tika/* "${DOCS_DIR}/"
-# UI assets one level above docs/, since HTML uses ../../_/ relative paths
-cp -r target/site/_/ "${PUBLISH_DIR}/_/"
+# UI assets one level above docs/, since HTML uses ../../_/ relative paths.
+# Replace wholesale: cp -r into an existing directory nests source as a
+# subdirectory (publish/_/_/), so remove first to keep the layout flat.
+# Refuse if '_' is a symlink: 'rm -rf _/' would follow it and wipe the
+# target's contents, and the cp below needs a real directory here anyway.
+if [[ -L "${PUBLISH_DIR}/_" ]]; then
+ echo "Refusing to remove '${PUBLISH_DIR}/_': it is a symlink, not a
directory." >&2
+ exit 1
+fi
+rm -rf "${PUBLISH_DIR}/_"
+cp -r target/site/_ "${PUBLISH_DIR}/_"
# Fix the root redirect and sitemap to match the flattened layout
sed 's|tika/||g' target/site/index.html > "${DOCS_DIR}/index.html"
sed 's|/docs/tika/|/docs/|g' target/site/sitemap.xml >
"${DOCS_DIR}/sitemap.xml"
cp target/site/404.html "${DOCS_DIR}/"
-cp target/site/search-index.js "${DOCS_DIR}/"
+# Lunr index lives next to _/ (one level above docs/), since HTML uses
../../search-index.js.
+# Remove the stale copy from its old publish/docs/ location left by earlier
runs.
+rm -f "${DOCS_DIR}/search-index.js"
+cp target/site/search-index.js "${PUBLISH_DIR}/"
echo "Published to: ${DOCS_DIR}/"
diff --git a/docs/supplemental-ui/css/search.css
b/docs/supplemental-ui/css/search.css
deleted file mode 100644
index 5fac6cf03b..0000000000
--- a/docs/supplemental-ui/css/search.css
+++ /dev/null
@@ -1,82 +0,0 @@
-.navbar .search {
- position: relative;
- margin-right: 0.5rem;
-}
-
-#search-input {
- border: 1px solid #dbdbdb;
- border-radius: 4px;
- padding: 0.375rem 0.625rem;
- font-size: 0.875rem;
- width: 200px;
- background: #fff;
-}
-
-#search-input:focus {
- border-color: #3273dc;
- outline: none;
- box-shadow: 0 0 0 0.125em rgba(50, 115, 220, 0.25);
-}
-
-#search-results {
- display: none;
- position: absolute;
- top: 100%;
- right: 0;
- background: white;
- border: 1px solid #dbdbdb;
- border-radius: 4px;
- max-height: 400px;
- overflow-y: auto;
- width: 350px;
- z-index: 1000;
- box-shadow: 0 4px 6px rgba(0,0,0,0.1);
- margin-top: 0.25rem;
-}
-
-.search-result-item {
- padding: 0.75rem 1rem;
- border-bottom: 1px solid #f0f0f0;
-}
-
-.search-result-item:last-child {
- border-bottom: none;
-}
-
-.search-result-item:hover {
- background: #f5f5f5;
-}
-
-.search-result-item a {
- color: #363636;
- text-decoration: none;
- display: block;
-}
-
-.search-result-item .title {
- font-weight: 600;
- margin-bottom: 0.25rem;
-}
-
-.search-result-item .text {
- font-size: 0.8125rem;
- color: #666;
- line-height: 1.4;
-}
-
-/* Footer styles */
-.footer {
- background: #363636;
- color: #b5b5b5;
- padding: 1.5rem;
- text-align: center;
- font-size: 0.875rem;
-}
-
-.footer p {
- margin: 0.25rem 0;
-}
-
-.footer a {
- color: #fff;
-}
diff --git a/docs/supplemental-ui/js/search.js
b/docs/supplemental-ui/js/search.js
deleted file mode 100644
index 00af02312d..0000000000
--- a/docs/supplemental-ui/js/search.js
+++ /dev/null
@@ -1,119 +0,0 @@
-/* Search functionality for Antora with Lunr */
-(function () {
- 'use strict'
-
- var defined = function (val) {
- return typeof val !== 'undefined'
- }
-
- var searchInput = document.getElementById('search-input')
- var searchResults = document.getElementById('search-results')
-
- if (!searchInput || !searchResults) return
-
- var index = null
- var store = null
- var indexLoaded = false
-
- // Determine the base path for the search index
- var siteRootPath = document.body.dataset.siteRootPath || ''
- var indexPath = siteRootPath + '/search-index.js'
-
- // Load the search index
- var script = document.createElement('script')
- script.src = indexPath
- script.onload = function () {
- if (typeof antoraSearch !== 'undefined' && defined(antoraSearch.index) &&
defined(antoraSearch.store)) {
- index = lunr.Index.load(antoraSearch.index)
- store = antoraSearch.store
- indexLoaded = true
- }
- }
- document.head.appendChild(script)
-
- // Load Lunr if not already loaded
- if (typeof lunr === 'undefined') {
- var lunrScript = document.createElement('script')
- lunrScript.src = 'https://unpkg.com/[email protected]/lunr.min.js'
- document.head.appendChild(lunrScript)
- }
-
- searchInput.addEventListener('input', debounce(search, 200))
- searchInput.addEventListener('focus', function () {
- if (this.value.length > 1) search()
- })
-
- document.addEventListener('click', function (e) {
- if (!e.target.closest('.search')) {
- searchResults.innerHTML = ''
- searchResults.style.display = 'none'
- }
- })
-
- function search () {
- var query = searchInput.value.trim()
-
- if (query.length < 2) {
- searchResults.innerHTML = ''
- searchResults.style.display = 'none'
- return
- }
-
- if (!indexLoaded) {
- searchResults.innerHTML = '<div class="search-result-item">Loading
search index...</div>'
- searchResults.style.display = 'block'
- return
- }
-
- var results = []
- try {
- results = index.search(query)
- } catch (e) {
- // Try wildcard search if exact search fails
- try {
- results = index.search(query + '*')
- } catch (e2) {
- results = []
- }
- }
-
- if (results.length === 0) {
- searchResults.innerHTML = '<div class="search-result-item">No results
found</div>'
- searchResults.style.display = 'block'
- return
- }
-
- var html = results.slice(0, 10).map(function (result) {
- var doc = store[result.ref]
- if (!doc) return ''
- var title = doc.title || 'Untitled'
- var text = doc.text || ''
- if (text.length > 150) text = text.substring(0, 150) + '...'
- return '<div class="search-result-item"><a href="' + doc.url + '">' +
- '<div class="title">' + escapeHtml(title) + '</div>' +
- '<div class="text">' + escapeHtml(text) + '</div>' +
- '</a></div>'
- }).join('')
-
- searchResults.innerHTML = html
- searchResults.style.display = 'block'
- }
-
- function debounce (fn, delay) {
- var timeout
- return function () {
- var context = this
- var args = arguments
- clearTimeout(timeout)
- timeout = setTimeout(function () {
- fn.apply(context, args)
- }, delay)
- }
- }
-
- function escapeHtml (text) {
- var div = document.createElement('div')
- div.textContent = text
- return div.innerHTML
- }
-})()
diff --git a/docs/supplemental-ui/partials/footer-scripts.hbs
b/docs/supplemental-ui/partials/footer-scripts.hbs
deleted file mode 100644
index 9aa19101f1..0000000000
--- a/docs/supplemental-ui/partials/footer-scripts.hbs
+++ /dev/null
@@ -1 +0,0 @@
-<script src="{{{uiRootPath}}}/js/search.js"></script>
diff --git a/docs/supplemental-ui/partials/head-scripts.hbs
b/docs/supplemental-ui/partials/head-scripts.hbs
deleted file mode 100644
index d5752e8e11..0000000000
--- a/docs/supplemental-ui/partials/head-scripts.hbs
+++ /dev/null
@@ -1 +0,0 @@
-<link rel="stylesheet" href="{{{uiRootPath}}}/css/search.css">
diff --git a/docs/supplemental-ui/partials/header-content.hbs
b/docs/supplemental-ui/partials/header-content.hbs
index 88488dfbe9..940d6b760a 100644
--- a/docs/supplemental-ui/partials/header-content.hbs
+++ b/docs/supplemental-ui/partials/header-content.hbs
@@ -1,11 +1,16 @@
<header class="header">
- <nav class="navbar">
+ <nav class="navbar" aria-label="Main">
<div class="navbar-brand">
<a class="navbar-item" href="{{or siteRootPath (or site.url '/')}}">
<img src="{{{uiRootPath}}}/img/ASF_Tika-colour.svg" alt="Apache Tika"
style="height: 2rem; margin-right: 0.5rem; background: white; padding: 2px 4px;
border-radius: 3px;">
{{site.title}}
</a>
- <button class="navbar-burger" aria-label="Toggle navigation"
data-target="topbar-nav">
+ <div class="navbar-item search hide-for-print" role="search">
+ <div id="search-field" class="field">
+ <input id="search-input" type="search" aria-label="Search the docs"
placeholder="Search the docs"{{#if page.home}} autofocus{{/if}}>
+ </div>
+ </div>
+ <button class="navbar-burger" aria-controls="topbar-nav"
aria-expanded="false" aria-label="Toggle main menu" data-target="topbar-nav">
<span></span>
<span></span>
<span></span>
@@ -13,14 +18,6 @@
</div>
<div id="topbar-nav" class="navbar-menu">
<div class="navbar-end">
- <div class="navbar-item search">
- <div class="field has-addons">
- <p class="control">
- <input id="search-input" class="input" type="text"
placeholder="Search docs...">
- </p>
- </div>
- <div id="search-results"></div>
- </div>
<a class="navbar-item" href="https://tika.apache.org">Apache Tika</a>
<a class="navbar-item" href="https://github.com/apache/tika">GitHub</a>
</div>
diff --git a/docs/supplemental-ui/partials/toolbar.hbs
b/docs/supplemental-ui/partials/toolbar.hbs
index c3fc82b802..0c6b8a9cc3 100644
--- a/docs/supplemental-ui/partials/toolbar.hbs
+++ b/docs/supplemental-ui/partials/toolbar.hbs
@@ -1,3 +1,3 @@
-<div class="toolbar" role="navigation">
-<button class="nav-toggle"></button>
+<div class="toolbar" role="navigation" aria-label="Page tools">
+<button class="nav-toggle" aria-label="Toggle navigation"></button>
</div>