diff --git a/site/__pycache__/colorlock.cpython-313.pyc b/site/__pycache__/colorlock.cpython-313.pyc new file mode 100644 index 00000000..c1186d1f Binary files /dev/null and b/site/__pycache__/colorlock.cpython-313.pyc differ diff --git a/site/colorlock.py b/site/colorlock.py new file mode 100644 index 00000000..2e1f2eeb --- /dev/null +++ b/site/colorlock.py @@ -0,0 +1,41 @@ +"""colorlock.py -- keep a page's own colours inside a wiki whose theme forces its own. + +Both XWikis carry a high-contrast theme (skins/flamingo/cssVariablesInit.css on the server) that sets +every element black on white with !important. On our pages the design's colours win instead +(Captain Bob, 2026-11-07), and on those pages only; the rest of the wiki keeps the theme: + + - every colour an element states in its style="" is made !important -- an inline !important beats + any stylesheet's; + - a stylesheet scoped to the page's root (class "ssos") covers the elements that state no colour: + ".ssos *" outranks the theme's "*" (both !important, the more specific wins). +""" +import re + +ROOT_CLASS = "ssos" +STYLE = """""" +COLOUR_PROPS = re.compile(r"^\s*(color|background|background-color|border|border-(top|right|bottom|left)|" + r"border-color|border-(top|right|bottom|left)-color|accent-color|fill)\s*:", re.I) + + +def _lock_style(m): + decls = [] + for d in m.group(1).split(";"): + if d.strip() and COLOUR_PROPS.match(d) and "!important" not in d: + d = d.rstrip() + " !important" + decls.append(d) + return 'style="%s"' % ";".join(decls) + + +def lock(html, root_marker): + """root_marker: the opening text of the page's root element, e.g. '
= 1, root_marker + html = html.replace(root_marker, root_marker.replace("
-
+ +
-
+
-

Inquiries

+

Inquiries

Talk to the bridge.

-

Licensing, research collaboration, press or plain curiosity — every message is read by a human. Want to contribute code? Head to starshipos-f18.org.

+

Licensing, research collaboration, press or plain curiosity — every message is read by a human. Want to contribute code? Head to starshipos-f18.org.

-
+ +
- - + +
- - + +
- - + +
- - @@ -48,46 +57,46 @@
- - + +
- - + +
- -Opens your e-mail program. Replies usually within a few days. + +Replies usually within a few days.
-