Skip to content

Commit

Permalink
Merge pull request #13 from RepoCamp/version_footer_magic
Browse files Browse the repository at this point in the history
Version footer magic 🎩
  • Loading branch information
adam malantonio authored May 8, 2018
2 parents d0b35ec + 99ed811 commit 1581a78
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ group :development, :test do
gem 'rspec-rails'
gem 'selenium-webdriver'
gem 'solr_wrapper', '>= 0.3'
gem 'xray-rails'
end

group :test do
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,8 @@ GEM
xml-simple (1.1.5)
xpath (3.0.0)
nokogiri (~> 1.8)
xray-rails (0.3.1)
rails (>= 3.1.0)

PLATFORMS
ruby
Expand Down Expand Up @@ -842,6 +844,7 @@ DEPENDENCIES
tzinfo-data
uglifier (>= 1.3.0)
web-console (>= 3.3.0)
xray-rails

BUNDLED WITH
1.16.1
4 changes: 4 additions & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@
*= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
*= require_self
*/

.site-footer {
height: initial;
}
20 changes: 20 additions & 0 deletions app/views/shared/_footer.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<footer class="navbar navbar-inverse site-footer">
<div class="container-fluid">
<div class="navbar-text text-left">
<p><%= t('hyrax.footer.service_html') %></p>
<p><%= t('hyrax.product_name') %> v<%= Hyrax::VERSION %></p>
</div>
<div class="navbar-right">
<div class="navbar-text text-right">
<p><%= t('hyrax.footer.copyright_html') %></p>
<p><%= t('hyrax.background_attribution_html') %></p>
<br>TEAM2 Version
<br>ENV: <%= Rails.env %>
<br>SHA: <%= link_to(GIT_SHA, "https://github.com/RepoCamp/ascteam2/commit/#{GIT_SHA}") %>
<br>Branch: <%= BRANCH %>
<br>Updated: <%= LAST_DEPLOYED %>
</div>

</div>
</div>
</footer>
1 change: 1 addition & 0 deletions config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
append :linked_dirs, "db"
append :linked_dirs, "public/assets"
append :linked_files, "config/secrets.yml"
append :linked_files, ".env.production"

# We have to re-define capistrano-sidekiq's tasks to work with
# systemctl in production. Note that you must clear the previously-defined
Expand Down
26 changes: 26 additions & 0 deletions config/initializers/git_sha.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
revisions_logfile = "/opt/#{ENV['PROJECT_NAME']}/revisions.log"
GIT_SHA =
if Rails.env.production? && File.exist?(revisions_logfile)
`tail -1 #{revisions_logfile}`.chomp.split(" ")[3].gsub(/\)$/, '')
elsif Rails.env.development? || Rails.env.test?
`git rev-parse HEAD`.chomp
else
"Unknown SHA"
end

BRANCH =
if Rails.env.production? && File.exist?(revisions_logfile)
`tail -1 #{revisions_logfile}`.chomp.split(" ")[1]
elsif Rails.env.development? || Rails.env.test?
`git rev-parse --abbrev-ref HEAD`.chomp
else
"Unknown branch"
end

LAST_DEPLOYED =
if Rails.env.production? && File.exist?(revisions_logfile)
deployed = `tail -1 #{revisions_logfile}`.chomp.split(" ")[7]
Date.parse(deployed).strftime("%d %B %Y")
else
"Not in deployed environment"
end

0 comments on commit 1581a78

Please sign in to comment.