From 96ec8e1e6fe5022f412da00992a164dc87d2ae50 Mon Sep 17 00:00:00 2001 From: James Collins Date: Thu, 4 Mar 2021 13:48:31 +1000 Subject: [PATCH] Added support to hide page elements #18 --- README.md | 311 ++++++++++++++++++++++++++---------------------- assets/mikio.js | 23 ++++ mikio.php | 30 +++++ 3 files changed, 221 insertions(+), 143 deletions(-) diff --git a/README.md b/README.md index c4cea9a..533ac22 100644 --- a/README.md +++ b/README.md @@ -6,219 +6,244 @@ `Mikio` is a Bootstrap 4 style template for [DokuWiki](http://dokuwiki.org) - ## Features - - * [bootstrap styling](http://getbootstrap.com/) - * Navbar with dropdown support - * Subnavbar support (using a page named submenu) - * Right sidebar - * Hero element - * Icon support - * Customizable breadcrumbs - * Theming support - * Tags plugin support - * Mobile friendly - +- [bootstrap styling](http://getbootstrap.com/) +- Navbar with dropdown support +- Subnavbar support (using a page named submenu) +- Right sidebar +- Hero element +- Icon support +- Customizable breadcrumbs +- Theming support +- Tags plugin support +- Mobile friendly ## Changes - * 2020-09-27 - * Sidebars now collapse by default on mobile. This can be overridden with the `sidebarMobileDefaultCollapse` option - * The mikio LESS stylesheet is now disabled by default, with a precompilied CSS used. This can be reverted using the `useLESS` option +- 2020-09-27 + - Sidebars now collapse by default on mobile. This can be overridden with the `sidebarMobileDefaultCollapse` option + - The mikio LESS stylesheet is now disabled by default, with a precompilied CSS used. This can be reverted using the `useLESS` option ## Configuration The configuration can be change with the [Configuration Manager Plugin](https://www.dokuwiki.org/plugin:config) - * `iconTag` : icon tag to use to engage the icon engine. Default to `icon` - * `customTheme` : the mikio theme to use, located in the `mikio/themes` directory - * `showNotifications` : where to show site notifications for admin staff - * `useLESS` : use the LESS compilier or direct CSS for the mikio stylesheet. Requires the ctype PHP extension installed - - * `navbarUseTitleIcon` : show the site logo in the navbar - * `navbarUseTitleText` : show the site title in the navbar - * `navbarUseTaglineText` : show the site tagline in the navbar. Requires the `navbarUseTitleText` to be enabled - * `navbarCustomMenuText` : custom menu to use in the navbar. Menu items are in the format of url|title with each item seperated by a semicolon. Requires one of the `navbarPos` to be set to `custom` +- `iconTag` : icon tag to use to engage the icon engine. Default to `icon` +- `customTheme` : the mikio theme to use, located in the `mikio/themes` directory +- `showNotifications` : where to show site notifications for admin staff +- `useLESS` : use the LESS compilier or direct CSS for the mikio stylesheet. Requires the ctype PHP extension installed - * `navbarDWMenuType` : how to show the DokuWiki menu items in the navbar. Can be either icons, text or both - * `navbarDWMenuCombine` : how to show the DokuWiki menu in the navbar. Can be either category dropdowns, single items or a combined dropdown. The combined menu title is pulled from the `tools-menu` language value +- `navbarUseTitleIcon` : show the site logo in the navbar +- `navbarUseTitleText` : show the site title in the navbar +- `navbarUseTaglineText` : show the site tagline in the navbar. Requires the `navbarUseTitleText` to be enabled +- `navbarCustomMenuText` : custom menu to use in the navbar. Menu items are in the format of url|title with each item seperated by a semicolon. Requires one of the `navbarPos` to be set to `custom` - * `navbarPosLeft` : what menu to show on the left of the navbar - * `navbarPosMiddle` : what menu to show in the middle of the navbar - * `navbarPosRight` : what menu to show on the right of the navbar - * `navbarShowSub` : show the sub navbar. This menu is pulled from the `submenu` page in the current or parent namespaces. The menu is also shown on child pages. If no page is found, the sub navbar is automatically hidden +- `navbarDWMenuType` : how to show the DokuWiki menu items in the navbar. Can be either icons, text or both +- `navbarDWMenuCombine` : how to show the DokuWiki menu in the navbar. Can be either category dropdowns, single items or a combined dropdown. The combined menu title is pulled from the `tools-menu` language value - * `searchButton` : show the search button as a icon or text +- `navbarPosLeft` : what menu to show on the left of the navbar +- `navbarPosMiddle` : what menu to show in the middle of the navbar +- `navbarPosRight` : what menu to show on the right of the navbar +- `navbarShowSub` : show the sub navbar. This menu is pulled from the `submenu` page in the current or parent namespaces. The menu is also shown on child pages. If no page is found, the sub navbar is automatically hidden - * `heroTitle` : show the hero block on pages - * `heroImagePropagation` : search for hero images in parent namespaces if none is found in the current namespace +- `searchButton` : show the search button as a icon or text - * `tagsConsolidate` : Consolidate tags found in the current page and display it in the hero, content header or sidebar +- `heroTitle` : show the hero block on pages +- `heroImagePropagation` : search for hero images in parent namespaces if none is found in the current namespace - * `breadcrumbHideHome` : hide breadcrumbs in the root namespace - * `breadcrumbPosition` : where to display the breadcrumbs, either under the navbar, in the hero element or above the page content - * `breadcrumbPrefix` : enable changing the breadcrumb prefix - * `breadcrumbPrefixText` : text to set the breadcrumb prefix. Requires `breadcrumbPrefix` to be enabled - * `breadcrumbSep` : enable changing the breadcrumb seperator - * `breadcrumbSepText` : text to set the breadcrumb seperator. Requires `breadcrumbSep` to be enabled - * `breadcrumbHome` : change the breadcrumb home item to none, page title of root page, 'home' or an icon/image. The 'home' text is pulled from the `home` language value - * `breadcrumbShowLast` : only show an amount of breadcrumbs from the last. Will also show the home item in the list if enabled. Set this to `0` to show all items +- `tagsConsolidate` : Consolidate tags found in the current page and display it in the hero, content header or sidebar - * `sidebarShowLeft` : show the left sidebar if content is found - * `sidebarLeftRow1` : content to show in the first row of the left sidebar - * `sidebarLeftRow2` : content to show in the second row of the left sidebar - * `sidebarLeftRow3` : content to show in the third row of the left sidebar - * `sidebarLeftRow4` : content to show in the forth row of the left sidebar - * `sidebarMobileDefaultCollapse` : collapse the sidebars by default when viewed on mobile - * `sidebarShowRight` : show the right sidebar if content is found +- `breadcrumbHideHome` : hide breadcrumbs in the root namespace +- `breadcrumbPosition` : where to display the breadcrumbs, either under the navbar, in the hero element or above the page content +- `breadcrumbPrefix` : enable changing the breadcrumb prefix +- `breadcrumbPrefixText` : text to set the breadcrumb prefix. Requires `breadcrumbPrefix` to be enabled +- `breadcrumbSep` : enable changing the breadcrumb seperator +- `breadcrumbSepText` : text to set the breadcrumb seperator. Requires `breadcrumbSep` to be enabled +- `breadcrumbHome` : change the breadcrumb home item to none, page title of root page, 'home' or an icon/image. The 'home' text is pulled from the `home` language value +- `breadcrumbShowLast` : only show an amount of breadcrumbs from the last. Will also show the home item in the list if enabled. Set this to `0` to show all items - * `tocFull` : show the table of contents as a full height item +- `sidebarShowLeft` : show the left sidebar if content is found +- `sidebarLeftRow1` : content to show in the first row of the left sidebar +- `sidebarLeftRow2` : content to show in the second row of the left sidebar +- `sidebarLeftRow3` : content to show in the third row of the left sidebar +- `sidebarLeftRow4` : content to show in the forth row of the left sidebar +- `sidebarMobileDefaultCollapse` : collapse the sidebars by default when viewed on mobile +- `sidebarShowRight` : show the right sidebar if content is found - * `pageToolsFloating` : when and if to show the floating page tools - * `pageToolsFooter` : when and if to show page tools in the footer +- `tocFull` : show the table of contents as a full height item - * `footerCustomMenuText` : custom menu to use in the footer. Menu items are in the format of url|title with each item seperated by a semicolon - * `footerSearch` : show the search bar in the footer +- `pageToolsFloating` : when and if to show the floating page tools +- `pageToolsFooter` : when and if to show page tools in the footer - * `licenseType` : how to show the license in the footer - * `licenseImageOnly` : show the license in the footer as an image only. Requires `licenseType` to at least be enabled +- `footerCustomMenuText` : custom menu to use in the footer. Menu items are in the format of url|title with each item seperated by a semicolon +- `footerSearch` : show the search bar in the footer - * `includePageUseACL` : respect ACL when including pages - * `includePagePropagate` : search parent namespaces when including pages +- `licenseType` : how to show the license in the footer +- `licenseImageOnly` : show the license in the footer as an image only. Requires `licenseType` to at least be enabled +- `includePageUseACL` : respect ACL when including pages +- `includePagePropagate` : search parent namespaces when including pages ## Include Pages The following pages can be either html files in the root of the template or a page in the namespace. Namespace pages take priority. - * `topheader` : content to include above the navbar - * `header` : content include below the navbar but above the page content - * `contentheader` : content to include above the page content - * `contentfooter` : content to include below the page content - * `sidebarheader` : content to include above the left sidebar content - * `sidebarfooter` : content to include below the left sidebar content - * `rightsidebarheader` : content to include above the right sidebar content - * `rightsidebarfooter` : content to include below the right sidebar content - * `footer` : content to include in the footer - * `bottomfooter` : content to include below the footer - +- `topheader` : content to include above the navbar +- `header` : content include below the navbar but above the page content +- `contentheader` : content to include above the page content +- `contentfooter` : content to include below the page content +- `sidebarheader` : content to include above the left sidebar content +- `sidebarfooter` : content to include below the left sidebar content +- `rightsidebarheader` : content to include above the right sidebar content +- `rightsidebarfooter` : content to include below the right sidebar content +- `footer` : content to include in the footer +- `bottomfooter` : content to include below the footer ## Include Images The following images can be used to replace content in the template. Images can be in the root of the template or in the namespace. Images can be either png, jpg, gif or svg. - * `logo` : site logo in the navbar - * `breadcrumb-prefix` breadcrumb prefix - * `breadcrumb-sep` breadcrumb seperator - * `hero` hero image for hero element - +- `logo` : site logo in the navbar +- `breadcrumb-prefix` breadcrumb prefix +- `breadcrumb-sep` breadcrumb seperator +- `hero` hero image for hero element ## Hero Element - * `title` : The hero title is sourced from the page title. The page title is removed from the page content - * `subtitle` : Pages can set the subtitle by inserting `~~hero-subtitle TEXT~~` in the page content - * `image` : The hero image is sourced from an image named hero in the current or parental namespace. Namespace searching can be confined by the `includePagePropagate` setting. Pages can also override the image by inserting `~~hero-image URL~~` in the page content. DokuWiki and external URLs are supported - * `colors` : Colors can be overridden by including `~~hero-colors BACKGROUND_COLOR HERO_TITLE_COLOR HERO_SUBTITLE_COLOR BREADCRUMB_TEXT_COLOR BREADCRUMB_HOVER_COLOR~~`. You do not need to include all the color options. Use 'initial' to skip a color override +- `title` : The hero title is sourced from the page title. The page title is removed from the page content +- `subtitle` : Pages can set the subtitle by inserting `~~hero-subtitle TEXT~~` in the page content +- `image` : The hero image is sourced from an image named hero in the current or parental namespace. Namespace searching can be confined by the `includePagePropagate` setting. Pages can also override the image by inserting `~~hero-image URL~~` in the page content. DokuWiki and external URLs are supported +- `colors` : Colors can be overridden by including `~~hero-colors BACKGROUND_COLOR HERO_TITLE_COLOR HERO_SUBTITLE_COLOR BREADCRUMB_TEXT_COLOR BREADCRUMB_HOVER_COLOR~~`. You do not need to include all the color options. Use 'initial' to skip a color override + +Namespaces can also apply the above hero settings in child pages by including the above settings in a page named `theme`. + +## Hiding Elements -Namespaces can also apply the above hero settings in child pages by including the above settings in a page named `theme`. +Mikio now supports hiding elements using the `~~hide-parts (parts)~~` macro. Each element within the hide-parts macro is required to be seperated by spaces. Currently the following parts are supported: +- `topheader` : content above the navbar +- `navbar` : the main navigation bar +- `header` : content below the navbar but above the page content +- `hero` : the page hero bar +- `contentheader` : content above the page content +- `contentfooter` : content below the page content +- `sidebarheader` : content above the left sidebar content +- `sidebarfooter` : content below the left sidebar content +- `rightsidebarheader` : content above the right sidebar content +- `rightsidebarfooter` : content below the right sidebar content +- `footer` : content in the footer +- `bottomfooter` : content below the footer + +To hide the topheader, navbar and hero, you would use the macro `~~hide-parts topheader navbar hero~~` ## Icon Engine - * Mikio includes an icon engine that allows you to include icons in your pages by using in your content - * If the icon tag conflicts with another plugin, you can change the tag from `icon` to a user set value in the settings - * By default, Mikio enables FontAwesome 4 by also includes FontAwesome 5, Elusive 2 and Bootstrap Icons which can be enabled by uncommenting their inclusions in `/icons/icons.php` +- Mikio includes an icon engine that allows you to include icons in your pages by using in your content +- If the icon tag conflicts with another plugin, you can change the tag from `icon` to a user set value in the settings +- By default, Mikio enables FontAwesome 4 by also includes FontAwesome 5, Elusive 2 and Bootstrap Icons which can be enabled by uncommenting their inclusions in `/icons/icons.php` Users can also add their own icon sets into the template. Supported icon sets can either be webfonts or indivial files (such as a SVG library). Instructions can be found in the `/icons/icons.php` file. - ## Themes Themes should be placed in the themes directory, in its own directory. LESS files are supported. - ## Mikio Plugin The [Mikio Plugin](https://github.com/nomadjimbob/mikioplugin/) is also available to add bootstrap 4 style + more elements to DokuWiki pages. - ## Languages - * `sidebar-title` : Text for the collapsable block in the sidebar - * `tools-menu` : Text for the combined tools DokuWiki menu title - * `home` : Text for the breadcrumb home title - +- `sidebar-title` : Text for the collapsable block in the sidebar +- `tools-menu` : Text for the combined tools DokuWiki menu title +- `home` : Text for the breadcrumb home title ## Releases - * ***2021-01-22*** - * Fixed a syntax error with the core css +- **_2021-03-04_** + + - Added support to hide page elements [#18](https://github.com/nomadjimbob/mikio/issues/18) + +- **_2021-01-22_** + + - Fixed a syntax error with the core css + +- **_2020-11-12_** + + - Corrected terminology in readme to match Dokuwiki [#17](https://github.com/nomadjimbob/mikio/issues/17) + - Fix showing part of the sidebar when it should be hidden in certain conditions [#16](https://github.com/nomadjimbob/mikio/issues/16) + - Added option to always show the sidebar, even when there is no content [#16](https://github.com/nomadjimbob/mikio/issues/16) + +- **_2020-10-07_** + + - Fixed hero header parsing on some servers + - Fixed safari color picker issue [#14](https://github.com/nomadjimbob/mikio/issues/14) + - LESS now defaults to enabled with fallback to ctype functions built into mikio for docker apps [#13](https://github.com/nomadjimbob/mikio/issues/13) + - Fix for Template Style Settings being ignored [#12](https://github.com/nomadjimbob/mikio/issues/12) + +- **_2020-10-01_** + + - Fix for `sidebarMobileDefaultCollapse` option being inconsistent in code and not working correctly [#11](https://github.com/nomadjimbob/mikio/issues/11). Thanks to GJRobert for catching that. + +- **_2020-09-27_** + + - Sidebars hidden by default in mobile view [#10](https://github.com/nomadjimbob/mikio/issues/10) + - Fixed errors with the LESS compilier on some nginx configurations + - Fixed styling and image display thumb size in media manager popup + - Fixed text field placeholders not disappearing with text entry + - Added support for Hogfather + - Added option to use LESS or direct CSS. Some configurations (docker linuxserver/dokuwiki) do not have the required PHP extensions installed + - Supports Docker linuxserver/dokuwiki container file structures + +- **_2020-09-10_** + + - Floating page tools is now a UL element with classes applied from getType and getLinkAttributes. Fixes popup dialogs initiated from the a page menu [#7](https://github.com/nomadjimbob/mikio/issues/7) + - Template.info.txt now shows correct release dates [#8](https://github.com/nomadjimbob/mikio/issues/8) + - Fixed rightsidebar php warnings + - Code/Pre blocks no longer have padding applied on the admin pages + +- **_2020-08-26_** + + - Footer is no longer shown outside of page view + - Public messages are now displayed on the page + - Fixed icon rendering in hero bar + - Fixed TOC rendering bug - * ***2020-11-12*** - * Corrected terminology in readme to match Dokuwiki [#17](https://github.com/nomadjimbob/mikio/issues/17) - * Fix showing part of the sidebar when it should be hidden in certain conditions [#16](https://github.com/nomadjimbob/mikio/issues/16) - * Added option to always show the sidebar, even when there is no content [#16](https://github.com/nomadjimbob/mikio/issues/16) +- **_2020-07-27_** - * ***2020-10-07*** - * Fixed hero header parsing on some servers - * Fixed safari color picker issue [#14](https://github.com/nomadjimbob/mikio/issues/14) - * LESS now defaults to enabled with fallback to ctype functions built into mikio for docker apps [#13](https://github.com/nomadjimbob/mikio/issues/13) - * Fix for Template Style Settings being ignored [#12](https://github.com/nomadjimbob/mikio/issues/12) + - Added option to show wiki footer in page content - * ***2020-10-01*** - * Fix for `sidebarMobileDefaultCollapse` option being inconsistent in code and not working correctly [#11](https://github.com/nomadjimbob/mikio/issues/11). Thanks to GJRobert for catching that. +- **_2020-07-24_** - * ***2020-09-27*** - * Sidebars hidden by default in mobile view [#10](https://github.com/nomadjimbob/mikio/issues/10) - * Fixed errors with the LESS compilier on some nginx configurations - * Fixed styling and image display thumb size in media manager popup - * Fixed text field placeholders not disappearing with text entry - * Added support for Hogfather - * Added option to use LESS or direct CSS. Some configurations (docker linuxserver/dokuwiki) do not have the required PHP extensions installed - * Supports Docker linuxserver/dokuwiki container file structures + - Fixed image detail bug - * ***2020-09-10*** - * Floating page tools is now a UL element with classes applied from getType and getLinkAttributes. Fixes popup dialogs initiated from the a page menu [#7](https://github.com/nomadjimbob/mikio/issues/7) - * Template.info.txt now shows correct release dates [#8](https://github.com/nomadjimbob/mikio/issues/8) - * Fixed rightsidebar php warnings - * Code/Pre blocks no longer have padding applied on the admin pages +- **_2020-07-20_** - * ***2020-08-26*** - * Footer is no longer shown outside of page view - * Public messages are now displayed on the page - * Fixed icon rendering in hero bar - * Fixed TOC rendering bug + - Fixed prewrap and sidebar search bar margins - * ***2020-07-27*** - * Added option to show wiki footer in page content +- **_2020-07-16_** - * ***2020-07-24*** - * Fixed image detail bug + - Merged code block styling with pre + - Fixed mediamanager failures on 2018-04-22a "Greebo" [#5](https://github.com/nomadjimbob/mikio/issues/5) + - Icon tag is rendered correctly in preview [#4](https://github.com/nomadjimbob/mikio/issues/4) - * ***2020-07-20*** - * Fixed prewrap and sidebar search bar margins +- **_2020-07-15_** - * ***2020-07-16*** - * Merged code block styling with pre - * Fixed mediamanager failures on 2018-04-22a "Greebo" [#5](https://github.com/nomadjimbob/mikio/issues/5) - * Icon tag is rendered correctly in preview [#4](https://github.com/nomadjimbob/mikio/issues/4) + - Fixed an issue with the simple_html_dom library when editing a section of a page caused page corruption [#3](https://github.com/nomadjimbob/mikio/issues/3) - * ***2020-07-15*** - * Fixed an issue with the simple_html_dom library when editing a section of a page caused page corruption [#3](https://github.com/nomadjimbob/mikio/issues/3) +- **_2020-07-14_** - * ***2020-07-14*** - * Added id=dokuwiki__content identifier for the page content element - * Added styling and fixed overflow issues with pre elements - * Fixed page width overflow issues + - Added id=dokuwiki\_\_content identifier for the page content element + - Added styling and fixed overflow issues with pre elements + - Fixed page width overflow issues - * ***2020-07-09*** - * Fixed cosmetic display issues when `input[type=file]` is hidden by plugins [#2](https://github.com/nomadjimbob/mikio/issues/2) +- **_2020-07-09_** - * ***2020-07-07*** - * Initial release + - Fixed cosmetic display issues when `input[type=file]` is hidden by plugins [#2](https://github.com/nomadjimbob/mikio/issues/2) +- **_2020-07-07_** + - Initial release ## Third Party Libraries @@ -226,5 +251,5 @@ This template uses a [modified version](https://github.com/nomadjimbob/simple_ht ## Support - * If you think you have found a problem, or would like to see a feature, please [open an issue](https://github.com/nomadjimbob/mikio/issues) - * If you are a coder, feel free to create a pull request, but please be detailed about your changes! +- If you think you have found a problem, or would like to see a feature, please [open an issue](https://github.com/nomadjimbob/mikio/issues) +- If you are a coder, feel free to create a pull request, but please be detailed about your changes! diff --git a/assets/mikio.js b/assets/mikio.js index 5a159a5..beac7c1 100644 --- a/assets/mikio.js +++ b/assets/mikio.js @@ -466,6 +466,29 @@ var mikio = { Array.from(document.getElementsByClassName('mikio-tags')).forEach(function(elem) { elem.innerHTML = str; }); + }, + + hidePart: function (part) { + var selectorArray = { + topheader: '.mikio-page-topheader', + header: '.mikio-page-header', + contentheader: '.mikio-page-contentheader', + contentfooter: '.mikio-page-contentfooter', + sidebarheader: '.mikio-sidebar-left .mikio-sidebar-header', + sidebarfooter: '.mikio-sidebar-left .mikio-sidebar-footer', + rightsidebarheader: '.mikio-sidebar-right .mikio-sidebar-header', + rightsidebarfooter: '.mikio-sidebar-right .mikio-sidebar-footer', + footer: '.mikio-footer', + bottomfooter: '.mikio-page-bottomfooter', + navbar: '.mikio-navbar', + hero: '.mikio-hero' + }; + + if(selectorArray.hasOwnProperty(part)) { + Array.from(document.querySelectorAll(selectorArray[part])).forEach(function (elem) { + elem.style.display = 'none'; + }); + } } }; diff --git a/mikio.php b/mikio.php index 6cbe370..8738b8c 100644 --- a/mikio.php +++ b/mikio.php @@ -1326,6 +1326,36 @@ public function parseContent($content) { } } + /* Hide parts - ~~hide-parts [parts]~~ */ + foreach($html->find('p') as $elm) { + $i = stripos($elm->innertext, '~~hide-parts'); + if($i !== false) { + $j = strpos($elm->innertext, '~~', $i + 2); + if($j !== false) { + if($j > $i + 13) { + $parts = explode(' ', substr($elm->innertext, $i + 13, $j - $i - 13)); + $script = ''; + + foreach($parts as $part) { + // $part = trim($part); + if(strlen($part) > 0) { + $script .= 'mikio.hidePart(\'' . $part .'\');'; + } + } + + if(strlen($script) > 0) { + $this->footerScript['hide-parts'] = $script; + } + + $elm->innertext = preg_replace('/~~hide-parts (.+?)~~.*/ui', '', $elm->innertext); + } + + break; + } + } + } + + /* Page Tags (tag plugin) */ if($this->getConf('tagsConsolidate')) { $tags = '';