From 66e09b2a95935353e3c25a051877100495b4f77a Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Tue, 29 Nov 2016 18:19:06 -0500 Subject: [PATCH] Switch landing page to read template from S3 bucket This change uses CORS to make the Angular template request to a defined S3 bucket, falling back to the compiled login template if the bucket is not available. Fixes #1313 --- config.py | 6 +- static/js/directives/quay-layout.js | 53 +++---- static/partials/landing-normal.html | 215 ---------------------------- static/partials/landing.html | 5 +- 4 files changed, 28 insertions(+), 251 deletions(-) delete mode 100644 static/partials/landing-normal.html 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 @@ -
-
-
-

Quay builds, analyzes, distributes your container images

- -
- Works with - - - Supports container image formats for both Docker and rkt -
-
-
- -
-
-

Trusted by companies of all sizes

-
-
-
-
- -
-
- -
-
- -
-
- -
-
-
- -
-
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
-
-
-
- -
-

Built with our users in mind

-
-
-
- -
-
-
- - Beautiful repository view -
- Repository is presented with the maximum amount of useful information, including a full tags list, - markdown based description and repository push and pull counts. -
-
- -
- - Repository Operations -
- Operations on a repository can be performed directly from the user interface, including adding, - removing, and reverting tags. -
-
- -
- - Share at your control -
- Set up the exact permissions your team, organization or business needs. Need to grant external access? Create one or more robot accounts to restrict access. -
-
- -
- - Dockerfile Build -
- Repositories can be linked to GitHub, BitBucket, GitLab or custom git repositories, with automatic building of the Dockerfile(s) found on push. -
-
-
-
-
-
- -
-

Seamlessly integrate into your Docker-based infrastructure

-
-
-
- Quay has become an essential part of our infrastructure as we move to Docker-based deploys. - The support and service that the Quay team provides is phenomenal. We couldn't do it without them! -
- -
- - - Mike Saffitz - Apptentive - CTO & Co-Founder - -
- Learn more -
-
-
- -
-

See what other people are saying about Quay

-
-
-
-
- -
- - - - -

-
-
- -
- -
-
-
- -
-

Start pushing to Quay in under a minute

-
- -
-
- -
- Mobile Analytics -
-
- diff --git a/static/partials/landing.html b/static/partials/landing.html index 7813e1ab8..2d9ba1bd1 100644 --- a/static/partials/landing.html +++ b/static/partials/landing.html @@ -1,3 +1,4 @@ -
- +
+