diff --git a/.gitignore b/.gitignore index 92646c57..0d9550db 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /node_modules /electron_build .env +dist/ diff --git a/Gulpfile.js b/Gulpfile.js index ff55200c..198623f9 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -20,21 +20,56 @@ var ngAnnotate = require('gulp-ng-annotate') var uglify = require('gulp-uglify') var minifyCss = require('gulp-minify-css') var merge = require('merge-stream') +var concat = require('gulp-concat') +var streamqueue = require('streamqueue') +var minifyHtml = require('gulp-minify-html') var config = require('./build.config.js') -gulp.task('env', function () { - return gulp.src('tpls/env.js') - .pipe(template({ - apiUrl: env.BUILD_API_URL - })) - .pipe(gulp.dest('build/config')) +gulp.task('js', function () { + return streamqueue({objectMode: true}, + gulp.src('tpls/env.js') + .pipe(template({ + apiUrl: env.BUILD_API_URL + })), + gulp.src(['src/**/*.js']) + ) + .pipe(changed('build')) + .pipe(gulp.dest('build')) }) -gulp.task('js', function () { - return gulp.src(['src/**/*.js']) - .pipe(changed('build')) - .pipe(gulp.dest('build')) +gulp.task('dist', function () { + var js = streamqueue({objectMode: true}, + gulp.src(['src/**/*.js']), + gulp.src('tpls/env.js') + .pipe(template({ + apiUrl: env.DIST_API_URL + })), + gulp.src('src/**/*.tpl.html') + .pipe(templateCache()) + ) + .pipe(ngAnnotate()) + .pipe(uglify()) + .pipe(concat('app.js')) + .pipe(gulp.dest('dist')) + + var css = gulp.src('src/styles/main.styl') + .pipe(plumber({errorHandler: notify.onError('Error: <%= error.message %>')})) + .pipe(styl()) + .pipe(autoprefixer()) + .pipe(minifyCss()) + .pipe(gulp.dest('dist')) + + var index = gulp.src('src/index.html') + .pipe(template({ + scripts: ['app.js'], + styles: ['main.css'], + env: 'dist' + })) + .pipe(minifyHtml()) + .pipe(gulp.dest('dist')) + + return merge(js, css, index) }) gulp.task('styl', function () { @@ -72,7 +107,7 @@ gulp.task('index', function () { .pipe(template({ scripts: scripts, styles: styles, - env: env + env: 'build' })) .pipe(gulp.dest('build')) .pipe(livereload()) @@ -100,13 +135,11 @@ gulp.task('resources', function () { }) gulp.task('build', function (cb) { - runSequence(['env', 'js', 'styl', 'tpls', 'vendor', 'resources'], 'index', cb) + runSequence(['js', 'styl', 'tpls', 'vendor', 'resources'], 'index', cb) }) gulp.task('watch', function (cb) { - gulp.watch(['.env', 'tpls/env.js'], ['env']) - - gulp.watch('src/**/*.js', ['js']) + gulp.watch(['.env', 'tpls/env.js', 'src/**/*.js'], ['js']) gulp.watch('src/styles/**/*.styl', ['styl']) diff --git a/electron_src/popup/services/snippet.js b/electron_src/popup/services/snippet.js index 42a5bc42..d28dfed6 100644 --- a/electron_src/popup/services/snippet.js +++ b/electron_src/popup/services/snippet.js @@ -1,6 +1,6 @@ /* global angular */ angular.module('codexen.popup') - .constant('apiUrl', 'http://localhost:8000/') + .constant('apiUrl', 'http://codexen-server-dev.elasticbeanstalk.com/') .config(function ($authProvider, $httpProvider, apiUrl) { $authProvider.baseUrl = apiUrl diff --git a/gulp-electron.js b/gulp-electron.js index 089fa9d3..4287040f 100644 --- a/gulp-electron.js +++ b/gulp-electron.js @@ -21,7 +21,7 @@ module.exports = function (gulp) { gulp.task('elec-env', function () { return gulp.src('tpls/env.js') .pipe(template({ - apiUrl: env.BUILD_API_URL + apiUrl: env.ELEC_API_URL })) .pipe(gulp.dest('electron_build/config')) }) @@ -78,7 +78,7 @@ module.exports = function (gulp) { .pipe(template({ scripts: scripts, styles: styles, - env: env + env: 'build' })) .pipe(gulp.dest('electron_build')) .pipe(livereload()) diff --git a/package.json b/package.json index a484ba49..02c43e57 100644 --- a/package.json +++ b/package.json @@ -68,5 +68,9 @@ "satellizer": "^0.10.1", "ui-select": "^0.11.2" }, - "devDependencies": {} + "devDependencies": { + "gulp-concat": "^2.5.2", + "gulp-minify-html": "^1.0.3", + "streamqueue": "^1.1.0" + } } diff --git a/src/controllers/states/SnippetsListController.js b/src/controllers/states/SnippetsListController.js index a4716a41..3b3f5163 100644 --- a/src/controllers/states/SnippetsListController.js +++ b/src/controllers/states/SnippetsListController.js @@ -1,6 +1,6 @@ /* global angular */ angular.module('codexen') - .controller('SnippetsListController', function ($auth, Snippet, $scope, $state, $scope, $filter, mySnippets) { + .controller('SnippetsListController', function ($auth, Snippet, $scope, $state, $scope, $filter, mySnippets, User) { var vm = this vm.isLoading = false @@ -12,6 +12,16 @@ angular.module('codexen') vm.searchSnippets = searchSnippets vm.searchSnippets() + vm.isAuthenticated = $auth.isAuthenticated() + var reloadUser = function () { + if (vm.isAuthenticated) { + User.me().success(function (data) { + vm.currentUser = data + }) + } + } + reloadUser() + // TODO: add Navigation methods // vm.nextSnippet() // vm.priorSnippet() diff --git a/src/index.html b/src/index.html index e126fbf9..55b10205 100644 --- a/src/index.html +++ b/src/index.html @@ -11,7 +11,16 @@ Codexen! - + + + <% if(env === 'dist') { %> + + <% } %> + + <% if(env === 'build') { %> + + <% } %> + <% styles.forEach(function(style){ %> <% }) %> @@ -22,15 +31,30 @@
- - - - - - - - - + <% if(env === 'dist') { %> + + + + + + + + + + <% } %> + + <% if(env === 'build') { %> + + + + + + + + + + <% } %> + <% scripts.forEach(function(script){ %> diff --git a/src/styles/_bootstrap.styl b/src/styles/_bootstrap.styl index 7c2c8c63..4e47dd8d 100644 --- a/src/styles/_bootstrap.styl +++ b/src/styles/_bootstrap.styl @@ -27,8 +27,8 @@ @import '../../node_modules/bootstrap-styl/bootstrap/navs' @import '../../node_modules/bootstrap-styl/bootstrap/navbar' // @import '../../node_modules/bootstrap-styl/bootstrap/breadcrumbs' -@import '../../node_modules/bootstrap-styl/bootstrap/pagination' -@import '../../node_modules/bootstrap-styl/bootstrap/pager' +// @import '../../node_modules/bootstrap-styl/bootstrap/pagination' +// @import '../../node_modules/bootstrap-styl/bootstrap/pager' @import '../../node_modules/bootstrap-styl/bootstrap/labels' @import '../../node_modules/bootstrap-styl/bootstrap/badges' @import '../../node_modules/bootstrap-styl/bootstrap/jumbotron' diff --git a/src/tpls/states/home.tpl.html b/src/tpls/states/home.tpl.html index 93c5ee20..b0b2c080 100644 --- a/src/tpls/states/home.tpl.html +++ b/src/tpls/states/home.tpl.html @@ -2,9 +2,6 @@

Codexen App v0.1

App for Code snippets
- - App: Rokt33r/codexen-app
- Server: Rokt33r/codexen-server

diff --git a/src/tpls/states/snippets.list.tpl.html b/src/tpls/states/snippets.list.tpl.html index c4ddc233..cd445e3b 100644 --- a/src/tpls/states/snippets.list.tpl.html +++ b/src/tpls/states/snippets.list.tpl.html @@ -29,7 +29,7 @@

  • - +