2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-08-21 19:11:18 +08:00

FEATURE: Show "Recently used devices" in user preferences (#6335)

* FEATURE: Added MaxMindDb to resolve IP information.

* FEATURE: Added browser detection based on user agent.

* FEATURE: Added recently used devices in user preferences.

* DEV: Added acceptance test for recently used devices.

* UX: Do not show 'Show more' button if there aren't more tokens.

* DEV: Fix unit tests.

* DEV: Make changes after code review.

* Add more detailed unit tests.

* Improve logging messages.

* Minor coding style fixes.

* DEV: Use DropdownSelectBoxComponent and run Prettier.

* DEV: Fix unit tests.
This commit is contained in:
Bianca Nenciu 2018-10-09 17:21:41 +03:00 committed by Régis Hanol
parent 1fb1f4c790
commit 1d26a473e7
28 changed files with 648 additions and 117 deletions

60
lib/browser_detection.rb Normal file
View file

@ -0,0 +1,60 @@
module BrowserDetection
def self.browser(user_agent)
case user_agent
when /Opera/i, /OPR/i
:opera
when /Firefox/i
:firefox
when /Chrome/i, /CriOS/i
:chrome
when /Safari/i
:safari
when /MSIE/i, /Trident/i
:ie
else
:unknown
end
end
def self.device(user_agent)
case user_agent
when /Android/i
:android
when /iPad/i
:ipad
when /iPhone/i
:iphone
when /iPod/i
:ipod
when /Mobile/i
:mobile
when /Macintosh/i
:mac
when /Linux/i
:linux
when /Windows/i
:windows
else
:unknown
end
end
def self.os(user_agent)
case user_agent
when /Android/i
:android
when /iPhone|iPad|iPod/i
:ios
when /Macintosh/i
:macos
when /Linux/i
:linux
when /Windows/i
:windows
else
:unknown
end
end
end