Captain Bob, 2026-11-07: "The banner XWiki should not say that." Both wikis now have a colour theme of their own, FlamingoThemes.StarshipOS (the stock Iceberg, copied, with the starshipOS wordmark as its logo; Iceberg untouched), and the browser tab's title ends "- StarshipOS". Installed on both; checked as a guest on each (logo and title), and the .org's top bar seen logged in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GE3SDvQn5EoxdGufk84zz2
58 lines
3.4 KiB
Bash
Executable File
58 lines
3.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# install.sh -- the wiki's banner says StarshipOS, not XWiki (Captain Bob, 2026-11-07: "The banner
|
|
# XWiki should not say that").
|
|
#
|
|
# site/brand/install.sh https://starshipos-f18.com starshipos-com.png
|
|
# site/brand/install.sh https://starshipos-f18.org starshipos-org.png
|
|
#
|
|
# In XWiki 17 the top bar's logo is the colour theme's. This makes a colour theme of our own,
|
|
# FlamingoThemes.StarshipOS -- a copy of the stock Iceberg with our wordmark as its logo -- and
|
|
# makes it the wiki's; the stock theme is not touched (set colorTheme back to
|
|
# FlamingoThemes.Iceberg to undo). It also makes the browser tab's title "<page> - StarshipOS".
|
|
# Run again after changing the wordmark: the logo is replaced. XWIKI_USER and XWIKI_PASSWORD as for
|
|
# site/*/install.sh. Everything goes as XML: XWiki refuses form and plain-text writes without its
|
|
# form token.
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")"
|
|
base=${1:?usage: install.sh <wiki URL> <logo.png>}
|
|
logo=${2:?usage: install.sh <wiki URL> <logo.png>}
|
|
rest="$base/rest/wikis/xwiki/spaces"
|
|
auth=(-u "${XWIKI_USER:?set XWIKI_USER}:${XWIKI_PASSWORD:?set XWIKI_PASSWORD}")
|
|
theme="$rest/FlamingoThemes/pages/StarshipOS"
|
|
x() { curl -fsS -m 60 "${auth[@]}" "$@"; }
|
|
prop() { # prop <object URL> <name> <value>: set one property
|
|
x -o /dev/null -w " $2: %{http_code}\n" -X PUT -H 'Content-Type: application/xml' \
|
|
--data-binary "$(python3 -c '
|
|
import sys
|
|
from xml.sax.saxutils import escape
|
|
print("<property xmlns=\"http://www.xwiki.org\" name=\"%s\"><value>%s</value></property>" % (escape(sys.argv[1]), escape(sys.argv[2])))' "$2" "$3")" \
|
|
"$1/properties/$2"
|
|
}
|
|
|
|
echo "=== $base: the colour theme FlamingoThemes.StarshipOS"
|
|
x -o /dev/null -w " page: %{http_code}\n" -X PUT -H 'Content-Type: application/xml' --data-binary \
|
|
'<page xmlns="http://www.xwiki.org"><title>StarshipOS</title><syntax>xwiki/2.1</syntax><content>{{include reference="FlamingoThemesCode.ThemeSheet"/}}</content></page>' \
|
|
"$theme"
|
|
x -o /dev/null -w " logo $logo: %{http_code}\n" -X PUT -H 'Content-Type: image/png' --data-binary "@$logo" \
|
|
"$theme/attachments/$logo"
|
|
have=$(x -H 'Accept: application/json' "$theme/objects/FlamingoThemesCode.ThemeClass" |
|
|
python3 -c 'import json,sys; print(len(json.load(sys.stdin).get("objectSummaries") or []))')
|
|
if [ "$have" = 0 ]; then
|
|
# Iceberg's theme object, every property as it is, posted to our page
|
|
x -H 'Accept: application/xml' "$rest/FlamingoThemes/pages/Iceberg/objects/FlamingoThemesCode.ThemeClass/0" |
|
|
x -o /dev/null -w " theme object, from Iceberg: %{http_code}\n" -X POST -H 'Content-Type: application/xml' \
|
|
--data-binary @- "$theme/objects"
|
|
fi
|
|
prop "$theme/objects/FlamingoThemesCode.ThemeClass/0" logo "$logo"
|
|
prop "$theme/objects/FlamingoThemesCode.ThemeClass/0" logo-description "StarshipOS"
|
|
|
|
echo "=== the wiki's preferences"
|
|
prefs="$rest/XWiki/pages/XWikiPreferences/objects/XWiki.XWikiPreferences/0"
|
|
prop "$prefs" colorTheme "FlamingoThemes.StarshipOS"
|
|
prop "$prefs" title "\$tdoc.getRenderedTitle('plain/1.0') - StarshipOS"
|
|
|
|
echo "=== check, as a guest"
|
|
page=$(curl -sS -m 60 "$base/bin/login/XWiki/XWikiLogin") # a page that shows the chrome to a guest
|
|
case "$page" in *"FlamingoThemes/StarshipOS/$logo"*) echo " the banner's logo: ours";; *) echo " the banner's logo: NOT ours" >&2; exit 1;; esac
|
|
case "$page" in *"- StarshipOS</title>"*) echo " the tab's title: ends - StarshipOS";; *) echo " the tab's title: NOT ours" >&2; exit 1;; esac
|