From b96d0169777f02e5f5a76527c65245f017103173 Mon Sep 17 00:00:00 2001 From: Jeremy Kauffman Date: Thu, 14 Dec 2017 14:02:19 -0500 Subject: [PATCH] Support for auto download parameter, dynamic OS /get routes, fix for dev analytics --- controller/Controller.class.php | 9 ++++----- controller/action/DownloadActions.class.php | 1 + lib/tools/OS.class.php | 5 ++++- view/template/download/get.php | 8 ++++++++ view/template/layout/_analytics.php | 5 +++-- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/controller/Controller.class.php b/controller/Controller.class.php index 462494da..565fbd2b 100644 --- a/controller/Controller.class.php +++ b/controller/Controller.class.php @@ -97,11 +97,10 @@ class Controller $router->get(['/get', 'get'], 'DownloadActions::executeGet'); $router->get(['/getrubin', 'getrubin'], 'DownloadActions::executeGet'); - $router->get(['/windows', 'get-windows'], 'DownloadActions::executeGet'); - $router->get(['/linux', 'get-linux'], 'DownloadActions::executeGet'); - $router->get(['/osx', 'get-osx'], 'DownloadActions::executeGet'); - $router->get(['/android', 'get-android'], 'DownloadActions::executeGet'); - $router->get(['/ios', 'get-ios'], 'DownloadActions::executeGet'); + foreach(array_keys(OS::getAll()) as $os) + { + $router->get(['/' . $os, 'get-' . $os], 'DownloadActions::executeGet'); + } $router->get('/roadmap', 'ContentActions::executeRoadmap'); $router->post('/quickstart/auth', 'DeveloperActions::executeQuickstartAuth'); diff --git a/controller/action/DownloadActions.class.php b/controller/action/DownloadActions.class.php index e977f207..6e8f9fb4 100644 --- a/controller/action/DownloadActions.class.php +++ b/controller/action/DownloadActions.class.php @@ -40,6 +40,7 @@ class DownloadActions extends Actions 'analyticsLabel' => $analyticsLabel, 'buttonLabel' => $buttonLabel, 'downloadUrl' => $asset ? $asset['browser_download_url'] : null, + 'isAuto' => Request::getParam('auto'), 'os' => $os, 'osTitle' => $osTitle, 'osIcon' => $osIcon, diff --git a/lib/tools/OS.class.php b/lib/tools/OS.class.php index 0939c68b..f78e4d0c 100644 --- a/lib/tools/OS.class.php +++ b/lib/tools/OS.class.php @@ -2,6 +2,9 @@ class OS { + /* + * if changing below constants, you should add permanent redirects for old OS names used in URLs + */ const OS_ANDROID = 'android', OS_IOS = 'ios', OS_LINUX = 'linux', @@ -32,7 +35,7 @@ class OS case 'pkg': return OS::OS_OSX; - case 'msi': // fallthrough + case 'Fmsi': // fallthrough case 'exe': return OS::OS_WINDOWS; diff --git a/view/template/download/get.php b/view/template/download/get.php index 9fbc5c5f..536a0c97 100644 --- a/view/template/download/get.php +++ b/view/template/download/get.php @@ -21,11 +21,19 @@ + + + var anchor = document.getElementById('get-download-btn'); + ga('send', 'event', anchor.getAttribute('data-analytics-category'), anchor.getAttribute('data-analytics-action'), anchor.getAttribute('data-analytics-label')); + setTimeout(function() { window.location = anchor.getAttribute('href'); }, 500); + +
, diff --git a/view/template/layout/_analytics.php b/view/template/layout/_analytics.php index d1fbf89e..18e58393 100644 --- a/view/template/layout/_analytics.php +++ b/view/template/layout/_analytics.php @@ -24,7 +24,8 @@ - + \ No newline at end of file