From d263eaf92d720fed6d6673238088343582fb249b Mon Sep 17 00:00:00 2001 From: HolgerHatGarKeineNode Date: Tue, 9 Dec 2025 22:45:26 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=20Add=20German=20portal?= =?UTF-8?q?=20domain=20and=20refactor=20URL=20handling=20for=20Nostr=20pub?= =?UTF-8?q?lishing=20-=20Introduce=20`portal.einundzwanzig.space`=20with?= =?UTF-8?q?=20locale=20settings=20in=20`DomainMiddleware`.=20-=20Replace?= =?UTF-8?q?=20verbose=20if=E2=80=91chain=20in=20`NostrTrait::getUrl()`=20w?= =?UTF-8?q?ith=20a=20concise=20match=20expression.=20-=20Add=20`DOMAIN=5FM?= =?UTF-8?q?AP`=20constant=20to=20`PublishUnpublishedItems`=20and=20force?= =?UTF-8?q?=20URL=20generation=20to=20use=20the=20correct=20domain=20per?= =?UTF-8?q?=20country.=20-=20Update=20command=20flow:=20set=20domain=20bef?= =?UTF-8?q?ore=20configuring=20timezone/locale.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Nostr/PublishUnpublishedItems.php | 18 ++++++++++++++- app/Http/Middleware/DomainMiddleware.php | 5 ++++ app/Traits/NostrTrait.php | 23 +++++++++---------- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/app/Console/Commands/Nostr/PublishUnpublishedItems.php b/app/Console/Commands/Nostr/PublishUnpublishedItems.php index 1c6e0e5..46a6943 100644 --- a/app/Console/Commands/Nostr/PublishUnpublishedItems.php +++ b/app/Console/Commands/Nostr/PublishUnpublishedItems.php @@ -9,6 +9,7 @@ use App\Models\MeetupEvent; use App\Traits\NostrTrait; use Illuminate\Console\Command; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\URL; class PublishUnpublishedItems extends Command { @@ -26,6 +27,15 @@ class PublishUnpublishedItems extends Command 'pt' => 'Europe/Lisbon', ]; + private const DOMAIN_MAP = [ + 'de' => 'portal.einundzwanzig.space', + 'nl' => 'portal.eenentwintig.net', + 'hu' => 'portal.huszonegy.world', + 'pl' => 'portal.dwadziesciajeden.pl', + // Default for other countries (e.g., 'es', 'pt') if added later + 'default' => 'portal.einundzwanzig.space', + ]; + public function handle(): void { $modelName = $this->option('model'); @@ -59,8 +69,14 @@ class PublishUnpublishedItems extends Command return; } - // Get country code and configure timezone/locale if applicable + // Get country code $countryCode = $this->getCountryCode($model); + + // Set the domain based on country code for URL generation + $domain = self::DOMAIN_MAP[$countryCode] ?? self::DOMAIN_MAP['default']; + URL::useOrigin('https://'.$domain); // Forces URL generation to use this domain + + // Configure timezone and locale $this->configureForCountry($countryCode); $text = $this->getText($model, $countryCode); diff --git a/app/Http/Middleware/DomainMiddleware.php b/app/Http/Middleware/DomainMiddleware.php index b3b1ec7..031ab0e 100644 --- a/app/Http/Middleware/DomainMiddleware.php +++ b/app/Http/Middleware/DomainMiddleware.php @@ -15,6 +15,11 @@ class DomainMiddleware // domains $domainArray = [ + 'portal.einundzwanzig.space' => [ + 'locale' => 'de', + 'lang_country' => 'de-DE', + 'app_name' => 'EINUNDZWANZIG Portal', + ], 'portal.eenentwintig.net' => [ 'locale' => 'nl', 'lang_country' => 'nl-NL', diff --git a/app/Traits/NostrTrait.php b/app/Traits/NostrTrait.php index 4f19831..f4d2bce 100644 --- a/app/Traits/NostrTrait.php +++ b/app/Traits/NostrTrait.php @@ -85,17 +85,16 @@ trait NostrTrait private function getUrl(Model $model, string $countryCode): string { - if ($model instanceof Course) { - return route('courses.landingpage', ['country' => $countryCode, 'course' => $model]); - } elseif ($model instanceof CourseEvent) { - return route('courses.landingpage', ['country' => $countryCode, 'course' => $model->course]); - } elseif ($model instanceof Meetup) { - return route('meetups.landingpage', ['country' => $countryCode, 'meetup' => $model]); - } elseif ($model instanceof MeetupEvent) { - return route('meetups.landingpage-event', - ['country' => $countryCode, 'meetup' => $model->meetup, 'event' => $model]); - } - - return ''; + return match (true) { + $model instanceof Course => url()->route('courses.landingpage', + ['country' => $countryCode, 'course' => $model]), + $model instanceof CourseEvent => url()->route('courses.landingpage', + ['country' => $countryCode, 'course' => $model->course]), + $model instanceof Meetup => url()->route('meetups.landingpage', + ['country' => $countryCode, 'meetup' => $model]), + $model instanceof MeetupEvent => url()->route('meetups.landingpage-event', + ['country' => $countryCode, 'meetup' => $model->meetup, 'event' => $model]), + default => '', + }; } }