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" %>