From 36970f0ffb4529a023aebf6ca6a1b6eae95a3652 Mon Sep 17 00:00:00 2001 From: Michael Prentice Date: Sun, 30 Aug 2015 21:30:59 -0400 Subject: [PATCH] Remove hardcoded GOOGLE_API_KEY that was spread around in the code and define it in hub.config.js. Fix broken links in Organizer cards. --- .jshintrc | 2 +- app/scripts/controllers/chapter.js | 8 ++++---- app/scripts/controllers/event.js | 4 ++-- app/scripts/controllers/gdg_stats.js | 2 +- app/scripts/directives/gplus.js | 6 +++--- app/scripts/hub.config.js | 8 ++++++++ app/views/directives/gplus_person.html | 12 +++++++----- 7 files changed, 26 insertions(+), 16 deletions(-) diff --git a/.jshintrc b/.jshintrc index d609302..e1be825 100755 --- a/.jshintrc +++ b/.jshintrc @@ -8,7 +8,7 @@ "eqeqeq": true, "immed": true, "indent": 2, - "latedef": true, + "latedef": "nofunc", "newcap": true, "noarg": true, "quotmark": "single", diff --git a/app/scripts/controllers/chapter.js b/app/scripts/controllers/chapter.js index 9223aa8..091def8 100644 --- a/app/scripts/controllers/chapter.js +++ b/app/scripts/controllers/chapter.js @@ -49,7 +49,7 @@ angular.module('gdgxHubApp') $scope.chapters = data; }); }) - .controller('ChapterMetricsCtrl', function ($scope, $http, $routeParams) { + .controller('ChapterMetricsCtrl', function ($scope, $http, $routeParams, config) { $scope.month = (moment().months() + 1); $scope.year = moment().year(); @@ -71,13 +71,13 @@ angular.module('gdgxHubApp') }); $http.get('https://www.googleapis.com/plus/v1/people/' + $routeParams.chapterId + - '?fields=aboutMe,image&key=AIzaSyD7v04m_bTu-rcWtuaN3fTP9NBmjhB7lXg') + '?fields=aboutMe,image&key=' + config.GOOGLE_API_KEY) .success(function (data) { $scope.about = data.aboutMe; $scope.image = data.image.url.replace('sz=50', 'sz=70'); }); }) - .controller('ChapterDetailCtrl', function ($scope, $http, $routeParams, $location, uiCalendarConfig) { + .controller('ChapterDetailCtrl', function ($scope, $http, $routeParams, $location, uiCalendarConfig, config) { $http.get('/api/v1/chapters/' + $routeParams.chapterId).success(function (data) { if (data.geo) { data.geo.latitude = data.geo.lat; @@ -94,7 +94,7 @@ angular.module('gdgxHubApp') }); $http.get('https://www.googleapis.com/plus/v1/people/' + $routeParams.chapterId + - '?fields=aboutMe,image&key=AIzaSyD7v04m_bTu-rcWtuaN3fTP9NBmjhB7lXg') + '?fields=aboutMe,image&key=' + config.GOOGLE_API_KEY) .success(function (data) { $scope.about = data.aboutMe; $scope.image = data.image.url.replace('sz=50', 'sz=70'); diff --git a/app/scripts/controllers/event.js b/app/scripts/controllers/event.js index 3b79c60..c5e31cc 100644 --- a/app/scripts/controllers/event.js +++ b/app/scripts/controllers/event.js @@ -45,7 +45,7 @@ angular.module('gdgxHubApp') $scope.eventSource = [$scope.events]; }) - .controller('EventDetailCtrl', function ($scope, $http, $routeParams) { + .controller('EventDetailCtrl', function ($scope, $http, $routeParams, config) { $http.get('/api/v1/events/' + $routeParams.eventId).success(function (data) { if (data.geo) { @@ -62,7 +62,7 @@ angular.module('gdgxHubApp') $scope.event = data; $http.get('https://www.googleapis.com/plus/v1/people/' + $scope.event.chapter + - '?fields=image&key=AIzaSyD7v04m_bTu-rcWtuaN3fTP9NBmjhB7lXg') + '?fields=image&key=' + config.GOOGLE_API_KEY) .success(function (data) { $scope.image = data.image.url.replace('sz=50', 'sz=70'); }); diff --git a/app/scripts/controllers/gdg_stats.js b/app/scripts/controllers/gdg_stats.js index ead5cc7..02890a8 100644 --- a/app/scripts/controllers/gdg_stats.js +++ b/app/scripts/controllers/gdg_stats.js @@ -34,7 +34,7 @@ angular.module('gdgxHubApp') data: { 'cols': [ {id: 't', label: 'Tags', type: 'string'}, - {id: 's', label: 'Occurences', type: 'number'} + {id: 's', label: 'Occurrences', type: 'number'} ] } }; diff --git a/app/scripts/directives/gplus.js b/app/scripts/directives/gplus.js index ec5dbfb..616dece 100644 --- a/app/scripts/directives/gplus.js +++ b/app/scripts/directives/gplus.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('gdgxHubApp.directives.gplus', []) - .directive('gplusPerson', ['$http', function ($http) { + .directive('gplusPerson', function ($http, config) { return { restrict: 'EA', templateUrl: 'directives/gplus_person', @@ -12,7 +12,7 @@ angular.module('gdgxHubApp.directives.gplus', []) scope.$watch('gplusId', function (oldVal, newVal) { if (newVal) { $http.get('https://www.googleapis.com/plus/v1/people/' + newVal + - '?fields=aboutMe%2CdisplayName%2Cimage&key=AIzaSyD7v04m_bTu-rcWtuaN3fTP9NBmjhB7lXg') + '?fields=aboutMe%2CdisplayName%2Cimage&key=' + config.GOOGLE_API_KEY) .success(function (data) { data.image.url = data.image.url.replace('sz=50', 'sz=170'); scope.person = data; @@ -21,4 +21,4 @@ angular.module('gdgxHubApp.directives.gplus', []) }); } }; - }]); + }); diff --git a/app/scripts/hub.config.js b/app/scripts/hub.config.js index 562c429..6690767 100755 --- a/app/scripts/hub.config.js +++ b/app/scripts/hub.config.js @@ -1,6 +1,8 @@ 'use strict'; angular.module('gdgxHubApp') + .constant('GOOGLE_API_KEY', 'AIzaSyD7v04m_bTu-rcWtuaN3fTP9NBmjhB7lXg') + .service('config', config) .config(function ($routeProvider, $locationProvider) { $routeProvider .when('/', { @@ -73,3 +75,9 @@ angular.module('gdgxHubApp') $locationProvider.html5Mode(true); }); + +function config(GOOGLE_API_KEY) { + return { + GOOGLE_API_KEY: GOOGLE_API_KEY + }; +} diff --git a/app/views/directives/gplus_person.html b/app/views/directives/gplus_person.html index fc2e8a6..dba3352 100644 --- a/app/views/directives/gplus_person.html +++ b/app/views/directives/gplus_person.html @@ -1,14 +1,16 @@
-
\ No newline at end of file +