From b564e69aafe840243ad351f65dea5beffb915914 Mon Sep 17 00:00:00 2001 From: Ole Vik Date: Thu, 20 Feb 2020 20:29:23 +0100 Subject: [PATCH] Lock to 1.6, gracefully fail --- CHANGELOG.md | 17 ++- README.md | 14 ++ blueprints.yaml | 213 +++++++++++++++++++++++++--- classes/Utilities.php | 6 + scholar.php | 4 + templates/partials/header.html.twig | 4 +- 6 files changed, 230 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c621094..17c67fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ +# v1.0.3 +## 20-02-2020 + +1. [](#new) + * Lock version to Grav 1.6.* until 1.7 stabilizes + * Silently fail on Flex +2. [](#bugfix) + * Gracefully fail lookups for Blueprints + * Fallback to Page titles if no menu-property is set + * Temporarily revert Blueprint-helpers + # v1.0.2 -## 28-12-2019 +## 28-12-2019 1. [](#improved) * Test-coverage @@ -9,7 +20,7 @@ * Article Search-field # v1.0.1 -## 27-12-2019 +## 27-12-2019 1. [](#improved) * Next- and previous-linking @@ -20,7 +31,7 @@ * Advanced Search link in Docs # v1.0.0 -## 25-12-2019 +## 25-12-2019 1. [](#new) * Initial public release diff --git a/README.md b/README.md index fdadb8a..b169813 100644 --- a/README.md +++ b/README.md @@ -67,3 +67,17 @@ This theme started as a clone of Paul Hibbitt's [Learn2 with Git Sync](https://g ## [Development](https://github.com/OleVik/grav-theme-scholar/blob/master/DEVELOPMENT.md) ## [Contributing](https://github.com/OleVik/grav-theme-scholar/blob/master/CONTRIBUTING.md) + +## TODO + +- [ ] Smaller type for related Pages + - [ ] Drop for Blog (or make dependant on Related?) + - [ ] Visible on mobile +- [ ] Enable header across the board + - [ ] Optional through toolbar.enabled +- [ ] Margin- and sidenotes across the board + - [ ] Theme.css adaptation +- [ ] Generalize chaper.html.twig and listing.html.twig + - [ ] Chapter: Hide all if content + - [ ] Listing: Show all always +- [ ] Extension: Filter content with FlexSearch \ No newline at end of file diff --git a/blueprints.yaml b/blueprints.yaml index 5646f1e..2fe1eeb 100644 --- a/blueprints.yaml +++ b/blueprints.yaml @@ -1,5 +1,5 @@ name: Scholar -version: 1.0.2 +version: 1.0.3 description: An academic-focused theme, for publishing papers, articles, books, documentation, your blog, and even your resumé. Features include high accessibility, fast performance, print-friendly styles and more. icon: book author: @@ -12,13 +12,13 @@ bugs: https://github.com/OleVik/grav-theme-scholar/issues readme: https://github.com/OleVik/grav-theme-scholar/blob/develop/README.md license: MIT dependencies: - - { name: grav, version: ">=1.7" } - - { name: error, version: ">=1.6.2" } - - { name: swiper, version: ">=1.0.0" } - - { name: problems, version: ">=2.0.3" } - - { name: breadcrumbs, version: ">=1.5.1" } - - { name: shortcode-core, version: ">=4.1.7" } - - { name: static-generator, version: ">=1.0.0" } + - { name: grav, version: "~1.6.21" } + - { name: error } + - { name: swiper } + - { name: problems } + - { name: breadcrumbs } + - { name: shortcode-core } + - { name: static-generator, version: "~1.0.0" } form: validation: strict @@ -30,24 +30,191 @@ form: options: type: tab title: PLUGIN_ADMIN.OPTIONS - data-fields@: - [ - '\Grav\Theme\Scholar::getConfigBlueprintFields', - "user://themes/scholar/blueprints/partials/basic.yaml", - ] + fields: + enabled: + type: toggle + label: PLUGIN_ADMIN.PLUGIN_STATUS + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + style: + type: select + label: THEME_SCHOLAR.ADMIN.STYLE + description: THEME_SCHOLAR.ADMIN.DESCRIPTION.STYLE + data-options@: '\Grav\Theme\Scholar::getStylesBlueprint' + toolbar.breadcrumbs: + type: toggle + label: THEME_SCHOLAR.TOOLBAR.BREADCRUMBS + description: THEME_SCHOLAR.ADMIN.DESCRIPTION.TOOLBAR + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + toolbar.search: + type: toggle + label: THEME_SCHOLAR.TOOLBAR.SEARCH + description: THEME_SCHOLAR.ADMIN.DESCRIPTION.TOOLBAR + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + toolbar.navigation: + type: toggle + label: THEME_SCHOLAR.TOOLBAR.NAVIGATION + description: THEME_SCHOLAR.ADMIN.DESCRIPTION.TOOLBAR + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + css: + type: toggle + label: THEME_SCHOLAR.ADMIN.CSS + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + js: + type: toggle + label: THEME_SCHOLAR.ADMIN.JS + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + itemize: + type: toggle + label: THEME_SCHOLAR.ADMIN.ITEMIZE + description: THEME_SCHOLAR.ADMIN.DESCRIPTION.ITEMIZE + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + linked_data: + type: toggle + label: THEME_SCHOLAR.ADMIN.LINKED_DATA + description: THEME_SCHOLAR.ADMIN.DESCRIPTION.LINKED_DATA + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + highlighter: + type: toggle + label: THEME_SCHOLAR.ADMIN.HIGHLIGHTER + description: THEME_SCHOLAR.ADMIN.DESCRIPTION.HIGHLIGHTER + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + flexsearch.enabled: + type: toggle + label: THEME_SCHOLAR.ADMIN.FLEXSEARCH + description: THEME_SCHOLAR.ADMIN.DESCRIPTION.FLEXSEARCH + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool advanced: type: tab title: PLUGIN_ADMIN.ADVANCED - data-fields@: - [ - '\Grav\Theme\Scholar::getConfigBlueprintFields', - "user://themes/scholar/blueprints/partials/advanced.yaml", - ] + fields: + components: + type: selectize + label: THEME_SCHOLAR.ADMIN.COMPONENTS + description: THEME_SCHOLAR.ADMIN.DESCRIPTION.COMPONENTS + allowEmptyOption: true + merge_items: true + selectize: + create: false + data-options@: '\Grav\Theme\Scholar::getComponentsBlueprint' + validate: + type: commalist + router: + type: toggle + label: THEME_SCHOLAR.ADMIN.API.ROUTER + description: THEME_SCHOLAR.ADMIN.DESCRIPTION.ROUTER + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + highlighter_theme: + type: select + label: THEME_SCHOLAR.ADMIN.HIGHLIGHTER_THEME + data-options@: '\Grav\Theme\Scholar::getHighlighterThemeBlueprint' + routes.data: + type: text + label: THEME_SCHOLAR.ADMIN.ROUTES.DATA + description: THEME_SCHOLAR.ADMIN.DESCRIPTION.ROUTES.DATA + routes.embed: + type: text + label: THEME_SCHOLAR.ADMIN.ROUTES.EMBED + description: THEME_SCHOLAR.ADMIN.DESCRIPTION.ROUTES.EMBED + routes.search: + type: text + label: THEME_SCHOLAR.ADMIN.ROUTES.SEARCH + description: THEME_SCHOLAR.ADMIN.DESCRIPTION.ROUTES.SEARCH + routes.print: + type: text + label: THEME_SCHOLAR.ADMIN.ROUTES.PRINT + description: THEME_SCHOLAR.ADMIN.DESCRIPTION.ROUTES.PRINT expert: type: tab title: PLUGIN_ADMIN.EXPERT - data-fields@: - [ - '\Grav\Theme\Scholar::getConfigBlueprintFields', - "user://themes/scholar/blueprints/partials/expert.yaml", - ] + fields: + notice: + type: spacer + title: THEME_SCHOLAR.ADMIN.NOTICE.TITLE + text: THEME_SCHOLAR.ADMIN.NOTICE.EXPERT + underline: true + api.content: + type: select + label: THEME_SCHOLAR.ADMIN.API.CONTENT + description: THEME_SCHOLAR.ADMIN.DESCRIPTION.API.CONTENT + data-options@: + - "\\Grav\\Theme\\Scholar::getClassNames" + - Content + api.linked_data.default: + type: select + label: THEME_SCHOLAR.ADMIN.API.LINKED_DATA.DEFAULT + description: THEME_SCHOLAR.ADMIN.DESCRIPTION.API.LINKED_DATA.DEFAULT + data-options@: + - "\\Grav\\Theme\\Scholar::getClassNames" + - LinkedData + api.linked_data.cv: + type: select + label: THEME_SCHOLAR.ADMIN.API.LINKED_DATA.CV + description: THEME_SCHOLAR.ADMIN.DESCRIPTION.API.LINKED_DATA.CV + data-options@: + - "\\Grav\\Theme\\Scholar::getClassNames" + - LinkedData + api.router: + type: select + label: THEME_SCHOLAR.ADMIN.API.ROUTER + description: THEME_SCHOLAR.ADMIN.DESCRIPTION.API.ROUTER + data-options@: + - "\\Grav\\Theme\\Scholar::getClassNames" + - Router + api.source: + type: select + label: THEME_SCHOLAR.ADMIN.API.SOURCE + description: THEME_SCHOLAR.ADMIN.DESCRIPTION.API.SOURCE + data-options@: + - "\\Grav\\Theme\\Scholar::getClassNames" + - Source + api.taxonomy_map: + type: select + label: THEME_SCHOLAR.ADMIN.API.TAXONOMY_MAP + description: THEME_SCHOLAR.ADMIN.DESCRIPTION.API.TAXONOMY_MAP + data-options@: + - "\\Grav\\Theme\\Scholar::getClassNames" + - TaxonomyMap diff --git a/classes/Utilities.php b/classes/Utilities.php index 28c3c63..47091bd 100644 --- a/classes/Utilities.php +++ b/classes/Utilities.php @@ -80,6 +80,9 @@ public static function folderFinder(string $folder, array $locations): string */ public static function filesFinder(string $directory, array $types): array { + if (!file_exists($directory)) { + return []; + } $iterator = new \RecursiveDirectoryIterator( $directory, \RecursiveDirectoryIterator::SKIP_DOTS @@ -109,6 +112,9 @@ public static function foldersFinder(array $locations): array { $return = array(); foreach ($locations as $location) { + if (!file_exists($location)) { + continue; + } $folders = new \DirectoryIterator($location); foreach ($folders as $folder) { if ($folder->isDir() && !$folder->isDot()) { diff --git a/scholar.php b/scholar.php index 441581b..c4a5d8b 100644 --- a/scholar.php +++ b/scholar.php @@ -67,6 +67,9 @@ public function onThemeInitialized() if ($this->config->get('themes.scholar.enabled') != true) { return; } + if ($this->config->get('system.pages.type') == "flex") { + return; + } $this->autoload(); if ($this->config->get('system.debugger.enabled')) { $this->grav['debugger']->startTimer('scholar', 'Scholar'); @@ -190,6 +193,7 @@ public static function getComponentsBlueprint(): array */ public static function getHighlighterThemeBlueprint(): array { + include __DIR__ . '/vendor/autoload.php'; $stylesFolders = Utils::arrayMergeRecursiveUnique( Utilities::filesFinder('theme://css/highlighter', ['css']), Utilities::filesFinder('user://themes/scholar/css/highlighter', ['css']) diff --git a/templates/partials/header.html.twig b/templates/partials/header.html.twig index dfcc8f0..f0e22b8 100644 --- a/templates/partials/header.html.twig +++ b/templates/partials/header.html.twig @@ -7,8 +7,8 @@ {% block links %}