Serve images without PHP, add the 720 and 1280 steps, trim two hot paths
- Image widths are 480, 720, 960, 1280, 1600 and 2400. A phone needed 721 pixels and got 960. Existing images receive the new steps from a task; stored pages pick them up at render time, so no document is rewritten. Mobile backgrounds use 720. - A variant served once is mirrored to public/media, and a rewrite rule lets the web server deliver it from there. var/media stays the source. - The hero preload follows the image each device really shows. - The post navigation reads the order and then two posts instead of up to 500 documents. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
dca2665138
commit
7d0369bada
32 files changed
+550
-57
No files matched your search
@@ -3,6 +3,7 @@
|
||||
namespace App\Ops;
|
||||
|
||||
use App\Content\DocumentValidator;
|
||||
use App\Content\MediaMirror;
|
||||
use App\Domain\InvalidDocument;
|
||||
use App\Domain\InvalidPage;
|
||||
use Doctrine\DBAL\Connection;
|
||||
@@ -49,6 +50,7 @@ final class SitePackage
|
||||
private Updater $updater,
|
||||
private string $root,
|
||||
private string $mediaDirectory,
|
||||
private ?MediaMirror $mirror = null,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -231,6 +233,8 @@ final class SitePackage
|
||||
return $fail();
|
||||
}
|
||||
$step('Medien ersetzen', true, sprintf('%d Datei(en) übernommen.', $moved));
|
||||
// Was der Webserver noch aus dem Abbild lieferte, gehört zur Website von vorher.
|
||||
$this->mirror?->prune();
|
||||
} finally {
|
||||
if (!$inWartung) {
|
||||
$this->updater->maintenance(false);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Ops\Tasks;
|
||||
|
||||
use App\Content\MediaMirror;
|
||||
use App\Ops\ArchiveUpdate;
|
||||
use App\Ops\Scheduler;
|
||||
use App\Ops\Updater;
|
||||
@@ -26,7 +27,7 @@ final class CleanupTask implements Task
|
||||
/** So viele Zeilen bleiben in den Protokollen stehen. */
|
||||
private const KEEP_LINES = 200;
|
||||
|
||||
public function __construct(private string $projectDir)
|
||||
public function __construct(private string $projectDir, private ?MediaMirror $mirror = null)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -57,12 +58,16 @@ final class CleanupTask implements Task
|
||||
{
|
||||
$limit = time() - self::KEEP_DAYS * 86400;
|
||||
|
||||
return sprintf(
|
||||
$bericht = sprintf(
|
||||
'%d Sitzungsdatei(en), %d Update-Ordner entfernt, %d Protokoll(e) gekürzt.',
|
||||
$this->sessions($limit),
|
||||
$this->updateFolders($limit),
|
||||
$this->logs(),
|
||||
);
|
||||
// Bildvarianten im öffentlichen Abbild, deren Bild es nicht mehr gibt.
|
||||
$verwaist = $this->mirror?->prune() ?? 0;
|
||||
|
||||
return 0 === $verwaist ? $bericht : $bericht.sprintf(' %d verwaiste Bilddatei(en) aus public/media entfernt.', $verwaist);
|
||||
}
|
||||
|
||||
/** Sitzungsdateien. Der Garbage Collector von PHP ist auf vielen Hostings abgeschaltet. */
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Ops\Tasks;
|
||||
|
||||
use App\Content\MediaLibrary;
|
||||
|
||||
/**
|
||||
* Reicht vorhandenen Bildern Größen nach, die es bei ihrem Upload noch nicht gab.
|
||||
*
|
||||
* Mit 1.42.0 kamen die Stufen 720 und 1280 dazu. Neue Uploads bekommen sie sofort; für alles,
|
||||
* was schon in der Mediathek liegt, rechnet diese Aufgabe sie portionsweise aus der größten
|
||||
* vorhandenen Variante. Ist nichts mehr offen, kostet ein Lauf eine Abfrage.
|
||||
*/
|
||||
final class ImageVariantsTask implements Task
|
||||
{
|
||||
public function __construct(private MediaLibrary $media)
|
||||
{
|
||||
}
|
||||
|
||||
public function name(): string
|
||||
{
|
||||
return 'image-variants';
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return 'Bildgrößen ergänzen';
|
||||
}
|
||||
|
||||
public function explanation(): string
|
||||
{
|
||||
return 'Ohne sie laden Telefone bei älteren Bildern eine größere Fassung als nötig. Angezeigt wird trotzdem alles.';
|
||||
}
|
||||
|
||||
public function interval(): int
|
||||
{
|
||||
return 900;
|
||||
}
|
||||
|
||||
public function run(): string
|
||||
{
|
||||
$ergebnis = $this->media->fillVariants();
|
||||
if (0 === $ergebnis['done'] && 0 === $ergebnis['left']) {
|
||||
return 'Alle Bilder haben alle Größen.';
|
||||
}
|
||||
|
||||
return sprintf('%d Bild(er) ergänzt, %d warten auf den nächsten Lauf.', $ergebnis['done'], $ergebnis['left']);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user