diff --git a/bin/update-path-opengraph-images b/bin/update-path-opengraph-images index 1ef622f..f95dee8 100755 --- a/bin/update-path-opengraph-images +++ b/bin/update-path-opengraph-images @@ -17,9 +17,6 @@ $container = require 'config/container.php'; $entityManager = $container->get(EntityManager::class); $postRepository = $entityManager->getRepository(Post::class); -$config = $container->get('config'); -$baseUrl = rtrim($config['application']['baseUrl'] ?? '', '/'); - /** * * @return array @@ -29,7 +26,7 @@ function indexUploadSources(string $uploadsDir, string $excludeDir): array $index = []; $iterator = new RecursiveIteratorIterator( - new RecursiveDirectoryIterator($uploadsDir, FilesystemIterator::SKIP_DOTS) + new RecursiveDirectoryIterator($uploadsDir, FilesystemIterator::SKIP_DOTS) ); foreach ($iterator as $file) { @@ -53,9 +50,13 @@ function indexUploadSources(string $uploadsDir, string $excludeDir): array $sourceIndex = indexUploadSources($uploadsDir, $ogDir); +if (! is_dir($ogDir) && ! mkdir($ogDir, 0775, true) && ! is_dir($ogDir)) { + fwrite(STDERR, sprintf("Failed to create directory '%s'%s", $ogDir, PHP_EOL)); + exit(1); +} + $postsUpdated = 0; $postsSkipped = 0; -$dirsCreated = 0; $imagesMissing = 0; $posts = $postRepository->findAll(); @@ -66,7 +67,7 @@ foreach ($posts as $post) { continue; } - if ($baseUrl !== '' && str_starts_with($image, $baseUrl . '/')) { + if (str_starts_with($image, '/uploads/opengraph/article/')) { continue; } @@ -81,22 +82,13 @@ foreach ($posts as $post) { continue; } - $targetDir = $ogDir . '/' . $post->getId()->toString(); - if (! is_dir($targetDir)) { - if (! mkdir($targetDir, 0775, true) && ! is_dir($targetDir)) { - fwrite(STDERR, sprintf("Failed to create directory '%s'%s", $targetDir, PHP_EOL)); - continue; - } - $dirsCreated++; - } - - $targetPath = $targetDir . '/' . $filename; - if (! file_exists($targetPath) && ! copy($sourceIndex[$filename], $targetPath)) { + $targetPath = $ogDir . '/' . $filename; + if (! copy($sourceIndex[$filename], $targetPath)) { fwrite(STDERR, sprintf("Failed to copy '%s' to '%s'%s", $sourceIndex[$filename], $targetPath, PHP_EOL)); continue; } - $post->setOpenGraphImage('/' . $targetPath); + $post->setOpenGraphImage('/uploads/opengraph/article/' . $filename); $postsUpdated++; } @@ -105,14 +97,12 @@ $entityManager->flush(); $postsSkipped = count($posts) - $postsUpdated - $imagesMissing; printf( - "Done. %d post%s updated, %d director%s created, %d image%s missing, %d post%s skipped.%s", - $postsUpdated, - $postsUpdated === 1 ? '' : 's', - $dirsCreated, - $dirsCreated === 1 ? 'y' : 'ies', - $imagesMissing, - $imagesMissing === 1 ? '' : 's', - $postsSkipped, - $postsSkipped === 1 ? '' : 's', - PHP_EOL + "Done. %d post%s updated, %d image%s missing, %d post%s skipped.%s", + $postsUpdated, + $postsUpdated === 1 ? '' : 's', + $imagesMissing, + $imagesMissing === 1 ? '' : 's', + $postsSkipped, + $postsSkipped === 1 ? '' : 's', + PHP_EOL ); diff --git a/src/App/templates/partial/meta.html.twig b/src/App/templates/partial/meta.html.twig index c196c3c..6c9335f 100644 --- a/src/App/templates/partial/meta.html.twig +++ b/src/App/templates/partial/meta.html.twig @@ -6,7 +6,7 @@ - + diff --git a/src/Blog/templates/page/contact.html.twig b/src/Blog/templates/page/contact.html.twig index 7813d41..bff0156 100644 --- a/src/Blog/templates/page/contact.html.twig +++ b/src/Blog/templates/page/contact.html.twig @@ -47,30 +47,6 @@ -
-
-
- About -

A full-fledged Headless Platform

-

A headless platform built on top of the Mezzio microframework using Laminas components, with both backend management and frontend-agnostic capabilities.

-
- -
-