forked from laysense/laysite
Allow deleting and recreating the homepage
This commit is contained in:
@@ -47,7 +47,12 @@ foreach (['header', 'footer'] as $kind) {
|
||||
$type = $page['page_type'];
|
||||
$kind = $page['layout_kind'] ?? (isset(SystemPage::TYPES[$type]) ? $type : null);
|
||||
$label = $kind === null ? '' : ($pageTypeLabels[$kind] ?? '');
|
||||
$path = $page['slug'] === 'home' ? '/' : '/' . $page['slug'];
|
||||
$home = $page['slug'] === 'home';
|
||||
$path = $home ? '/' : '/' . $page['slug'];
|
||||
$deleteNote = '确定删除「' . $page['name'] . '」?此操作不可撤销。';
|
||||
if ($home) {
|
||||
$deleteNote .= '删除首页后,访问 / 将显示 404 页面。';
|
||||
}
|
||||
$published = $page['status'] === 'published';
|
||||
$public = $kind === null && $published;
|
||||
?>
|
||||
@@ -65,14 +70,12 @@ foreach (['header', 'footer'] as $kind) {
|
||||
'icon' => $public ? 'external' : 'preview',
|
||||
'label' => ($public ? '查看公开页面' : '预览页面') . ' · ' . $page['name'],
|
||||
]) ?>
|
||||
<?php if ($page['slug'] !== 'home'): ?>
|
||||
<form method="post" action="/admin/pages/<?= $e($page['slug']) ?>/delete">
|
||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||
<input type="hidden" name="version" value="<?= $e($page['version']) ?>">
|
||||
<button class="button button-outline admin-view-link destructive-action" type="submit"
|
||||
title="删除页面" aria-label="删除页面" data-confirm="<?= $e('确定删除「' . $page['name'] . '」?此操作不可撤销。') ?>"><?= View::fragment('studio-icon', ['icon' => 'delete']) ?></button>
|
||||
</form>
|
||||
<?php endif ?>
|
||||
<form method="post" action="/admin/pages/<?= $e($page['slug']) ?>/delete">
|
||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||
<input type="hidden" name="version" value="<?= $e($page['version']) ?>">
|
||||
<button class="button button-outline admin-view-link destructive-action" type="submit"
|
||||
title="删除页面" aria-label="删除页面" data-confirm="<?= $e($deleteNote) ?>"><?= View::fragment('studio-icon', ['icon' => 'delete']) ?></button>
|
||||
</form>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
|
||||
@@ -314,7 +314,7 @@ $spacingPresets = [0, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128];
|
||||
<?php endif ?>
|
||||
<div class="form-submit studio-settings-actions">
|
||||
<button class="button button-primary" type="submit"><?= View::fragment('studio-icon', ['icon' => 'save']) ?>保存页面</button>
|
||||
<?php if (!$layout && $slug !== 'home'): ?>
|
||||
<?php if (!$layout): ?>
|
||||
<div class="studio-publication">
|
||||
<span>发布状态</span><span class="dashboard-page-state" data-page-publication data-published="<?= $published ? 'true' : 'false' ?>"><?= $published ? '已发布' : '草稿' ?></span>
|
||||
<button class="button button-outline" type="submit" name="status" value="<?= $published ? 'draft' : 'published' ?>" data-publish-button>
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
<div class="wrap">
|
||||
<p class="overline">404</p>
|
||||
<h1>页面未找到</h1>
|
||||
<p>请检查网址,或回到首页浏览产品与服务。</p>
|
||||
<a class="button button-primary" href="/">返回首页</a>
|
||||
<?php if ($atHomepage): ?>
|
||||
<p>当前没有可显示的首页。</p>
|
||||
<?php else: ?>
|
||||
<p>请检查网址,或返回首页。</p>
|
||||
<a class="button button-primary" href="/">返回首页</a>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -18,7 +18,7 @@ $e = View::escape(...);
|
||||
</select></label>
|
||||
<label>页面名称<input name="name" maxlength="100" value="<?= $e($name) ?>" required></label>
|
||||
<label data-new-page-slug<?= $type !== 'page' ? ' hidden' : '' ?>>网址标识<input name="slug" maxlength="70" value="<?= $e($slug) ?>" pattern="[a-z0-9]+(-[a-z0-9]+)*" placeholder="my-page"<?= $type === 'page' ? ' required' : ' disabled' ?>>
|
||||
<small>创建后为草稿。可在编辑画布中预览,并自行发布。</small>
|
||||
<small>创建后为草稿。网址标识为 home 的普通页面发布后会显示在首页(/)。</small>
|
||||
</label>
|
||||
<div class="form-submit"><button type="submit" class="button button-primary"><?= View::fragment('studio-icon', ['icon' => 'add']) ?>创建页面</button></div>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user