Skip to content

Commit 7478ffd

Browse files
authored
TIKA-4743 improve search and navigation on site (#2845)
1 parent 499e703 commit 7478ffd

8 files changed

Lines changed: 50 additions & 219 deletions

File tree

docs/modules/ROOT/pages/maintainers/release-guides/release-artifacts.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,4 +230,4 @@ The `release-tika-server` job builds from `tika-server-standard-<v>.zip`
230230

231231
* xref:maintainers/release-guides/tika.adoc[Releasing Apache Tika]
232232
* xref:maintainers/release-guides/docker.adoc[Releasing Tika Docker Images]
233-
* xref:maintainers/release-guides/site-updates.adoc[Updating the Website After a Release]
233+
* xref:maintainers/site.adoc[Updating the Website After a Release]

docs/publish-docs.sh

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,31 @@ set -euo pipefail
2828
cd "$(dirname "$0")"
2929

3030
PUBLISH_DIR="${1:?usage: publish-docs.sh <tika-site-publish-dir>}"
31+
32+
# Guard the 'rm -rf' below: the publish dir must already exist (it's a
33+
# tika-site checkout, not something we create) and not be a dangerously
34+
# short/root path that a typo could expand to.
35+
if [[ ! -d "${PUBLISH_DIR}" ]]; then
36+
echo "PUBLISH_DIR '${PUBLISH_DIR}' is not an existing directory." >&2
37+
echo "Point it at a tika-site 'publish/' checkout." >&2
38+
exit 1
39+
fi
40+
PUBLISH_DIR="$(cd "${PUBLISH_DIR}" && pwd -P)"
41+
if [[ "${#PUBLISH_DIR}" -lt 4 || "${PUBLISH_DIR}" != *"/"* ]]; then
42+
echo "Refusing to operate on suspiciously short PUBLISH_DIR '${PUBLISH_DIR}'." >&2
43+
exit 1
44+
fi
45+
# Confirm this looks like a tika-site 'publish/' dir: the documented argument
46+
# is always <tika-site-checkout>/publish, and the downstream 'svn add' step
47+
# hardcodes that name for the things written here (publish/docs, publish/_,
48+
# publish/search-index.js). Refusing a non-'publish' basename catches a
49+
# wrong-but-valid checkout before we 'rm -rf' inside it.
50+
if [[ "$(basename "${PUBLISH_DIR}")" != "publish" ]]; then
51+
echo "PUBLISH_DIR '${PUBLISH_DIR}' does not look like a tika-site publish dir" >&2
52+
echo "(expected its name to be 'publish'). Refusing to modify it." >&2
53+
exit 1
54+
fi
55+
3156
DOCS_DIR="${PUBLISH_DIR}/docs"
3257

3358
if [[ ! -d target/site ]]; then
@@ -40,12 +65,24 @@ mkdir -p "${DOCS_DIR}"
4065

4166
# Strip the 'tika/' component dir prefix so URLs are /docs/X.Y.Z/...
4267
cp -r target/site/tika/* "${DOCS_DIR}/"
43-
# UI assets one level above docs/, since HTML uses ../../_/ relative paths
44-
cp -r target/site/_/ "${PUBLISH_DIR}/_/"
68+
# UI assets one level above docs/, since HTML uses ../../_/ relative paths.
69+
# Replace wholesale: cp -r into an existing directory nests source as a
70+
# subdirectory (publish/_/_/), so remove first to keep the layout flat.
71+
# Refuse if '_' is a symlink: 'rm -rf _/' would follow it and wipe the
72+
# target's contents, and the cp below needs a real directory here anyway.
73+
if [[ -L "${PUBLISH_DIR}/_" ]]; then
74+
echo "Refusing to remove '${PUBLISH_DIR}/_': it is a symlink, not a directory." >&2
75+
exit 1
76+
fi
77+
rm -rf "${PUBLISH_DIR}/_"
78+
cp -r target/site/_ "${PUBLISH_DIR}/_"
4579
# Fix the root redirect and sitemap to match the flattened layout
4680
sed 's|tika/||g' target/site/index.html > "${DOCS_DIR}/index.html"
4781
sed 's|/docs/tika/|/docs/|g' target/site/sitemap.xml > "${DOCS_DIR}/sitemap.xml"
4882
cp target/site/404.html "${DOCS_DIR}/"
49-
cp target/site/search-index.js "${DOCS_DIR}/"
83+
# Lunr index lives next to _/ (one level above docs/), since HTML uses ../../search-index.js.
84+
# Remove the stale copy from its old publish/docs/ location left by earlier runs.
85+
rm -f "${DOCS_DIR}/search-index.js"
86+
cp target/site/search-index.js "${PUBLISH_DIR}/"
5087

5188
echo "Published to: ${DOCS_DIR}/"

docs/supplemental-ui/css/search.css

Lines changed: 0 additions & 82 deletions
This file was deleted.

docs/supplemental-ui/js/search.js

Lines changed: 0 additions & 119 deletions
This file was deleted.

docs/supplemental-ui/partials/footer-scripts.hbs

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/supplemental-ui/partials/head-scripts.hbs

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/supplemental-ui/partials/header-content.hbs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
11
<header class="header">
2-
<nav class="navbar">
2+
<nav class="navbar" aria-label="Main">
33
<div class="navbar-brand">
44
<a class="navbar-item" href="{{or siteRootPath (or site.url '/')}}">
55
<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;">
66
{{site.title}}
77
</a>
8-
<button class="navbar-burger" aria-label="Toggle navigation" data-target="topbar-nav">
8+
<div class="navbar-item search hide-for-print" role="search">
9+
<div id="search-field" class="field">
10+
<input id="search-input" type="search" aria-label="Search the docs" placeholder="Search the docs"{{#if page.home}} autofocus{{/if}}>
11+
</div>
12+
</div>
13+
<button class="navbar-burger" aria-controls="topbar-nav" aria-expanded="false" aria-label="Toggle main menu" data-target="topbar-nav">
914
<span></span>
1015
<span></span>
1116
<span></span>
1217
</button>
1318
</div>
1419
<div id="topbar-nav" class="navbar-menu">
1520
<div class="navbar-end">
16-
<div class="navbar-item search">
17-
<div class="field has-addons">
18-
<p class="control">
19-
<input id="search-input" class="input" type="text" placeholder="Search docs...">
20-
</p>
21-
</div>
22-
<div id="search-results"></div>
23-
</div>
2421
<a class="navbar-item" href="https://tika.apache.org">Apache Tika</a>
2522
<a class="navbar-item" href="https://github.com/apache/tika">GitHub</a>
2623
</div>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<div class="toolbar" role="navigation">
2-
<button class="nav-toggle"></button>
1+
<div class="toolbar" role="navigation" aria-label="Page tools">
2+
<button class="nav-toggle" aria-label="Toggle navigation"></button>
33
</div>

0 commit comments

Comments
 (0)