From f076a6188def2977a5069a46f8e1173d08409b96 Mon Sep 17 00:00:00 2001 From: sec77 Date: Sun, 14 Jan 2024 03:45:52 +0100 Subject: [PATCH] show TOC and local Graph --- Changelog.md | 1 + docker-compose-build.yml | 1 + docker-compose-dev.yml | 3 ++- docker-compose.yml | 3 ++- perlite/.js/perlite.js | 58 +++++++++++++++++++++------------------- perlite/helper.php | 33 +++++++++++++---------- perlite/index.php | 31 ++++++++++----------- 7 files changed, 72 insertions(+), 58 deletions(-) diff --git a/Changelog.md b/Changelog.md index 88b49c63..fac5f2a9 100644 --- a/Changelog.md +++ b/Changelog.md @@ -16,6 +16,7 @@ - updated vis-network to 9.1.9 - added new custom logo and social media section - fixed issue Folder arrow marker randomly disappears [#94](https://github.com/secure-77/Perlite/issues/94) +- changed to show TOC and local Graph at the same time ## 1.5.7 diff --git a/docker-compose-build.yml b/docker-compose-build.yml index 826edeca..a9330e27 100644 --- a/docker-compose-build.yml +++ b/docker-compose-build.yml @@ -12,6 +12,7 @@ services: - ALLOWED_FILE_LINK_TYPES=pdf,mp4 - DISABLE_POP_HOVER=true - SHOW_TOC=true + - SHOW_LOCAL_GRAPH=true - HOME_FILE=README - FONT_SIZE=15 - HTML_SAFE_MODE=true diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml index 98a16469..00becc8c 100644 --- a/docker-compose-dev.yml +++ b/docker-compose-dev.yml @@ -12,7 +12,8 @@ services: - ABSOLUTE_PATHES=false - ALLOWED_FILE_LINK_TYPES=pdf,mp4 - DISABLE_POP_HOVER=false - - SHOW_TOC=false + - SHOW_TOC=true + - SHOW_LOCAL_GRAPH=true - HOME_FILE=README - FONT_SIZE=15 - HTML_SAFE_MODE=true diff --git a/docker-compose.yml b/docker-compose.yml index e1d5135f..36cc68e4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,7 +12,8 @@ services: - ABSOLUTE_PATHES=false - ALLOWED_FILE_LINK_TYPES=pdf,mp4 - DISABLE_POP_HOVER=false - - SHOW_TOC=false + - SHOW_TOC=true + - SHOW_LOCAL_GRAPH=true - HOME_FILE=README - FONT_SIZE=15 - HTML_SAFE_MODE=true diff --git a/perlite/.js/perlite.js b/perlite/.js/perlite.js index bf143dd5..a5e463bc 100644 --- a/perlite/.js/perlite.js +++ b/perlite/.js/perlite.js @@ -25,18 +25,20 @@ if ($('#disablePopHovers').data('option') == true && localStorage.getItem("disab } // show toc -if ($('#showTOC').data('option') == true && localStorage.getItem("showTOC") === null) { +if ($('#showTOC').data('option') == false || localStorage.getItem("showTOC") === false) { - $('.clickable-icon.view-action[aria-label="Open outline"]').css('display', 'none') - $('.clickable-icon.view-action[aria-label="Open localGraph"]').css('display', 'unset') + localStorage.setItem("showTOC", "false") + $('#outline').css('display', 'none') +} - localStorage.setItem("showTOC", "true") - $('#mynetwork').css('display', 'none') - $('#outline').css('display', 'unset') +if ($('#showLocalGraph').data('option') == false || localStorage.getItem("showLocalGraph") === false) { + localStorage.setItem("showLocalGraph", "false") + $('#localGraph').css('display', 'none') } + /** * scroll to anchor * @param {String} aid @@ -1025,8 +1027,8 @@ $(document).ready(function () { $('.clickable-icon.side-dock-ribbon-action[aria-label="Open graph view"]').css('display', 'none') $('.clickable-icon.view-action[aria-label="Open outline"]').css('display', 'none') $('.clickable-icon.view-action[aria-label="Open localGraph"]').css('display', 'none') - $('#mynetwork').css('display', 'none') - $('#outline').css('display', 'unset') + $('#localGraph').css('display', 'none') + $('#outline').css('display', 'inline') } @@ -1456,16 +1458,12 @@ $(document).ready(function () { }); - // show toc - if (localStorage.getItem("showTOC") === 'true') { - - $('.clickable-icon.view-action[aria-label="Open outline"]').css('display', 'none') - $('.clickable-icon.view-action[aria-label="Open localGraph"]').css('display', 'unset') + // // show toc + // if (localStorage.getItem("showTOC") === 'true') { - //$('#mynetwork').css('display', 'none') - $('#outline').css('display', 'unset') + // $('#outline').css('display', 'unset') - } + // } @@ -1736,22 +1734,28 @@ $(document).ready(function () { // local Graph & Toc (outline) Switch $('.clickable-icon.view-action[aria-label="Open outline"]').click(function (e) { - $('.clickable-icon.view-action[aria-label="Open outline"]').css('display', 'none') - $('.clickable-icon.view-action[aria-label="Open localGraph"]').css('display', 'unset') + console.log('click') + if ($('#outline').css('display') == 'inline') { + localStorage.setItem("showTOC", "false") + $('#outline').css('display', 'none') + console.log('into') - localStorage.setItem("showTOC", "true") - $('#mynetwork').css('display', 'none') - $('#outline').css('display', 'unset') + } else { + localStorage.setItem("showTOC", "true") + $('#outline').css('display', 'inline') + } + }); $('.clickable-icon.view-action[aria-label="Open localGraph"]').click(function (e) { - $('.clickable-icon.view-action[aria-label="Open outline"]').css('display', 'unset') - $('.clickable-icon.view-action[aria-label="Open localGraph"]').css('display', 'none') - - localStorage.setItem("showTOC", "false") - $('#mynetwork').css('display', 'unset') - $('#outline').css('display', 'none') + if ($('#localGraph').css('display') == 'inline') { + localStorage.setItem("showLocalGraph", "false") + $('#localGraph').css('display', 'none') + } else { + localStorage.setItem("showLocalGraph", "true") + $('#localGraph').css('display', 'inline') + } }); diff --git a/perlite/helper.php b/perlite/helper.php index 7d34c43c..b80a6c70 100644 --- a/perlite/helper.php +++ b/perlite/helper.php @@ -43,13 +43,16 @@ $lineBreaks = empty(getenv('LINE_BREAKS')) ? true : filter_var(getenv('LINE_BREAKS'), FILTER_VALIDATE_BOOLEAN); // file types -$allowedFileLinkTypes = empty(getenv('ALLOWED_FILE_LINK_TYPES')) ? ['pdf','mp4'] : explode(",", getenv('ALLOWED_FILE_LINK_TYPES')); +$allowedFileLinkTypes = empty(getenv('ALLOWED_FILE_LINK_TYPES')) ? ['pdf', 'mp4'] : explode(",", getenv('ALLOWED_FILE_LINK_TYPES')); // disable PopHovers $disablePopHovers = empty(getenv('DISABLE_POP_HOVER')) ? "false" : getenv('DISABLE_POP_HOVER'); -// show TOC instead of graph -$showTOC = empty(getenv('SHOW_TOC')) ? "false" : getenv('SHOW_TOC'); +// show TOC +$showTOC = empty(getenv('SHOW_TOC')) ? "true" : getenv('SHOW_TOC'); + +// show local Graph +$showLocalGraph = empty(getenv('SHOW_LOCAL_GRAPH')) ? "true" : getenv('SHOW_TOC'); // Set home page from environment variable $index = empty(getenv('HOME_FILE')) ? "README" : getenv('HOME_FILE'); @@ -67,20 +70,20 @@ if (getenv('SITE_LOGO')) { $customSection = '
 
- +
 
'; - - $customSection = $customSection . '
'. $siteDescription . '
+ + $customSection = $customSection . '
' . $siteDescription . '
'; $customSection = $customSection . '
'; @@ -538,6 +541,7 @@ function loadSettings($rootDir) global $disablePopHovers; global $showTOC; + global $showLocalGraph; global $index; global $siteTitle; global $siteType; @@ -607,6 +611,7 @@ function loadSettings($rootDir) // default settings $defaultSettings .= ''; $defaultSettings .= ''; + $defaultSettings .= ''; $defaultSettings .= ''; diff --git a/perlite/index.php b/perlite/index.php index 335ad0fc..df7dfb5d 100644 --- a/perlite/index.php +++ b/perlite/index.php @@ -252,7 +252,7 @@ class="svg-icon lucide-x">
  • --> - + - +