fix: align stage preland picker and demo layout
This commit is contained in:
1 parent
4fa9eebcfb
commit
45e20ed0cd
128 files changed
+196
-13
No files matched your search
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Наборы примеров Preland должны копироваться с Index без переложения:
|
||||
* images/demo/<пример>/ и images/demo-N/<пример>/.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
$root = dirname(__DIR__);
|
||||
$failures = [];
|
||||
|
||||
foreach ([
|
||||
'images/demo/1/source.avif',
|
||||
'images/demo/1/result.avif',
|
||||
'images/demo/1/thumb.avif',
|
||||
'images/demo/5/source_mob.avif',
|
||||
'images/demo-2/1/source.avif',
|
||||
'images/demo-2/5/result_mob.avif',
|
||||
] as $relativePath) {
|
||||
if (!is_file($root . '/' . $relativePath)) {
|
||||
$failures[] = "Отсутствует Index-совместимый asset {$relativePath}.";
|
||||
}
|
||||
}
|
||||
|
||||
foreach ([
|
||||
'images/demo/1/1',
|
||||
'images/demo/2/1',
|
||||
] as $legacyPath) {
|
||||
if (is_dir($root . '/' . $legacyPath)) {
|
||||
$failures[] = "Не должна оставаться промежуточная группировка {$legacyPath}.";
|
||||
}
|
||||
}
|
||||
|
||||
$template = (string) file_get_contents($root . '/template.php');
|
||||
$examples = (string) file_get_contents($root . '/components/examples.php');
|
||||
$pathBuilder = "\$demoDirName = 'demo' . (\$indpic === '1' ? '' : '-' . \$indpic);";
|
||||
if (!str_contains($template, $pathBuilder)
|
||||
|| !str_contains($examples, $pathBuilder)
|
||||
|| !str_contains($template, '"/images/{$demoDirName}/1"')
|
||||
|| !str_contains($examples, '"/images/{$demoDirName}"')) {
|
||||
$failures[] = 'Template и examples должны строить путь из Index-совместимого имени demo/demo-N.';
|
||||
}
|
||||
|
||||
if ($failures !== []) {
|
||||
fwrite(STDERR, "FAILED\n- " . implode("\n- ", $failures) . "\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fwrite(STDOUT, "OK: Preland demo layout matches Index\n");
|
||||
@@ -6,7 +6,7 @@ $form = file_get_contents(dirname(__DIR__) . '/components/form.php');
|
||||
$failures = [];
|
||||
|
||||
foreach ([
|
||||
"\$basePickerAccept = 'image/jpeg,image/png,image/gif,image/webp,image/bmp,image/avif,image/heic,image/heif,image/jxl,image/tiff," => 'Preland должен ограничивать штатный picker поддерживаемыми raster-контейнерами.',
|
||||
"\$basePickerAccept = 'image/jpeg,image/png,image/gif,image/webp,image/bmp,image/avif,image/heic,image/heif,image/jxl,image/tiff,application/pdf,.pdf," => 'Preland должен сразу предлагать raster-контейнеры и PDF, не ожидая upload-policy.',
|
||||
'accept="<?= htmlspecialchars($basePickerAccept' => 'Preland должен передать допустимые типы в штатный file input.',
|
||||
'picker_accept' => 'Preland должен получать актуальный accept из API policy для PDF.',
|
||||
'max_file_size_bytes' => 'Preland должен получить лимит размера для preflight без передачи гигабайтного файла.',
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Контракт Preland → сайт: собственные метки всегда разрешены до перехода,
|
||||
* а внешние рекламные параметры не теряются.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
$_GET = [
|
||||
'utm_source' => 'stage-ad',
|
||||
'subid' => 'click-42',
|
||||
'key' => 'must-not-replace-client-key',
|
||||
];
|
||||
$_SERVER['HTTP_HOST'] = 'zoomstage.online';
|
||||
|
||||
ob_start();
|
||||
require dirname(__DIR__) . '/index.php';
|
||||
$html = (string) ob_get_clean();
|
||||
|
||||
if (!preg_match('/const redirectUrlUtm = (.+);/', $html, $match)) {
|
||||
fwrite(STDERR, "FAIL: Preland не отдал redirectUrlUtm.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$query = json_decode($match[1], true);
|
||||
if (!is_string($query)) {
|
||||
fwrite(STDERR, "FAIL: redirectUrlUtm должен быть JSON-строкой.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
parse_str($query, $params);
|
||||
$expected = [
|
||||
'indpic' => '1',
|
||||
'theme' => 'dark',
|
||||
'degr' => '1',
|
||||
'registration' => 'after',
|
||||
'bchoice' => 'a',
|
||||
'chb' => 'b',
|
||||
'tp' => '1',
|
||||
'utm_source' => 'stage-ad',
|
||||
'subid' => 'click-42',
|
||||
];
|
||||
|
||||
ksort($params);
|
||||
ksort($expected);
|
||||
|
||||
if ($params !== $expected) {
|
||||
fwrite(STDERR, "FAIL: claim URL обязан нести все resolved UTM и внешние параметры.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (isset($params['key'])) {
|
||||
fwrite(STDERR, "FAIL: внешний key не должен подменять одноразовый ключ загрузки.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fwrite(STDOUT, "OK: preland redirects resolved UTM and external parameters\n");
|
||||
Reference in new issue
Block a user