aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhellekin <hellekin@cepheide.org>2021-01-22 14:45:15 +0100
committerhellekin <hellekin@cepheide.org>2021-01-22 14:46:50 +0100
commit9d51444479cec02d0b250ae65a91d36beb5f6b1b (patch)
tree71475d4157eaa2f65207e43cec433a18304d1a50
parent97bfc3f6012027077077ea4a6b5f2f709c76158e (diff)
downloadincommon-map-9d51444479cec02d0b250ae65a91d36beb5f6b1b.tar.gz
Link to current source code version (per AGPL-3.0)
-rw-r--r--app/assets/stylesheets/application/_footer.scss20
-rw-r--r--app/helpers/application_helper.rb11
-rw-r--r--app/lib/incommon.rb10
-rw-r--r--app/views/welcome/index.html.erb4
4 files changed, 45 insertions, 0 deletions
diff --git a/app/assets/stylesheets/application/_footer.scss b/app/assets/stylesheets/application/_footer.scss
new file mode 100644
index 0000000..4ab34a2
--- /dev/null
+++ b/app/assets/stylesheets/application/_footer.scss
@@ -0,0 +1,20 @@
+body>footer {
+ position: absolute;
+ z-index: 1004;
+ margin: 0 auto;
+ background-color: rgba(0,0,0,0.5);
+ color: white;
+ text-align: center;
+ bottom: 0;
+ left: 0;
+ right: 0;
+ width: 10rem;
+ border-top-left-radius: 1rem;
+ border-top-right-radius: 1rem;
+}
+
+.app-version a:link,
+.app-version a:visited {
+ color: whitesmoke;
+}
+
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index e39da5f..89b3b6d 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -23,6 +23,17 @@ module ApplicationHelper
).to_html.html_safe, class: 'markdown')
end
+ # Display current application version
+ def version_string
+ version = begin
+ IO.read('.app-version')&.strip
+ rescue
+ 'HEAD'
+ end
+
+ tag.div(link_to(version, INCOMMON.repo_url(version), title: 'Read source code'), class: 'app-version')
+ end
+
private
# CommonMarker extensions
diff --git a/app/lib/incommon.rb b/app/lib/incommon.rb
index 091f022..c2f30b5 100644
--- a/app/lib/incommon.rb
+++ b/app/lib/incommon.rb
@@ -3,4 +3,14 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
module INCOMMON
+ module_function
+ def repo_url(version)
+ case version
+ when /^(HEAD|v\d)/
+ query="h=#{version}"
+ else
+ query="h=HEAD&id=#{version}"
+ end
+ URI.parse("https://code.cepheide.org/incommon-map.git/tree/?#{query}").to_s
+ end
end
diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb
index d9fd0f6..a7bf9b8 100644
--- a/app/views/welcome/index.html.erb
+++ b/app/views/welcome/index.html.erb
@@ -16,3 +16,7 @@
<% if current_user.present? %>
<% end %><%# ensure it does not break when we don't have a record... %>
<% end %>
+
+<% content_for :footer do %>
+ <%= version_string %>
+<% end %>