From b98cda881e6f848c761825a76dc174c138530e2e Mon Sep 17 00:00:00 2001 From: Benjamin Nussbaum Date: Tue, 4 Nov 2025 22:53:47 +0100 Subject: [PATCH] feat: set preferred_renderer when installing from catalog --- Dockerfile | 4 ++++ app/Services/PluginImportService.php | 3 ++- resources/views/livewire/catalog/trmnl.blade.php | 11 ++++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 57a919f..4e50553 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,9 @@ ENV APP_VERSION=${APP_VERSION} ENV AUTORUN_ENABLED="true" +# Mark trmnl-liquid-cli as installed +ENV TRMNL_LIQUID_ENABLED=1 + # Switch to the root user so we can do root things USER root @@ -49,5 +52,6 @@ FROM base AS production COPY --chown=www-data:www-data --from=assets /app/public/build /var/www/html/public/build COPY --chown=www-data:www-data --from=assets /app/node_modules /var/www/html/node_modules +COPY --chown=www-data:www-data --from=bnussbau/trmnl-liquid-cli:latest /usr/local/bin/trmnl-liquid-cli /usr/local/bin/ # Drop back to the www-data user USER www-data diff --git a/app/Services/PluginImportService.php b/app/Services/PluginImportService.php index a9d93b3..7c77767 100644 --- a/app/Services/PluginImportService.php +++ b/app/Services/PluginImportService.php @@ -143,7 +143,7 @@ class PluginImportService * * @throws Exception If the ZIP file is invalid or required files are missing */ - public function importFromUrl(string $zipUrl, User $user, ?string $zipEntryPath = null): Plugin + public function importFromUrl(string $zipUrl, User $user, ?string $zipEntryPath = null, $preferredRenderer = null): Plugin { // Download the ZIP file $response = Http::timeout(60)->get($zipUrl); @@ -232,6 +232,7 @@ class PluginImportService 'render_markup' => $fullLiquid, 'configuration_template' => $configurationTemplate, 'data_payload' => json_decode($settings['static_data'] ?? '{}', true), + 'preferred_renderer' => $preferredRenderer, ]); if (! $plugin_updated) { diff --git a/resources/views/livewire/catalog/trmnl.blade.php b/resources/views/livewire/catalog/trmnl.blade.php index 6f04ca4..4d1a60f 100644 --- a/resources/views/livewire/catalog/trmnl.blade.php +++ b/resources/views/livewire/catalog/trmnl.blade.php @@ -91,11 +91,16 @@ new class extends Component { try { $zipUrl = "https://usetrmnl.com/api/plugin_settings/{$recipeId}/archive"; - $plugin = $pluginImportService->importFromUrl($zipUrl, auth()->user()); - + + $plugin = $pluginImportService->importFromUrl( + $zipUrl, + auth()->user(), + preferredRenderer: config('services.trmnl.liquid_enabled') ? 'trmnl-liquid' : null + ); + $this->dispatch('plugin-installed'); Flux::modal('import-from-trmnl-catalog')->close(); - + } catch (\Exception $e) { Log::error('Plugin installation failed: ' . $e->getMessage()); $this->addError('installation', 'Error installing plugin: ' . $e->getMessage());