forked from laysense/laysite
Prepare LaySite 1.4.5 site icons, Head settings and release images
This commit is contained in:
@@ -12,7 +12,7 @@ use Throwable;
|
||||
final class SiteBackup
|
||||
{
|
||||
private const FORMAT = 'laysite-site';
|
||||
private const VERSION = 4;
|
||||
private const VERSION = 5;
|
||||
private const TABLES = [
|
||||
'site_settings', 'design_presets', 'pages', 'sections', 'article_categories', 'articles',
|
||||
'article_category_links', 'article_redirects', 'article_deletions', 'media',
|
||||
@@ -140,7 +140,7 @@ final class SiteBackup
|
||||
private static function prepare(mixed $manifest): array
|
||||
{
|
||||
if (!is_array($manifest) || ($manifest['format'] ?? '') !== self::FORMAT
|
||||
|| !in_array($manifest['version'] ?? null, [1, 2, 3, self::VERSION], true) || !is_array($manifest['tables'] ?? null)) {
|
||||
|| !in_array($manifest['version'] ?? null, [1, 2, 3, 4, self::VERSION], true) || !is_array($manifest['tables'] ?? null)) {
|
||||
throw new RuntimeException('备份格式不受支持,请使用相同或更新版本的 LaySite。');
|
||||
}
|
||||
$tables = $manifest['tables'];
|
||||
@@ -172,6 +172,8 @@ final class SiteBackup
|
||||
throw new RuntimeException('备份的站点名称无效。');
|
||||
}
|
||||
$site = ['name' => $settings['name'], 'cdn' => ['origin' => Assets::cdn($settings['cdn']['origin'] ?? '')], 'revisions' => ['general' => time()]];
|
||||
$site['head_html'] = PageHead::normalize($settings['head_html'] ?? '');
|
||||
$site['favicon'] = SiteIcon::normalize($settings['favicon'] ?? '');
|
||||
$layoutDefaults = $settings['layout_defaults'] ?? [];
|
||||
if (!is_array($layoutDefaults)) {
|
||||
throw new RuntimeException('备份的基础页头页脚配置无效。');
|
||||
@@ -210,6 +212,7 @@ final class SiteBackup
|
||||
$row['visibility'] = Database::json(array_intersect_key(self::decode($row['visibility'] ?? '{}'), array_flip(['header', 'hero', 'footer'])));
|
||||
$row['alignments'] = Database::json(self::decode($row['alignments'] ?? '{}'));
|
||||
$row['presentation'] = CanvasStyle::encode(CanvasStyle::normalize(self::decode($row['presentation'] ?? '{}'), CanvasStyle::PAGE));
|
||||
$row['head_html'] = $layout === null ? PageHead::normalize($row['head_html'] ?? '') : '';
|
||||
if (($row['theme'] ?? '') !== '' && !isset(PageTemplates::groups()[$row['theme']])) {
|
||||
$row['theme'] = '';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user