From f27009836d12ea33b6397d6eec1284c22695924b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86ndrew=20Rininsland?= Date: Thu, 19 Mar 2015 18:16:36 +0000 Subject: [PATCH] New dev branch. In-prog. --- Gruntfile.js | 2 +- bower.json | 4 +-- client/app/main/edit/edit.controller.js | 32 +++++++++---------- client/app/main/new/new.controller.js | 41 ++++++++++--------------- client/app/preview/preview.js | 4 +-- 5 files changed, 38 insertions(+), 45 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index b2f53b0..98f43d1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -430,7 +430,7 @@ module.exports = function (grunt) { }, dist: [ 'sass', - // 'imagemin', + 'imagemin', 'svgmin' ] }, diff --git a/bower.json b/bower.json index bf93f0c..432f3db 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "axismaker", - "version": "0.0.0", + "version": "0.0.1", "dependencies": { "angular": ">=1.2.*", "json3": "~3.3.1", @@ -17,7 +17,7 @@ "angular-ui-router": "~0.2.10", "angular-post-message": "~1.1.1", "jsonfn": "vkiryukhin/jsonfn", - "github": "aendrew/github#147_fix_getSha_write" + "github": "aendrew/github" }, "devDependencies": { "angular-mocks": ">=1.2.*", diff --git a/client/app/main/edit/edit.controller.js b/client/app/main/edit/edit.controller.js index 34c374a..e846c65 100644 --- a/client/app/main/edit/edit.controller.js +++ b/client/app/main/edit/edit.controller.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('axismakerApp') - .controller('EditCtrl', function ($scope, $window, $location, Auth, $stateParams, $modal, $http) { + .controller('EditCtrl', function ($scope, $window, $location, Auth, $stateParams, $modal, $templateCache) { var branch = 'gh-pages'; // change to gh-pages in prod $scope.itemName = typeof $stateParams.item !== 'undefined' ? $stateParams.item : undefined; $scope.filename = $scope.itemName; @@ -53,25 +53,25 @@ angular.module('axismakerApp') // Update chart var createNew = function(config) { if ($scope.filename !== '') { - $http.get('/app/preview/preview.html').success(function(template){ - var timestamp = new Date(); - //var url = 'https://' + repoName[1] + '.github.io/' + repoName[2] + '/' + $scope.filename; // Takes too long to push to GH-pages for preview. Use RawGit instead. - var url = 'https://rawgit.com/' + $scope.repoName[1] + '/' + $scope.repoName[2] + '/index.html'; - var cdnUrl = 'https://cdn.rawgit.com/' + $scope.repoName[1] + '/' + $scope.repoName[2] + '/index.html'; + var template = $templateCache.get('/app/preview/preview.html'); + var timestamp = new Date(); + //var url = 'https://' + repoName[1] + '.github.io/' + repoName[2] + '/' + $scope.filename; // Takes too long to push to GH-pages for preview. Use RawGit instead. + var url = 'https://rawgit.com/' + $scope.repoName[1] + '/' + $scope.repoName[2] + '/index.html'; + var cdnUrl = 'https://cdn.rawgit.com/' + $scope.repoName[1] + '/' + $scope.repoName[2] + '/index.html'; - repo.write($scope.branch, $scope.filename + '/index.html', template, 'Updated ' + timestamp.toISOString() , function(err, res, xmlhttprequest){ - repo.write($scope.branch, $scope.filename + '/axis.json', config.config, 'Updated ' + timestamp.toISOString(), function(err, res, xmlhttprequest){ - $modal.open({ - templateUrl: 'components/modal/modal.html', - controller: function($scope, $sce){ - $scope.modal = {}; - $scope.modal.title = url; - $scope.modal.html = $sce.trustAsHtml('
Open in new window '); - } - }); + repo.write($scope.branch, $scope.filename + '/index.html', template, 'Updated ' + timestamp.toISOString() , function(err, res, xmlhttprequest){ + repo.write($scope.branch, $scope.filename + '/axis.json', config.config, 'Updated ' + timestamp.toISOString(), function(err, res, xmlhttprequest){ + $modal.open({ + templateUrl: 'components/modal/modal.html', + controller: function($scope, $sce){ + $scope.modal = {}; + $scope.modal.title = url; + $scope.modal.html = $sce.trustAsHtml('
Open in new window '); + } }); }); }); + } }; diff --git a/client/app/main/new/new.controller.js b/client/app/main/new/new.controller.js index 7832702..a305ce8 100644 --- a/client/app/main/new/new.controller.js +++ b/client/app/main/new/new.controller.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('axismakerApp') - .controller('NewCtrl', function ($scope, Auth, $compile, $http, $window, $modal) { + .controller('NewCtrl', function ($scope, Auth, $compile, $window, $modal, $templateCache) { $window.axisConfig = undefined; // clear global config from previous edits $scope.branch = 'gh-pages'; // change to gh-pages in prod $scope.token = Auth.getCurrentUser().githubToken; @@ -15,24 +15,23 @@ angular.module('axismakerApp') var repo = $scope.github.getRepo($scope.repoName[1], $scope.repoName[2]); var createNew = function(config) { if ($scope.filename !== '') { - $http.get('/app/preview/preview.html').success(function(template){ - repo.write($scope.branch, $scope.filename + '/index.html', template, 'initial -- ' + $scope.filename, function(err, res, xmlhttprequest){ - console.dir([err, res, xmlhttprequest]); - //var url = 'https://' + $scope.repoName[1] + '.github.io/' + $scope.repoName[2] + '/' + res.content.path; // GH-pages 5 minute delay sucks. - var url = 'https://rawgit.com/' + $scope.repoName[1] + '/' + $scope.repoName[2] + '/index.html'; - var cdnUrl = 'https://cdn.rawgit.com/' + $scope.repoName[1] + '/' + $scope.repoName[2] + '/index.html'; + var template = $templateCache.get('/app/preview/preview.html'); + repo.write($scope.branch, $scope.filename + '/index.html', template, 'initial -- ' + $scope.filename, function(err, res, xmlhttprequest){ + console.dir([err, res, xmlhttprequest]); + //var url = 'https://' + $scope.repoName[1] + '.github.io/' + $scope.repoName[2] + '/' + res.content.path; // GH-pages 5 minute delay sucks. + var url = 'https://rawgit.com/' + $scope.repoName[1] + '/' + $scope.repoName[2] + '/master/index.html'; + var cdnUrl = 'https://cdn.rawgit.com/' + $scope.repoName[1] + '/' + $scope.repoName[2] + '/master/index.html'; - // Second write has to be after the first completes. - repo.write($scope.branch, $scope.filename + '/axis.json', config.config, 'initial config -- ' + $scope.filename, function(err, res, xmlhttprequest){ - console.dir([err, res, xmlhttprequest]); - $modal.open({ - templateUrl: 'components/modal/modal.html', - controller: function($scope, $sce){ - $scope.modal = {}; - $scope.modal.title = url; - $scope.modal.html = $sce.trustAsHtml('
Open in new window '); - } - }); + // Second write has to be after the first completes. + repo.write($scope.branch, $scope.filename + '/axis.json', config.config, 'initial config -- ' + $scope.filename, function(err, res, xmlhttprequest){ + console.dir([err, res, xmlhttprequest]); + $modal.open({ + templateUrl: 'components/modal/modal.html', + controller: function($scope, $sce){ + $scope.modal = {}; + $scope.modal.title = url; + $scope.modal.html = $sce.trustAsHtml('
Open in new window '); + } }); }); }); @@ -43,10 +42,4 @@ angular.module('axismakerApp') var config = angular.fromJson(e.originalEvent.data); createNew(config); }); - - // $scope.$root.$on('$messageIncoming', function (event, data){ - // console.log('yay'); - // var config = angular.fromJson(data); - // createNew(config); - // }); }); diff --git a/client/app/preview/preview.js b/client/app/preview/preview.js index 1a316fc..1275b0a 100644 --- a/client/app/preview/preview.js +++ b/client/app/preview/preview.js @@ -5,7 +5,7 @@ angular.module('axismakerApp') $stateProvider .state('preview', { url: '/preview', - templateUrl: 'app/preview/preview/preview.html', + templateUrl: 'app/preview/preview.html', controller: 'PreviewCtrl' }); - }); \ No newline at end of file + });