Skip to content

Commit

Permalink
Add version footer (#722)
Browse files Browse the repository at this point in the history
* Add version footer

- Includes branch or release name, date deployed if in production environment, and title with git sha

* Add Hyrax version to footer, link to Hy-C and Hyrax

- Three sections for version footer

* Adjust html and center all footer menus

Co-authored-by: lfarrell <[email protected]>
  • Loading branch information
maxkadel and lfarrell authored Dec 8, 2021
1 parent d1eff11 commit d28f477
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 16 deletions.
29 changes: 25 additions & 4 deletions app/assets/stylesheets/unc_custom.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,11 @@ div.person {
}

.site-footer, .social {
height: 30px;
height: auto;
}



#unc-footer {
background-color: $carolina-blue-dark;

Expand All @@ -322,18 +324,33 @@ div.person {
width: 100%;
}

a {
color: $text-color;
}

ul {
margin: auto;

li {
color: $text-color;
display: inline-block;
margin: -10px 0 0 15px;
padding-right: 15px;
border-right: 1px solid $text-color;

&:first-child {
margin-left: 0;
}

&:last-child {
border-right: none;
}
}
}

#unc-version-footer {
margin-top: 15px;
}
}

div.unc-modal {
Expand Down Expand Up @@ -701,6 +718,10 @@ li {
padding-top: 10px;
border-right: none;
}

#unc-version-footer {
margin-top: auto;
}
}

#unc-featured {
Expand Down Expand Up @@ -863,6 +884,7 @@ li {
#unc-footer {
ul li {
display: block;
margin-left: 0;
margin-top: 5px;
}
}
Expand Down Expand Up @@ -913,8 +935,7 @@ li {
}

ul.navbar-nav {
margin-top: 8px;
padding-left: 20px;
margin: 8px auto;
}
}

Expand Down Expand Up @@ -1001,4 +1022,4 @@ li {
display: block !important;
}
}
}
}
33 changes: 21 additions & 12 deletions app/views/shared/_footer.html.erb
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
<%# [hyc-override] Overriding partial in hyrax gem to update homepage %>
<footer id="unc-footer" class="navbar navbar-inverse site-footer">
<div class="container-fluid">
<div class="navbar-text">
<ul class="navbar-nav list-unstyled">
<li><%= link_to t('hyrax.links.home'), '/' %></li>
<li><%= link_to t('hyrax.links.browse_collections'), main_app.search_catalog_path(f: { human_readable_type_sim: ["Collection"]}) %></li>
<li><%= link_to t('hyrax.links.help'), "https://blogs.lib.unc.edu/cdr" %></li>
<li><%= link_to t('hyrax.links.contact'), "https://blogs.lib.unc.edu/cdr/index.php/contact-us" %></li>
<li><%= link_to t('hyrax.links.library_home'), "https://library.unc.edu" %></li>
<li><%= link_to t('hyrax.links.privacy_policy'), "https://library.unc.edu/privacy-policy" %></li>
<li><%= link_to t('hyrax.links.accessibility'), "https://digitalaccess.unc.edu/report" %></li>
</ul>
<div class="navbar-text text-center">
<div class="text-center">
<div>
<ul class="navbar-nav list-unstyled">
<li><%= link_to t('hyrax.links.home'), '/' %></li>
<li><%= link_to t('hyrax.links.browse_collections'), main_app.search_catalog_path(f: { human_readable_type_sim: ["Collection"]}) %></li>
<li><%= link_to t('hyrax.links.help'), "https://blogs.lib.unc.edu/cdr" %></li>
<li><%= link_to t('hyrax.links.contact'), "https://blogs.lib.unc.edu/cdr/index.php/contact-us" %></li>
<li><%= link_to t('hyrax.links.library_home'), "https://library.unc.edu" %></li>
<li><%= link_to t('hyrax.links.privacy_policy'), "https://library.unc.edu/privacy-policy" %></li>
<li><%= link_to t('hyrax.links.accessibility'), "https://digitalaccess.unc.edu/report" %></li>
</ul>
</div>
<div>
<ul id="unc-version-footer" class="list-unstyled">
<li title="<%= GIT_SHA %>"><%= link_to("Hy-C #{BRANCH}", "https://github.com/UNC-Libraries/hy-c") %></li>
<li><%= LAST_DEPLOYED %></li>
<li><%= link_to("Hyrax version #{HYRAX_VERSION}", "https://hyrax.samvera.org/") %></li>
</ul>
</div>
</div>
</div>
</div>
</footer>
<%= render '/shared/select_work_type_modal' %>
18 changes: 18 additions & 0 deletions config/initializers/git_sha.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
GIT_SHA = `git rev-parse HEAD`.chomp
BRANCH = `git rev-parse --abbrev-ref HEAD`.chomp
Rails.logger.debug("in initializer: #{Rails.env}")
LAST_DEPLOYED = if Rails.env.production?
# on cdr-test this returns /net/deploy/ir/test/releases/DEPLOY_DATE
# e.g. /net/deploy/ir/test/releases/20211202095413
directory_name = `pwd -P`.chomp
deploy_date = directory_name.match(/\d+/).try(:[], 0)
begin
Date.parse(deploy_date).strftime("Deployed on %B %-d, %Y")
rescue ArgumentError, TypeError
"Cannot determine deploy date"
end
else
"Not in deployed environment"
end

HYRAX_VERSION = Gem.loaded_specs["hyrax"].version.to_s
40 changes: 40 additions & 0 deletions spec/features/footer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
require "rails_helper"

RSpec.feature 'custom shared footer' do
before do
visit "/"
end

it "displays the version footer" do
expect(page).to have_css("#unc-version-footer")
end

it "has the Hyrax version from the gemfile" do
expect(page).to have_link("Hyrax version", href: "https://hyrax.samvera.org/")
expect(page).to have_link("Hy-C")
end

context "in the development environment" do
before do
allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new("development"))
end

it "displays that it's not in a deployed environment" do
expect(page).to have_content("Not in deployed environment")
end
end

context "in a deployed environment" do
before do
Rails.logger.debug("in test 'before' block, before 'allow': #{Rails.env}")
allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new("production"))
Rails.logger.debug("in test 'before' block, after 'allow': #{Rails.env}")
end

it "displays data based on the directory it's in" do
pending("Cannot mock production environment in initializer")
Rails.logger.debug("in test 'it' block: #{Rails.env}")
expect(page).to have_content("Deployed some_date")
end
end
end

0 comments on commit d28f477

Please sign in to comment.