diff --git a/config.py b/config.py index dc647cd30..3b9eebfc8 100644 --- a/config.py +++ b/config.py @@ -19,7 +19,8 @@ CLIENT_WHITELIST = ['SERVER_HOSTNAME', 'PREFERRED_URL_SCHEME', 'MIXPANEL_KEY', 'STRIPE_PUBLISHABLE_KEY', 'ENTERPRISE_LOGO_URL', 'SENTRY_PUBLIC_DSN', 'AUTHENTICATION_TYPE', 'REGISTRY_TITLE', 'REGISTRY_TITLE_SHORT', 'CONTACT_INFO', 'AVATAR_KIND', 'LOCAL_OAUTH_HANDLER', 'DOCUMENTATION_LOCATION', - 'DOCUMENTATION_METADATA', 'SETUP_COMPLETE', 'DEBUG', 'MARKETO_MUNCHKIN_ID'] + 'DOCUMENTATION_METADATA', 'SETUP_COMPLETE', 'DEBUG', 'MARKETO_MUNCHKIN_ID', + 'STATIC_SITE_BUCKET'] def frontend_visible_config(config_dict): @@ -395,3 +396,6 @@ class DefaultConfig(object): # Delays workers from starting until a random point in time between 0 and their regular interval. STAGGER_WORKERS = True + + # Location of the static marketing site. + STATIC_SITE_BUCKET = None diff --git a/static/js/directives/quay-layout.js b/static/js/directives/quay-layout.js index 96053510a..139a00b07 100644 --- a/static/js/directives/quay-layout.js +++ b/static/js/directives/quay-layout.js @@ -118,54 +118,41 @@ angular.module('quay').directive('quayClasses', function(Features, Config) { }); /** - * Adds a quay-include attribtue that adds a template solely if the expression evaluates to true. - * Automatically adds the Features and Config services to the scope. + * Adds a quay-static-include attribute handles adding static marketing content from a defined + * S3 bucket. If running under QE, the local template is used. * - Usage: quay-include="{'Features.BILLING': 'partials/landing-normal.html', '!Features.BILLING': 'partials/landing-login.html'}" + * Usage: quay-static-include="{'hosted': 'index.html', 'otherwise': 'partials/landing-login.html'}" */ -angular.module('quay').directive('quayInclude', function($compile, $templateCache, $http, Features, Config) { +angular.module('quay').directive('quayStaticInclude', function($compile, $templateCache, $http, Features, Config) { return { priority: 595, restrict: 'A', link: function($scope, $element, $attr, ctrl) { - var getTemplate = function(templateName) { - var templateUrl = '/static/' + templateName; - return $http.get(templateUrl, {cache: $templateCache}); + var getTemplate = function(hostedTemplateName, staticTemplateName) { + var staticTemplateUrl = '/static/' + staticTemplateName; + var templateUrl = staticTemplateUrl; + if (Features.BILLING && Config['STATIC_SITE_BUCKET']) { + templateUrl = Config['STATIC_SITE_BUCKET'] + hostedTemplateName; + } + + return $http.get(templateUrl, {cache: $templateCache}).catch(function(resolve, reject) { + // Fallback to the static local URL if the hosted URL doesn't work. + return $http.get(staticTemplateUrl, {cache: $templateCache}); + }); }; - var result = $scope.$eval($attr.quayInclude); + var result = $scope.$eval($attr.quayStaticInclude); if (!result) { return; } - var scopeVals = { - 'Features': Features, - 'Config': Config - }; - - var templatePath = null; - for (var expr in result) { - if (!result.hasOwnProperty(expr)) { continue; } - - // Evaluate the expression with the entire features list added. - var value = $scope.$eval(expr, scopeVals); - if (value) { - templatePath = result[expr]; - break; - } - } - - if (!templatePath) { - return; - } - - var promise = getTemplate(templatePath).success(function(html) { - $element.html(html); - }).then(function (response) { - $element.replaceWith($compile($element.html())($scope)); + var promise = getTemplate(result['hosted'], result['otherwise']).then(function (response) { + $element.replaceWith($compile(response['data'])($scope)); if ($attr.onload) { $scope.$eval($attr.onload); } + }).catch(function(err) { + console.log(err) }); } }; diff --git a/static/partials/landing-normal.html b/static/partials/landing-normal.html deleted file mode 100644 index 8b623c999..000000000 --- a/static/partials/landing-normal.html +++ /dev/null @@ -1,215 +0,0 @@ -