xiaowang/kirby/views/panel.php

81 lines
1.8 KiB
PHP
Raw Permalink Normal View History

2021-10-29 18:05:46 +02:00
<?php
2022-08-31 16:08:03 +02:00
use Kirby\Cms\Url;
2021-10-29 18:05:46 +02:00
/**
* @var \Kirby\Cms\App $kirby
* @var string $icons
2021-11-18 17:44:47 +01:00
* @var array<string, mixed> $assets
* @var array<string, mixed> $fiber
2021-10-29 18:05:46 +02:00
* @var string $panelUrl
* @var string $nonce
*/ ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta name="referrer" content="same-origin">
<title>Kirby Panel</title>
2022-03-22 15:39:39 +01:00
<script nonce="<?= $nonce ?>">
2021-11-18 17:44:47 +01:00
if (
!window.CSS ||
window.CSS.supports("display", "grid") === false ||
!window.fetch
) {
window.location.href = "<?= $panelUrl ?>browser";
}
</script>
2021-10-29 18:05:46 +02:00
2021-11-18 17:44:47 +01:00
<?php foreach ($assets['css'] as $css): ?>
<link nonce="<?= $nonce ?>" rel="stylesheet" href="<?= $css ?>">
<?php endforeach ?>
2021-10-29 18:05:46 +02:00
2021-11-18 17:44:47 +01:00
<?php foreach ($assets['icons'] as $rel => $icon): ?>
2022-08-31 16:08:03 +02:00
<link nonce="<?= $nonce ?>" rel="<?= $rel ?>" href="<?= Url::to($icon['url']) ?>" type="<?= $icon['type'] ?>">
<?php endforeach ?>
<?php foreach ($assets['js'] as $js): ?>
<?php if (($js['type'] ?? null) === 'module'): ?>
<link rel="modulepreload" href="<?= $js['src'] ?>">
<?php endif ?>
2021-11-18 17:44:47 +01:00
<?php endforeach ?>
2021-10-29 18:05:46 +02:00
<base href="<?= $panelUrl ?>">
</head>
<body>
<div id="app"></div>
<noscript>
Please enable JavaScript in your browser
</noscript>
<?= $icons ?>
2021-11-18 17:44:47 +01:00
<script nonce="<?= $nonce ?>">
// Panel state
const json = <?= json_encode($fiber) ?>;
window.panel = JSON.parse(JSON.stringify(json));
// Fiber setup
window.fiber = json;
</script>
2022-08-31 16:08:03 +02:00
<?php foreach ($assets['js'] as $key => $js): ?>
<?php if ($key === 'index'): ?>
<script type="module" nonce="<?= $nonce ?>">
<?= $assets['plugin-imports'] ?>
import('<?= $js['src'] ?>')
</script>
<?php else: ?>
2021-11-18 17:44:47 +01:00
<?= Html::tag('script', '', $js) . PHP_EOL ?>
2022-08-31 16:08:03 +02:00
<?php endif ?>
2021-11-18 17:44:47 +01:00
<?php endforeach ?>
2021-10-29 18:05:46 +02:00
</body>
</html>