From b9a49bfa5eaa59da8bcbb250eefb964b2382fd3d Mon Sep 17 00:00:00 2001 From: Martin Donnelly Date: Tue, 15 Mar 2016 13:15:41 +0000 Subject: [PATCH] Updating to Version 3 --- .idea/workspace.xml | 608 ++++++++++++++++++++++++++------------------ .jshintrc | 51 ++-- gulp/build.js | 16 ++ gulpfile.js | 82 ++++++ html/css/app.css | 2 +- html/index.html | 16 +- html/js/app.v3.js | 123 ++++----- html/js/shell.js | 2 +- package.json | 14 + pipes-server.js | 4 +- 10 files changed, 575 insertions(+), 343 deletions(-) create mode 100644 gulp/build.js create mode 100644 gulpfile.js diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 25c7330..f3c6018 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,39 +2,16 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + @@ -55,111 +32,205 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -215,6 +293,11 @@ true + + + $PROJECT_DIR$/gulpfile.js + + @@ -337,7 +426,7 @@ - + @@ -390,6 +479,14 @@ false + + + $PROJECT_DIR$/gulpfile.js + + + + + @@ -399,11 +496,12 @@ - - - - - + + + + + + @@ -548,7 +646,13 @@ @@ -559,7 +663,7 @@ - + @@ -624,58 +728,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -738,26 +790,6 @@ - - - - - - - - - - - - - - - - - - - - @@ -774,14 +806,6 @@ - - - - - - - - @@ -846,17 +870,6 @@ - - - - - - - - - - - @@ -974,26 +987,36 @@ + + + + + + + + - + - + - - - + + + + + - + - - + + @@ -1006,5 +1029,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.jshintrc b/.jshintrc index 2f30d16..da32b7f 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,33 +1,32 @@ { - "predef": [ - "server", - "document", - "window", - "-Promise" - ], - "browser": true, - "boss": true, + "node": true, + "esnext": true, + "bitwise": true, + "camelcase": true, "curly": true, - "debug": false, - "devel": true, "eqeqeq": true, - "evil": true, - "forin": false, - "immed": false, - "laxbreak": false, + "immed": true, + "indent": 2, + "latedef": true, "newcap": true, "noarg": true, - "noempty": false, - "nonew": false, - "nomen": false, - "onevar": false, - "plusplus": false, - "regexp": false, + "quotmark": "single", + "regexp": true, "undef": true, - "sub": true, - "strict": false, - "white": false, - "eqnull": true, - "esnext": true, - "unused": true + "unused": true, + "strict": true, + "trailing": true, + "smarttabs": true, + "white": true, + "validthis": true, + "browser" : true, + "jquery":true, + + "globals": { + + "$": false, + "EJS": false, + "MicroEvent": false + + } } diff --git a/gulp/build.js b/gulp/build.js new file mode 100644 index 0000000..790e92f --- /dev/null +++ b/gulp/build.js @@ -0,0 +1,16 @@ +/** + * Created by Martin on 15/03/2016. + */ +'use strict'; + +var gulp = require('gulp'); + + +function handleError(err) { + console.error(err.toString()); + this.emit('end'); +} + +gulp.task('clean', function () { + return gulp.src(['.tmp', 'dist'], { read: false }).pipe($.rimraf()); +}); diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..2feeb63 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,82 @@ +"use strict"; +var gulp = require('gulp'), + + autoprefixer = require('gulp-autoprefixer'), + cssnano = require('gulp-cssnano'), + jshint = require('gulp-jshint'), + uglify = require('gulp-uglify'), + + rename = require('gulp-rename'), + concat = require('gulp-concat'), + notify = require('gulp-notify'), + cache = require('gulp-cache'), + livereload = require('gulp-livereload'), + htmlmin = require('gulp-htmlmin'), + inject = require('gulp-inject'), + del = require('del'), + htmlreplace = require('gulp-html-replace'); + + +var filePath = { + build_dir: './dist' +}; + +gulp.task('scripts', function() { + return gulp.src(['html/js/shell.js','html/js/app.v3.js']) + .pipe(jshint('.jshintrc')) + .pipe(jshint.reporter('default')) + .pipe(concat('app.js')) + /*.pipe(gulp.dest('dist/js'))*/ + /*.pipe(rename({suffix: '.min'}))*/ + /* .pipe(uglify())*/ + /*.pipe(concat('app.js'))*/ + .pipe(gulp.dest('dist/js')) + .pipe(notify({ message: 'Scripts task complete' })); +}); + +gulp.task('vendor', function() { + return gulp.src(['html/libs/microevent.js','html/js/moment.min.js','html/js/ejs_production.js','html/js/jquery.unveil.js']) + .pipe(concat('vendor.js')) + .pipe(gulp.dest('dist/js')) + .pipe(notify({ message: 'Scripts task complete' })); +}); + +gulp.task('styles', function() { + return gulp.src(['html/css/app.css','html/css/md.css']) + .pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4')) + /*.pipe(gulp.dest('dist/css'))*/ + /*.pipe(rename({suffix: '.min'}))*/ + .pipe(cssnano()) + .pipe(concat('app.css')) + .pipe(gulp.dest('dist/css')) + .pipe(notify({ message: 'Styles task complete' })); +}); + +gulp.task('partials', function() { + gulp.src(['html/ejs/**/*']).pipe(gulp.dest('dist/ejs')); + gulp.src(['html/icons/**/*']).pipe(gulp.dest('dist/icons')); +}); + + + +gulp.task('index', function () { + var sources = gulp.src(['js/apps.js', 'css/app.css'], {read: false}); + + return gulp.src(['html/index.html']) + .pipe(htmlreplace({ + 'css': 'css/app.css', + 'js': 'js/app.js', + 'vendor': 'js/vendor.js' + })) + .pipe(htmlmin({removeComments: true, collapseWhitespace: true, keepClosingSlash: true})) + .pipe(gulp.dest('dist/')); +}); + +gulp.task('clean', function() { + return del(['dist']); +}); + + +gulp.task('default', ['clean'], function() { + gulp.start('styles', 'scripts','vendor', 'partials','index'); +}); diff --git a/html/css/app.css b/html/css/app.css index 4910183..df9673d 100644 --- a/html/css/app.css +++ b/html/css/app.css @@ -176,5 +176,5 @@ float:right; #footer, .mui-appbar { - background-color: #FB7820; + background-color: #775585; } diff --git a/html/index.html b/html/index.html index b41f41c..8c1fd55 100644 --- a/html/index.html +++ b/html/index.html @@ -36,14 +36,19 @@ } - + - + + + - + + + + @@ -114,10 +119,7 @@ - - - - + diff --git a/html/js/app.v3.js b/html/js/app.v3.js index a015109..8fd41d0 100644 --- a/html/js/app.v3.js +++ b/html/js/app.v3.js @@ -1,9 +1,10 @@ /** * Created by Martin on 15/03/2016. */ +"use strict"; var APP = function () { - refreshStep = 0, + var refreshStep = 0, preUrl = '/', _storage = { @@ -17,25 +18,18 @@ var APP = function () { lastUpdated = null, preCache = function () { - _list = new EJS({url: 'ejs/list.ejs'}); + _list = new EJS({url: 'ejs/list.ejs'}); _feed = new EJS({ url: 'ejs/testcards.ejs' }); }, - init = function () { - $('#fnRefresh').on('click', $.proxy(refresh, this)); - console.log('app starting...'); - preCache(); - doLoad(); - getLastUpdateDate(); - console.log('Last updated: ' + lastUpdated); - }, getLastUpdateDate = function () { var formatted, dt; // this.lastUpdated = localStorage.getItem('lastUpdated') || null; - if (lastUpdated == null) + if (lastUpdated === null) { $('#lastupdate').empty().append('Never'); + } else { dt = new Date(lastUpdated); formatted = moment(dt).startOf('minute').fromNow(); @@ -44,16 +38,16 @@ var APP = function () { } }, - refresh = function () { - refreshStep = 0; - console.log('refresh'); - console.log(this); - console.log('get ' + feeds[refreshStep]); - $('#lastupdate').empty().append('Refreshing...'); - // $.zprogress.start(); - doRefresh(); - + doSave = function () { + console.log('Saving...'); + lastUpdated = new Date(); + _storage.lastupdated = lastUpdated; + localStorage.setItem('lastUpdated', lastUpdated); + localStorage.setItem('_storage', JSON.stringify(_storage)); + getLastUpdateDate(); + // $.zprogress.done(true); }, + doRefresh = function () { var self = this; if (refreshStep < feeds.length) { @@ -70,6 +64,18 @@ var APP = function () { doSave(); } }, + showFeed = function (opt) { + var output, d; + console.log('show feed ' + opt); + // $('#feedcontent').empty(); + d = { + d: _storage.feeds[opt] + }; + output = _feed.render(d); + + $('#bodyContents').empty().html(output); + $('img').unveil(); + }, doUpdate = function (data) { console.log(this); console.log(data); @@ -80,33 +86,10 @@ var APP = function () { // $.zprogress.inc(0.2); doRefresh(); }, - doSave = function () { - console.log('Saving...'); - lastUpdated = new Date(); - _storage.lastupdated = lastUpdated; - localStorage.setItem('lastUpdated', lastUpdated); - localStorage.setItem('_storage', JSON.stringify(_storage)); - getLastUpdateDate(); - // $.zprogress.done(true); - }, - doLoad = function () { - - var _load = localStorage.getItem('_storage'); - $('#lastupdate').empty().append('Loading...'); - if (_load != null) - _storage = JSON.parse(_load); - else - _storage = { - lastupdated: null, - feeds: {} - }; - lastUpdated = _storage.lastupdated || null; - showList(); - }, showList = function () { - var output, d = {}, + var key, output, d = {}, list = []; - for (var key in _storage.feeds) { + for (key in _storage.feeds) { console.log(key); list.push({ name: key @@ -115,26 +98,50 @@ var APP = function () { d.list = list; - var output = _list.render(d); + output = _list.render(d); $('#listContainer').empty().html(output); - for (var key in _storage.feeds) { + for (key in _storage.feeds) { $('#' + key).on('click', $.proxy(showFeed, this, key)); } }, - showFeed = function (opt) { - var output, d; - console.log('show feed ' + opt); - // $('#feedcontent').empty(); - d = { - d: _storage.feeds[opt] - }; - var output = _feed.render(d); + doLoad = function () { - $('#bodyContents').empty().html(output); - $("img").unveil(); - }; + var _load = localStorage.getItem('_storage'); + $('#lastupdate').empty().append('Loading...'); + if (_load !== null) { + _storage = JSON.parse(_load); + } + + else { + _storage = { + lastupdated: null, + feeds: {} + }; + } + + lastUpdated = _storage.lastupdated || null; + showList(); + }, + + refresh = function () { + refreshStep = 0; + console.log('refresh'); + console.log(this); + console.log('get ' + feeds[refreshStep]); + $('#lastupdate').empty().append('Refreshing...'); + // $.zprogress.start(); + doRefresh(); + + }, init = function () { + $('#fnRefresh').on('click', $.proxy(refresh, this)); + console.log('app starting...'); + preCache(); + doLoad(); + getLastUpdateDate(); + console.log('Last updated: ' + lastUpdated); + } ; $('#fnRefresh').on('click', function () { doLoad(); diff --git a/html/js/shell.js b/html/js/shell.js index 1f95864..6797301 100644 --- a/html/js/shell.js +++ b/html/js/shell.js @@ -33,7 +33,7 @@ jQuery(function($) { $('.js-hide-sidedrawer').on('click', hideSidedrawer); }); -var $titleEls = $('strong', $sidedrawerEl); +var $titleEls = $('strong', $('#sidedrawer')); $titleEls .next() diff --git a/package.json b/package.json index ca13355..8538392 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,21 @@ "name": "silvrtree", "version": "0.1.1", "devDependencies": { + "del": "^2.2.0", "ejs": "^2.3.3", + "gulp": "^3.9.1", + "gulp-autoprefixer": "^3.1.0", + "gulp-cache": "^0.4.2", + "gulp-concat": "^2.6.0", + "gulp-cssnano": "^2.1.1", + "gulp-html-replace": "^1.5.5", + "gulp-htmlmin": "^1.3.0", + "gulp-inject": "^3.0.0", + "gulp-jshint": "^2.0.0", + "gulp-livereload": "^3.8.1", + "gulp-notify": "^2.2.0", + "gulp-rename": "^1.2.2", + "gulp-uglify": "^1.5.3", "lodash": "^4.6.1", "rss-braider": "^1.0.0" }, diff --git a/pipes-server.js b/pipes-server.js index e9679f5..673815a 100644 --- a/pipes-server.js +++ b/pipes-server.js @@ -26,12 +26,12 @@ app.use(function (req, res, next) { next(); }); //app.use(app.router); - app.use(express.static(path.join(__dirname, 'html'))); + app.use(express.static(path.join(__dirname, 'dist'))); app.use(errorhandler({dumpExceptions: true, showStack: true})); - + //}); /**