feat: готовый бренд ZoomStage и минимальный доменный подвал (refs #12)
deploy-preland / deploy zoomstage.online (push) Successful in 44s
deploy-preland / deploy zoomstage.online (push) Successful in 44s
This commit is contained in:
1 parent
a2c3197a16
commit
ec087ea636
24 files changed
+365
-237
No files matched your search
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/** Готовые доменные SVG, без генерации логотипа при запросе страницы. */
|
||||
declare(strict_types=1);
|
||||
function prelandBrand(string $root, string $domain): array
|
||||
{
|
||||
$catalog = json_decode(file_get_contents($root . '/release/brands.json'), true, 512, JSON_THROW_ON_ERROR);
|
||||
if (!isset($catalog[$domain])) throw new RuntimeException('Для домена не утверждён бренд: ' . $domain);
|
||||
$brand = $catalog[$domain];
|
||||
if (array_keys($brand['logos']) !== ['docs/logo.svg', 'docs/logo-alt.svg']) throw new RuntimeException('Нужна полная пара SVG');
|
||||
foreach ($brand['logos'] as $target => $record) {
|
||||
if (!preg_match('~^brands/' . preg_quote($domain, '~') . '/(?:light|dark)\.svg$~D', $record['file'])) throw new RuntimeException('Некорректный путь бренда');
|
||||
$body = str_replace("\r\n", "\n", file_get_contents($root . '/' . $record['file']));
|
||||
if (hash('sha256', $body) !== $record['sha256'] || str_contains($body, '<text') || !str_contains($body, '<title>' . $brand['label'] . '</title>')) throw new RuntimeException('Не совпал утверждённый готовый SVG: ' . $target);
|
||||
}
|
||||
return $brand;
|
||||
}
|
||||
|
||||
function prelandBrandState(array $actual, array $brand): int
|
||||
{
|
||||
$expected = array_map(static fn(array $record): string => $record['sha256'], $brand['logos']);
|
||||
if ($actual === $expected) return 0;
|
||||
if (array_keys($actual) !== array_keys($expected)) return 1;
|
||||
foreach ($expected as $path => $hash) {
|
||||
if ($actual[$path] !== $hash && $actual[$path] !== ($brand['replace_from'][$path] ?? null)) return 1;
|
||||
}
|
||||
return 10;
|
||||
}
|
||||
Reference in new issue
Block a user