summaryrefslogtreecommitdiff
path: root/core/app/helpers
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2013-10-15 14:31:52 +0200
committerAzul <azul@leap.se>2013-10-15 15:11:53 +0200
commit8e5aa5093ab6e67db4f603a44bb7027245b91a21 (patch)
treeba2de17a08c11619a74a0be6cf4c3939a2b9f223 /core/app/helpers
parent0acbf6a158f149c1f4273bde0cfca47547e080f8 (diff)
detect os in browser and show proper download link
We add a class to the html element based on the detected os and use that to pick which download link should be visible. If we detect an os that is not supported we display a deactivated download link instead with all alternatives.
Diffstat (limited to 'core/app/helpers')
-rw-r--r--core/app/helpers/core_helper.rb38
1 files changed, 37 insertions, 1 deletions
diff --git a/core/app/helpers/core_helper.rb b/core/app/helpers/core_helper.rb
index a496144..29a4700 100644
--- a/core/app/helpers/core_helper.rb
+++ b/core/app/helpers/core_helper.rb
@@ -10,4 +10,40 @@ module CoreHelper
render 'common/home_page_buttons'
end
-end \ No newline at end of file
+ def available_clients
+ CLIENT_AVAILABILITY
+ end
+
+ def alternative_client_links(os = nil)
+ alternative_clients(os).map do |client|
+ link_to(client.capitalize, client_download_url(client))
+ end
+ end
+
+ def alternative_clients(os = nil)
+ CLIENT_AVAILABILITY - [os]
+ end
+
+ def client_download_url(os = nil)
+ client_download_domain(os) + client_download_path(os)
+ end
+
+ def client_download_domain(os)
+ "https://downloads.leap.se"
+ end
+
+ def client_download_path(os)
+ CLIENT_DOWNLOAD_PATHS[os] || '/client'
+ end
+
+
+ CLIENT_AVAILABILITY = %w/linux32 linux64 mac windows android/
+ CLIENT_DOWNLOAD_PATHS = {
+ android: '/client/android',
+ linux: '/client/linux',
+ linux32: '/client/linux/Bitmask-linux32-latest.tar.bz2',
+ linux64: '/client/linux/Bitmask-linux64-latest.tar.bz2',
+ osx: '/client/osx/Bitmask-OSC-latest.dmg',
+ windows: '/client/windows'
+ }.with_indifferent_access
+end