254 lines
10 KiB
HTML
254 lines
10 KiB
HTML
<!DOCTYPE html>
|
|
<html
|
|
xmlns:th="https://www.thymeleaf.org"
|
|
th:lang="${#locale.toLanguageTag}"
|
|
th:fragment="html (header, content, footer)">
|
|
<head>
|
|
<meta charset="UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
<title th:text="${title}"></title>
|
|
<script th:if="${theme.config.basic.assert_enable}" no-pjax th:inline="javascript">
|
|
(function () {
|
|
const assertCode = /*[[${theme.config.basic.assert_code}]]*/ "";
|
|
|
|
try {
|
|
new Function(assertCode)();
|
|
} catch (e) {
|
|
location.href = 'about:blank';
|
|
setTimeout(() => document.close(), 0.1);
|
|
}
|
|
})();
|
|
</script>
|
|
<script no-pjax th:inline="javascript">
|
|
window.TerminalThemeConfig = {
|
|
systemFontEnabled: /*[[${theme.config.style.system_font_enable}]]*/ false,
|
|
darkTheme: /*[[${theme.config.style.dark_color_scheme}]]*/ "dark",
|
|
lightTheme: /*[[${theme.config.style.light_color_scheme}]]*/ "light",
|
|
customDarkTheme: /*[[${theme.config.style.custom_dark}]]*/ "",
|
|
customLightTheme: /*[[${theme.config.style.custom_light}]]*/ "",
|
|
defaultMode: /*[[${theme.config.style.default_scheme_mode}]]*/ "system",
|
|
pixelStyle: /*[[${theme.config.style.pixel_style}]]*/ false,
|
|
pixelCssHref: /*[[@{/assets/dist/pixel.css?v={version}(version=${theme.spec.version})}]]*/ "",
|
|
customCss: /*[[${theme.config.style.custom}]]*/ ""
|
|
};
|
|
</script>
|
|
<script no-pjax>
|
|
(function () {
|
|
const config = window.TerminalThemeConfig || {};
|
|
const root = document.documentElement;
|
|
const storageKeys = {
|
|
themeMode: "theme-mode",
|
|
pixelStyle: "pixel_style"
|
|
};
|
|
|
|
function resolveTheme(scheme) {
|
|
if (scheme === "light") {
|
|
return config.lightTheme === "custom" ? config.customLightTheme : config.lightTheme;
|
|
}
|
|
return config.darkTheme === "custom" ? config.customDarkTheme : config.darkTheme;
|
|
}
|
|
|
|
function getSystemScheme() {
|
|
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
}
|
|
|
|
function applyTheme(mode) {
|
|
const actualMode = mode === "system" ? getSystemScheme() : mode;
|
|
root.setAttribute("data-color-scheme", actualMode);
|
|
root.setAttribute("theme-color-scheme", resolveTheme(actualMode));
|
|
}
|
|
|
|
function syncSystemFont() {
|
|
root.setAttribute("system_font_enable", String(config.systemFontEnabled));
|
|
}
|
|
|
|
function syncPixelStyle() {
|
|
let storedStatus = localStorage.getItem(storageKeys.pixelStyle);
|
|
|
|
if (!storedStatus) {
|
|
storedStatus = String(config.pixelStyle);
|
|
localStorage.setItem(storageKeys.pixelStyle, storedStatus);
|
|
}
|
|
|
|
root.setAttribute("pixel_style", storedStatus);
|
|
}
|
|
|
|
function syncPixelFont() {
|
|
const existingLink = document.getElementById("terminal-pixel-font");
|
|
const pixelEnabled = root.getAttribute("pixel_style") === "true";
|
|
|
|
if (!pixelEnabled && existingLink) {
|
|
existingLink.remove();
|
|
return;
|
|
}
|
|
|
|
if (!pixelEnabled || existingLink || !config.pixelCssHref) return;
|
|
|
|
const link = document.createElement("link");
|
|
link.id = "terminal-pixel-font";
|
|
link.setAttribute("no-pjax", "");
|
|
link.rel = "stylesheet";
|
|
link.href = config.pixelCssHref;
|
|
document.head.appendChild(link);
|
|
}
|
|
|
|
function applyCustomCss(text = config.customCss) {
|
|
if (!text || document.getElementById("terminal-custom-css")) return;
|
|
|
|
const style = document.createElement("style");
|
|
style.id = "terminal-custom-css";
|
|
style.textContent = text;
|
|
document.head.appendChild(style);
|
|
}
|
|
|
|
function syncThemeMode() {
|
|
let storedMode = localStorage.getItem(storageKeys.themeMode);
|
|
|
|
if (config.defaultMode === "system" || !storedMode) {
|
|
storedMode = config.defaultMode;
|
|
localStorage.setItem(storageKeys.themeMode, storedMode);
|
|
}
|
|
|
|
applyTheme(storedMode);
|
|
}
|
|
|
|
window.applyTheme = applyTheme;
|
|
window.TerminalTheme = {
|
|
applyTheme,
|
|
applyCustomCss,
|
|
syncPixelFont,
|
|
syncPixelStyle
|
|
};
|
|
|
|
syncSystemFont();
|
|
syncThemeMode();
|
|
syncPixelStyle();
|
|
syncPixelFont();
|
|
|
|
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", () => {
|
|
if (localStorage.getItem(storageKeys.themeMode) === "system") {
|
|
applyTheme("system");
|
|
}
|
|
});
|
|
})();
|
|
</script>
|
|
<link no-pjax rel="stylesheet" th:href="@{/assets/dist/main.css?v={version}(version=${theme.spec.version})}"/>
|
|
<script no-pjax type="module" th:src="@{/assets/dist/main.js?v={version}(version=${theme.spec.version})}"></script>
|
|
<script no-pjax type="module" th:if="${theme.config.basic.pjax_enable}"
|
|
th:src="@{/assets/dist/libs/pjax.js?v={version}(version=${theme.spec.version})}"></script>
|
|
<style no-pjax th:if="${not #strings.isEmpty(theme.config.style.media_max_width)}" th:inline="css">
|
|
:root {
|
|
--width-theme-media-max: [(${theme.config.style.media_max_width})];
|
|
}
|
|
</style>
|
|
<style no-pjax th:if="${not #strings.isEmpty(theme.config.style.font_size)}" th:inline="css">
|
|
:root {
|
|
--size-theme-font: [(${theme.config.style.font_size})];
|
|
}
|
|
</style>
|
|
<style no-pjax th:if="${not #strings.isEmpty(theme.config.style.content_padding)}" th:inline="css">
|
|
:root {
|
|
--spacing-theme-container-padding: [(${theme.config.style.content_padding})];
|
|
--spacing-theme-container-padding-mobile: [(${theme.config.style.content_padding})];
|
|
}
|
|
</style>
|
|
<style no-pjax th:if="${not #strings.isEmpty(theme.config.style.list_marker)}" th:inline="css">
|
|
:root {
|
|
--list-theme-marker: [(${theme.config.style.list_marker})];
|
|
}
|
|
</style>
|
|
<style no-pjax th:if="${not #strings.isEmpty(theme.config.style.border_width)}" th:inline="css">
|
|
:root {
|
|
--width-theme-border: [(${theme.config.style.border_width})];
|
|
}
|
|
</style>
|
|
<style no-pjax th:if="${not #strings.isEmpty(theme.config.style.border_style)}" th:inline="css">
|
|
:root {
|
|
--style-theme-border: [(${theme.config.style.border_style})];
|
|
}
|
|
</style>
|
|
<style no-pjax th:if="${not #strings.isEmpty(theme.config.style.table_border_width)}" th:inline="css">
|
|
:root {
|
|
--width-theme-table-border: [(${theme.config.style.table_border_width})];
|
|
}
|
|
</style>
|
|
<style no-pjax th:if="${not #strings.isEmpty(theme.config.style.table_border_style)}" th:inline="css">
|
|
:root {
|
|
--style-theme-table-border: [(${theme.config.style.table_border_style})];
|
|
}
|
|
</style>
|
|
<style no-pjax th:if="${not #strings.isEmpty(theme.config.style.title_divider_style)}" th:inline="css">
|
|
:root {
|
|
--style-theme-title-divider: [(${theme.config.style.title_divider_style})];
|
|
}
|
|
</style>
|
|
<script no-pjax>
|
|
window.TerminalTheme?.applyCustomCss?.();
|
|
</script>
|
|
<th:block
|
|
th:if="${theme.config?.style?.custom_font_enable and not theme.config?.style?.system_font_enable}"
|
|
th:with="font=${#objects.nullSafe(theme.config?.style?.custom_font_file, #theme.assets('/dist/JetBrainsMono-Regular.woff2'))},
|
|
ext=${font.substring(font.lastIndexOf('.') + 1)},
|
|
format=${ext == 'woff2' ? 'woff2' :
|
|
(ext == 'woff' ? 'woff' :
|
|
(ext == 'ttf' ? 'truetype' :
|
|
(ext == 'otf' ? 'opentype' :
|
|
(ext == 'eot' ? 'embedded-opentype' :
|
|
((ext == 'ttc' or ext == 'otc') ? 'collection' : ext)))))},
|
|
mime=${ext == 'woff2' ? 'font/woff2' :
|
|
(ext == 'woff' ? 'font/woff' :
|
|
(ext == 'ttf' ? 'font/ttf' :
|
|
(ext == 'otf' ? 'font/otf' :
|
|
(ext == 'sfnt' ? 'font/sfnt' :
|
|
(ext == 'eot' ? 'application/vnd.ms-fontobject' :
|
|
((ext == 'ttc' or ext == 'otc') ? 'font/collection' : 'application/octet-stream'))))))}">
|
|
<link rel="preload" th:href="${font}" as="font" th:type="${mime}" crossorigin />
|
|
<!--/*/
|
|
<style th:inline="css">
|
|
@font-face {
|
|
font-display: swap;
|
|
font-family: "custom";
|
|
font-style: normal;
|
|
font-weight: 400;
|
|
src:
|
|
local("[(${theme.config?.style?.custom_font_name})]"),
|
|
url("[(${font})]") format("[(${format})]");
|
|
}
|
|
:root {
|
|
--family-theme-font: custom;
|
|
}
|
|
</style>
|
|
/*/-->
|
|
</th:block>
|
|
</head>
|
|
|
|
<body th:attr="layout_mode=${theme.config.style.fullscreen_layout ? 'fullscreen' : 'normal'},
|
|
table_full_width=${theme.config.style.table_full_width ? 'true' : 'false'}">
|
|
<div class="page">
|
|
<header role="banner">
|
|
<div id="header-slot" aria-hidden="true"></div>
|
|
</header>
|
|
<div class="wrapper">
|
|
<aside class="sidebar-left">
|
|
</aside>
|
|
<main class="container" role="main" th:attr="style=${#strings.isEmpty(theme.config.style.max_width) ? '' : 'max-width:' + theme.config.style.max_width}">
|
|
<header class="header">
|
|
<th:block th:replace="~{modules/header :: header(isHome = true)}"/>
|
|
</header>
|
|
<div class="content">
|
|
<th:block th:replace="${content}"/>
|
|
</div>
|
|
</main>
|
|
<aside class="sidebar-right">
|
|
</aside>
|
|
</div>
|
|
<footer class="footer" role="contentinfo">
|
|
<div id="footer-slot-head" aria-hidden="true"></div>
|
|
<th:block th:replace="~{modules/footer}"/>
|
|
<div id="footer-slot-tail" aria-hidden="true"></div>
|
|
</footer>
|
|
</div>
|
|
</body>
|
|
</html>
|