forked from laysense/laysite
Prepare LaySite 1.5.0 canvas and publishing improvements
This commit is contained in:
+102
-65
@@ -10,6 +10,9 @@ use App\Content\View;
|
||||
$e = View::escape(...);
|
||||
$slug = $page['slug'];
|
||||
$path = $slug === 'home' ? '/' : '/' . $slug;
|
||||
$published = $page['status'] === 'published';
|
||||
$publicPage = !$page['layout_kind'] && $page['page_type'] === 'page';
|
||||
$paletteOptions = [['id' => '', 'name' => '页面原有配色', 'colors' => []], ...$palettes];
|
||||
$previewUrl = '/admin/pages/' . $slug . '/preview';
|
||||
$systemLabel = SystemPage::TYPES[$page['page_type']] ?? null;
|
||||
$fontSizes = [8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 28, 32, 36, 40, 48, 56, 64, 72, 96, 120, 144];
|
||||
@@ -17,9 +20,9 @@ $spacingPresets = [0, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128];
|
||||
?>
|
||||
<a class="back-link" href="/admin">返回页面</a>
|
||||
<header class="admin-heading">
|
||||
<div><h1><?= $e($title) ?></h1><p class="studio-page-meta">
|
||||
<div><h1 data-page-editor-title><?= $e($title) ?></h1><p class="studio-page-meta">
|
||||
<?php if ($layout): ?><span class="dashboard-page-state"><?= $e(LayoutPage::TYPES[$layout['kind']]) ?></span>
|
||||
<?php else: ?><?php if ($systemLabel): ?><span><?= $e($systemLabel) ?></span><?php else: ?><code><?= $e($path) ?></code><?php endif ?><span class="dashboard-page-state" data-published="<?= $page['status'] === 'published' ? 'true' : 'false' ?>"><?= $page['status'] === 'draft' ? '草稿' : '已发布' ?></span><?php endif ?>
|
||||
<?php else: ?><?php if ($systemLabel): ?><span><?= $e($systemLabel) ?></span><?php else: ?><code><?= $e($path) ?></code><?php endif ?><span class="dashboard-page-state" data-page-publication data-published="<?= $published ? 'true' : 'false' ?>"><?= $page['status'] === 'draft' ? '草稿' : '已发布' ?></span><?php endif ?>
|
||||
</p></div>
|
||||
<div class="actions">
|
||||
<a class="button button-outline" href="#studio-page-settings"><?= View::fragment('studio-icon', ['icon' => 'settings']) ?>页面设置</a>
|
||||
@@ -31,11 +34,14 @@ $spacingPresets = [0, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128];
|
||||
<?php endforeach ?>
|
||||
<button type="button" class="button button-outline" data-open-page-templates hidden><?= View::fragment('studio-icon', ['icon' => 'templates']) ?>整页模板</button>
|
||||
<?php if ($systemLabel): ?><a class="button button-outline" href="/admin/settings"><?= View::fragment('studio-icon', ['icon' => 'settings']) ?>站点设置</a>
|
||||
<?php elseif ($page['status'] === 'published'): ?><?= View::fragment('admin-view-link', ['href' => $path, 'icon' => 'external']) ?><?php endif ?>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
<?php if ($layout || $systemLabel || $page['status'] !== 'published'): ?>
|
||||
<?php if ($publicPage): ?>
|
||||
<span data-page-public<?= $published ? '' : ' hidden' ?>><?= View::fragment('admin-view-link', ['href' => $path, 'icon' => 'external']) ?></span>
|
||||
<?php endif ?>
|
||||
<span data-page-preview<?= $publicPage && $published ? ' hidden' : '' ?>>
|
||||
<?= View::fragment('admin-view-link', ['href' => $previewUrl, 'icon' => 'preview', 'label' => '预览已保存内容']) ?>
|
||||
<?php endif ?>
|
||||
</span>
|
||||
</div>
|
||||
</header>
|
||||
<?= View::fragment('admin-feedback', compact('error', 'saved')) ?>
|
||||
@@ -57,14 +63,17 @@ $spacingPresets = [0, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128];
|
||||
</div>
|
||||
</div>
|
||||
<div class="editor-toolbar studio-canvas-toolbar" data-canvas-toolbar hidden aria-label="正文工具">
|
||||
<div>
|
||||
<button type="button" data-canvas-command="heading">小标题</button>
|
||||
<button type="button" data-canvas-command="paragraph" title="换段(Ctrl/⌘+Enter)" aria-keyshortcuts="Control+Enter Meta+Enter">换段</button>
|
||||
<button type="button" data-canvas-command="list">列表</button>
|
||||
<button type="button" data-canvas-command="link">插入链接</button>
|
||||
<button type="button" data-canvas-command="media">插入媒体</button>
|
||||
<div data-canvas-text-commands role="group" aria-label="插入文本结构" hidden>
|
||||
<?php foreach (['heading' => '小标题', 'paragraph' => '换段', 'list' => '列表', 'link' => '插入链接'] as $command => $label): ?>
|
||||
<button type="button" data-canvas-command="<?= $command ?>" aria-label="<?= $label ?>"
|
||||
title="<?= $label ?><?= $command === 'paragraph' ? '(Ctrl/⌘+Enter)' : '' ?>"<?= $command === 'paragraph' ? ' aria-keyshortcuts="Control+Enter Meta+Enter"' : '' ?>><?= View::fragment('studio-icon', ['icon' => $command]) ?></button>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<div class="canvas-format-tools" role="group" aria-label="文字格式">
|
||||
<div role="group" aria-label="插入与填充" data-canvas-insert hidden>
|
||||
<button type="button" data-canvas-command="media" aria-label="插入媒体" title="插入媒体" hidden><?= View::fragment('studio-icon', ['icon' => 'media']) ?></button>
|
||||
<button type="button" data-canvas-background aria-label="背景填充" title="背景填充" hidden><?= View::fragment('studio-icon', ['icon' => 'fill']) ?></button>
|
||||
</div>
|
||||
<div class="canvas-format-tools" role="group" aria-label="文字格式" data-canvas-text-tools hidden>
|
||||
<div class="canvas-font-picker">
|
||||
<label for="canvas-font-size">字号</label>
|
||||
<div class="canvas-font-combo">
|
||||
@@ -75,18 +84,25 @@ $spacingPresets = [0, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128];
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<label>文字颜色 <input type="color" aria-label="文字颜色" data-canvas-color disabled></label>
|
||||
<button type="button" data-clear-color title="恢复默认文字颜色" aria-label="恢复默认文字颜色" disabled><?= View::fragment('studio-icon', ['icon' => 'refresh']) ?></button>
|
||||
<label>字距 <input type="number" data-canvas-letter min="-5" max="24" step="1" placeholder="px" aria-label="字距(px)"></label>
|
||||
<label>行距 <input type="number" data-canvas-line min="0.8" max="3" step="0.1" placeholder="倍" aria-label="行距(倍)"></label>
|
||||
<button type="button" data-canvas-color title="文字颜色" aria-label="文字颜色"><span aria-hidden="true">A</span><svg viewBox="0 0 16 4" aria-hidden="true"><rect width="16" height="4" rx="1" fill="currentColor"/></svg></button>
|
||||
<button type="button" data-canvas-format="weight" aria-label="加粗" title="加粗" aria-pressed="false" disabled><strong>B</strong></button>
|
||||
<button type="button" data-canvas-format="slant" aria-label="斜体" title="斜体" aria-pressed="false" disabled><em>I</em></button>
|
||||
<button type="button" data-canvas-format="strike" aria-label="删除线" title="删除线" aria-pressed="false" disabled><s>S</s></button>
|
||||
</div>
|
||||
<label class="canvas-image-display">图片布局 <select data-canvas-image-display disabled>
|
||||
<label class="canvas-image-display" hidden>图片布局 <select data-canvas-image-display disabled>
|
||||
<option value="">随模板</option><option value="block">块级</option><option value="inline">行内</option><option value="inline-block">行内块</option>
|
||||
</select></label>
|
||||
<div class="studio-media-sizing" data-media-sizing hidden>
|
||||
<output data-media-size aria-hidden="true"></output>
|
||||
<button class="button button-outline" type="button" data-reset-media>原始尺寸</button>
|
||||
<button class="button button-outline" type="button" data-replace-media>替换媒体</button>
|
||||
</div>
|
||||
<div role="group" aria-label="画布历史">
|
||||
<button type="button" data-canvas-history="undo" title="撤销(Ctrl/⌘ Z)" disabled>撤销</button>
|
||||
<button type="button" data-canvas-history="redo" title="重做(Ctrl/⌘ Shift Z)" disabled>重做</button>
|
||||
<?php foreach (['undo' => ['撤销', 'Ctrl/⌘+Z'], 'redo' => ['重做', 'Ctrl/⌘+Shift+Z']] as $direction => [$label, $shortcut]): ?>
|
||||
<button type="button" data-canvas-history="<?= $direction ?>" aria-label="<?= $label ?>" title="<?= $label ?>(<?= $shortcut ?>)" disabled><?= View::fragment('studio-icon', ['icon' => $direction]) ?></button>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<button class="button button-primary" form="studio-page-settings" type="submit"><?= View::fragment('studio-icon', ['icon' => 'save']) ?>保存页面</button>
|
||||
</div>
|
||||
@@ -103,13 +119,10 @@ $spacingPresets = [0, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128];
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<button class="studio-media-handle" type="button" role="slider" aria-label="媒体宽度" aria-valuemin="<?= CanvasStyle::MIN_MEDIA_SCALE ?>" aria-valuemax="100" aria-valuenow="100" data-media-handle hidden></button>
|
||||
<div class="studio-media-sizing" data-media-sizing hidden>
|
||||
<output data-media-size aria-hidden="true"></output>
|
||||
<button class="button button-outline" type="button" data-reset-media>原始尺寸</button>
|
||||
<button class="button button-outline" type="button" data-replace-media>替换媒体</button>
|
||||
</div>
|
||||
</div>
|
||||
<?= View::fragment('studio-fill') ?>
|
||||
<p class="field-note studio-canvas-status" data-canvas-status role="status"></p>
|
||||
<p class="feedback success" data-page-save-feedback role="status" hidden></p>
|
||||
<dialog class="media-picker canvas-source" data-canvas-source aria-labelledby="canvas-source-heading">
|
||||
<div class="admin-heading compact"><h2 id="canvas-source-heading">编辑区块 HTML</h2></div>
|
||||
<form class="admin-form" method="dialog">
|
||||
@@ -197,7 +210,7 @@ $spacingPresets = [0, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128];
|
||||
</dialog>
|
||||
</section>
|
||||
</div>
|
||||
<form id="studio-page-settings" class="admin-form admin-panel studio-inspector" method="post" action="/admin/pages/<?= $e($slug) ?>">
|
||||
<form id="studio-page-settings" class="admin-form admin-panel studio-inspector" data-save-inline data-public-page="<?= $publicPage ? '1' : '0' ?>" method="post" action="/admin/pages/<?= $e($slug) ?>">
|
||||
<h2>页面设置</h2>
|
||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||
<input type="hidden" name="version" value="<?= $e($page['version']) ?>">
|
||||
@@ -219,44 +232,60 @@ $spacingPresets = [0, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128];
|
||||
<?php if (!$layout && !$systemLabel && $slug !== 'home'): ?><button class="button button-outline" type="button" disabled data-hero-control="breadcrumbs">面包屑路径</button><?php endif ?>
|
||||
</div>
|
||||
</details>
|
||||
<label>页面名称<input name="name" value="<?= $e($page['name']) ?>" required maxlength="100"></label>
|
||||
<?php if ($layout): ?>
|
||||
<input type="hidden" name="title" value="<?= $e($page['title']) ?>">
|
||||
<?php if ($layoutDefault && $layoutBase): ?>
|
||||
<p class="field-note">当前站点默认<?= $e(LayoutPage::TYPES[$layout['kind']]) ?></p>
|
||||
<?php else: ?>
|
||||
<label><input type="checkbox" name="make_default" value="1"<?= $layoutDefault ? ' checked' : '' ?>> 用作站点默认<?= $e(LayoutPage::TYPES[$layout['kind']]) ?></label>
|
||||
<?php endif ?>
|
||||
<?php else: ?>
|
||||
<label>SEO 标题<input name="title" value="<?= $e($page['title']) ?>" required maxlength="160"></label>
|
||||
<label>SEO 描述<textarea name="description" rows="2" maxlength="300"><?= $e($page['description']) ?></textarea></label>
|
||||
<?php endif ?>
|
||||
<fieldset class="admin-options form-grid">
|
||||
<legend>页面显示</legend>
|
||||
<?php $heroVisible = $page['visibility']['hero'] ?? true; ?>
|
||||
<label>首屏<select name="show_hero"><option value="1"<?= $heroVisible ? ' selected' : '' ?>>显示</option>
|
||||
<option value="0"<?= !$heroVisible ? ' selected' : '' ?>>隐藏</option></select></label>
|
||||
<?php if (!$layout): ?>
|
||||
<?php foreach (['header' => '页头', 'footer' => '页脚'] as $kind => $label): ?>
|
||||
<?php $visible = $page['visibility'][$kind] ?? true; ?>
|
||||
<label><?= $e($label) ?><select name="<?= $e($kind) ?>_choice">
|
||||
<option value="hidden"<?= !$visible ? ' selected' : '' ?>>隐藏</option>
|
||||
<option value=""<?= $visible && $page[$kind . '_id'] === null ? ' selected' : '' ?>>站点默认</option>
|
||||
<?php foreach ($designs as $item): ?>
|
||||
<?php if ($item['kind'] !== $kind) continue; ?>
|
||||
<option value="<?= $e($item['id']) ?>"<?= $visible && $page[$kind . '_id'] === $item['id'] ? ' selected' : '' ?>><?= $e($item['name']) ?></option>
|
||||
<?php endforeach ?>
|
||||
</select></label>
|
||||
<?php endforeach ?>
|
||||
<label>配色方案<select name="palette_id">
|
||||
<option value="">页面原有配色</option>
|
||||
<?php foreach ($designs as $item): ?>
|
||||
<?php if ($item['kind'] !== 'palette') continue; ?>
|
||||
<option value="<?= $e($item['id']) ?>"<?= $page['palette_id'] === $item['id'] ? ' selected' : '' ?>><?= $e($item['name']) ?></option>
|
||||
<div class="studio-settings-grid">
|
||||
<div class="studio-settings-content">
|
||||
<label>页面名称<input name="name" value="<?= $e($page['name']) ?>" required maxlength="100"></label>
|
||||
<?php if ($layout): ?>
|
||||
<input type="hidden" name="title" value="<?= $e($page['title']) ?>">
|
||||
<?php if ($layoutDefault && $layoutBase): ?>
|
||||
<p class="field-note">当前站点默认<?= $e(LayoutPage::TYPES[$layout['kind']]) ?></p>
|
||||
<?php else: ?>
|
||||
<label><input type="checkbox" name="make_default" value="1"<?= $layoutDefault ? ' checked' : '' ?>> 用作站点默认<?= $e(LayoutPage::TYPES[$layout['kind']]) ?></label>
|
||||
<?php endif ?>
|
||||
<?php else: ?>
|
||||
<label>SEO 标题<input name="title" value="<?= $e($page['title']) ?>" required maxlength="160"></label>
|
||||
<label>SEO 描述<textarea name="description" rows="2" maxlength="300"><?= $e($page['description']) ?></textarea></label>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<fieldset class="admin-options form-grid">
|
||||
<legend>页面显示</legend>
|
||||
<?php $heroVisible = $page['visibility']['hero'] ?? true; ?>
|
||||
<label>首屏<select name="show_hero"><option value="1"<?= $heroVisible ? ' selected' : '' ?>>显示</option>
|
||||
<option value="0"<?= !$heroVisible ? ' selected' : '' ?>>隐藏</option></select></label>
|
||||
<?php if (!$layout): ?>
|
||||
<?php foreach (['header' => '页头', 'footer' => '页脚'] as $kind => $label): ?>
|
||||
<?php $visible = $page['visibility'][$kind] ?? true; ?>
|
||||
<label><?= $e($label) ?><select name="<?= $e($kind) ?>_choice">
|
||||
<option value="hidden"<?= !$visible ? ' selected' : '' ?>>隐藏</option>
|
||||
<option value=""<?= $visible && $page[$kind . '_id'] === null ? ' selected' : '' ?>>站点默认</option>
|
||||
<?php foreach ($designs as $item): ?>
|
||||
<?php if ($item['kind'] !== $kind) continue; ?>
|
||||
<option value="<?= $e($item['id']) ?>"<?= $visible && $page[$kind . '_id'] === $item['id'] ? ' selected' : '' ?>><?= $e($item['name']) ?></option>
|
||||
<?php endforeach ?>
|
||||
</select></label>
|
||||
<?php endforeach ?>
|
||||
</select></label>
|
||||
<?php endif ?>
|
||||
</fieldset>
|
||||
<div data-palette-picker>
|
||||
<label for="page-palette">配色方案</label>
|
||||
<select id="page-palette" name="palette_id">
|
||||
<?php foreach ($paletteOptions as $option): ?>
|
||||
<option value="<?= $e($option['id']) ?>"<?= (string) $page['palette_id'] === (string) $option['id'] ? ' selected' : '' ?>><?= $e($option['name']) ?></option>
|
||||
<?php endforeach ?>
|
||||
</select>
|
||||
<details class="palette-picker" hidden>
|
||||
<summary aria-label="选择配色方案"><span data-palette-current></span><?= View::fragment('studio-icon', ['icon' => 'chevron']) ?></summary>
|
||||
<div class="palette-picker-options">
|
||||
<?php foreach ($paletteOptions as $option): ?>
|
||||
<button type="button" data-palette-option="<?= $e($option['id']) ?>"
|
||||
aria-pressed="<?= (string) $page['palette_id'] === (string) $option['id'] ? 'true' : 'false' ?>">
|
||||
<span class="palette-name"><?= $e($option['name']) ?><?= $option['colors'] ? View::fragment('palette-swatches', ['colors' => $option['colors']]) : '' ?></span>
|
||||
</button>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</fieldset>
|
||||
</div>
|
||||
<?php if (($layout['kind'] ?? '') === 'header'): ?>
|
||||
<details class="admin-options" data-shared-auth<?= $layoutHasMember ? '' : ' hidden' ?>>
|
||||
<summary>会员登录设置</summary>
|
||||
@@ -278,16 +307,24 @@ $spacingPresets = [0, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128];
|
||||
<input type="hidden" name="<?= $e($field) ?>" value="<?= $e($value) ?>">
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
<?php if (!$layout && $slug !== 'home'): ?>
|
||||
<label>发布状态<select name="status"><option value="draft" <?= $page['status'] === 'draft' ? 'selected' : '' ?>>草稿</option>
|
||||
<option value="published" <?= $page['status'] === 'published' ? 'selected' : '' ?>>已发布</option></select></label>
|
||||
<?php endif ?>
|
||||
<?php if ($headEditor): ?>
|
||||
<?= View::fragment('head-settings', ['label' => '本页 Head', 'head' => $page['head_html']]) ?>
|
||||
<?php elseif (!$layout): ?>
|
||||
<p class="field-note">本页 Head 尚不可用。<?= $e(Database::MIGRATION_REQUIRED) ?></p>
|
||||
<?php endif ?>
|
||||
<div class="form-submit"><button class="button button-primary" type="submit"><?= View::fragment('studio-icon', ['icon' => 'save']) ?>保存页面</button></div>
|
||||
<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'): ?>
|
||||
<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>
|
||||
<span data-publication-action="published"<?= $published ? ' hidden' : '' ?>><?= View::fragment('studio-icon', ['icon' => 'publish']) ?>发布</span>
|
||||
<span data-publication-action="draft"<?= $published ? '' : ' hidden' ?>><?= View::fragment('studio-icon', ['icon' => 'unpublish']) ?>转为草稿</span>
|
||||
</button>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<p class="feedback success" data-page-save-feedback role="status" hidden></p>
|
||||
</form>
|
||||
</div>
|
||||
<?php if (!$layout): ?><?= View::fragment('studio-page-templates', compact('token')) ?><?php endif ?>
|
||||
|
||||
Reference in New Issue
Block a user