From bed07386ef008126aac3d927ace53265d6701501 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Sat, 7 Nov 2026 10:38:41 -0500 Subject: [PATCH] About page links to the source code and the running commit APP_REPOSITORY_URL overrides the repository for a fork. Co-Authored-By: Claude Opus 5.5 --- app/models/system_info.rb | 10 ++++++++++ app/views/admin/about/show.html.erb | 5 ++++- test/integration/admin_about_test.rb | 3 ++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/models/system_info.rb b/app/models/system_info.rb index 70e7428..776bec3 100644 --- a/app/models/system_info.rb +++ b/app/models/system_info.rb @@ -7,6 +7,9 @@ class SystemInfo omniauth omniauth_openid_connect rubyzip roo pdf-reader bcrypt ].freeze + # Where the source lives; APP_REPOSITORY_URL overrides it for a fork. + REPOSITORY_URL = ENV["APP_REPOSITORY_URL"].presence || "https://github.com/rickbarrette/simple-aircraft-manager-rails" + DATABASES = { "Main" => :primary, "Cache" => :cache, "Jobs" => :queue, "Cable" => :cable }.freeze # Set by the Docker build (see Dockerfile); in development, read from git. @@ -16,6 +19,13 @@ class SystemInfo "unknown" end + def repository_url = REPOSITORY_URL.chomp("/") + + # The running commit on the repository host, when the revision is known. + def revision_url + "#{repository_url}/commit/#{revision}" if revision.match?(/\A\h{7,40}\z/) + end + def built_at Time.zone.parse(ENV["APP_BUILT_AT"].to_s) if ENV["APP_BUILT_AT"].present? rescue ArgumentError diff --git a/app/views/admin/about/show.html.erb b/app/views/admin/about/show.html.erb index 5ccc85e..9311432 100644 --- a/app/views/admin/about/show.html.erb +++ b/app/views/admin/about/show.html.erb @@ -8,7 +8,10 @@

Version

-

<%= info.revision %>

+

+ <%= info.revision_url ? link_to(info.revision, info.revision_url, class: "link", target: "_blank", rel: "noopener", title: "This commit on GitHub") : info.revision %> +

+

<%= link_to "Source code", info.repository_url, class: "link", target: "_blank", rel: "noopener" %>

Built
<%= info.built_at ? l(info.built_at.in_time_zone, format: :short) : "—" %>
diff --git a/test/integration/admin_about_test.rb b/test/integration/admin_about_test.rb index 8f38fd1..ec0c27b 100644 --- a/test/integration/admin_about_test.rb +++ b/test/integration/admin_about_test.rb @@ -15,7 +15,8 @@ class AdminAboutTest < ActionDispatch::IntegrationTest get admin_about_path end assert_response :success - assert_select "[data-revision]", text: "abc1234" + assert_select "[data-revision] a[href='#{SystemInfo::REPOSITORY_URL}/commit/abc1234']", text: "abc1234" + assert_select "a[href='#{SystemInfo::REPOSITORY_URL}']", text: "Source code" body = response.body [ RUBY_VERSION, Rails.version, SQLite3::SQLITE_VERSION, Gem.loaded_specs["turbo-rails"].version.to_s ].each { assert_includes body, _1 } assert_includes body, "on (#{LogbookTranscriber::MODEL})"