Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version footer magic 🎩 #13

Merged
merged 5 commits into from
May 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -812,6 +812,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 @@ -852,6 +854,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"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am working on adding this my org's Sufia, and I can't remember what this line's purpose is. Anyone remember?

cc: @bess

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it was a deployment bugfix, rather than related to the git footer? short of the ENV['PROJECT_NAME'] being called in config/initializers/git_sha.rb, i can't find any instances of the ENV hash in this PR?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, yes, that rings a bell! Thanks @malantonio, hope all's well.


# 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