2021-03-23 00:51:45 +08:00
|
|
|
<?php
|
|
|
|
|
2021-11-24 14:24:09 +08:00
|
|
|
require_once "./src/Data/PageMeta.php";
|
2021-03-23 00:51:45 +08:00
|
|
|
require_once "./src/Element/Bookshelf.php";
|
2021-05-10 12:09:29 +08:00
|
|
|
require_once "./constant.php";
|
2021-03-23 00:51:45 +08:00
|
|
|
|
|
|
|
class SiteMeta {
|
|
|
|
|
|
|
|
private static Bookshelf $BOOKSHELF;
|
2021-09-30 19:34:16 +08:00
|
|
|
|
2021-05-10 12:09:29 +08:00
|
|
|
static function get_frontpage_generate_version (): string {
|
2021-09-30 19:34:16 +08:00
|
|
|
return APP_NAME." ".VERSION;
|
2021-05-10 12:09:29 +08:00
|
|
|
}
|
2021-03-23 00:51:45 +08:00
|
|
|
|
2021-11-22 16:08:50 +08:00
|
|
|
public static function getProgramVersion(): string {
|
|
|
|
return sprintf("%s @%s/%s", VERSION, CHANNEL, BRANCH);
|
|
|
|
}
|
|
|
|
|
2021-03-23 00:51:45 +08:00
|
|
|
/**
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public static function load () {
|
|
|
|
self::$BOOKSHELF = Bookshelf::parseString(file_get_contents("./data/bookshelf.xml"));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getBookshelf(): Bookshelf {
|
|
|
|
return self::$BOOKSHELF;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getGlobalIcon (): string {
|
|
|
|
return "/favicon.ico"; // TODO ICON
|
|
|
|
}
|
|
|
|
|
2021-11-24 14:24:09 +08:00
|
|
|
public static function getStylesheetsList (): array {
|
2021-03-23 00:51:45 +08:00
|
|
|
return array(
|
2021-09-30 19:34:16 +08:00
|
|
|
// "/assets/gitbook/style.css",
|
|
|
|
// "/assets/gitbook/gitbook-plugin-fontsettings/website.css",
|
|
|
|
// "/assets/gitbook-fix.css",
|
|
|
|
// "/assets/ref.css",
|
2021-11-24 14:24:09 +08:00
|
|
|
(PageMeta::getConfigurationLevelPage("customization.article.codeblock.highlightjs")=="false"?
|
2022-09-29 17:51:25 +08:00
|
|
|
null:"//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.3.1/styles/".PageMeta::highlightJsTheme().".min.css"),
|
|
|
|
"/assets/bread-card-markdown.css?ver=1",
|
2021-11-24 14:24:09 +08:00
|
|
|
(PageMeta::getConfigurationLevelPage("customization.article.listing.rainbow.marker")=="true"?
|
2022-09-29 17:51:25 +08:00
|
|
|
"/assets/bread-card-markdown-enhanced-listing-rainbow.css?ver=1":null),
|
|
|
|
"/assets/bread-card-markdown-compat-highlight-js.css?ver=1",
|
|
|
|
"/assets/main.css?ver=1",
|
2021-03-23 00:51:45 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-11-24 14:24:09 +08:00
|
|
|
public static function getJavascriptList (): array {
|
2021-03-23 00:51:45 +08:00
|
|
|
return array(
|
2021-09-30 19:34:16 +08:00
|
|
|
// "/assets/gitbook/gitbook.js",
|
|
|
|
// "/assets/gitbook-fix.js",
|
|
|
|
// "https://cdn.jsdelivr.net/npm/marked/marked.min.js",
|
|
|
|
// "/assets/ref.js",
|
2021-11-24 14:24:09 +08:00
|
|
|
(PageMeta::getConfigurationLevelPage("customization.article.codeblock.highlightjs")=="false"?
|
2022-09-29 17:51:25 +08:00
|
|
|
null:"//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.3.1/highlight.min.js"),
|
|
|
|
"/assets/utils-touchscreen-event.js?ver=1",
|
|
|
|
"/assets/main.js?ver=1",
|
2021-03-23 00:51:45 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-05-05 13:42:29 +08:00
|
|
|
public static function getCustomCssContent (string $id): string {
|
2021-11-24 14:24:09 +08:00
|
|
|
if (!file_exists("./data/$id.css")) return "";
|
2021-05-05 13:42:29 +08:00
|
|
|
return file_get_contents("./data/$id.css");
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getCustomScriptContent (string $id): string {
|
2021-11-22 22:53:02 +08:00
|
|
|
if (!file_exists("./data/$id.js")) return "";
|
2021-05-05 13:42:29 +08:00
|
|
|
return file_get_contents("./data/$id.js");
|
|
|
|
}
|
|
|
|
|
2021-05-27 16:22:48 +08:00
|
|
|
public static function getUserThemes (): string {
|
|
|
|
$fontSize = $_COOKIE['font-size'] ?? 2;
|
|
|
|
$fontFamily = $_COOKIE['font-family'] ?? 1;
|
|
|
|
$colorTheme = $_COOKIE['color-theme'] ?? 0;
|
|
|
|
return "font-size-$fontSize font-family-$fontFamily color-theme-$colorTheme";
|
|
|
|
}
|
|
|
|
|
2021-11-24 14:24:09 +08:00
|
|
|
public static function getConfigurationLevelShelf (string $key): ?string {
|
|
|
|
return self::$BOOKSHELF->getConfiguration($key);
|
|
|
|
}
|
|
|
|
|
2021-03-23 00:51:45 +08:00
|
|
|
}
|