Skip to content

Commit

Permalink
✨ site/page->boost() forces ids to make migrations easier
Browse files Browse the repository at this point in the history
  • Loading branch information
bnomei committed Dec 3, 2021
1 parent 6bd0624 commit 9983165
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bnomei/kirby3-boost",
"type": "kirby-plugin",
"version": "1.7.0",
"version": "1.7.1",
"description": "Boost the speed of Kirby by having content files of pages cached, with automatic unique ID, fast lookup and Tiny-URL.",
"license": "MIT",
"authors": [
Expand Down
18 changes: 14 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,27 @@ function siteIndexFilterByBoostID(string $id): ?\Kirby\Cms\Page
return \Bnomei\Bolt::page($id, $this);
},
'boost' => function () {
$page = $this;

// has boost?
if ($this->hasBoost() === false) {
if ($page->hasBoost() === false) {
return false;
}
$this->boostIndexAdd();

// if not has an id force one
$page = $page->forceNewBoostId();

// needs write?
$lang = kirby()->languageCode();
$content = $this->readContentCache($lang);
$content = $page->readContentCache($lang);

// add after cache was read and id exists
$page->boostIndexAdd();

// if needs write
if (! $content) {
// then write
return $this->writeContentCache($this->content()->toArray(), $lang);
return $page->writeContentCache($page->content()->toArray(), $lang);
}
return true;
},
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php return array(
'root' => array(
'pretty_version' => '1.7.0',
'version' => '1.7.0.0',
'pretty_version' => '1.7.1',
'version' => '1.7.1.0',
'type' => 'kirby-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand All @@ -20,8 +20,8 @@
'dev_requirement' => false,
),
'bnomei/kirby3-boost' => array(
'pretty_version' => '1.7.0',
'version' => '1.7.0.0',
'pretty_version' => '1.7.1',
'version' => '1.7.1.0',
'type' => 'kirby-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand Down

0 comments on commit 9983165

Please sign in to comment.