diff --git a/app/SculpinKernel.php b/app/SculpinKernel.php index ec4162d2..db658693 100644 --- a/app/SculpinKernel.php +++ b/app/SculpinKernel.php @@ -3,6 +3,7 @@ use App\Bundles\AtomFeedGeneratorBundle\SculpinAtomFeedGeneratorBundle; use App\Bundles\MermaidBundle\SculpinMermaidBundle; use App\Bundles\PhpFoundationBundle\PhpFoundationBundle; +use App\Bundles\RedditifyBundle\SculpinRedditifyBundle; use App\Bundles\SharingImageGeneratorBundle\SculpinSharingImageGeneratorBundle; use Sculpin\Bundle\SculpinBundle\HttpKernel\AbstractKernel; @@ -14,6 +15,7 @@ protected function getAdditionalSculpinBundles(): array SculpinAtomFeedGeneratorBundle::class, SculpinSharingImageGeneratorBundle::class, SculpinMermaidBundle::class, + SculpinRedditifyBundle::class, PhpFoundationBundle::class, App\Bundles\RedirectBundle\SculpinRedirectBundle::class, ]; diff --git a/app/src/Bundles/RedditifyBundle/DependencyInjection/SculpinRedditifyExtension.php b/app/src/Bundles/RedditifyBundle/DependencyInjection/SculpinRedditifyExtension.php new file mode 100644 index 00000000..a924a832 --- /dev/null +++ b/app/src/Bundles/RedditifyBundle/DependencyInjection/SculpinRedditifyExtension.php @@ -0,0 +1,17 @@ +load('services.xml'); + } +} diff --git a/app/src/Bundles/RedditifyBundle/RedditifyAssetCopier.php b/app/src/Bundles/RedditifyBundle/RedditifyAssetCopier.php new file mode 100644 index 00000000..1c455083 --- /dev/null +++ b/app/src/Bundles/RedditifyBundle/RedditifyAssetCopier.php @@ -0,0 +1,55 @@ +configuration = $configuration; + $this->filesystem = new Filesystem(); + } + + public static function getSubscribedEvents(): array + { + return [ + Sculpin::EVENT_BEFORE_RUN => 'copyRedditifyAssets', + ]; + } + + public function copyRedditifyAssets(): void + { + $env = $this->configuration->get('env') ?? 'dev'; + $outputDir = "output_{$env}"; + + $jsTargetDir = "{$outputDir}/assets/js"; + $cssTargetDir = "{$outputDir}/assets/css"; + + $this->filesystem->mkdir([$jsTargetDir, $cssTargetDir]); + + $nodePath = 'node_modules/redditify/dist/'; + + if (file_exists($nodePath . 'redditify.min.js')) { + $this->filesystem->copy( + $nodePath . 'redditify.min.js', + $jsTargetDir . '/redditify.min.js' + ); + } + + if (file_exists($nodePath . 'redditify.css')) { + $this->filesystem->copy( + $nodePath . 'redditify.css', + $cssTargetDir . '/redditify.css' + ); + } + } +} diff --git a/app/src/Bundles/RedditifyBundle/Resources/config/services.xml b/app/src/Bundles/RedditifyBundle/Resources/config/services.xml new file mode 100644 index 00000000..e64131d9 --- /dev/null +++ b/app/src/Bundles/RedditifyBundle/Resources/config/services.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + diff --git a/app/src/Bundles/RedditifyBundle/SculpinRedditifyBundle.php b/app/src/Bundles/RedditifyBundle/SculpinRedditifyBundle.php new file mode 100644 index 00000000..94ff0ce6 --- /dev/null +++ b/app/src/Bundles/RedditifyBundle/SculpinRedditifyBundle.php @@ -0,0 +1,9 @@ + ['html']]), + ]; + } + + public function renderRedditifyWidget(string $url, array $options = []): Markup + { + $maxDepth = $options['max_depth'] ?? 10; + $showContent = $options['show_content'] ?? false; + $showControls = $options['show_controls'] ?? true; + $cssClass = $options['class'] ?? 'thread-container'; + + $showContentStr = $showContent ? 'true' : 'false'; + $showControlsStr = $showControls ? 'true' : 'false'; + + $html = sprintf( + '
', + htmlspecialchars($cssClass, ENT_QUOTES), + htmlspecialchars($url, ENT_QUOTES), + $maxDepth, + $showContentStr, + $showControlsStr + ); + + $html .= ''; + $html .= ''; + + return new Markup($html, 'UTF-8'); + } +} diff --git a/package-lock.json b/package-lock.json index bb020d52..3b811d26 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,9 @@ "name": "the-php-foundation", "version": "1.0.0", "license": "ISC", + "dependencies": { + "redditify": "^0.2.2" + }, "devDependencies": { "@mermaid-js/mermaid-cli": "^11.4.2", "autoprefixer": "^10.4.21", @@ -2299,6 +2302,16 @@ "node": ">= 14" } }, + "node_modules/date-fns": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-3.6.0.tgz", + "integrity": "sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/kossnocorp" + } + }, "node_modules/dayjs": { "version": "1.11.13", "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.13.tgz", @@ -4170,6 +4183,15 @@ "node": ">= 12.13.0" } }, + "node_modules/redditify": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/redditify/-/redditify-0.2.2.tgz", + "integrity": "sha512-vuX+F0e2yJitA6Vs2ocuRJ0NTMMASCRk6IcUksVoGi6dbw+hZgkiQ/48nwDFjq3l6/FgZ54k/P2Zj1zyxVfRbQ==", + "license": "MIT", + "dependencies": { + "date-fns": "^3.0.6" + } + }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", diff --git a/package.json b/package.json index 01b0ca27..337e69b4 100644 --- a/package.json +++ b/package.json @@ -24,5 +24,8 @@ "bugs": { "url": "https://github.com/thephpf/thephp.foundation/issues" }, - "homepage": "https://github.com/thephpf/thephp.foundation" + "homepage": "https://github.com/thephpf/thephp.foundation", + "dependencies": { + "redditify": "^0.2.2" + } } diff --git a/source/_partials/redditify.html b/source/_partials/redditify.html deleted file mode 100644 index 2bebd043..00000000 --- a/source/_partials/redditify.html +++ /dev/null @@ -1,9 +0,0 @@ -
- - diff --git a/source/_posts/2025-06-08-php-30.md b/source/_posts/2025-06-08-php-30.md index 0245a136..64043056 100644 --- a/source/_posts/2025-06-08-php-30.md +++ b/source/_posts/2025-06-08-php-30.md @@ -34,6 +34,4 @@ Happy 30th birthday, PHP! 🎉 🐘💜 -{{ include('redditify.html', { - url: 'https://www.reddit.com/r/PHP/comments/1l7v0df/30_years_of_php_frankenphp_is_now_part_of_the_php/' -}) }} +{{ redditify('https://www.reddit.com/r/PHP/comments/1l7v0df/30_years_of_php_frankenphp_is_now_part_of_the_php/') }} diff --git a/source/_posts/2025-08-05-compile-generics.md b/source/_posts/2025-08-05-compile-generics.md index c0c7891a..5a58062b 100644 --- a/source/_posts/2025-08-05-compile-generics.md +++ b/source/_posts/2025-08-05-compile-generics.md @@ -369,6 +369,4 @@ Would a partial-generics approach like that described here be acceptable? Even **Would you support (and vote in favor of) compile-time-only generics as described here?** -{{ include('redditify.html', { -url: 'https://www.reddit.com/r/PHP/comments/1mhe7qf/compile_time_generics_yay_or_nay/' -}) }} +{{ redditify('https://www.reddit.com/r/PHP/comments/1mhe7qf/compile_time_generics_yay_or_nay/') }}