From 3bbf06a19f08d9db1dc0db8312b90a4f2a422be2 Mon Sep 17 00:00:00 2001 From: Ole Vik Date: Fri, 12 Mar 2021 00:24:36 +0100 Subject: [PATCH] Fix search-pages, internals --- CHANGELOG.md | 16 +++++++++++++++- README.md | 6 +++--- blueprints.yaml | 2 +- classes/Content/Content.php | 11 ++++++----- classes/LinkedData/AbstractLinkedData.php | 2 +- classes/LinkedData/CVLinkedData.php | 2 +- classes/LinkedData/LinkedDataInterface.php | 2 +- classes/LinkedData/PageLinkedData.php | 2 +- classes/Router/Router.php | 12 +++++++----- classes/Router/RouterInterface.php | 3 ++- .../docs/partials/docs/toolbar/menu.html.twig | 6 +++--- pages/search.md | 1 - scholar.php | 7 +++++-- .../partials/components/search/assets.html.twig | 6 +++--- templates/partials/header.html.twig | 8 ++++---- templates/search.html.twig | 13 +++---------- 16 files changed, 56 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b8fd06..dc96850 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +# v3.0.0-beta.2 +## 12-03-2021 + +1. [](#new) + * `render`-variables for `templates/partials/header.html.twig` and `components/docs/partials/docs/toolbar/menu.html.twig` +2. [](#improved) + * Search-template + * Expect metadata in `user://data/persist/index.js` + * Expect full data in `user://data/persist/static/index.full.js` +3. [](#bugfix) + * API-alignment to use `Grav\Common\Page\Interfaces\PageInterface` + * ClassNames-getter + * Patch Router Page-instance + # v3.0.0-beta.1 ## 08-03-2021 @@ -8,7 +22,7 @@ * Dependencies strictness 2. [](#bugfix) * Relocate search-results for correct keyboard-navigation - * Forcibly cast Linked Dataas strings + * Forcibly cast Linked Data as strings * Fall back to `en` for Linked Data * Search-mechanisms * Remove redundant `aria-checked`-attribute diff --git a/README.md b/README.md index d62c6fb..b2cba4c 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ A demonstration is available at [OleVik.me/staging/grav-skeleton-scholar](https: ### Version 3.0.0 and higher -This major-version update targets compatibility with Grav Core 1.7, but also updates some internals. +This major-version update targets compatibility with Grav Core 1.7, and also updates and changes some internals. ### Grav Package Manager @@ -64,7 +64,7 @@ You should now have all the theme files under /your/site/grav/user/themes/scholar -This theme started as a clone of Paul Hibbitt's [Learn2 with Git Sync](https://github.com/hibbitts-design/grav-theme-learn2-git-sync)-theme, which is a customized version of the [Learn2](https://github.com/getgrav/grav-theme-learn2)-theme. As this theme decouples and supercedes much of the logic in either, it is rebranded as Scholar. +This theme started as a clone of Paul Hibbitt's [Learn2 with Git Sync](https://github.com/hibbitts-design/grav-theme-learn2-git-sync)-theme, which is a customized version of the [Learn2](https://github.com/getgrav/grav-theme-learn2)-theme. As this theme decouples and supercedes most of the logic in either, it is rebranded as Scholar. It also goes much further in what a documentation-theme can be and do. ## [Advanced Usage](https://github.com/OleVik/grav-theme-scholar/blob/master/ADVANCED.md) @@ -75,4 +75,4 @@ This theme started as a clone of Paul Hibbitt's [Learn2 with Git Sync](https://g ## TODO - [ ] Evaluate metadata text-wrapping -- [ ] Extension: Filter content with FlexSearch \ No newline at end of file +- [ ] Search: Replace with engine-agnostic approach, decoupling into a plugin \ No newline at end of file diff --git a/blueprints.yaml b/blueprints.yaml index 7d7b3ef..9ce2d4d 100644 --- a/blueprints.yaml +++ b/blueprints.yaml @@ -1,5 +1,5 @@ name: Scholar -version: 3.0.0-beta.1 +version: 3.0.0-beta.2 testing: true slug: scholar type: theme diff --git a/classes/Content/Content.php b/classes/Content/Content.php index 3d3c8a2..76573b7 100644 --- a/classes/Content/Content.php +++ b/classes/Content/Content.php @@ -1,4 +1,5 @@ createDocumentFragment(); $fragment->appendXML( '<' . $element->nodeName - . '>' . $element->textContent - . 'nodeName . '>' + . '>' . $element->textContent + . 'nodeName . '>' ); $element->parentNode->replaceChild($fragment, $element); } else { @@ -193,7 +194,7 @@ public static function wrapHTML(string $content, string $wrapperTag, array $targ $node = $doc->getElementsByTagName('body')[0]; return self::getInnerHTML($node, false); } - + /** * Extract headings from HTML * @@ -214,7 +215,7 @@ public static function buildList($data): string $href = $data[$title]['href']; $level = $data[$title]['level']; $nextLevel = $data[next($keys)]['level'] ?? null; - + if ($nextLevel > $level) { $output .= '
  • ' . $title . '
      '; } else { diff --git a/classes/LinkedData/AbstractLinkedData.php b/classes/LinkedData/AbstractLinkedData.php index 86371e7..414757e 100644 --- a/classes/LinkedData/AbstractLinkedData.php +++ b/classes/LinkedData/AbstractLinkedData.php @@ -17,7 +17,7 @@ use Grav\Common\Grav; use Grav\Common\Utils; -use Grav\Common\Page\Page; +use Grav\Common\Page\Interfaces\PageInterface as Page; use Spatie\SchemaOrg\Schema; use Grav\Theme\Scholar\Utilities; use Grav\Theme\Scholar\LinkedData\LinkedDataInterface; diff --git a/classes/LinkedData/CVLinkedData.php b/classes/LinkedData/CVLinkedData.php index 37615cb..7acc701 100644 --- a/classes/LinkedData/CVLinkedData.php +++ b/classes/LinkedData/CVLinkedData.php @@ -16,7 +16,7 @@ namespace Grav\Theme\Scholar\LinkedData; use Grav\Common\Inflector; -use Grav\Common\Page\Page; +use Grav\Common\Page\Interfaces\PageInterface as Page; use Grav\Common\Language\Language; /** diff --git a/classes/LinkedData/LinkedDataInterface.php b/classes/LinkedData/LinkedDataInterface.php index d06f7e5..aea1d2c 100644 --- a/classes/LinkedData/LinkedDataInterface.php +++ b/classes/LinkedData/LinkedDataInterface.php @@ -15,7 +15,7 @@ namespace Grav\Theme\Scholar\LinkedData; -use Grav\Common\Page\Page; +use Grav\Common\Page\Interfaces\PageInterface as Page; /** * Linked Data Interface diff --git a/classes/LinkedData/PageLinkedData.php b/classes/LinkedData/PageLinkedData.php index 5e49ca7..094dede 100644 --- a/classes/LinkedData/PageLinkedData.php +++ b/classes/LinkedData/PageLinkedData.php @@ -16,7 +16,7 @@ namespace Grav\Theme\Scholar\LinkedData; use Grav\Theme\Scholar; -use Grav\Common\Page\Page; +use Grav\Common\Page\Interfaces\PageInterface as Page; use Grav\Common\Language\Language; use Grav\Common\Config\Config; diff --git a/classes/Router/Router.php b/classes/Router/Router.php index da08b42..eebb237 100644 --- a/classes/Router/Router.php +++ b/classes/Router/Router.php @@ -53,7 +53,6 @@ public function __construct(Grav $Grav) $this->printRoute = $this->grav['config']->get('theme.routes.print') ?? $this->grav['config']->get('themes.scholar.routes.print') ?? '/print'; - $path = $this->grav['uri']->path(); if (\in_array( '/' . basename($path), @@ -65,11 +64,14 @@ public function __construct(Grav $Grav) ] )) { $page = $this->dispatch($path); - $page->parent( - $this->grav['pages']->find( - str_replace('/' . basename($path), '', $path) - ) + $parent = $this->grav['pages']->find( + str_replace('/' . basename($path), '', $path) ); + if ($parent == null) { + $parent = $this->grav['pages']->find('/'); + $parent->template('default'); + } + $page->parent($parent); } else { return; } diff --git a/classes/Router/RouterInterface.php b/classes/Router/RouterInterface.php index 9955756..bc8cbe1 100644 --- a/classes/Router/RouterInterface.php +++ b/classes/Router/RouterInterface.php @@ -1,4 +1,5 @@ {% block mobile %} - {% if config.theme.toolbar.navigation %} + {% if renderMobile ?? config.theme.toolbar.navigation %}
      {# Icon8 LineAwesome v1.3.0 Bars #} @@ -15,7 +15,7 @@ page.topParent.header.search, 'user://data/persist/index.js' ]) %} - {% if config.theme.toolbar.search and searchFile %} + {% if renderSearch ?? config.theme.toolbar.search and searchFile %}