mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06: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:
committed by
Régis Hanol
parent
1fb1f4c790
commit
1d26a473e7
22
lib/tasks/maxminddb.rake
Normal file
22
lib/tasks/maxminddb.rake
Normal file
@@ -0,0 +1,22 @@
|
||||
require 'rubygems/package'
|
||||
require 'zlib'
|
||||
|
||||
desc "downloads MaxMind's GeoLite2-City database"
|
||||
task "maxminddb:get" => :environment do
|
||||
uri = URI("http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz")
|
||||
tar_gz_archive = Net::HTTP.get(uri)
|
||||
|
||||
extractor = Gem::Package::TarReader.new(Zlib::GzipReader.new(StringIO.new(tar_gz_archive)))
|
||||
extractor.rewind
|
||||
|
||||
extractor.each do |entry|
|
||||
next unless entry.full_name.ends_with?(".mmdb")
|
||||
|
||||
filename = File.join(Rails.root, 'vendor', 'data', 'GeoLite2-City.mmdb')
|
||||
File.open(filename, "wb") do |f|
|
||||
f.write(entry.read)
|
||||
end
|
||||
end
|
||||
|
||||
extractor.close
|
||||
end
|
||||
Reference in New Issue
Block a user