Skip to content

Commit dc4978e

Browse files
Copy vendor, layouts, and helpers from Tesseract
** Why are these changes being introduced: * Starting from the boilerplate engine, we need to copy/paste the contents of the proof-of-concept gem (Tesseract) which was developed earlier in this ticket. * We also need to remove an unused application layout template in a namespaced folder path, to prevent future confusion. * The tests for the link helper class need to be added. * The theme assets in vendor/assets need to be added to the asset pipeline. ** Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/engx-175 ** How does this address that need: * This copies the key parts of the Tesseract proof of concept into this gem: * link helper class (including tests) * layout partials * vendor/assets materials (including adding them to asset pipeline) * The changes made in these files from the old theme gem will appear in the overall diff. Most of these changes are the addition of new boilerplate files, but the following specific changes should be noted: * The addition of `extend self` to the link helper class, which helps expose `nav_link_to` to implementing apps. * The addition of the csp_meta_tag directive to the application layout * The change of the body class from `app-thing` to `app-tesseract` * Removes the unused application layout template from its namespaced path. The file which gets used is still in the prior location. ** Document any side effects to this change: * None
1 parent 569a38d commit dc4978e

34 files changed

Lines changed: 2165 additions & 15 deletions

app/helpers/link_helper.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module LinkHelper
2+
extend self
3+
4+
# helper wrapper around link_to that inserts visual and screen reader info
5+
# for navigation links
6+
def nav_link_to(name, url)
7+
link_to(name, url,
8+
class: link_class(url),
9+
'aria-current': aria_current?(url))
10+
end
11+
12+
private
13+
14+
# Includes css `current` class if current page
15+
def link_class(url)
16+
return 'nav-item' unless current_page?(url)
17+
'nav-item current'
18+
end
19+
20+
# Includes css `current` class if current page
21+
def aria_current?(url)
22+
return 'page' if current_page?(url)
23+
end
24+
end

app/views/layouts/_flash.html.erb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<% if flash %>
2+
<% flash.each do |msg_type, message| %>
3+
<% next if msg_type == 'global' %>
4+
<div class="alert alert-banner <%= msg_type %>" role="alert">
5+
<%= sanitize(message) %>
6+
</div>
7+
<% end %>
8+
<% end %>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<% if ENV['GLOBAL_ALERT'] %>
2+
<div class="wrap-notices info layout-band">
3+
<div class="wrap-notice">
4+
<div class="alert alert-global">
5+
<h1 class="title"><%= sanitize(ENV['GLOBAL_ALERT']) %></h1>
6+
</div>
7+
</div>
8+
</div>
9+
<% end %>

app/views/layouts/_head.html.erb

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<meta charset="utf-8">
2+
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
3+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
4+
<title><%= content_for?(:title) ? yield(:title) : " MIT Libraries" %></title>
5+
<%= csrf_meta_tags %>
6+
<%= csp_meta_tag %>
7+
8+
<%= yield :additional_meta_tag %>
9+
10+
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
11+
<!--[if lt IE 9]>
12+
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.1/html5shiv.js" type="text/javascript"></script>
13+
<![endif]-->
14+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/4.1.1/normalize.min.css">
15+
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,400italic,600,600italic,700,700italic&subset=latin,latin-ext" type="text/css">
16+
<%= stylesheet_link_tag "application", :media => "all" %>
17+
18+
<!-- For all other devices -->
19+
<!-- Size should be 32 x 32 pixels -->
20+
<%= favicon_link_tag 'favicon.ico', :rel => 'shortcut icon' %>
21+
22+
<%= render partial: "layouts/js_exception_handler" %>
23+
<%= javascript_include_tag "application" %>
24+
25+
<script type='text/javascript' src='https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js'></script>
26+
27+
<%= yield :additional_js %>
28+
29+
<% if (ENV['MATOMO_URL'].present? && ENV['MATOMO_SITE_ID'].present?) %>
30+
<!-- Matomo -->
31+
<script type="text/javascript">
32+
var _paq = window._paq || [];
33+
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
34+
_paq.push(['trackPageView']);
35+
_paq.push(['enableLinkTracking']);
36+
(function() {
37+
var u='<%= ENV['MATOMO_URL'] %>';
38+
_paq.push(['setTrackerUrl', u+'matomo.php']);
39+
_paq.push(['setSiteId', '<%= ENV['MATOMO_SITE_ID'] %>']);
40+
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
41+
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
42+
})();
43+
</script>
44+
<!-- End Matomo Code -->
45+
<% end %>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<div class="wrap-outer-footer-institute layout-band">
2+
<div class="wrap-footer-institute">
3+
<footer class="footer-info-institute" aria-label="MIT footer" role="contentinfo">
4+
<a class="link-logo-mit" href="https://www.mit.edu">
5+
<span class="sr">MIT</span>
6+
<svg x="0" y="0" width="54" height="28" viewBox="0 0 54 28" enable-background="new 0 0 54 28" xml:space="preserve" class="logo-mit"><rect x="28.9" y="8.9" width="5.8" height="19.1" class="color"/><rect width="5.8" height="28"/><rect x="9.6" width="5.8" height="18.8"/><rect x="19.3" width="5.8" height="28"/><rect x="38.5" y="8.9" width="5.8" height="19.1"/><rect x="38.8" width="15.2" height="5.6"/><rect x="28.9" width="5.8" height="5.6"/></svg>
7+
</a>
8+
<div class="about-mit">
9+
<span class="item">Massachusetts Institute of Technology</span>
10+
</div>
11+
<div class="license">Content created by the MIT Libraries, <a href="https://creativecommons.org/licenses/by-nc/4.0/">CC BY-NC</a> unless otherwise noted. <a href="https://libraries.mit.edu/research-support/notices/copyright-notify/">Notify us about copyright concerns</a>.
12+
</div>
13+
</footer><!-- end .footer-info-institute -->
14+
</div>
15+
</div>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<% if ENV['JS_EXCEPTION_LOGGER_KEY'].present? %>
2+
<script
3+
src="https://browser.sentry-cdn.com/6.13.3/bundle.min.js"
4+
integrity="sha384-sGMbmxgVprpEFMz6afNDyADd4Kav86v5Tvo2Y6w5t8tHUn1P1at3lCjN7IQo2c7E"
5+
crossorigin="anonymous"
6+
></script>
7+
8+
<script>
9+
Sentry.init({
10+
dsn: <%= ENV['JS_EXCEPTION_LOGGER_KEY'] %>,
11+
maxBreadcrumbs: 50,
12+
});
13+
</script>
14+
<% end %>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<div class="wrap-outer-footer layout-band">
2+
<div class="wrap-footer footer-slim">
3+
<div class="footer-main" aria-label="MIT Libraries footer">
4+
<div class="identity">
5+
<div class="wrap-logo-lib">
6+
<a href="https://libraries.mit.edu" class="logo-mit-lib">
7+
<span class="sr">MIT Libraries home</span>
8+
<%= image_tag("mitlib-wordmark.svg", :alt => "MIT Libraries logo") %>
9+
</a>
10+
</div>
11+
<div class="wrap-social">
12+
<p class="text-find-us">Find us on</p>
13+
<a href="https://twitter.com/mitlibraries" title="Twitter">
14+
<svg class="icon-social--twitter" width="2048" height="2048" viewBox="-192 -384 2048 2048" xmlns="http://www.w3.org/2000/svg"><g transform="scale(1 -1) translate(0 -1280)"><path d="M1620 1128q-67 -98 -162 -167q1 -14 1 -42q0 -130 -38 -259.5t-115.5 -248.5t-184.5 -210.5t-258 -146t-323 -54.5q-271 0 -496 145q35 -4 78 -4q225 0 401 138q-105 2 -188 64.5t-114 159.5q33 -5 61 -5q43 0 85 11q-112 23 -185.5 111.5t-73.5 205.5v4q68 -38 146 -41 q-66 44 -105 115t-39 154q0 88 44 163q121 -149 294.5 -238.5t371.5 -99.5q-8 38 -8 74q0 134 94.5 228.5t228.5 94.5q140 0 236 -102q109 21 205 78q-37 -115 -142 -178q93 10 186 50z" fill="black"></path></g></svg>
15+
<span class="sr">Twitter</span>
16+
</a><!-- End Twitter -->
17+
18+
<a href="https://www.facebook.com/mitlib" title="Facebook">
19+
<svg class="icon-social--facebook" width="2048" height="2048" viewBox="-640 -384 2048 2048" xmlns="http://www.w3.org/2000/svg"><g transform="scale(1 -1) translate(0 -1280)"><path d="M511 980h257l-30 -284h-227v-824h-341v824h-170v284h170v171q0 182 86 275.5t283 93.5h227v-284h-142q-39 0 -62.5 -6.5t-34 -23.5t-13.5 -34.5t-3 -49.5v-142z" fill="black"></path></g></svg>
20+
<span class="sr">Facebook</span>
21+
</a><!-- End Facebook -->
22+
23+
<a href="https://instagram.com/mitlibraries/" title="Instagram">
24+
<svg class="icon-social--instagram" viewBox="0 0 120 120" enable-background="new 0 0 120 120" xml:space="preserve"><path id="Instagram_10_" fill="#FFFFFF" d="M95.1,103.9H24.9c-0.2,0-0.4-0.1-0.6-0.1c-3.9-0.5-7.1-3.4-8-7.2 c-0.1-0.4-0.2-0.9-0.2-1.3V24.8c0-0.2,0.1-0.3,0.1-0.5c0.6-3.9,3.4-7.1,7.3-8c0.4-0.1,0.8-0.2,1.3-0.2h70.4c0.2,0,0.3,0.1,0.5,0.1 c4,0.5,7.2,3.6,8,7.5c0.1,0.4,0.1,0.8,0.2,1.2v70.2c-0.1,0.4-0.1,0.8-0.2,1.2c-0.7,3.6-3.6,6.6-7.2,7.4 C96,103.7,95.5,103.8,95.1,103.9z M25.6,51.7v0.2c0,13,0,26,0,38.9c0,1.9,1.6,3.5,3.5,3.5c20.6,0,41.2,0,61.8,0 c1.9,0,3.5-1.6,3.5-3.5c0-13,0-25.9,0-38.9v-0.3H86c1.2,3.8,1.5,7.6,1.1,11.5c-0.5,3.9-1.7,7.6-3.8,10.9c-2.1,3.4-4.7,6.2-8,8.4 c-8.5,5.8-19.6,6.3-28.6,1.2c-4.5-2.5-8.1-6.1-10.6-10.7c-3.7-6.8-4.3-14-2.1-21.4C31.2,51.7,28.4,51.7,25.6,51.7L25.6,51.7z M60,42.2c-9.7,0-17.6,7.8-17.8,17.5c-0.1,9.9,7.8,17.8,17.4,18c9.9,0.2,18-7.7,18.2-17.4C78,50.4,70,42.2,60,42.2L60,42.2z M86.7,38.7L86.7,38.7c1.4,0,2.9,0,4.3,0c1.9,0,3.4-1.6,3.4-3.5c0-2.8,0-5.5,0-8.3c0-2-1.6-3.6-3.6-3.6c-2.8,0-5.5,0-8.3,0 c-2,0-3.6,1.6-3.6,3.6c0,2.7,0,5.5,0,8.2c0,0.4,0.1,0.8,0.2,1.2c0.5,1.5,1.8,2.4,3.5,2.4C84,38.7,85.3,38.7,86.7,38.7L86.7,38.7z"></path></svg>
25+
<span class="sr">Instagram</span>
26+
</a><!-- End Instagram -->
27+
28+
<a href="https://www.youtube.com/user/MITLibraries" title="YouTube">
29+
<svg aria-hidden="true" focusable="false" data-prefix="fab" data-icon="youtube" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" class="icon-social--youtube"><path fill="black" d="M549.655 124.083c-6.281-23.65-24.787-42.276-48.284-48.597C458.781 64 288 64 288 64S117.22 64 74.629 75.486c-23.497 6.322-42.003 24.947-48.284 48.597-11.412 42.867-11.412 132.305-11.412 132.305s0 89.438 11.412 132.305c6.281 23.65 24.787 41.5 48.284 47.821C117.22 448 288 448 288 448s170.78 0 213.371-11.486c23.497-6.321 42.003-24.171 48.284-47.821 11.412-42.867 11.412-132.305 11.412-132.305s0-89.438-11.412-132.305zm-317.51 213.508V175.185l142.739 81.205-142.739 81.201z" class=""></path></svg>
30+
<span class="sr">YouTube</span>
31+
</a><!-- End YouTube -->
32+
33+
<a href="https://libguides.mit.edu/mit-feeds" title="RSS">
34+
<svg class="icon-social--rss" width="2048" height="2048" viewBox="-320 -384 2048 2048" xmlns="http://www.w3.org/2000/svg"><g transform="scale(1 -1) translate(0 -1280)"><path d="M384 192q0 -80 -56 -136t-136 -56t-136 56t-56 136t56 136t136 56t136 -56t56 -136zM896 69q2 -28 -17 -48q-18 -21 -47 -21h-135q-25 0 -43 16.5t-20 41.5q-22 229 -184.5 391.5t-391.5 184.5q-25 2 -41.5 20t-16.5 43v135q0 29 21 47q17 17 43 17h5q160 -13 306 -80.5 t259 -181.5q114 -113 181.5 -259t80.5 -306zM1408 67q2 -27 -18 -47q-18 -20 -46 -20h-143q-26 0 -44.5 17.5t-19.5 42.5q-12 215 -101 408.5t-231.5 336t-336 231.5t-408.5 102q-25 1 -42.5 19.5t-17.5 43.5v143q0 28 20 46q18 18 44 18h3q262 -13 501.5 -120t425.5 -294 q187 -186 294 -425.5t120 -501.5z" fill="black"></path></g></svg>
35+
<span class="sr">RSS</span>
36+
</a><!-- End RSS -->
37+
</div><!-- end .social -->
38+
<div class="wrap-middle">
39+
<div class="wrap-sitemap">
40+
<nav class="sitemap-libraries-abbrev" aria-label="MIT Libraries site menu">
41+
<h2 class="sr">MIT Libraries navigation</h2>
42+
<a class="item" href="https://libraries.mit.edu/search">Search</a>
43+
<a class="item" href="https://libraries.mit.edu/hours">Hours &amp; locations</a>
44+
<a class="item" href="https://libraries.mit.edu/borrow">Borrow &amp; request</a>
45+
<a class="item" href="https://libraries.mit.edu/research-support">Research support</a>
46+
<a class="item" href="https://libraries.mit.edu/about">About us</a>
47+
</nav>
48+
</div><!-- end .links-all -->
49+
<div class="wrap-policies">
50+
<nav aria-label="MIT Libraries policy menu">
51+
<span class="item"><a href="https://libraries.mit.edu/privacy" class="link-sub">Privacy</a></span>
52+
<span class="item"><a href="https://libraries.mit.edu/permissions" class="link-sub">Permissions</a></span>
53+
<span class="item"><a href="https://libraries.mit.edu/accessibility" class="link-sub">Accessibility</a></span>
54+
</nav>
55+
</div>
56+
</div>
57+
</div><!-- end .identity -->
58+
</div>
59+
</div>
60+
</div>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%# This template can be used to place content at the bottom of each page above the libraries and institute footers %>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<div class="wrap-outer-header layout-band <%= 'reasons' if params[:rainbows] %>">
2+
<div class="wrap-header">
3+
<header class="header-site header-slim" role="banner">
4+
<div class="wrap-header-core">
5+
<h1 class="name-site group nav-logo">
6+
<a href="https://libraries.mit.edu/" class="logo-mit-lib">
7+
<span class="sr">MIT Libraries home</span>
8+
<%= image_tag("mitlib-wordmark.svg", :alt => "MIT Libraries logo") %>
9+
</a>
10+
</h1>
11+
</div>
12+
<div class="wrap-header-supp">
13+
<a class="link-logo-mit" href="https://www.mit.edu"><span class="sr">MIT</span><svg x="0" y="0" width="54" height="28" viewBox="0 0 54 28" enable-background="new 0 0 54 28" xml:space="preserve" class="logo-mit"><rect x="28.9" y="8.9" width="5.8" height="19.1" class="color"/><rect width="5.8" height="28"/><rect x="9.6" width="5.8" height="18.8"/><rect x="19.3" width="5.8" height="28"/><rect x="38.5" y="8.9" width="5.8" height="19.1"/><rect x="38.8" width="15.2" height="5.6"/><rect x="28.9" width="5.8" height="5.6"/></svg></a>
14+
</div>
15+
</header>
16+
</div>
17+
</div>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<div class="wrap-outer-header-local layout-band">
2+
<div class="wrap-header-local">
3+
<div class="local-identity">
4+
<h2 class="title title-site"><a href="/">Site Title</a></h2>
5+
</div>
6+
<div class="wrap-local-nav">
7+
<div class="wrap-bar">
8+
<nav class="local-nav" aria-label="Main menu">
9+
<%= nav_link_to("Home", root_path) %>
10+
11+
Psst. You may want to copy this file out of the gem and do your thing.
12+
</nav>
13+
</div>
14+
</div>
15+
</div>
16+
</div>

0 commit comments

Comments
 (0)