No application code reads ENV, and the wiki has one address again

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) <noreply@anthropic.com>
This commit is contained in:
2026-08-23 09:02:46 +02:00
co-authored by Claude Opus 5
parent 7087a9bbc7
commit c8a84e8f8a
+3 -1
View File
@@ -1,7 +1,8 @@
module WarpEngine module WarpEngine
class Configuration class Configuration
attr_accessor :file_container_path, attr_accessor :site_url,
:file_container_path,
:update_secret, :update_secret,
:application_token_source, :application_token_source,
:application_token_owner_class, :application_token_owner_class,
@@ -19,6 +20,7 @@ module WarpEngine
:device_code_interval :device_code_interval
def initialize def initialize
@site_url = nil
@file_container_path = ENV.fetch("FILE_CONTAINER_PATH", "/softwares") @file_container_path = ENV.fetch("FILE_CONTAINER_PATH", "/softwares")
@update_secret = ENV["UPDATE_SECRET"] @update_secret = ENV["UPDATE_SECRET"]
@application_token_source = :env @application_token_source = :env