]> git.openstreetmap.org Git - rails.git/commitdiff
Add browser detection framework
authorTom Hughes <tom@compton.nu>
Wed, 30 Jan 2019 11:59:47 +0000 (11:59 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 30 Jan 2019 12:11:34 +0000 (12:11 +0000)
Gemfile
Gemfile.lock
config/initializers/browser.rb [new file with mode: 0644]

diff --git a/Gemfile b/Gemfile
index fa1bed46886eccae3b083b73794ba3a85e878e1a..0393c9e7fd87b42e0971a80f737d3401e1bdf45c 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -117,6 +117,9 @@ gem "logstasher"
 # Used to generate images for traces
 gem "gd2-ffij"
 
+# Used for browser detection
+gem "browser"
+
 # Gems useful for development
 group :development do
   gem "annotate"
index 53fb236918afe7a37af85d031aabc9cfed0646ca..7bd384a9fea7df6967077001750916fff59b2250 100644 (file)
@@ -67,6 +67,7 @@ GEM
       debug_inspector (>= 0.0.1)
     bootsnap (1.3.2)
       msgpack (~> 1.0)
+    browser (2.5.3)
     builder (3.2.3)
     cancancan (2.3.0)
     canonical-rails (0.2.5)
@@ -394,6 +395,7 @@ DEPENDENCIES
   bigdecimal (~> 1.1.0)
   binding_of_caller
   bootsnap (>= 1.1.0)
+  browser
   cancancan
   canonical-rails
   capybara (~> 2.13)
diff --git a/config/initializers/browser.rb b/config/initializers/browser.rb
new file mode 100644 (file)
index 0000000..167fd29
--- /dev/null
@@ -0,0 +1,19 @@
+module OpenStreetMap
+  module Browser
+    module Features
+      def html5?
+        webkit? || firefox? || safari? || edge? || ie?(">8")
+      end
+
+      def es5?
+        webkit? || firefox? || safari? || edge? || ie?(">8")
+      end
+
+      def es6?
+        webkit? || firefox? || safari? || edge?
+      end
+    end
+  end
+end
+
+Browser::Base.include(OpenStreetMap::Browser::Features)