1
0
mirror of https://github.com/suk-ws/ph-Bookshelf.git synced 2025-01-19 15:25:03 +08:00

add support for prism plugins customize import

This commit is contained in:
A.C.Sukazyo Eyre 2023-03-28 11:32:42 +08:00
parent 5824548b40
commit 175b1ad04a
Signed by: Eyre_S
GPG Key ID: C17CE40291207874
5 changed files with 47 additions and 8 deletions

View File

@ -2,6 +2,6 @@
const APP_NAME = "ph-Bookshelf"; const APP_NAME = "ph-Bookshelf";
const VERSION = "0.5.0-alpha3"; const VERSION = "0.5.0-alpha4";
const CHANNEL = "suk-ws"; const CHANNEL = "suk-ws";
const BRANCH = "config-v2.0"; const BRANCH = "config-v2.0";

View File

@ -94,6 +94,26 @@ class PageMeta {
return $theme; return $theme;
} }
/**
* @return string[]
*/
public static function prismPlugins (): array {
$langDef = "";
{
$langDefList = array();
$langDefList[] = SiteMeta::getConfigurationLevelShelf(ConfigName::prism_plugins);
$langDefList[] = PageMeta::getConfigurationLevelBook(ConfigName::prism_plugins);
$langDefList[] = PageMeta::getConfigurationLevelPage(ConfigName::prism_plugins);
foreach ($langDefList as $langDefNode) $langDef .= $langDefNode . ";";
}
$lang = array();
foreach (explode(";", $langDef) as $i) {
$i = trim($i);
if ($i != "") $lang[] =$i;
}
return array_unique($lang);
}
public static function getPagePath (?string $extension = null): string { public static function getPagePath (?string $extension = null): string {
return "./data/" . self::$bookId . "/" . self::$page_id . ($extension == null ? "" : ".".$extension); return "./data/" . self::$bookId . "/" . self::$page_id . ($extension == null ? "" : ".".$extension);
} }

View File

@ -8,6 +8,7 @@ class ConfigName {
public const prism = "prism"; public const prism = "prism";
public const prism_theme = "prism.theme"; public const prism_theme = "prism.theme";
public const prism_plugins = "prism.plugins";
public const codeblock_bg = "codeblock.bg-color"; public const codeblock_bg = "codeblock.bg-color";
public const codeblock_fg = "codeblock.fg-color"; public const codeblock_fg = "codeblock.fg-color";

View File

@ -35,7 +35,7 @@ class SiteMeta {
} }
public static function getStylesheetsList (): array { public static function getStylesheetsList (): array {
return array( return array_merge(array(
// "/assets/gitbook/style.css", // "/assets/gitbook/style.css",
// "/assets/gitbook/gitbook-plugin-fontsettings/website.css", // "/assets/gitbook/gitbook-plugin-fontsettings/website.css",
// "/assets/gitbook-fix.css", // "/assets/gitbook-fix.css",
@ -51,6 +51,8 @@ class SiteMeta {
(PageMeta::getConfigurationLevelPage(ConfigName::ext_listing_rainbow)=="true"? (PageMeta::getConfigurationLevelPage(ConfigName::ext_listing_rainbow)=="true"?
"/assets/bread-card-markdown-enhanced-listing-rainbow.css?ver=1":null), "/assets/bread-card-markdown-enhanced-listing-rainbow.css?ver=1":null),
"/assets/main.css?ver=1", "/assets/main.css?ver=1",
),
self::getPrismPluginsCss(PageMeta::prismPlugins())
); );
} }
@ -72,7 +74,8 @@ class SiteMeta {
"/assets/bread-card-markdown-heading-permalink-highlight.js?ver=1":null), "/assets/bread-card-markdown-heading-permalink-highlight.js?ver=1":null),
"/assets/utils-touchscreen-event.js?ver=1", "/assets/utils-touchscreen-event.js?ver=1",
"/assets/main.js?ver=1", "/assets/main.js?ver=1",
) ),
self::getPrismPluginsJs(PageMeta::prismPlugins())
); );
} }
@ -106,4 +109,20 @@ class SiteMeta {
}; };
} }
public static function getPrismPluginsJs (array $plugins): array {
$links = array();
foreach ($plugins as $i) {
$links[] = "//cdn.jsdelivr.net/npm/prismjs@v1.x/plugins/$i/prism-$i.min.js";
}
return $links;
}
public static function getPrismPluginsCss (array $plugins): array {
$links = array();
foreach ($plugins as $i) {
$links[] = "//cdn.jsdelivr.net/npm/prismjs@v1.x/plugins/$i/prism-$i.min.css";
}
return $links;
}
} }

View File

@ -14,10 +14,9 @@
<script> <script>
bookCurrentId = "<?= PageMeta::$bookId ?>"; bookCurrentId = "<?= PageMeta::$bookId ?>";
pageCurrentId = "<?= PageMeta::$page_id ?>"; pageCurrentId = "<?= PageMeta::$page_id ?>";
// <?php //if (!(PageMeta::getConfigurationLevelPage(ConfigName::highlightjs)=="false")) : <?php if (!(PageMeta::getConfigurationLevelPage(ConfigName::regex_highlight)=="false")) :?>
// ?>//hljs.highlightAll();<?php //endif; ?> RegexColorizer.coloringAll();
// <?php //if (!(PageMeta::getConfigurationLevelPage(ConfigName::regex_highlight)=="false")) : <?php endif; ?>
// ?>//RegexColorizer.coloringAll();<?php //endif; ?>
</script> </script>
</body> </body>