From 3a3758654caebf8a29622db8679f0cea39eb9edb Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Tue, 8 Apr 2014 20:33:20 -0400 Subject: [PATCH] - Move all quay.io domain references to config and add new methods for easy construction of URLs - Make the Olark chat live behind a feature flag --- endpoints/common.py | 1 + static/js/app.js | 28 +++++++++++++++++++--------- static/js/controllers.js | 15 +++++++++------ static/partials/view-repo.html | 8 ++++---- static/tutorial/create-image.html | 4 ++-- static/tutorial/docker-login.html | 2 +- static/tutorial/push-image.html | 6 +++--- templates/base.html | 4 ++-- 8 files changed, 41 insertions(+), 27 deletions(-) diff --git a/endpoints/common.py b/endpoints/common.py index 2dbc28e19..6d201d911 100644 --- a/endpoints/common.py +++ b/endpoints/common.py @@ -123,6 +123,7 @@ def render_page_template(name, **kwargs): config_set=json.dumps(getFrontendVisibleConfig(app.config)), mixpanel_key=app.config.get('MIXPANEL_KEY', ''), is_debug=str(app.config.get('DEBUGGING', False)).lower(), + show_chat=features.OLARK_CHAT, cache_buster=random_string(), **kwargs)) diff --git a/static/js/app.js b/static/js/app.js index 693d89365..11c8da0c5 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -471,6 +471,15 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'angu } var config = window.__config; + config.getDomain = function() { + return config['SERVER_NAME']; + }; + + config.getUrl = function(opt_path) { + var path = opt_path || ''; + return config['PREFERRED_URL_SCHEME'] + '://' + config['SERVER_NAME'] + path; + }; + config.getValue = function(name, opt_defaultValue) { var value = config[name]; if (value == null) { @@ -879,7 +888,7 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'angu keyService['stripePublishableKey'] = Config['STRIPE_PUBLISHABLE_KEY']; keyService['githubClientId'] = Config['GITHUB_CLIENT_ID']; keyService['githubLoginClientId'] = Config['GITHUB_LOGIN_CLIENT_ID']; - keyService['githubRedirectUri'] = Config['PREFERRED_URL_SCHEME'] + '://' + Config['SERVER_NAME'] + '/oauth2/github/callback'; + keyService['githubRedirectUri'] = Config.getUrl('/oauth2/github/callback'); return keyService; }]); @@ -1195,7 +1204,7 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'angu email: email, amount: planDetails.price, currency: 'usd', - name: 'Quay ' + planDetails.title + ' Subscription', + name: 'Quay.io ' + planDetails.title + ' Subscription', description: 'Up to ' + planDetails.privateRepos + ' private repositories', panelLabel: 'Subscribe', token: submitToken, @@ -1861,7 +1870,7 @@ quayApp.directive('plansTable', function () { }); -quayApp.directive('dockerAuthDialog', function () { +quayApp.directive('dockerAuthDialog', function (Config) { var directiveDefinitionObject = { priority: 0, templateUrl: '/static/directives/docker-auth-dialog.html', @@ -1882,11 +1891,10 @@ quayApp.directive('dockerAuthDialog', function () { $scope.downloadCfg = function() { var auth = $.base64.encode($scope.username + ":" + $scope.token); - config = { - "https://quay.io/v1/": { - "auth": auth, - "email": "" - } + config = {} + config[Config.getUrl('/v1/')] = { + "auth": auth, + "email": "" }; var file = JSON.stringify(config, null, ' '); @@ -3803,7 +3811,7 @@ quayApp.directive('dockerfileCommand', function () { scope: { 'command': '=command' }, - controller: function($scope, $element, $sanitize) { + controller: function($scope, $element, $sanitize, Config) { var registryHandlers = { 'quay.io': function(pieces) { var rnamespace = pieces[pieces.length - 2]; @@ -3818,6 +3826,8 @@ quayApp.directive('dockerfileCommand', function () { } }; + registryHandlers[Config.getDomain()] = registryHandlers['quay.io']; + var kindHandlers = { 'FROM': function(title) { var pieces = title.split('/'); diff --git a/static/js/controllers.js b/static/js/controllers.js index 0221e0573..fee9029ea 100644 --- a/static/js/controllers.js +++ b/static/js/controllers.js @@ -48,14 +48,15 @@ function PlansCtrl($scope, $location, UserService, PlanService) { }; } -function TutorialCtrl($scope, AngularTour, AngularTourSignals, UserService) { +function TutorialCtrl($scope, AngularTour, AngularTourSignals, UserService, Config) { // Default to showing sudo on all commands if on linux. var showSudo = navigator.appVersion.indexOf("Linux") != -1; $scope.tour = { 'title': 'Quay.io Tutorial', 'initialScope': { - 'showSudo': showSudo + 'showSudo': showSudo, + 'domainName': Config.getDomain() }, 'steps': [ { @@ -316,7 +317,9 @@ function LandingCtrl($scope, UserService, ApiService, Features, Config) { }; } -function RepoCtrl($scope, $sanitize, Restangular, ImageMetadataService, ApiService, $routeParams, $rootScope, $location, $timeout) { +function RepoCtrl($scope, $sanitize, Restangular, ImageMetadataService, ApiService, $routeParams, $rootScope, $location, $timeout, Config) { + $scope.Config = Config; + var namespace = $routeParams.namespace; var name = $routeParams.name; @@ -1162,7 +1165,7 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope fetchRepository(); } -function RepoAdminCtrl($scope, Restangular, ApiService, KeyService, $routeParams, $rootScope, $location, UserService) { +function RepoAdminCtrl($scope, Restangular, ApiService, KeyService, $routeParams, $rootScope, $location, UserService, Config) { var namespace = $routeParams.namespace; var name = $routeParams.name; @@ -1178,12 +1181,12 @@ function RepoAdminCtrl($scope, Restangular, ApiService, KeyService, $routeParams $scope.getBadgeFormat = function(format, repo) { if (!repo) { return; } - var imageUrl = 'https://quay.io/repository/' + namespace + '/' + name + '/status'; + var imageUrl = Config.getUrl('/' + namespace + '/' + name + '/status'); if (!$scope.repo.is_public) { imageUrl += '?token=' + $scope.repo.status_token; } - var linkUrl = 'https://quay.io/repository/' + namespace + '/' + name; + var linkUrl = Config.getUrl('/' + namespace + '/' + name); switch (format) { case 'svg': diff --git a/static/partials/view-repo.html b/static/partials/view-repo.html index 795420ccb..b5db777de 100644 --- a/static/partials/view-repo.html +++ b/static/partials/view-repo.html @@ -58,7 +58,7 @@
- + @@ -87,13 +87,13 @@
How to push a new image to this repository:
First login to Quay.io (if you have not done so already): -
sudo docker login quay.io
+
sudo docker login {{ Config.getDomain() }}
Tag an image to this repository: -
sudo docker tag 0u123imageidgoeshere quay.io/{{repo.namespace}}/{{repo.name}}
+
sudo docker tag 0u123imageidgoeshere {{ Config.getDomain() }}/{{repo.namespace}}/{{repo.name}}
Push the image to this repository: -
sudo docker push quay.io/{{repo.namespace}}/{{repo.name}}
+
sudo docker push {{ Config.getDomain() }}/{{repo.namespace}}/{{repo.name}}
diff --git a/static/tutorial/create-image.html b/static/tutorial/create-image.html index ad56d91fc..a10148dd7 100644 --- a/static/tutorial/create-image.html +++ b/static/tutorial/create-image.html @@ -15,8 +15,8 @@

Once a container has terminated in Docker, the next step is to commit the container to an image, and then tag that image with a relevant name so it can be saved to a repository.

-

Docker lets us do this in one step with the commit command. To do so, we run the docker commit with the container ID from the previous step and tag it to be a repository under quay.io. +

Docker lets us do this in one step with the commit command. To do so, we run the docker commit with the container ID from the previous step and tag it to be a repository under {{ tour.tourScope.domainName }}.

-sudo docker commit {{ tour.tourScope.containerId || 'containerId' }} quay.io/{{ tour.tourScope.username }}/{{ tour.tourScope.repoName || 'myfirstrepo' }}
+sudo docker commit {{ tour.tourScope.containerId || 'containerId' }} {{ tour.tourScope.domainName }}/{{ tour.tourScope.username }}/{{ tour.tourScope.repoName || 'myfirstrepo' }}
 
diff --git a/static/tutorial/docker-login.html b/static/tutorial/docker-login.html index 64c6d0af7..f7d27aaea 100644 --- a/static/tutorial/docker-login.html +++ b/static/tutorial/docker-login.html @@ -10,7 +10,7 @@

The first step when using Quay.io is to login via the docker login command.

Enter your Quay.io username and your password when prompted.

-
sudo docker login quay.io
+  
sudo docker login {{ tour.tourScope.domainName }}
 Username: {{ tour.tourScope.username }}
 Password: (password here)
 Email: {{ tour.tourScope.email }}
diff --git a/static/tutorial/push-image.html b/static/tutorial/push-image.html index e700a6901..e6be7043a 100644 --- a/static/tutorial/push-image.html +++ b/static/tutorial/push-image.html @@ -1,8 +1,8 @@

Now that we've tagged our image with a repository name, we can push the repository to Quay.io:

-sudo docker push quay.io/{{ tour.tourScope.username }}/{{ tour.tourScope.repoName || 'myfirstrepo' }}
-The push refers to a repository [quay.io/{{ tour.tourScope.username }}/{{ tour.tourScope.repoName || 'myfirstrepo' }}] (len: 1)
+sudo docker push {{ tour.tourScope.domainName }}/{{ tour.tourScope.username }}/{{ tour.tourScope.repoName || 'myfirstrepo' }}
+The push refers to a repository [{{ tour.tourScope.domainName }}/{{ tour.tourScope.username }}/{{ tour.tourScope.repoName || 'myfirstrepo' }}] (len: 1)
 Sending image list
-Pushing repository quay.io/{{ tour.tourScope.username }}/{{ tour.tourScope.repoName || 'myfirstrepo' }} (1 tags)
+Pushing repository {{ tour.tourScope.domainName }}/{{ tour.tourScope.username }}/{{ tour.tourScope.repoName || 'myfirstrepo' }} (1 tags)
 
diff --git a/templates/base.html b/templates/base.html index b43447317..ae787e699 100644 --- a/templates/base.html +++ b/templates/base.html @@ -140,8 +140,8 @@ mixpanel.init("{{ mixpanel_key }}", { track_pageview : false, debug: {{ is_debug + {% if show_chat %} - {% if request.host == 'quay.io' %} - {% endif %} + {% endif %}