diff --git a/index.php b/index.php
old mode 100644
new mode 100755
index 1cfca5c..82de746
--- a/index.php
+++ b/index.php
@@ -2,189 +2,190 @@
$debug = '';
-Kirby::plugin('animaux/devkit', [
+Kirby::plugin(
name: 'animaux/devkit',
- version: '0.4.1',
+ version: '0.4.3',
info: [
'description' => 'Get easily accessible info on variables and data in frontend for template development.',
'homepage' => 'https://github.com/animaux/kirby-devkit',
'license' => 'MIT',
],
-
- 'hooks' => [
- 'page.render:after' => function (string $contentType, array $data, $html, Kirby\Cms\Page $page) {
-
- $kirby = $this;
- $user = $this->user();
- $site = $this->site();
- $files = $page->files();
- $content = $page->content();
- global $debug;
-
- function addVar($name, $value) {
- global $debug;
- $debug .= '
' . $name . '' . $value . '';
- }
+ extends: [
+ 'hooks' => [
+ 'page.render:after' => function (string $contentType, array $data, $html, Kirby\Cms\Page $page) {
- /* Check for ?devkit or ?dev, debug mode and logged in user */
- if ($kirby->option('debug') === true && $user && $user->isLoggedIn() && (isset($_GET['dev']) or isset($_GET['devkit']))) {
-
- $debug .= '';
- $debug .= '';
-
- /* System */
- addVar('kirby', Kirby::version());
- addVar('php', phpversion());
-
- $debug .= '
';
+ ul.debug > li > span {
+ flex: 1 0 0;
+ }
+
+ ul.files li {
+ display: flex;
+ flex-flow: row wrap;
+ gap: 1em;
+ }
+
+ ul.files li + li {
+ margin: .5em 0 0 0;
+ }
+
+ ul.files li * {
+ flex: 1;
+ }
+
+ ul.files li img {
+ max-width: 46px;
+ height: 46px;
+ }
+
+ ul.files div.file {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-weight: bold;
+ text-transform: uppercase;
+ letter-spacing: .05em;
+ max-width: 46px;
+ height: 46px;
+ color: black;
+ background: rgba(255,255,255,.5);
+ }
+ ';
+ $debug .= '';
- /* Basics */
- addVar('$site->title()', $site->title());
- addVar('$site->root()', $site->root());
- addVar('$site->url()', $site->url());
-
- $debug .= '
';
-
- /* User */
- addVar('$user', $user);
- addVar('$user->name()', $user->name());
- $debug .= '
';
-
-
- /* PageTemplates */
- addVar('$page->slug()', $page->slug());
- addVar('$page->intendedTemplate()', $page->intendedTemplate());
- addVar('$page->template()', $page->template());
- $debug .= '
';
+ /* System */
+ addVar('kirby', Kirby::version());
+ addVar('php', phpversion());
+
+ $debug .= '
';
+
+ /* Basics */
+ addVar('$site->title()', $site->title());
+ addVar('$site->root()', $site->root());
+ addVar('$site->url()', $site->url());
+
+ $debug .= '
';
+
+ /* User */
+ addVar('$user', $user);
+ addVar('$user->name()', $user->name());
+ $debug .= '
';
- /* Fields/Data */
- foreach($content->data() as $key => $val) {
- $debug .= '- $page->' . $key . '()';
- if (is_array($val)) {
- foreach ($val as $subKey => $subVal) {
- $debug .= '' . $subKey . ': ';
- /* Subarrays */
- if (is_array($subVal)) {
- foreach ($subVal as $subSubKey => $subSubVal) {
- $debug .= '[' . array_search($subSubKey,array_keys($subVal)) . '] ';
- if (is_string($subSubVal[0])) {
- $debug .= $subSubVal[0] . ' —> ' . $subSubVal[1];
+
+ /* PageTemplates */
+ addVar('$page->slug()', $page->slug());
+ addVar('$page->intendedTemplate()', $page->intendedTemplate());
+ addVar('$page->template()', $page->template());
+ $debug .= '
';
+
+ /* Fields/Data */
+ foreach($content->data() as $key => $val) {
+ $debug .= '- $page->' . $key . '()';
+ if (is_array($val)) {
+ foreach ($val as $subKey => $subVal) {
+ $debug .= '' . $subKey . ': ';
+ /* Subarrays */
+ if (is_array($subVal)) {
+ foreach ($subVal as $subSubKey => $subSubVal) {
+ $debug .= '[' . array_search($subSubKey,array_keys($subVal)) . '] ';
+ if (is_string($subSubVal[0])) {
+ $debug .= $subSubVal[0] . ' —> ' . $subSubVal[1];
+ }
+ if ($subSubKey != array_key_last($subVal)) {$debug .= '
';}
}
- if ($subSubKey != array_key_last($subVal)) {$debug .= '
';}
+ } else {
+ $debug .= $subVal;
}
- } else {
- $debug .= $subVal;
+ }
+ $debug .= '
';
+ } else {
+ /* Files */
+ if (is_string($val) && str_starts_with($val, '- file://')) {
+ $files = $page->$key()->sortBy('sort','desc')->toFiles();
+ $debug .= '';
+ } else if (is_string($val)) {
+ $debug .= $val;
}
}
- $debug .= '
';
- } else {
- /* Files */
- if (is_string($val) && str_starts_with($val, '- file://')) {
- $files = $page->$key()->sortBy('sort','desc')->toFiles();
- $debug .= '';
- } else if (is_string($val)) {
- $debug .= $val;
- }
+ $debug .= ' ';
}
- $debug .= ' ';
+ $debug .= '
';
}
- $debug .= '
';
- }
-
- /* Page Controllers abgrasen? */
- //$debug .= $kirby->controller($page->intendedTemplate()->name());
-
-
- /* Output */
- return $debug . $html;
-
- }
+
+ /* Page Controllers abgrasen? */
+ //$debug .= $kirby->controller($page->intendedTemplate()->name());
+
+
+ /* Output */
+ return $debug . $html;
+
+ }
+ ]
]
-]);
\ No newline at end of file
+);
\ No newline at end of file