diff --git a/data/config.ini b/data/config.ini index 9fe2e4f6..e178b64a 100644 --- a/data/config.ini +++ b/data/config.ini @@ -1,5 +1,5 @@ [chibi] -prettyPrint=1 +enableCache=1 [main] dbDriver = "sqlite" diff --git a/lib/chibi-core b/lib/chibi-core index 9653960e..4628a3d8 160000 --- a/lib/chibi-core +++ b/lib/chibi-core @@ -1 +1 @@ -Subproject commit 9653960e235c2c932bce404d3fe8ff4ea3990e08 +Subproject commit 4628a3d8dde54b411294be6c07b62a163cd9c774 diff --git a/src/Bootstrap.php b/src/Bootstrap.php index 9e2cb4ce..6b581cfc 100644 --- a/src/Bootstrap.php +++ b/src/Bootstrap.php @@ -3,24 +3,10 @@ class Bootstrap { public function render($callback = null) { - if ($callback === null) - { - $callback = function() - { - (new \Chibi\View())->renderFile($this->context->layoutName); - }; - } - - if ($this->context->layoutName == 'layout-normal') - { - ob_start(['LayoutHelper', 'transformHtml']); + if ($callback !== null) $callback(); - ob_end_flush(); - } else - { - $callback(); - } + (new \Chibi\View())->renderFile($this->context->layoutName); } public function workWrapper($workCallback) @@ -29,7 +15,7 @@ class Bootstrap session_start(); $this->context->handleExceptions = false; - LayoutHelper::setTitle($this->config->main->title); + CustomAssetViewDecorator::setTitle($this->config->main->title); $this->context->json = isset($_GET['json']); $this->context->layoutName = $this->context->json @@ -48,6 +34,8 @@ class Bootstrap return; } + $this->context->viewDecorators []= new CustomAssetViewDecorator(); + $this->context->viewDecorators []= new \Chibi\PrettyPrintViewDecorator(); try { $this->render($workCallback); diff --git a/src/Helpers/CustomAssetViewDecorator.php b/src/Helpers/CustomAssetViewDecorator.php new file mode 100644 index 00000000..86acb35c --- /dev/null +++ b/src/Helpers/CustomAssetViewDecorator.php @@ -0,0 +1,40 @@ +'; + $headSnippet .= ''; + if (!empty(self::$pageThumb)) + $headSnippet .= ''; + + $bodySnippet = ''; + + $html = str_replace('', $headSnippet . '', $html); + $html = str_replace('', $bodySnippet . '', $html); + return $html; + } +} diff --git a/src/Helpers/LayoutHelper.php b/src/Helpers/LayoutHelper.php deleted file mode 100644 index a4ce0a92..00000000 --- a/src/Helpers/LayoutHelper.php +++ /dev/null @@ -1,66 +0,0 @@ -' . $title . ''; - - $headSnippet .= ''; - $headSnippet .= ''; - if (!empty(self::$pageThumb)) - $headSnippet .= ''; - - foreach (array_unique(self::$stylesheets) as $name) - $headSnippet .= ''; - - foreach (array_unique(self::$scripts) as $name) - $bodySnippet .= ''; - - $bodySnippet .= ''; - - $html = str_replace('', $headSnippet . '', $html); - $html = str_replace('', $bodySnippet . '', $html); - return $html; - } -} diff --git a/src/Views/auth-login.phtml b/src/Views/auth-login.phtml index 4defa9af..5c72cbd8 100644 --- a/src/Views/auth-login.phtml +++ b/src/Views/auth-login.phtml @@ -1,6 +1,6 @@
diff --git a/src/Views/comment-add.phtml b/src/Views/comment-add.phtml index ca581dc2..bfd9734f 100644 --- a/src/Views/comment-add.phtml +++ b/src/Views/comment-add.phtml @@ -1,6 +1,6 @@ diff --git a/src/Views/comment-edit.phtml b/src/Views/comment-edit.phtml index 6069f03a..e368d5ef 100644 --- a/src/Views/comment-edit.phtml +++ b/src/Views/comment-edit.phtml @@ -1,6 +1,6 @@ diff --git a/src/Views/comment-list.phtml b/src/Views/comment-list.phtml index 91caa144..021b26da 100644 --- a/src/Views/comment-list.phtml +++ b/src/Views/comment-list.phtml @@ -1,15 +1,15 @@ context->transport->posts)): ?>

No comments to show.

diff --git a/src/Views/comment-small.phtml b/src/Views/comment-small.phtml index f9567def..4a2aabea 100644 --- a/src/Views/comment-small.phtml +++ b/src/Views/comment-small.phtml @@ -1,7 +1,7 @@
diff --git a/src/Views/debug.phtml b/src/Views/debug.phtml index d49d2973..80c3ac62 100644 --- a/src/Views/debug.phtml +++ b/src/Views/debug.phtml @@ -1,4 +1,4 @@ - +
diff --git a/src/Views/index-help.phtml b/src/Views/index-help.phtml index d231edb7..94519725 100644 --- a/src/Views/index-help.phtml +++ b/src/Views/index-help.phtml @@ -1,6 +1,6 @@ config->help->subTitles; $firstTab = !empty($tabs) ? array_keys($tabs)[0] : null; diff --git a/src/Views/index-index.phtml b/src/Views/index-index.phtml index e5523586..b44ca4f8 100644 --- a/src/Views/index-index.phtml +++ b/src/Views/index-index.phtml @@ -1,6 +1,6 @@
diff --git a/src/Views/layout-normal.phtml b/src/Views/layout-normal.phtml index a7f440bd..ace048bf 100644 --- a/src/Views/layout-normal.phtml +++ b/src/Views/layout-normal.phtml @@ -1,10 +1,10 @@ diff --git a/src/Views/log-view.phtml b/src/Views/log-view.phtml index 91cf6ccc..a0b9827d 100644 --- a/src/Views/log-view.phtml +++ b/src/Views/log-view.phtml @@ -1,13 +1,13 @@ context->transport->lines)): ?>

This log is empty. Go back

diff --git a/src/Views/paginator.phtml b/src/Views/paginator.phtml index 2ac00a64..4b037f11 100644 --- a/src/Views/paginator.phtml +++ b/src/Views/paginator.phtml @@ -42,9 +42,9 @@ if (!function_exists('pageUrl')) context->user->hasEnabledEndlessScrolling()) - LayoutHelper::addScript('paginator-endless.js'); + CustomAssetViewDecorator::addScript('paginator-endless.js'); ?>