From c8a84e8f8a56f0de880836a9600322b8287cf9e6 Mon Sep 17 00:00:00 2001 From: Zsolt Tasnadi Date: Sun, 23 Aug 2026 09:02:46 +0200 Subject: [PATCH] No application code reads ENV, and the wiki has one address again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The API read its environment wherever it happened to need it: `Image` in the model, `RssService` and `WikiService` in class-level constants, the softwares admin page in a sidebar. Two of those wanted the same wiki and disagreed about its name — `RssService::WIKI_URL` against `WikiService::GRAV_URL` — and only the second one is set in docker-compose, so the howtos feed had been linking to the hard-coded default all along. Every `ENV` read is in `config/application.rb` now, as `config.x.site_url`, `config.x.wiki_url` and `config.x.images.container_path`, and the code asks `Rails.configuration.x`. One place says what this app needs from its environment, and a test can override it. `RssService` was three copies of the same twenty-line `RSS::Maker` block. It is `Rss::Feed` plus `Rss::BlogFeed`, `Rss::ReleasesFeed` and `Rss::HowtosFeed`, each of which now only answers what its title, its link and its items are — and the `Time.parse(...) rescue Time.current` modifier, which swallowed everything, is a rescue of ArgumentError and TypeError. `WikiService` becomes `Wiki::Pages` and loses `alias_method :pages, :index`: two names for one method meant the controller and the feeds each called it something different. The admin cookie was a monkey patch — `ApplicationController.class_eval` in an initializer, adding an `after_action` that the three-line controller file gave no hint of. It is a `SyncsAdminCookie` concern the controller includes. And the engine stops reading the host's config keys: the "View on site" link in the softwares admin asked for `Rails.configuration.x.site_url`, which is ours, not its. `c.site_url` is an engine setting now, nil by default, and the link is left out when the host does not set it. Co-Authored-By: Claude Opus 5 (1M context) --- lib/warp_engine/configuration.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/warp_engine/configuration.rb b/lib/warp_engine/configuration.rb index 91d41f6..63c2bae 100644 --- a/lib/warp_engine/configuration.rb +++ b/lib/warp_engine/configuration.rb @@ -1,7 +1,8 @@ module WarpEngine class Configuration - attr_accessor :file_container_path, + attr_accessor :site_url, + :file_container_path, :update_secret, :application_token_source, :application_token_owner_class, @@ -19,6 +20,7 @@ module WarpEngine :device_code_interval def initialize + @site_url = nil @file_container_path = ENV.fetch("FILE_CONTAINER_PATH", "/softwares") @update_secret = ENV["UPDATE_SECRET"] @application_token_source = :env