"""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("
#menuview, #hierarchy_breadcrumb, .document-header, #xdocFooter, #footerglobal, #leftPanels, #rightPanels, #leftPanelsToggle, #rightPanelsToggle, .tour, .tour-backdrop, #bootstrap_tour_restart, .xtour-restart, #xwikimaincontainerinner > a.btn { display: none !important; } html, body, #xwikimaincontainer, #xwikimaincontainerinner, #contentcontainer, #contentcolumn, .main, #mainContentArea, #xwikicontent, #mainContentArea .row { background-color: #0A1222 !important; } #contentcontainer, #contentcolumn, .main, #mainContentArea, #xwikicontent, #mainContentArea .row { width: 100% !important; max-width: none !important; margin: 0 !important; padding: 0 !important; border: 0 !important; float: none !important; } #xwikicontent > .ssos { border: 0 !important; } #xwikimaincontainer { padding: 0 !important; } .main hr:not(.ssos hr), #xwikicontent > :not(.ssos) { display: none !important; } {{/html}}]]# #end {{/velocity}} """