Remove browser gem direct dependency

While the browser gem is great, we don't need it in this case for such a
simple usage.

There are a few really small differences between this code and the old
one: matching `/MSIE/` will return true for Opera 12 and false for
certain versions of IE11. Since we're only rendering a comment for IE8
and below, we don't care about IE11, and Opera 12 is six years old and
its users won't be affected by the comment.

Note we're still using the browser gem because ahoy_matey depends on it,
but now it's an indirect dependency.
This commit is contained in:
Javi Martín
2019-11-18 12:28:23 +01:00
parent 5f62916394
commit 442baf8384
3 changed files with 1 additions and 3 deletions

View File

@@ -8,7 +8,6 @@ gem "ahoy_matey", "~> 1.6.0"
gem "ancestry", "~> 3.0.7" gem "ancestry", "~> 3.0.7"
gem "audited", "~> 4.9.0" gem "audited", "~> 4.9.0"
gem "autoprefixer-rails", "~> 8.2.0" gem "autoprefixer-rails", "~> 8.2.0"
gem "browser", "~> 2.5.3"
gem "cancancan", "~> 2.3.0" gem "cancancan", "~> 2.3.0"
gem "ckeditor", "~> 4.3.0" gem "ckeditor", "~> 4.3.0"
gem "cocoon", "~> 1.2.9" gem "cocoon", "~> 1.2.9"

View File

@@ -586,7 +586,6 @@ DEPENDENCIES
ancestry (~> 3.0.7) ancestry (~> 3.0.7)
audited (~> 4.9.0) audited (~> 4.9.0)
autoprefixer-rails (~> 8.2.0) autoprefixer-rails (~> 8.2.0)
browser (~> 2.5.3)
bullet (~> 5.7.0) bullet (~> 5.7.0)
byebug (~> 10.0.0) byebug (~> 10.0.0)
cancancan (~> 2.3.0) cancancan (~> 2.3.0)

View File

@@ -21,7 +21,7 @@
<div class="wrapper <%= yield (:wrapper_class) %>"> <div class="wrapper <%= yield (:wrapper_class) %>">
<%= render "layouts/header", with_subnavigation: true %> <%= render "layouts/header", with_subnavigation: true %>
<% if browser.ie? && cookies["ie_alert_closed"] != "true" %> <% if request.headers["User-Agent"] =~ /MSIE/ && cookies["ie_alert_closed"] != "true" %>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<div data-alert class="callout primary ie-callout" data-closable> <div data-alert class="callout primary ie-callout" data-closable>
<button class="close-button ie-callout-close-js" <button class="close-button ie-callout-close-js"