Updates Webclient, several bugfixes, updated Buildsystem for automatic update on ESP8266

This commit is contained in:
Tobias Blum
2016-05-17 00:29:50 +02:00
parent caf3c511f5
commit d2b7bcc94f
7 changed files with 167 additions and 464 deletions
+37 -10
View File
@@ -1,17 +1,23 @@
var gulp = require('gulp'),
connect = require('gulp-connect');
request = require('request'),
fs = require('fs'),
connect = require('gulp-connect'),
fileinclude = require('gulp-file-include');
var src_dir = "src/";
var build_dir = "build/";
gulp.task('html', function() {
gulp.src('*.html')
gulp.src(src_dir + '*.htm')
.pipe(fileinclude({
prefix: '@@',
basepath: '@file'
}))
.pipe(gulp.dest('build'))
.pipe(connect.reload());
});
gulp.task('js', function() {
gulp.src('js/*.js')
.pipe(gulp.dest('build/js'))
.pipe(connect.reload());
});
gulp.task('connect', function() {
connect.server({
@@ -21,8 +27,29 @@ gulp.task('connect', function() {
});
gulp.task('watch', function() {
gulp.watch('*.html', ['html']);
gulp.watch('js/*.js', ['js']);
gulp.watch(src_dir + '*.htm', ['html']);
gulp.watch(src_dir + 'js/*.js', ['html']);
});
gulp.task('default', ['watch', 'connect']);
gulp.task('upload', ['html'], function() {
var url = 'http://192.168.0.24/edit';
var options = {
url: url,
headers: {
'Content-Type': 'multipart/form-data'
}
};
var r = request.post(options, function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log('Upload successful! Server responded with:', body);
});
var form = r.form();
form.append('data', fs.createReadStream(__dirname + "/" + build_dir + '/index.htm'), {filename: '/index.htm', contentType: "application/octet-stream"});
});
gulp.task('default', ['html']);
gulp.task('serve', ['watch', 'connect']);