Edit shared headers and footers as page types
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
<?php
|
||||
use App\Content\LayoutPage;
|
||||
use App\Content\View;
|
||||
|
||||
$e = View::escape(...);
|
||||
$live = count(array_filter($pages, static fn (array $page): bool => $page['status'] === 'published'));
|
||||
$regular = array_filter($pages, static fn (array $page): bool => $page['layout_kind'] === null);
|
||||
$live = count(array_filter($regular, static fn (array $page): bool => $page['status'] === 'published'));
|
||||
?>
|
||||
<header class="admin-heading dashboard-heading">
|
||||
<h1>网站后台</h1>
|
||||
@@ -16,7 +18,7 @@ $live = count(array_filter($pages, static fn (array $page): bool => $page['statu
|
||||
<section class="admin-panel dashboard-pages" aria-labelledby="pages-title" data-page-list>
|
||||
<div class="admin-heading compact">
|
||||
<h2 id="pages-title">网站页面</h2>
|
||||
<p class="field-note"><?= $live ?> 个已发布 · <?= count($pages) - $live ?> 个草稿</p>
|
||||
<p class="field-note"><?= $live ?> 个已发布 · <?= count($regular) - $live ?> 个草稿 · <?= count($pages) - count($regular) ?> 个页头页脚</p>
|
||||
</div>
|
||||
<div class="dashboard-filters" data-page-filters hidden>
|
||||
<label>查找页面<input type="search" data-page-search placeholder="页面名称或地址"></label>
|
||||
@@ -24,15 +26,17 @@ $live = count(array_filter($pages, static fn (array $page): bool => $page['statu
|
||||
<option value="">全部状态</option>
|
||||
<option value="published">已发布</option>
|
||||
<option value="draft">草稿</option>
|
||||
<option value="header">页头</option>
|
||||
<option value="footer">页脚</option>
|
||||
</select></label>
|
||||
</div>
|
||||
<p class="empty-state" data-page-empty role="status"<?= $pages ? ' hidden' : '' ?>><?= $pages ? '没有匹配的页面。' : '暂无页面。' ?></p>
|
||||
<ul class="admin-list dashboard-page-list">
|
||||
<?php foreach ($pages as $page): ?>
|
||||
<?php $path = $page['slug'] === 'home' ? '/' : '/' . $page['slug']; $published = $page['status'] === 'published'; ?>
|
||||
<li data-page-item="<?= $e($page['status']) ?>" data-page-label="<?= $e($page['name'] . ' ' . $page['title'] . ' ' . $path) ?>">
|
||||
<div class="dashboard-page-label"><strong><?= $e($page['name']) ?></strong><small><?= $e($path) ?></small></div>
|
||||
<span class="dashboard-page-state" data-published="<?= $published ? 'true' : 'false' ?>"><?= $published ? '已发布' : '草稿' ?></span>
|
||||
<?php $kind = $page['layout_kind']; $path = $page['slug'] === 'home' ? '/' : '/' . $page['slug']; $published = $kind === null && $page['status'] === 'published'; ?>
|
||||
<li data-page-item="<?= $e($kind ?? $page['status']) ?>" data-page-label="<?= $e($page['name'] . ' ' . $page['title'] . ' ' . ($kind ? LayoutPage::TYPES[$kind] : $path)) ?>">
|
||||
<div class="dashboard-page-label"><strong><?= $e($page['name']) ?></strong><?php if (!$kind): ?><small><?= $e($path) ?></small><?php endif ?></div>
|
||||
<span class="dashboard-page-state" data-published="<?= $published ? 'true' : 'false' ?>"><?= $kind ? $e(LayoutPage::TYPES[$kind]) : ($published ? '已发布' : '草稿') ?></span>
|
||||
<div class="dashboard-page-actions">
|
||||
<a class="button button-outline" href="/admin/pages/<?= $e($page['slug']) ?>">编辑页面</a>
|
||||
<a href="<?= $e($published ? $path : '/admin/pages/' . $page['slug'] . '/preview') ?>" target="_blank" rel="noopener"><?= $published ? '查看' : '预览' ?></a>
|
||||
@@ -50,8 +54,6 @@ $live = count(array_filter($pages, static fn (array $page): bool => $page['statu
|
||||
<section class="admin-panel dashboard-settings" aria-labelledby="quick-title">
|
||||
<h2 id="quick-title">站点编辑</h2>
|
||||
<ul class="dashboard-setting-buttons">
|
||||
<li><a class="button button-outline" href="/admin/design/header/new">新建页头</a></li>
|
||||
<li><a class="button button-outline" href="/admin/design/footer/new">新建页脚</a></li>
|
||||
<li><a class="button button-outline" href="/admin/settings">站点设置</a></li>
|
||||
<li><a class="button button-outline" href="/admin/media">打开媒体库</a></li>
|
||||
</ul>
|
||||
|
||||
+10
-133
@@ -1,13 +1,9 @@
|
||||
<?php
|
||||
use App\Content\Buttons;
|
||||
use App\Content\Database;
|
||||
use App\Content\DesignLibrary;
|
||||
use App\Content\View;
|
||||
|
||||
$e = View::escape(...);
|
||||
$data = $item['payload'];
|
||||
$action = $data['action'][0] ?? [];
|
||||
$provider = $data['provider'] ?? [];
|
||||
$errorId = static fn (string $name): string => 'design-error-' . View::escape($name);
|
||||
$describe = static fn (string $name): string => ' aria-describedby="' . $errorId($name) . '"'
|
||||
. ($field === $name ? ' aria-invalid="true"' : '');
|
||||
@@ -20,137 +16,18 @@ $fieldError = static function (string $name) use ($errorId, $field, $error, $e):
|
||||
?>
|
||||
<a class="back-link" href="/admin/design">返回站点设计</a>
|
||||
<header class="admin-heading">
|
||||
<h1><?= $e(['header' => '页头组件', 'footer' => '页脚组件', 'palette' => '配色方案'][$kind]) ?></h1>
|
||||
<?php if ($key !== 'new'): ?><a class="button button-outline" href="/admin/design/<?= $e($kind) ?>/<?= $e($key) ?>/preview" target="_blank" rel="noopener noreferrer">预览已保存的配置</a><?php endif ?>
|
||||
<h1>配色方案</h1>
|
||||
<?php if ($key !== 'new'): ?><a class="button button-outline" href="/admin/design/palette/<?= $e($key) ?>/preview" target="_blank" rel="noopener noreferrer">预览已保存的配置</a><?php endif ?>
|
||||
</header>
|
||||
<?= View::fragment('admin-feedback', ['error' => $field === '' ? $error : '', 'saved' => $saved]) ?>
|
||||
<form class="admin-form<?= $layoutEditor ? ' design-editor' : ' admin-panel' ?>" method="post"
|
||||
action="/admin/design/<?= $e($kind) ?>/<?= $e($key) ?>"<?= $layoutEditor ? ' data-layout-editor="' . $e($kind) . '" data-site-name="' . $e($siteName) . '"' : '' ?>>
|
||||
<form class="admin-form admin-panel" method="post" action="/admin/design/palette/<?= $e($key) ?>">
|
||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||
<input type="hidden" name="version" value="<?= $e($item['version']) ?>">
|
||||
<?php if ($kind === 'palette'): ?>
|
||||
<label>配置名称<input name="name" maxlength="100" value="<?= $e($item['name']) ?>" required<?= $describe('name') ?>><?php $fieldError('name'); ?></label>
|
||||
<input type="hidden" name="preset" value="custom">
|
||||
<?php $fieldError('preset'); ?>
|
||||
<div class="palette-fields">
|
||||
<?php foreach (DesignLibrary::COLORS as $color => [$label, $fallback]): ?>
|
||||
<label><?= $e($label) ?><input type="<?= $field === $color ? 'text' : 'color' ?>" name="<?= $e($color) ?>" value="<?= $e($data[$color] ?? $fallback) ?>"<?= $describe($color) ?>><?php $fieldError($color); ?></label>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<div class="form-submit"><button type="submit" class="button button-primary">保存配置</button></div>
|
||||
<?php else: ?>
|
||||
<div class="admin-panel design-editor-bar">
|
||||
<label>配置名称<input name="name" maxlength="100" value="<?= $e($item['name']) ?>" required<?= $describe('name') ?>><?php $fieldError('name'); ?></label>
|
||||
<label><input type="checkbox" name="make_default" value="1" <?= $default ? 'checked' : '' ?>> 用作站点默认<?= $kind === 'header' ? '页头' : '页脚' ?></label>
|
||||
<button type="submit" class="button button-primary">保存配置</button>
|
||||
</div>
|
||||
<div class="design-editor-grid">
|
||||
<div class="design-editor-main">
|
||||
<section class="admin-panel design-canvas" data-layout-workspace hidden aria-labelledby="design-canvas-title">
|
||||
<div class="admin-heading compact">
|
||||
<h2 id="design-canvas-title">编辑画布</h2>
|
||||
<div class="preview-selector" role="group" aria-label="预览尺寸">
|
||||
<button type="button" class="button button-outline" data-layout-viewport="desktop" aria-pressed="true">桌面</button>
|
||||
<button type="button" class="button button-outline" data-layout-viewport="phone" aria-pressed="false">手机</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="design-canvas-stage">
|
||||
<div class="design-canvas-viewport">
|
||||
<iframe data-layout-frame sandbox="allow-same-origin" title="可编辑的<?= $kind === 'header' ? '页头' : '页脚' ?>画布"
|
||||
srcdoc="<?= $e(View::fragment('design-layout-document', ['kind' => $kind, 'preset' => array_key_first(DesignLibrary::PRESETS[$kind]), 'layoutEditor' => true])) ?>"></iframe>
|
||||
</div>
|
||||
<p class="field-note" data-layout-empty hidden>勾选组件,添加到画布。</p>
|
||||
</div>
|
||||
<p class="field-note">点击画布中的文字可直接修改。链接、图片和用户区在组件面板设置。</p>
|
||||
</section>
|
||||
<fieldset class="admin-panel design-templates"<?= $describe('preset') ?>>
|
||||
<legend>布局模板</legend>
|
||||
<div class="design-template-grid">
|
||||
<?php foreach (DesignLibrary::PRESETS[$kind] as $preset => $label): ?>
|
||||
<label class="design-template-choice">
|
||||
<span class="design-template-image">
|
||||
<iframe aria-hidden="true" tabindex="-1" inert title="<?= $e($label) ?>缩略预览" sandbox
|
||||
srcdoc="<?= $e(View::fragment('design-layout-document', ['kind' => $kind, 'preset' => $preset, 'layoutEditor' => false])) ?>"></iframe>
|
||||
</span>
|
||||
<span class="design-template-caption"><input type="radio" name="preset" value="<?= $e($preset) ?>" data-layout-preset required <?= $preset === $item['preset'] ? 'checked' : '' ?>><?= $e($label) ?></span>
|
||||
</label>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<?php $fieldError('preset'); ?>
|
||||
</fieldset>
|
||||
</div>
|
||||
<aside class="admin-panel design-editor-inspector" aria-label="组件和属性">
|
||||
<fieldset class="admin-options design-component-panel"<?= $describe('components') ?>>
|
||||
<legend>组件</legend>
|
||||
<ul class="admin-list layout-components" data-layout-components>
|
||||
<?php foreach (array_unique([...$data['components'], ...array_keys(DesignLibrary::COMPONENTS[$kind])]) as $component): ?>
|
||||
<li data-layout-layer="<?= $e($component) ?>">
|
||||
<label><input type="checkbox" name="components[]" value="<?= $e($component) ?>" <?= in_array($component, $data['components'], true) ? 'checked' : '' ?>><?= $e(DesignLibrary::COMPONENTS[$kind][$component]) ?></label>
|
||||
<div class="actions">
|
||||
<button type="button" class="button button-outline" data-layout-select="<?= $e($component) ?>" aria-label="编辑<?= $e(DesignLibrary::COMPONENTS[$kind][$component]) ?>" title="编辑<?= $e(DesignLibrary::COMPONENTS[$kind][$component]) ?>" hidden><?= View::fragment('studio-icon', ['icon' => 'edit']) ?></button>
|
||||
<button type="button" class="button button-outline" data-component-move="-1" aria-label="上移<?= $e(DesignLibrary::COMPONENTS[$kind][$component]) ?>" title="上移">↑</button>
|
||||
<button type="button" class="button button-outline" data-component-move="1" aria-label="下移<?= $e(DesignLibrary::COMPONENTS[$kind][$component]) ?>" title="下移">↓</button>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
<?php $fieldError('components'); ?>
|
||||
</fieldset>
|
||||
<fieldset class="admin-options design-properties" data-layout-panel="brand">
|
||||
<legend>站点标识</legend>
|
||||
<label>品牌名称<input name="brand" maxlength="100" value="<?= $e($data['brand']) ?>"<?= $describe('brand') ?>><?php $fieldError('brand'); ?></label>
|
||||
<div>
|
||||
<?= View::fragment('studio-asset-field', ['name' => 'logo', 'label' => '品牌图片', 'value' => $data['logo'],
|
||||
'describedBy' => $errorId('logo'), 'invalid' => $field === 'logo']) ?>
|
||||
<?php $fieldError('logo'); ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset class="admin-options design-properties" data-layout-panel="links"<?= $describe('links') ?>>
|
||||
<legend><?= $kind === 'header' ? '导航链接' : '页脚链接' ?></legend>
|
||||
<label data-layout-legacy-links>链接列表<textarea name="links" rows="4"<?= $describe('links') ?>><?= $e($links) ?></textarea><small>每行填写「名称 | 链接」。</small></label>
|
||||
<input type="hidden" name="canvas_links" value="<?= $e(Database::json($data['links'] ?? [])) ?>" disabled>
|
||||
<div data-layout-link-editor hidden>
|
||||
<div class="design-link-rows" data-layout-link-rows></div>
|
||||
<button class="button button-outline" type="button" data-layout-link-add>添加链接</button>
|
||||
<template data-layout-link-template>
|
||||
<div class="design-link-row">
|
||||
<label>文案<input maxlength="70" data-layout-link-field="1"></label>
|
||||
<label>地址<input maxlength="1000" data-layout-link-field="0" placeholder="/articles"></label>
|
||||
<div class="design-link-controls">
|
||||
<button class="button button-outline" type="button" data-layout-link-move="-1" title="上移链接" aria-label="上移链接">↑</button>
|
||||
<button class="button button-outline" type="button" data-layout-link-move="1" title="下移链接" aria-label="下移链接">↓</button>
|
||||
<button class="button button-outline" type="button" data-layout-link-remove title="删除链接" aria-label="删除链接"><?= View::fragment('studio-icon', ['icon' => 'delete']) ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<?php $fieldError('links'); ?>
|
||||
</fieldset>
|
||||
<?php if ($kind === 'header'): ?>
|
||||
<fieldset class="admin-options design-properties" data-layout-panel="action"<?= $describe('action') ?>>
|
||||
<legend>行动按钮</legend>
|
||||
<label>文案<input name="action_label" maxlength="70" value="<?= $e($action[1] ?? '') ?>"></label>
|
||||
<label>链接<input name="action_url" maxlength="1000" value="<?= $e($action[0] ?? '') ?>"></label>
|
||||
<label>样式<select name="action_style"><?php foreach (Buttons::STYLES as $style => $label): ?>
|
||||
<option value="<?= $e($style) ?>" <?= ($action[2] ?? 'outline') === $style ? 'selected' : '' ?>><?= $e($label) ?></option>
|
||||
<?php endforeach ?></select></label>
|
||||
<label><input type="checkbox" name="action_blank" value="1" <?= !empty($action[3]) ? 'checked' : '' ?>> 在新标签页打开</label>
|
||||
<?php $fieldError('action'); ?>
|
||||
</fieldset>
|
||||
<div data-layout-panel="account">
|
||||
<?= View::fragment('design-provider-fields', compact('item', 'provider', 'e', 'describe', 'fieldError', 'reenterSecret', 'field') + ['components' => $data['components']]) ?>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<fieldset class="admin-options design-properties" data-layout-panel="text">
|
||||
<legend>说明文字</legend>
|
||||
<label>内容<textarea name="text" rows="3" maxlength="1200"<?= $describe('text') ?>><?= $e($data['text']) ?></textarea><?php $fieldError('text'); ?></label>
|
||||
</fieldset>
|
||||
<fieldset class="admin-options design-properties" data-layout-panel="legal">
|
||||
<legend>版权文字</legend>
|
||||
<label>内容<input name="legal" maxlength="300" value="<?= $e($data['legal']) ?>"<?= $describe('legal') ?>><?php $fieldError('legal'); ?></label>
|
||||
</fieldset>
|
||||
<?php endif ?>
|
||||
</aside>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<label>配置名称<input name="name" maxlength="100" value="<?= $e($item['name']) ?>" required<?= $describe('name') ?>><?php $fieldError('name'); ?></label>
|
||||
<div class="palette-fields">
|
||||
<?php foreach (DesignLibrary::COLORS as $color => [$label, $fallback]): ?>
|
||||
<label><?= $e($label) ?><input type="<?= $field === $color ? 'text' : 'color' ?>" name="<?= $e($color) ?>" value="<?= $e($data[$color] ?? $fallback) ?>"<?= $describe($color) ?>><?php $fieldError($color); ?></label>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<div class="form-submit"><button type="submit" class="button button-primary">保存配置</button></div>
|
||||
</form>
|
||||
|
||||
+12
-17
@@ -4,20 +4,15 @@ use App\Content\View;
|
||||
$e = View::escape(...);
|
||||
?>
|
||||
<header class="admin-heading"><h1>站点设计</h1><div class="actions"><a class="button button-outline" href="/admin/settings">站点设置</a><a class="button button-outline" href="/admin/backup">站点备份</a></div></header>
|
||||
<div class="design-overview">
|
||||
<?php foreach (['header' => '页头', 'footer' => '页脚', 'palette' => '配色方案'] as $kind => $label): ?>
|
||||
<section class="admin-panel">
|
||||
<div class="admin-heading compact"><h2><?= $e($label) ?></h2><a class="button button-outline" href="/admin/design/<?= $e($kind) ?>/new">新建<?= $e($label) ?></a></div>
|
||||
<?php $group = array_filter($items, static fn (array $item): bool => $item['kind'] === $kind); ?>
|
||||
<?php if (!$group): ?><p class="field-note">暂无自定义配置。</p><?php endif ?>
|
||||
<ul class="admin-list">
|
||||
<?php foreach ($group as $item): ?>
|
||||
<li><strong><?= $e($item['name']) ?></strong>
|
||||
<?php if (($site[$kind . '_id'] ?? null) === $item['id']): ?><small>站点默认</small><?php endif ?>
|
||||
<a class="button button-outline" href="/admin/design/<?= $e($kind) ?>/<?= $e($item['id']) ?>">编辑</a>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</section>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<p><a href="/admin">在网站页面中管理页头和页脚</a></p>
|
||||
<section class="admin-panel">
|
||||
<div class="admin-heading compact"><h2>配色方案</h2><a class="button button-outline" href="/admin/design/palette/new">新建配色方案</a></div>
|
||||
<?php if (!$items): ?><p class="field-note">暂无自定义配色。</p><?php endif ?>
|
||||
<ul class="admin-list">
|
||||
<?php foreach ($items as $item): ?>
|
||||
<li><strong><?= $e($item['name']) ?></strong>
|
||||
<a class="button button-outline" href="/admin/design/palette/<?= $e($item['id']) ?>">编辑</a>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
@@ -24,10 +24,6 @@ $active = match (true) {
|
||||
<script src="/assets/jquery-4.0.0.min.js" defer></script>
|
||||
<script src="/assets/admin.js" defer></script>
|
||||
<script src="/assets/studio.js" defer></script>
|
||||
<?php if (!empty($layoutEditor)): ?>
|
||||
<link rel="stylesheet" href="/assets/design-editor.css">
|
||||
<script src="/assets/design-editor.js" defer></script>
|
||||
<?php endif ?>
|
||||
<?php if (!empty($pageTemplateDrawer)): ?>
|
||||
<link rel="stylesheet" href="/assets/page-template-drawer.css">
|
||||
<script src="/assets/page-template-drawer.js" defer></script>
|
||||
|
||||
+50
-30
@@ -2,6 +2,7 @@
|
||||
use App\Content\Buttons;
|
||||
use App\Content\CanvasStyle;
|
||||
use App\Content\Database;
|
||||
use App\Content\LayoutPage;
|
||||
use App\Content\SiteDesign;
|
||||
use App\Content\View;
|
||||
|
||||
@@ -12,17 +13,21 @@ $previewUrl = '/admin/pages/' . $slug . '/preview';
|
||||
?>
|
||||
<a class="back-link" href="/admin">返回页面</a>
|
||||
<header class="admin-heading">
|
||||
<div><h1><?= $e($title) ?></h1><p class="studio-page-meta"><code><?= $e($path) ?></code>
|
||||
<span class="dashboard-page-state" data-published="<?= $page['status'] === 'published' ? 'true' : 'false' ?>"><?= $page['status'] === 'draft' ? '草稿' : '已发布' ?></span></p></div>
|
||||
<div><h1><?= $e($title) ?></h1><p class="studio-page-meta">
|
||||
<?php if ($layout): ?><span class="dashboard-page-state"><?= $e(LayoutPage::TYPES[$layout['kind']]) ?></span>
|
||||
<?php else: ?><code><?= $e($path) ?></code><span class="dashboard-page-state" data-published="<?= $page['status'] === 'published' ? 'true' : 'false' ?>"><?= $page['status'] === 'draft' ? '草稿' : '已发布' ?></span><?php endif ?>
|
||||
</p></div>
|
||||
<div class="actions">
|
||||
<a class="button button-outline" href="#studio-page-settings">页面设置</a>
|
||||
<?php foreach (['header' => '编辑页头', 'footer' => '编辑页脚'] as $kind => $label): ?>
|
||||
<?php $default = $layoutDefaults[$kind . '_id'] ?? ''; $id = $page[$kind . '_id'] ?? $default; ?>
|
||||
<a class="button button-outline" data-page-layout-editor="<?= $kind ?>" data-default-id="<?= $e($default) ?>"
|
||||
href="/admin/design/<?= $kind ?>/<?= $id ? $e($id) : 'new?default=1' ?>" target="_blank" rel="noopener"><?= $label ?></a>
|
||||
<?php endforeach ?>
|
||||
<button type="button" class="button button-outline" data-open-page-templates hidden>整页模板</button>
|
||||
<?php if ($page['status'] === 'published'): ?><a class="button button-outline" href="<?= $e($path) ?>">公开页面</a><?php endif ?>
|
||||
<?php if (!$layout): ?>
|
||||
<?php foreach (['header' => '编辑页头', 'footer' => '编辑页脚'] as $kind => $label): ?>
|
||||
<?php $defaultId = $layoutDefaults[$kind . '_id'] ?? ''; $id = $page[$kind . '_id'] ?? $defaultId; ?>
|
||||
<a class="button button-outline" data-page-layout-editor="<?= $e($kind) ?>" data-default-id="<?= $e($defaultId) ?>"
|
||||
href="<?= $id ? '/admin/pages/' . $e(LayoutPage::slug($kind, $id)) : '/admin/new-page?type=' . $e($kind) ?>" target="_blank" rel="noopener"<?= !($page['visibility'][$kind] ?? true) ? ' hidden' : '' ?>><?= $e($label) ?></a>
|
||||
<?php endforeach ?>
|
||||
<button type="button" class="button button-outline" data-open-page-templates hidden>整页模板</button>
|
||||
<?php if ($page['status'] === 'published'): ?><a class="button button-outline" href="<?= $e($path) ?>">公开页面</a><?php endif ?>
|
||||
<?php endif ?>
|
||||
<a class="button button-outline" href="<?= $e($previewUrl) ?>" target="_blank" rel="noopener">打开预览</a>
|
||||
</div>
|
||||
</header>
|
||||
@@ -32,7 +37,7 @@ $previewUrl = '/admin/pages/' . $slug . '/preview';
|
||||
<h2 id="studio-library-title">页面编辑</h2>
|
||||
<?= View::fragment('studio-templates', [
|
||||
'layers' => View::fragment('studio-layers', compact('page', 'slug', 'token')),
|
||||
'anchorForm' => View::fragment('studio-anchor-form', compact('slug', 'token')),
|
||||
'layoutKind' => $page['layout_kind'], 'slug' => $slug, 'token' => $token,
|
||||
]) ?>
|
||||
</aside>
|
||||
<div class="studio-workspace">
|
||||
@@ -158,30 +163,45 @@ $previewUrl = '/admin/pages/' . $slug . '/preview';
|
||||
</div>
|
||||
</details>
|
||||
<label>页面名称<input name="name" value="<?= $e($page['name']) ?>" required maxlength="100"></label>
|
||||
<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 if ($layout): ?>
|
||||
<input type="hidden" name="title" value="<?= $e($page['title']) ?>">
|
||||
<label><input type="checkbox" name="make_default" value="1"<?= $layoutDefault ? ' checked' : '' ?>> 用作站点默认<?= $e(LayoutPage::TYPES[$layout['kind']]) ?></label>
|
||||
<?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 foreach (['header' => '页头', 'hero' => '首屏', 'footer' => '页脚'] as $area => $label): ?>
|
||||
<?php $visible = $page['visibility'][$area] ?? true; ?>
|
||||
<label><?= $e($label) ?><select name="show_<?= $e($area) ?>">
|
||||
<option value="1" <?= $visible ? 'selected' : '' ?>>显示</option>
|
||||
<option value="0" <?= !$visible ? 'selected' : '' ?>>隐藏</option>
|
||||
</select></label>
|
||||
<?php endforeach ?>
|
||||
</fieldset>
|
||||
<fieldset class="admin-options form-grid"><legend>页头、页脚与配色</legend>
|
||||
<?php foreach (['header' => '页头方案', 'footer' => '页脚方案', 'palette' => '配色方案'] as $kind => $label): ?>
|
||||
<label><?= $e($label) ?><select name="<?= $e($kind) ?>_id">
|
||||
<option value=""><?= $kind === 'palette' ? '页面原有配色' : '站点默认' ?></option>
|
||||
<?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'] !== $kind) continue; ?>
|
||||
<option value="<?= $e($item['id']) ?>" <?= ($page[$kind . '_id'] ?? null) === $item['id'] ? 'selected' : '' ?>><?= $e($item['name']) ?></option>
|
||||
<?php if ($item['kind'] !== 'palette') continue; ?>
|
||||
<option value="<?= $e($item['id']) ?>"<?= $page['palette_id'] === $item['id'] ? ' selected' : '' ?>><?= $e($item['name']) ?></option>
|
||||
<?php endforeach ?>
|
||||
</select></label>
|
||||
<?php endforeach ?>
|
||||
<a href="/admin/design" target="_blank" rel="noopener noreferrer">管理设计配置</a>
|
||||
<?php endif ?>
|
||||
</fieldset>
|
||||
<?php if (($layout['kind'] ?? '') === 'header'): ?>
|
||||
<details class="admin-options" data-shared-auth<?= $layoutHasMember ? '' : ' hidden' ?>>
|
||||
<summary>会员登录设置</summary>
|
||||
<?= View::fragment('design-provider-fields', ['item' => $layout, 'provider' => $layout['payload']['provider'], 'layoutHasMember' => $layoutHasMember]) ?>
|
||||
</details>
|
||||
<?php endif ?>
|
||||
<textarea name="hero_actions" hidden><?= $e(Database::json(Buttons::validate($page['actions']))) ?></textarea>
|
||||
<?php
|
||||
$contentFields = [
|
||||
@@ -197,11 +217,11 @@ $previewUrl = '/admin/pages/' . $slug . '/preview';
|
||||
<input type="hidden" name="<?= $e($field) ?>" value="<?= $e($value) ?>">
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
<?php if ($slug !== 'home'): ?>
|
||||
<?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 ?>
|
||||
<div class="form-submit"><button class="button button-primary" type="submit">保存页面</button></div>
|
||||
</form>
|
||||
</div>
|
||||
<?= View::fragment('studio-page-templates', compact('token')) ?>
|
||||
<?php if (!$layout): ?><?= View::fragment('studio-page-templates', compact('token')) ?><?php endif ?>
|
||||
|
||||
@@ -1,18 +1,5 @@
|
||||
<?php
|
||||
use App\Content\DesignLibrary;
|
||||
use App\Content\View;
|
||||
|
||||
$layout = [
|
||||
'id' => 0,
|
||||
'preset' => $preset,
|
||||
'payload' => array_replace(DesignLibrary::defaults($kind), [
|
||||
'brand' => '品牌名称',
|
||||
'text' => '关于网站的一句话介绍。',
|
||||
'links' => $layoutEditor ? [] : [['/', '首页'], ['/articles', '文章']],
|
||||
'legal' => '© 品牌名称',
|
||||
'action' => [['/articles', '了解更多', 'solid', false]],
|
||||
]),
|
||||
];
|
||||
use App\Content\LayoutPage;
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
@@ -20,12 +7,8 @@ $layout = [
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="/assets/site.css">
|
||||
<link rel="stylesheet" href="/assets/design-editor.css">
|
||||
</head>
|
||||
<body class="design-frame <?= $layoutEditor ? 'design-frame-editing' : 'design-frame-sample' ?>">
|
||||
<?= View::fragment($kind, [
|
||||
$kind => $layout, 'site' => ['name' => '品牌名称'], 'showHeader' => true, 'showFooter' => true,
|
||||
'path' => '/', 'visitor' => null, 'member' => $preset === 'member', 'layoutEditor' => $layoutEditor,
|
||||
]) ?>
|
||||
<body class="layout-thumbnail">
|
||||
<?= LayoutPage::sample($kind, $preset) ?>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,29 +1,28 @@
|
||||
<?php
|
||||
use App\Content\DesignLibrary;
|
||||
use App\Content\View;
|
||||
|
||||
$e = View::escape(...);
|
||||
?>
|
||||
<fieldset class="admin-options design-properties" data-provider-settings<?= DesignLibrary::hasAccount($item['preset'], $components) ? '' : ' hidden' ?>><legend>用户区认证</legend>
|
||||
<label>认证方式<select name="provider_mode"<?= $describe('provider_mode') ?>><option value="">关闭</option>
|
||||
<fieldset class="admin-options form-grid" data-provider-settings<?= $layoutHasMember ? '' : ' disabled' ?>><legend>用户区认证</legend>
|
||||
<label>认证方式<select name="provider_mode"><option value="">关闭</option>
|
||||
<?php foreach (['oidc' => 'OpenID Connect', 'oauth2' => 'OAuth 2.0 + 用户资料'] as $mode => $label): ?>
|
||||
<option value="<?= $e($mode) ?>" <?= ($provider['mode'] ?? '') === $mode ? 'selected' : '' ?>><?= $e($label) ?></option>
|
||||
<?php endforeach ?>
|
||||
</select><?php $fieldError('provider_mode'); ?></label>
|
||||
<label data-provider-field>客户端 ID<input name="provider_client_id" value="<?= $e($provider['client_id'] ?? '') ?>"<?= $describe('provider_client_id') ?>><?php $fieldError('provider_client_id'); ?></label>
|
||||
</select></label>
|
||||
<label data-provider-field>客户端 ID<input name="provider_client_id" value="<?= $e($provider['client_id'] ?? '') ?>"></label>
|
||||
<label data-provider-field>客户端密钥
|
||||
<input type="password" name="provider_secret" maxlength="4096" autocomplete="new-password"<?= $describe('provider_secret') ?>>
|
||||
<?php $fieldError('provider_secret'); ?>
|
||||
<?php if ($reenterSecret && $field !== 'provider_secret'): ?><small>请重新输入本次提交的客户端密钥。</small><?php endif ?>
|
||||
<input type="password" name="provider_secret" maxlength="4096" autocomplete="new-password">
|
||||
<?php if (!empty($item['credential_revision'])): ?><small>留空会保留已保存的密钥。</small><?php endif ?>
|
||||
</label>
|
||||
<label data-provider-field>令牌端点认证<select name="provider_token_auth"<?= $describe('provider_token_auth') ?>>
|
||||
<label data-provider-field>令牌端点认证<select name="provider_token_auth">
|
||||
<?php foreach (['' => '自动', 'client_secret_basic' => 'HTTP Basic', 'client_secret_post' => '表单客户端密钥'] as $method => $label): ?>
|
||||
<option value="<?= $e($method) ?>" <?= ($provider['token_auth'] ?? '') === $method ? 'selected' : '' ?>><?= $e($label) ?></option>
|
||||
<?php endforeach ?>
|
||||
</select><?php $fieldError('provider_token_auth'); ?></label>
|
||||
<label data-provider-field>权限范围<input name="provider_scope" value="<?= $e($provider['scope'] ?? '') ?>" placeholder="openid profile email"<?= $describe('provider_scope') ?>><?php $fieldError('provider_scope'); ?></label>
|
||||
<label data-provider-mode="oidc">OIDC Issuer<input name="provider_issuer" value="<?= $e($provider['issuer'] ?? '') ?>" placeholder="https://id.example.com"<?= $describe('provider_issuer') ?>><?php $fieldError('provider_issuer'); ?></label>
|
||||
</select></label>
|
||||
<label data-provider-field>权限范围<input name="provider_scope" value="<?= $e($provider['scope'] ?? '') ?>" placeholder="openid profile email"></label>
|
||||
<label data-provider-mode="oidc">OIDC Issuer<input name="provider_issuer" value="<?= $e($provider['issuer'] ?? '') ?>" placeholder="https://id.example.com"></label>
|
||||
<?php foreach (['authorization' => '授权端点', 'token' => '令牌端点', 'userinfo' => '用户资料端点', 'subject_field' => '用户 ID 字段', 'name_field' => '名称字段', 'avatar_field' => '头像字段'] as $providerField => $label): ?>
|
||||
<label data-provider-mode="oauth2"><?= $e($label) ?><input name="provider_<?= $e($providerField) ?>" value="<?= $e($provider[$providerField] ?? '') ?>"<?= $describe('provider_' . $providerField) ?>><?php $fieldError('provider_' . $providerField); ?></label>
|
||||
<label data-provider-mode="oauth2"><?= $e($label) ?><input name="provider_<?= $e($providerField) ?>" value="<?= $e($provider[$providerField] ?? '') ?>"></label>
|
||||
<?php endforeach ?>
|
||||
<p class="field-note" data-provider-field>回调地址 <code><?= $e(View::absolute('/account/callback')) ?></code></p>
|
||||
</fieldset>
|
||||
|
||||
+8
-11
@@ -4,25 +4,22 @@ use App\Content\View;
|
||||
$e = View::escape(...);
|
||||
$data = $footer['payload'];
|
||||
$brand = $data['brand'] ?: $site['name'];
|
||||
$layoutEditor ??= false;
|
||||
$part = static fn (string $component): string => $layoutEditor ? ' data-layout-component="' . $component . '"' : '';
|
||||
?>
|
||||
<footer class="site-footer site-footer-<?= $e($footer['preset']) ?>" id="contact"<?= $showFooter ? '' : ' hidden' ?>>
|
||||
<div class="wrap site-footer-components">
|
||||
<?php foreach ($data['components'] as $component): ?>
|
||||
<?php if ($component === 'brand'): ?>
|
||||
<a class="wordmark site-brand" href="/" aria-label="<?= $e($brand) ?>,首页"<?= $part('brand') ?>>
|
||||
<?php if ($layoutEditor): ?><img alt="" hidden><span data-layout-text="brand"></span>
|
||||
<?php elseif ($data['logo'] !== ''): ?><img src="<?= $e($data['logo']) ?>" alt="<?= $e($brand) ?>" loading="lazy"><?php else: ?><?= $e($brand) ?><?php endif ?>
|
||||
<a class="wordmark site-brand" href="/" aria-label="<?= $e($brand) ?>,首页">
|
||||
<?php if ($data['logo'] !== ''): ?><img src="<?= $e($data['logo']) ?>" alt="<?= $e($brand) ?>" loading="lazy"><?php else: ?><?= $e($brand) ?><?php endif ?>
|
||||
</a>
|
||||
<?php elseif ($component === 'text' && ($layoutEditor || $data['text'] !== '')): ?>
|
||||
<p class="site-footer-text"<?= $part('text') ?><?= $layoutEditor ? ' data-layout-text="text"' : '' ?>><?= $e($data['text']) ?></p>
|
||||
<?php elseif ($component === 'links' && ($layoutEditor || $data['links'])): ?>
|
||||
<nav class="site-footer-nav" aria-label="页脚导航"<?= $part('links') ?>>
|
||||
<?php elseif ($component === 'text' && $data['text'] !== ''): ?>
|
||||
<p class="site-footer-text"><?= $e($data['text']) ?></p>
|
||||
<?php elseif ($component === 'links' && $data['links']): ?>
|
||||
<nav class="site-footer-nav" aria-label="页脚导航">
|
||||
<?php foreach ($data['links'] as [$url, $label]): ?><a href="<?= $e($url) ?>"><?= $e($label) ?></a><?php endforeach ?>
|
||||
</nav>
|
||||
<?php elseif ($component === 'legal' && ($layoutEditor || $data['legal'] !== '')): ?>
|
||||
<small<?= $part('legal') ?><?= $layoutEditor ? ' data-layout-text="legal"' : '' ?>><?= $e($data['legal']) ?></small>
|
||||
<?php elseif ($component === 'legal' && $data['legal'] !== ''): ?>
|
||||
<small><?= $e($data['legal']) ?></small>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
|
||||
+13
-21
@@ -5,40 +5,32 @@ use App\Content\View;
|
||||
$e = View::escape(...);
|
||||
$data = $header['payload'];
|
||||
$brand = $data['brand'] ?: $site['name'];
|
||||
$layoutEditor ??= false;
|
||||
$part = static fn (string $component): string => $layoutEditor ? ' data-layout-component="' . $component . '"' : '';
|
||||
$layoutTemplate ??= false;
|
||||
?>
|
||||
<header class="masthead masthead-<?= $e($header['preset']) ?>"<?= $showHeader ? '' : ' hidden' ?>>
|
||||
<div class="wrap masthead-inner">
|
||||
<?php foreach ($data['components'] as $component): ?>
|
||||
<?php if ($component === 'brand'): ?>
|
||||
<a class="wordmark site-brand" href="/" aria-label="<?= $e($brand) ?>,首页"<?= $part('brand') ?>>
|
||||
<?php if ($layoutEditor): ?><img alt="" hidden><span data-layout-text="brand"></span>
|
||||
<?php elseif ($data['logo'] !== ''): ?><img src="<?= $e($data['logo']) ?>" alt="<?= $e($brand) ?>"><?php else: ?><?= $e($brand) ?><?php endif ?>
|
||||
<a class="wordmark site-brand" href="/" aria-label="<?= $e($brand) ?>,首页">
|
||||
<?php if ($data['logo'] !== ''): ?><img src="<?= $e($data['logo']) ?>" alt="<?= $e($brand) ?>"><?php else: ?><?= $e($brand) ?><?php endif ?>
|
||||
</a>
|
||||
<?php elseif ($component === 'links' && ($layoutEditor || $data['links'])): ?>
|
||||
<?php if (!$layoutEditor): ?>
|
||||
<?php elseif ($component === 'links' && $data['links']): ?>
|
||||
<button class="menu-toggle" type="button" aria-expanded="false" aria-controls="primary-navigation" hidden>
|
||||
<span></span><span></span><span class="sr-only">菜单</span>
|
||||
</button>
|
||||
<?php endif ?>
|
||||
<nav id="primary-navigation" class="primary-nav" aria-label="主导航"<?= $part('links') ?>>
|
||||
<nav id="primary-navigation" class="primary-nav" aria-label="主导航">
|
||||
<?php foreach ($data['links'] as [$url, $label]): ?>
|
||||
<a href="<?= $e($url) ?>"<?= $url === $path ? ' aria-current="page"' : '' ?>><?= $e($label) ?></a>
|
||||
<?php endforeach ?>
|
||||
</nav>
|
||||
<?php elseif ($component === 'action' && ($layoutEditor || $data['action'])): ?>
|
||||
<?php [$url, $label, $style, $blank] = $data['action'][0] ?? ['/', '', 'outline', false]; ?>
|
||||
<a class="<?= $e(Buttons::css($style)) ?> masthead-action" href="<?= $e($url) ?>"<?= Buttons::target($blank) ?><?= $part('action') ?><?= $layoutEditor ? ' data-layout-text="action_label"' : '' ?>><?= $e($label) ?></a>
|
||||
<?php elseif ($component === 'account' && ($layoutEditor || $member)): ?>
|
||||
<?php if ($visitor): ?>
|
||||
<a class="site-account" href="/account" aria-label="打开用户中心">
|
||||
<?php if ($visitor['avatar'] !== ''): ?><img class="account-avatar" src="<?= $e($visitor['avatar']) ?>" alt="" width="36" height="36"><?php else: ?>
|
||||
<span class="account-avatar account-initial" aria-hidden="true"><?= $e(mb_substr($visitor['name'], 0, 1)) ?></span>
|
||||
<?php endif ?>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<a class="button button-outline site-account" href="/account/login/<?= $e($header['id']) ?>"<?= $part('account') ?>>登录</a>
|
||||
<?php elseif ($component === 'action' && $data['action']): ?>
|
||||
<?php [$url, $label, $style, $blank] = $data['action'][0]; ?>
|
||||
<a class="<?= $e(Buttons::css($style)) ?> masthead-action" href="<?= $e($url) ?>"<?= Buttons::target($blank) ?>><?= $e($label) ?></a>
|
||||
<?php elseif ($component === 'account'): ?>
|
||||
<?php if ($layoutTemplate && $header['preset'] === 'member'): ?>
|
||||
<a class="button button-outline site-account studio-member-slot" href="/account">登录</a>
|
||||
<?php elseif ($member): ?>
|
||||
<?= View::fragment('member-account', ['layoutId' => $header['id'], 'visitor' => $visitor]) ?>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
|
||||
+7
-5
@@ -44,7 +44,7 @@ $showFooter = $page['visibility']['footer'] ?? true;
|
||||
<?php endif ?>
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<link rel="stylesheet" href="/assets/site.css">
|
||||
<?php if (!empty($canvas) || str_contains($content, 'studio-style-')): ?><link rel="stylesheet" href="<?= $e(CanvasStyle::stylesheetUrl()) ?>"><?php endif ?>
|
||||
<?php if (!empty($canvas) || str_contains($content . ($headerMarkup ?? '') . ($footerMarkup ?? ''), 'studio-style-')): ?><link rel="stylesheet" href="<?= $e(CanvasStyle::stylesheetUrl()) ?>"><?php endif ?>
|
||||
<?php if ($theme !== ''): ?><link rel="stylesheet" href="/assets/page-themes.css"><?php endif ?>
|
||||
<?php if ($palette): ?><link rel="stylesheet" data-page-palette href="/palette/<?= $e($palette['id']) ?>.css?v=<?= $e($palette['version']) ?>"><?php endif ?>
|
||||
<script src="/assets/jquery-4.0.0.min.js" defer></script>
|
||||
@@ -52,12 +52,14 @@ $showFooter = $page['visibility']['footer'] ?? true;
|
||||
</head>
|
||||
<body>
|
||||
<a class="skip-link" href="#main-content">跳到内容</a>
|
||||
<?php if ($showHeader || !empty($canvas)): ?>
|
||||
<?= View::fragment('header', compact('header', 'site', 'showHeader', 'visitor', 'member', 'path')) ?>
|
||||
<?php if (empty($page['layout_kind']) && ($showHeader || !empty($canvas))): ?>
|
||||
<?php if (isset($headerMarkup)): ?><div role="banner" data-site-area="header"<?= $showHeader ? '' : ' hidden' ?>><?= $headerMarkup ?></div>
|
||||
<?php else: ?><?= View::fragment('header', compact('header', 'site', 'showHeader', 'visitor', 'member', 'path')) ?><?php endif ?>
|
||||
<?php endif ?>
|
||||
<main id="main-content"<?= $theme !== '' ? ' class="page-theme theme-' . $e($theme) . '"' : '' ?> tabindex="-1"><?= $content ?></main>
|
||||
<?php if ($showFooter || !empty($canvas)): ?>
|
||||
<?= View::fragment('footer', compact('footer', 'site', 'showFooter')) ?>
|
||||
<?php if (empty($page['layout_kind']) && ($showFooter || !empty($canvas))): ?>
|
||||
<?php if (isset($footerMarkup)): ?><div id="contact" role="contentinfo" data-site-area="footer"<?= $showFooter ? '' : ' hidden' ?>><?= $footerMarkup ?></div>
|
||||
<?php else: ?><?= View::fragment('footer', compact('footer', 'site', 'showFooter')) ?><?php endif ?>
|
||||
<?php endif ?>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
use App\Content\View;
|
||||
|
||||
$e = View::escape(...);
|
||||
?>
|
||||
<?php if ($visitor): ?>
|
||||
<a class="site-account" href="/account" aria-label="打开用户中心">
|
||||
<?php if ($visitor['avatar'] !== ''): ?>
|
||||
<img class="account-avatar" src="<?= $e($visitor['avatar']) ?>" alt="" width="36" height="36">
|
||||
<?php else: ?>
|
||||
<span class="account-avatar account-initial" aria-hidden="true"><?= $e(mb_substr($visitor['name'], 0, 1)) ?></span>
|
||||
<?php endif ?>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<a class="button button-outline site-account" href="/account/login/<?= $e($layoutId) ?>">登录</a>
|
||||
<?php endif ?>
|
||||
+10
-2
@@ -5,6 +5,7 @@ use App\Content\View;
|
||||
|
||||
$e = View::escape(...);
|
||||
$home = $page['slug'] === 'home';
|
||||
$shared = !empty($page['layout_kind']);
|
||||
$showHero = $page['visibility']['hero'] ?? true;
|
||||
$heroLinks = array_filter($page['sections'], static fn (array $section): bool => $section['style'] === 'hero-links');
|
||||
$alignments = $page['alignments'];
|
||||
@@ -15,13 +16,13 @@ $styleField = static fn (string $role): string => $canvas ? ' data-studio-style-
|
||||
$alignField = static fn (string $name): string => $canvas ? ' data-studio-align-field="' . $name . '"' : '';
|
||||
$field = static fn (string $name): string => $canvas ? ' data-studio-field="' . $name . '"' : '';
|
||||
?>
|
||||
<?php if (!$showHero && !$canvas): ?><h1 class="sr-only"><?= $e($page['name']) ?></h1><?php endif ?>
|
||||
<?php if (!$showHero && !$canvas && !$shared): ?><h1 class="sr-only"><?= $e($page['name']) ?></h1><?php endif ?>
|
||||
<?php if ($showHero || $canvas || $heroLinks): ?>
|
||||
<section class="hero hero-<?= $e($page['slug']) ?><?= $style('hero') ?>" id="home" data-enter<?= $canvas ? ' data-studio-hero' : '' ?><?= $styleField('hero') ?>>
|
||||
<?php if ($showHero || $canvas): ?>
|
||||
<div class="wrap hero-inner<?= $page['image'] === '' ? ' hero-text-only' : '' ?>"<?= $canvas ? ' data-studio-hero-content' : '' ?><?= $showHero ? '' : ' hidden' ?>>
|
||||
<div class="hero-copy">
|
||||
<?php if (!$home): ?>
|
||||
<?php if (!$home && !$shared): ?>
|
||||
<nav class="breadcrumbs" aria-label="面包屑" itemscope itemtype="https://schema.org/BreadcrumbList">
|
||||
<span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
|
||||
<a itemprop="item" href="/"><span itemprop="name">首页</span></a>
|
||||
@@ -73,8 +74,15 @@ $field = static fn (string $name): string => $canvas ? ' data-studio-field="' .
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
<?php if ($canvas): ?>
|
||||
<?php if ($shared): ?>
|
||||
<p class="wrap studio-layout-empty" data-studio-empty-layout hidden>从「组件」添加版式,或在页面设置中显示首屏。</p>
|
||||
<?php endif ?>
|
||||
<template data-studio-section-end><?= View::fragment('section', [
|
||||
'section' => ['style' => 'plain', 'key' => 'new', 'version' => null, 'title' => '', 'lead' => '', 'body' => ''],
|
||||
'moment' => false, 'canvas' => true,
|
||||
]) ?></template>
|
||||
<template data-studio-section-layout><?= View::fragment('section', [
|
||||
'section' => ['style' => 'layout', 'key' => 'new-layout', 'version' => null, 'title' => '', 'lead' => '', 'body' => ''],
|
||||
'moment' => false, 'canvas' => true,
|
||||
]) ?></template>
|
||||
<?php endif ?>
|
||||
|
||||
@@ -13,6 +13,16 @@ $studio = $canvas ? ' data-studio-section="' . $e($section['version']) . '" data
|
||||
if ($canvas && $dynamic) {
|
||||
$studio .= ' data-studio-dynamic data-studio-feed="' . $e($section['feed']) . '" tabindex="0"';
|
||||
}
|
||||
if ($section['style'] === 'layout'):
|
||||
?>
|
||||
<section class="studio-layout-block<?= $style('section') ?>" id="<?= $e($section['key']) ?>"<?= $studio ?>>
|
||||
<?php if ($canvas): ?><span data-studio-part="title" hidden><?= $text('title') ?></span><span data-studio-part="lead" hidden><?= $text('lead') ?></span><?php endif ?>
|
||||
<div class="<?= trim($style('body')) ?>"<?= $canvas ? ' data-studio-part="body"' : '' ?>><?= $body ?></div>
|
||||
</section>
|
||||
<?php
|
||||
return;
|
||||
endif;
|
||||
|
||||
if ($section['style'] === 'hero-links'):
|
||||
?>
|
||||
<div class="wrap hero-directory-slot<?= $style('section') ?>" id="<?= $e($section['key']) ?>"<?= $studio ?>>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
use App\Content\BlockTemplates;
|
||||
use App\Content\View;
|
||||
|
||||
$e = View::escape(...);
|
||||
@@ -11,7 +10,7 @@ $e = View::escape(...);
|
||||
<input type="hidden" name="operation" value="create">
|
||||
<label>锚点<input name="key" pattern="[a-z0-9]+(-[a-z0-9]+)*" maxlength="70" placeholder="overview" required></label>
|
||||
<label>模板<select name="preset">
|
||||
<?php foreach (BlockTemplates::groups() as [$category, $templates]): ?>
|
||||
<?php foreach ($groups as [$category, $templates]): ?>
|
||||
<optgroup label="<?= $e($category) ?>">
|
||||
<?php foreach ($templates as $preset => [$label]): ?>
|
||||
<option value="<?= $e($preset) ?>"><?= $e($label) ?></option>
|
||||
|
||||
@@ -30,10 +30,18 @@ $modules = $kind === 'modules';
|
||||
<?php [$label, $markup, $option, $feed] = array_pad($item, 4, null); ?>
|
||||
<?php if ($modules): ?>
|
||||
<article class="studio-template-card" data-template-card data-library-item data-template-search-text="<?= $e($label . ' ' . $key) ?>">
|
||||
<?php if (($item[4] ?? '') === 'layout'): ?>
|
||||
<?php [$previewKind, $previewPreset] = explode('-', $key, 2); ?>
|
||||
<div class="studio-layout-card-preview">
|
||||
<iframe sandbox inert aria-hidden="true" tabindex="-1" title="<?= $e($label) ?>"
|
||||
srcdoc="<?= $e(View::fragment('design-layout-document', ['kind' => $previewKind, 'preset' => $previewPreset])) ?>"></iframe>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<button type="button" class="studio-template-image" data-template-preview="<?= $e($key) ?>" data-template-title="<?= $e($label) ?>"
|
||||
aria-label="预览<?= $e($label) ?>组件">
|
||||
<img src="/assets/template-previews/<?= $e($key) ?>.webp" alt="" width="768" height="480" loading="lazy">
|
||||
</button>
|
||||
<?php endif ?>
|
||||
<div class="studio-template-meta">
|
||||
<span><?= $e($label) ?></span>
|
||||
<button type="button" class="button button-outline" disabled data-canvas-template="<?= $e($key) ?>"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
use App\Content\LayoutPage;
|
||||
use App\Content\View;
|
||||
|
||||
$e = View::escape(...);
|
||||
@@ -11,10 +12,15 @@ $e = View::escape(...);
|
||||
<?= View::fragment('admin-feedback', ['error' => $error, 'saved' => false]) ?>
|
||||
<form class="admin-form admin-panel" method="post" action="/admin/new-page">
|
||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||
<label>页面类型<select name="type" data-new-page-type>
|
||||
<?php foreach (LayoutPage::TYPES as $value => $label): ?>
|
||||
<option value="<?= $e($value) ?>" <?= $type === $value ? 'selected' : '' ?>><?= $e($label) ?></option>
|
||||
<?php endforeach ?>
|
||||
</select></label>
|
||||
<label>页面名称<input name="name" maxlength="100" value="<?= $e($name) ?>" required></label>
|
||||
<label>网址标识<input name="slug" maxlength="70" value="<?= $e($slug) ?>" pattern="[a-z0-9]+(-[a-z0-9]+)*" placeholder="my-page" required>
|
||||
<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>
|
||||
</label>
|
||||
<div class="form-submit"><button type="submit" class="button button-primary">创建草稿</button></div>
|
||||
<div class="form-submit"><button type="submit" class="button button-primary">创建页面</button></div>
|
||||
</form>
|
||||
<?= View::fragment('studio-page-templates', compact('token', 'openTemplates')) ?>
|
||||
|
||||
@@ -5,6 +5,11 @@ use App\Content\View;
|
||||
|
||||
$e = View::escape(...);
|
||||
$labels = ['modules' => '组件', 'elements' => '元素', 'layers' => '图层'];
|
||||
$modules = BlockTemplates::groups();
|
||||
if ($layoutKind !== 'header') {
|
||||
unset($modules['headers'][1]['header-member']);
|
||||
}
|
||||
$anchorForm = View::fragment('studio-anchor-form', ['groups' => $modules, 'slug' => $slug, 'token' => $token]);
|
||||
?>
|
||||
<div class="studio-presets" data-canvas-presets>
|
||||
<div class="studio-library-tabs" role="tablist" aria-label="页面编辑工具" data-library-tabs hidden>
|
||||
@@ -13,7 +18,7 @@ $labels = ['modules' => '组件', 'elements' => '元素', 'layers' => '图层'];
|
||||
aria-selected="false" tabindex="-1" data-library-tab="<?= $kind ?>"><?= $e($label) ?></button>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<?php foreach (['modules' => BlockTemplates::groups(), 'elements' => BlockTemplates::ELEMENT_GROUPS] as $kind => $groups): ?>
|
||||
<?php foreach (['modules' => $modules, 'elements' => BlockTemplates::ELEMENT_GROUPS] as $kind => $groups): ?>
|
||||
<?= View::fragment('studio-library-panel', compact('kind', 'groups', 'anchorForm')) ?>
|
||||
<?php endforeach ?>
|
||||
<section role="tabpanel" id="studio-panel-layers" aria-labelledby="studio-tab-layers" data-library-panel="layers">
|
||||
|
||||
Reference in New Issue
Block a user