”2016-07-28”

This commit is contained in:
Martin Donnelly 2016-07-28 16:45:02 +01:00
parent 32f042bb41
commit 1dc6d36fca
8 changed files with 397 additions and 164 deletions

View File

@ -56,7 +56,7 @@ if (process.env.NODE_ENV === 'production') {
isProduction = true; isProduction = true;
} }
logger.debug('isProduction:', isProduction); logger.warn('isProduction:', isProduction);
var app = express(); var app = express();

View File

@ -5,13 +5,13 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Console</title> <title>Console</title>
<!-- build:fonts --> <!-- build:fonts -->
<!-- <link rel="stylesheet" <link rel="stylesheet"
href="http://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700" href="http://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700"
type="text/css"> type="text/css">
<link href='https://fonts.googleapis.com/css?family=Ubuntu+Condensed' <link href='https://fonts.googleapis.com/css?family=Ubuntu+Condensed'
rel='stylesheet' type='text/css'> rel='stylesheet' type='text/css'>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" <link href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet">--> rel="stylesheet">
<!-- endbuild --> <!-- endbuild -->
<!-- build:css --> <!-- build:css -->
<link href="css/mui.css" rel="stylesheet" type="text/css"/> <link href="css/mui.css" rel="stylesheet" type="text/css"/>
@ -151,12 +151,12 @@
<div class="mui-col-xs-4 mui--text-center" id="auxFront" <div class="mui-col-xs-4 mui--text-center" id="auxFront"
style="display:none;"> style="display:none;">
<div> <div>
<button class="mui-btn mui-btn--small mui-btn--accent turnUp" <button class="mui-btn mui-btn--small mui-btn--accent lightUp"
id="frontUp">BRIGHTER id="frontUp">BRIGHTER
</button> </button>
</div> </div>
<div> <div>
<button class="mui-btn mui-btn--small mui-btn--accent turnDown" <button class="mui-btn mui-btn--small mui-btn--accent lightDown"
id="frontDown">DARKER id="frontDown">DARKER
</button> </button>
</div> </div>
@ -205,12 +205,12 @@
<div class="mui-col-xs-4 mui--text-center" id="auxBack" <div class="mui-col-xs-4 mui--text-center" id="auxBack"
style="display: none;"> style="display: none;">
<div> <div>
<button class="mui-btn mui-btn--small mui-btn--accent turnUp" <button class="mui-btn mui-btn--small mui-btn--accent lightUp"
id="backUp">BRIGHTER id="backUp">BRIGHTER
</button> </button>
</div> </div>
<div> <div>
<button class="mui-btn mui-btn--small mui-btn--accent turnDown" <button class="mui-btn mui-btn--small mui-btn--accent lightDown"
id="backDown">DARKER id="backDown">DARKER
</button> </button>
</div> </div>
@ -311,6 +311,7 @@
<script src="js/parts/clock.js"></script> <script src="js/parts/clock.js"></script>
<script src="js/parts/meetings.js"></script> <script src="js/parts/meetings.js"></script>
<script src="js/parts/lights.js"></script> <script src="js/parts/lights.js"></script>
<script src="js/parts/projector.js"></script>
<script src="js/appv3.js"></script> <script src="js/appv3.js"></script>
</body> </body>
<!-- endbuild --> <!-- endbuild -->

View File

@ -105,6 +105,7 @@ var SOController = (function() {
} }
/*
function lightCommand(id) { function lightCommand(id) {
console.log('lightCommand',path + 'api/v1/lighting/cmd'); console.log('lightCommand',path + 'api/v1/lighting/cmd');
$.post(path + 'api/v1/lighting/cmd', {id: id}, function() {}); $.post(path + 'api/v1/lighting/cmd', {id: id}, function() {});
@ -118,6 +119,7 @@ var SOController = (function() {
function turnOffLights(id) { function turnOffLights(id) {
$.post(path + 'api/v1/lighting/off', {light: id}, function() {}); $.post(path + 'api/v1/lighting/off', {light: id}, function() {});
} }
*/
function turnOnHeating() { function turnOnHeating() {
$.post(path + 'api/v1/heating/on', {}, function() {}); $.post(path + 'api/v1/heating/on', {}, function() {});
@ -147,6 +149,7 @@ var SOController = (function() {
} }
function attachClicks() { function attachClicks() {
/*
$('#projectorOn').on('click', function() { $('#projectorOn').on('click', function() {
turnOnProjector(); turnOnProjector();
}); });
@ -154,6 +157,7 @@ var SOController = (function() {
$('#projectorOff').on('click', function() { $('#projectorOff').on('click', function() {
turnOffProjector(); turnOffProjector();
}); });
*/
$('#heatingOn').on('click', function() { $('#heatingOn').on('click', function() {
turnOnHeating(); turnOnHeating();
@ -163,33 +167,6 @@ var SOController = (function() {
turnOffHeating(); turnOffHeating();
}); });
$('#frontLightOn').on('click', function() {
// 1 for board lights
turnOnLights('o');
});
$('#middleLightOn').on('click', function() {
turnOnLights(2);
});
$('#backLightOn').on('click', function() {
// 3 for board lights
turnOnLights('n');
});
$('#frontLightOff').on('click', function() {
// A for board lights
turnOffLights('f');
});
$('#middleLightOff').on('click', function() {
turnOffLights('b');
});
$('#backLightOff').on('click', function() {
turnOffLights('g');
});
$('#extend05').on('click', function() { $('#extend05').on('click', function() {
extendMeetingBy(5); extendMeetingBy(5);
@ -207,33 +184,6 @@ var SOController = (function() {
extendMeetingBy(30); extendMeetingBy(30);
}); });
$('#frontUp').on('click', function(event) {
var target = $(event.target);
lightCommand('9');
delayButton(target);
});
$('#frontDown').on('click', function(event) {
var target = $(event.target);
lightCommand('1');
delayButton(target);
});
$('#backUp').on('click', function(event) {
var target = $(event.target);
lightCommand('8');
delayButton(target);
});
$('#backDown').on('click', function(event) {
var target = $(event.target);
lightCommand('2');
delayButton(target);
});
$('#projectorHDMI').on('click', function(event) { $('#projectorHDMI').on('click', function(event) {
var target = $(event.target); var target = $(event.target);
@ -339,7 +289,8 @@ var SOController = (function() {
this.backLightData = new LightModel({device: 'back',on: 'n',off: 'g', up: '8', down: '2'}); this.backLightData = new LightModel({device: 'back',on: 'n',off: 'g', up: '8', down: '2'});
this.backLight = new Light({el: $('#back-light'),model: this.backLightData}); this.backLight = new Light({el: $('#back-light'),model: this.backLightData});
this.projectorData = new ProjectorModel({device: 'projector', up: '8', down: '2'});
this.projector = new Projector({el: $('#projector-panel'),model: this.projectorData});
this.addLight(this.frontLightData); this.addLight(this.frontLightData);
this.addLight(this.backLightData); this.addLight(this.backLightData);

View File

@ -8,39 +8,41 @@
*/ */
var path = 'http://localhost:3000/'; var path = 'http://localhost:3000/';
var LightModel = Backbone.Model.extend({ var LightModel = Backbone.Model.extend({
//$.post(path + 'api/v1/lighting/on', {light: id}, function() {});
urlRoot: path + 'api/v1/lighting/', urlRoot: path + 'api/v1/lighting/',
initialize: function() { initialize: function() {
this.set('status',false); this.set('status',false);
this.set('enabled',true);
}, },
turnOn: function() { turnOn: function() {
console.log('LightModel:TurnOn');
this.set('id','on'); this.set('id','on');
this.save({light: this.get('on')},{ this.save({light: this.get('on')},{
type: 'POST' type: 'POST'
}); });
}, },
turnOff: function() { turnOff: function() {
console.log('LightModel:TurnOff');
this.set('id','off'); this.set('id','off');
this.save({light: this.get('off')},{ this.save({light: this.get('off')},{
type: 'POST' type: 'POST'
}); });
}, },
turnUp: function() { turnUp: function() {
console.log('LightModel:TurnOff');
this.set('id','cmd'); this.set('id','cmd');
this.save({light: this.get('up')},{ this.save({light: this.get('up')},{
type: 'POST' type: 'POST'
}); });
}, },
turnDown: function() { turnDown: function() {
console.log('LightModel:TurnDown');
this.set('id','cmd'); this.set('id','cmd');
this.save({light: this.get('down')},{ this.save({light: this.get('down')},{
type: 'POST' type: 'POST'
}); });
},
disable: function() {
this.set('enabled',false);
},
enable: function() {
this.set('enabled',true);
} }
}); });
@ -49,24 +51,35 @@ var Light = Backbone.View.extend({
events: { events: {
'click .lightOn': 'turnOn', 'click .lightOn': 'turnOn',
'click .lightOff': 'turnOff', 'click .lightOff': 'turnOff',
'click .lightPp': 'turnup' 'click .lightUp': 'turnUp',
'click .lightDown': 'turnDown'
}, },
initialize: function() { initialize: function() {
var tStr; var tStr;
_.bindAll(this, 'render', 'update', 'turnOn','turnOff'); _.bindAll(this, 'render', 'update', 'turnOn','turnOff', 'turnUp','turnDown','updateStatus','updateEnabled');
this.model.bind('change', this.update); this.model.bind('change', this.update);
this.$onButton = $('#' + this.model.get('device') + 'LightOn'); this.$onButton = this.$('#' + this.model.get('device') + 'LightOn');
this.$offButton = $('#' + this.model.get('device') + 'LightOff'); this.$offButton = this.$('#' + this.model.get('device') + 'LightOff');
this.$upButton = this.$('#' + this.model.get('device') + 'Up');
this.$downButton = this.$('#' + this.model.get('device') + 'Down');
tStr = this.model.get('device')[0].toUpperCase() + this.model.get('device').substring(1); tStr = this.model.get('device')[0].toUpperCase() + this.model.get('device').substring(1);
this.$aux = $('#aux' + tStr); this.$aux = this.$('#aux' + tStr);
// This.render(); // This.render();
}, },
render: function() { render: function() {
console.log('Light:Render');
console.log(this);
}, },
update: function() { update: function() {
if (this.model.hasChanged('status')) {
this.updateStatus();
}
if (this.model.hasChanged('enabled')) {
this.updateEnabled();
}
},
updateStatus: function() {
if (this.model.get('status') === true) { if (this.model.get('status') === true) {
// Lights are on.. // Lights are on..
this.$onButton.hide(); this.$onButton.hide();
@ -78,17 +91,32 @@ var Light = Backbone.View.extend({
this.$aux.fadeOut(); this.$aux.fadeOut();
} }
},
updateEnabled: function() {
var enabled = this.model.get('enabled');
if (enabled) {
this.$el.removeClass('lostConnection');
} else {
this.$el.addClass('lostConnection');
}
this.$onButton.attr('disabled', !enabled);
this.$offButton.attr('disabled', !enabled);
this.$upButton.attr('disabled', !enabled);
this.$downButton.attr('disabled', !enabled);
}, },
turnOn: function() { turnOn: function() {
console.log('Light:On');
this.model.turnOn(); this.model.turnOn();
}, },
turnOff: function() { turnOff: function() {
console.log('Light:Off');
this.model.turnOff(); this.model.turnOff();
}, },
turnUp: function() { turnUp: function() {
console.log('Light:Up');
this.model.turnUp(); this.model.turnUp();
},
turnDown: function() {
this.model.turnDown();
} }
}); });

View File

@ -1,3 +1,4 @@
'use strict';
/** /**
* *
* User: Martin Donnelly * User: Martin Donnelly
@ -5,3 +6,117 @@
* Time: 09:25 * Time: 09:25
* *
*/ */
var path = 'http://localhost:3000/';
var ProjectorModel = Backbone.Model.extend({
urlRoot: path + 'api/v1/projector/',
initialize: function() {
this.set('status',false);
this.set('enabled',true);
},
turnOn: function() {
this.set('id','on');
this.save({projector: this.get('on')},{
type: 'POST'
});
},
turnOff: function() {
this.set('id','off');
this.save({projector: this.get('off')},{
type: 'POST'
});
},
turnUp: function() {
this.set('id','cmd');
this.save({projector: this.get('up')},{
type: 'POST'
});
},
turnDown: function() {
this.set('id','cmd');
this.save({projector: this.get('down')},{
type: 'POST'
});
},
disable: function() {
this.set('enabled',false);
},
enable: function() {
this.set('enabled',true);
}
});
var Projector = Backbone.View.extend({
tagName: 'div',
events: {
'click .projectorOn': 'turnOn',
'click .projectorOff': 'turnOff',
'click .projectorUp': 'turnUp',
'click .projectorDown': 'turnDown'
},
initialize: function() {
var tStr;
_.bindAll(this, 'render', 'update', 'turnOn','turnOff', 'updateStatus','updateEnabled');
this.model.bind('change', this.update);
console.log('Projector:initialize',this.model.get('device'));
this.$onButton = this.$('#' + this.model.get('device') + 'On');
this.$offButton = this.$('#' + this.model.get('device') + 'Off');
tStr = this.model.get('device')[0].toUpperCase() + this.model.get('device').substring(1);
this.$aux = this.$('#aux' + tStr);
// This.render();
},
render: function() {
},
update: function() {
console.log('Projector:update');
if (this.model.hasChanged('status')) {
this.updateStatus();
}
if (this.model.hasChanged('enabled')) {
this.updateEnabled();
}
},
updateStatus: function() {
if (this.model.get('status') === true) {
// projectors are on..
this.$onButton.hide();
this.$offButton.show();
this.$aux.fadeIn(500);
} else {
this.$onButton.show();
this.$offButton.hide();
this.$aux.fadeOut();
}
},
updateEnabled: function() {
var enabled = this.model.get('enabled');
if (enabled) {
this.$el.removeClass('lostConnection');
} else {
this.$el.addClass('lostConnection');
}
this.$onButton.attr('disabled', !enabled);
this.$offButton.attr('disabled', !enabled);
this.$upButton.attr('disabled', !enabled);
this.$downButton.attr('disabled', !enabled);
},
turnOn: function() {
this.model.turnOn();
},
turnOff: function() {
this.model.turnOff();
},
turnUp: function() {
this.model.turnUp();
},
turnDown: function() {
this.model.turnDown();
}
});

View File

@ -93,17 +93,24 @@ var SOWEBSOCKET = function(newController) {
$aux = $('#auxProjector'); $aux = $('#auxProjector');
if (status) { if (status) {
controller.projectorData.set('status',true);
/*
$hide = $('#projectorOn'); $hide = $('#projectorOn');
$show = $('#projectorOff'); $show = $('#projectorOff');
$aux.fadeIn(); $aux.fadeIn();
*/
} else { } else {
controller.projectorData.set('status',false);
/*
$show = $('#projectorOn'); $show = $('#projectorOn');
$hide = $('#projectorOff'); $hide = $('#projectorOff');
$aux.fadeOut(); $aux.fadeOut();
*/
} }
$($show).show(); /* $($show).show();
$($hide).hide(); $($hide).hide();
*/
}; };
this.updateLighting = function(obj) { this.updateLighting = function(obj) {
@ -200,20 +207,8 @@ var SOWEBSOCKET = function(newController) {
$('#longWait').hide(); $('#longWait').hide();
$('#noSocket').slideUp(); $('#noSocket').slideUp();
$('#front-light').removeClass('lostConnection'); controller.getLight(0).set('enabled',true);
$('#back-light').removeClass('lostConnection'); controller.getLight(1).set('enabled',true);
$('#frontLightOn').attr('disabled', false);
$('#frontLightOff').attr('disabled', false);
$('#frontUp').attr('disabled', false);
$('#frontDown').attr('disabled', false);
$('#backLightOn').attr('disabled', false);
$('#backLightOff').attr('disabled', false);
$('#backUp').attr('disabled', false);
$('#backDown').attr('disabled', false);
var now = new Date; var now = new Date;
var mod = 60000 - (now.getTime() % 60000); var mod = 60000 - (now.getTime() % 60000);
@ -273,21 +268,10 @@ var SOWEBSOCKET = function(newController) {
if (this.retry === 3) { if (this.retry === 3) {
$('#longWait:hidden').fadeIn(); $('#longWait:hidden').fadeIn();
$('#front-light').addClass('lostConnection');
$('#back-light').addClass('lostConnection');
$('#frontLightOn').attr('disabled', true); controller.getLight(0).set('enabled',false);
$('#frontLightOff').attr('disabled', true); controller.getLight(1).set('enabled',false);
$('#frontUp').attr('disabled', true); }
$('#frontDown').attr('disabled', true);
$('#backLightOn').attr('disabled', true);
$('#backLightOff').attr('disabled', true);
$('#backUp').attr('disabled', true);
$('#backDown').attr('disabled', true);
//LostConnection
}
if (this.retry > 0) { if (this.retry > 0) {
delay = 5000 * this.retry; delay = 5000 * this.retry;

View File

@ -0,0 +1,134 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script src="lib/jquery.js"
integrity="sha256-laXWtGydpwqJ8JA+X9x2miwmaiKhn8tVmOVEigRNtP4="
crossorigin="anonymous"></script>
<script src="lib/underscore.js"></script>
<script src="lib/backbone.js"></script>
<div id="output"></div>
<script type="text/template" id="list-template">
<ul></ul>
</script>
<script type="text/template" id="todo-template">
<li>
<%= item.device_id %>
<%= item.device_type %>
</li>
</script>
<script>
(function($) {
var mqttConfig = {
orgId: 'qz0da4',
userName: 'a-qz0da4-dfwwdkmkzr',
appKey: '9txJEf3Cjy7hkSOvkv',
prefix: 'iot-2/type/mDot/id/'
};
sendAuthentication = function(xhr) {
var user = 'a-qz0da4-dfwwdkmkzr';// your actual username
var pass = '9txJEf3Cjy7hkSOvkv';// your actual password
var token = user.concat(":", pass);
xhr.setRequestHeader('Authorization', ("Basic ".concat(btoa(token))));
};
var mDotModel = Backbone.Model.extend({});
var mDotCollection = Backbone.Collection.extend({
model:mDotModel,
url: 'https://qz0da4.internetofthings.ibmcloud.com/api/v0002/historian/types/mDot/devices/HIE-smart-campus-4'
});
var ItemView = Backbone.View.extend({
tagName:'li',
className:'item',
initialize: function() {
this.template = _.template($('item-template').html());
this.render();
},
render: function() {
this.$el.html(this.template({item:this.model}));
return this;
}
});
var MDOT = Backbone.View.extend({
model:mDotModel,
el: $('#output'),
events: {
'click button#refresh': 'refresh'
}, initialize: function() {
_.bindAll(this, 'render', 'refresh', 'update');
//this.collection = new mDotCollection();
this.collection.bind('change reset add remove', this.update, this);
this.template = _.template($('#list-template').html());
this.render();
//this.collection.
}, refresh: function() {
}, update: function() {
console.log('MDOT:update');
console.log(this);
this.collection.each(function(model) {
var events = model.get('events');
console.log(events);
//that.$el.append(new TodoView({model: model.toJSON()}));
});
this.render();
},
render: function() {
console.log('render');
that = this;
this.$el.empty();
this.$el.append(this.template());
this.collection.each(function(model) {
var events = model.get('events');
console.log(events);
//that.$el.append(new TodoView({model: model.toJSON()}));
_(events).each(function(model) {
console.log(model);
that.$el.append(new ItemView({model: model.toJSON()}));
})
});
// var events = this.collection.model.get('events');
// console.log(events);
/*events.each(function(model) {
that.$el.append(new ItemView({model: model.toJSON()}));
});*/
return this;
}
});
var mdotCollection = new mDotCollection();
var mdot = new MDOT({collection:mdotCollection});
mdotCollection.fetch({beforeSend: sendAuthentication});
})(jQuery);
</script>
</body>
</html>

View File

@ -22,51 +22,70 @@ var size = require('gulp-size');
var debug = require('gulp-debug'); var debug = require('gulp-debug');
var filePath = { var filePath = {
build_dir: './dist' build_dir: './dist'
}; };
gulp.task('scripts', function() { gulp.task('scripts', function() {
return gulp.src(['app/js/sowebsocket.js','app/js/colours.js','app/js/appv2.js']) return gulp.src([
.pipe(jshint('.jshintrc')) 'app/js/sowebsocket.js',
.pipe(jshint.reporter('default')) 'app/js/colours.js',
.pipe(concat('app.js')) 'app/js/parts/clock.js',
// .pipe(stripDebug()) 'app/js/parts/meetings.js',
.pipe(jsmin()) 'app/js/parts/lights.js',
.pipe(size({title: 'Scripts'})) 'app/js/appv3.js'
.pipe(gulp.dest('dist/js')); ])
}); .pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'))
.pipe(concat('app.js'))
.pipe(stripDebug())
.pipe(jsmin())
.pipe(size({title: 'Scripts'}))
.pipe(gulp.dest('dist/js'));
});
gulp.task('vendor', function() { gulp.task('vendor', function() {
return gulp.src(['bower_components/jquery/dist/jquery.min.js', return gulp.src([
'bower_components/mui/packages/cdn/js/mui.min.js', 'bower_components/jquery/dist/jquery.min.js',
'bower_components/chroma-js/chroma.min.js', 'bower_components/mui/packages/cdn/js/mui.min.js',
'bower_components/sugar/release/sugar-full.min.js', 'bower_components/chroma-js/chroma.min.js',
'app/lib/skycons.js', 'src/bower_modules/underscore/underscore-min.js',
'app/lib/microevent.js']) 'src/bower_modules/backbone/backbone-min.js',
.pipe(concat('vendor.js')) 'bower_components/sugar/release/sugar-full.min.js',
.pipe(uglify({mangle: false})) 'app/lib/skycons.js',
.pipe(size({title: 'Vendor'})) 'app/lib/microevent.js'
.pipe(gulp.dest('dist/js')); ])
}); .pipe(concat('vendor.js'))
.pipe(uglify({mangle: false}))
.pipe(size({title: 'Vendor'}))
.pipe(gulp.dest('dist/js'));
});
gulp.task('styles', function() { gulp.task('styles', function() {
return gulp.src(['app/css/mui.custom.css','app/css/material-icons.css','app/css/app.css']) return gulp.src([
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4')) 'app/css/mui.custom.css',
.pipe(cssnano()) 'app/css/material-icons.css',
.pipe(concat('app.css')) 'app/css/app.css'
.pipe(size({title: 'Styles'})) ])
.pipe(gulp.dest('dist/css')); .pipe(autoprefixer('last 2 version',
}); 'safari 5',
'ie 8',
'ie 9',
'opera 12.1',
'ios 6',
'android 4'))
.pipe(cssnano())
.pipe(concat('app.css'))
.pipe(size({title: 'Styles'}))
.pipe(gulp.dest('dist/css'));
});
gulp.task('partials', function() { gulp.task('partials', function() {
// Gulp.src(['app/partials/**/*']).pipe(gulp.dest('dist/partials')); // Gulp.src(['app/partials/**/*']).pipe(gulp.dest('dist/partials'));
// gulp.src(['app/libs/ejs_production.js']).pipe(gulp.dest('dist/libs')); // gulp.src(['app/libs/ejs_production.js']).pipe(gulp.dest('dist/libs'));
// gulp.src(['app/libs/microevent.js']).pipe(gulp.dest('dist/libs')); // gulp.src(['app/libs/microevent.js']).pipe(gulp.dest('dist/libs'));
gulp.src(['app/fav/**/*']).pipe(size({title: 'Partials'})).pipe(gulp.dest('dist/fav')); gulp.src(['app/fav/**/*']).pipe(size({title: 'Partials'})).pipe(gulp.dest(
'dist/fav'));
gulp.src(['app/gfx/censis_logo_white.png']).pipe(gulp.dest('dist/gfx')); gulp.src(['app/gfx/censis_logo_white.png']).pipe(gulp.dest('dist/gfx'));
}); });
@ -78,40 +97,41 @@ gulp.task('migrate', function() {
}); });
gulp.task('index', function() { gulp.task('index', function() {
var sources = gulp.src(['js/apps.js', 'css/app.css'], {read: false}); var sources = gulp.src(['js/apps.js', 'css/app.css'], {read: false});
return gulp.src(['app/index.html']) return gulp.src(['app/index.html'])
.pipe(htmlreplace({ .pipe(htmlreplace({
css: 'css/app.css', css: 'css/app.css',
js: 'js/app.js', js: 'js/app.js',
vendor: 'js/vendor.js', vendor: 'js/vendor.js',
fonts: 'fonts/fonts.css' fonts: 'fonts/fonts.css'
})) }))
.pipe(htmlmin({removeComments: true, collapseWhitespace: true, keepClosingSlash: true})) .pipe(htmlmin({
.pipe(size({title: 'Index'})) removeComments: true,
.pipe(gulp.dest('dist/')); collapseWhitespace: true,
}); keepClosingSlash: true
}))
.pipe(size({title: 'Index'}))
.pipe(gulp.dest('dist/'));
});
var options = { }; var options = {};
gulp.task('fonts', function() { gulp.task('fonts', function() {
return gulp.src('./fonts.list') return gulp.src('./fonts.list')
.pipe(googleWebFonts(options)) .pipe(googleWebFonts(options))
.pipe(size({title: 'Fonts'})) .pipe(size({title: 'Fonts'}))
.pipe(gulp.dest('dist/fonts')) .pipe(gulp.dest('dist/fonts'));
;
}); });
gulp.task('clean', function() { gulp.task('clean', function() {
return del(['dist']); return del(['dist']);
}); });
gulp.task('default', ['clean'], function() { gulp.task('default', ['clean'], function() {
gulp.start('styles', 'scripts', 'vendor', 'fonts', 'partials', 'index'); gulp.start('styles', 'scripts', 'vendor', 'fonts', 'partials', 'index');
}); });
gulp.task('Cordova', ['clean'], function() { gulp.task('Cordova', ['clean'], function() {
gulp.start('styles', 'scripts', 'vendor', 'fonts', 'index'); gulp.start('styles', 'scripts', 'vendor', 'fonts', 'index');
}); });