Browse Source

Pre-build the different available WebUI images

rfm69
Xose Pérez 6 years ago
parent
commit
1c755cfb89
17 changed files with 10778 additions and 3307 deletions
  1. +5
    -0
      code/build.sh
  2. BIN
      code/espurna/data/index.html.gz
  3. BIN
      code/espurna/data/index.light.html.gz
  4. BIN
      code/espurna/data/index.rfbridge.html.gz
  5. BIN
      code/espurna/data/index.sensor.html.gz
  6. BIN
      code/espurna/data/index.small.html.gz
  7. +0
    -3079
      code/espurna/static/index.html.gz.h
  8. +2951
    -0
      code/espurna/static/index.light.html.gz.h
  9. +2550
    -0
      code/espurna/static/index.rfbridge.html.gz.h
  10. +2589
    -0
      code/espurna/static/index.sensor.html.gz.h
  11. +2506
    -0
      code/espurna/static/index.small.html.gz.h
  12. +15
    -5
      code/espurna/web.ino
  13. +0
    -10
      code/extra_scripts.py
  14. +72
    -38
      code/gulpfile.js
  15. +87
    -0
      code/package-lock.json
  16. +3
    -1
      code/package.json
  17. +0
    -174
      code/platformio.ini

+ 5
- 0
code/build.sh View File

@ -54,6 +54,11 @@ revision=${revision:0:7}
cp espurna/config/version.h espurna/config/version.h.original
sed -i -e "s/APP_REVISION \".*\"/APP_REVISION \"$revision\"/g" espurna/config/version.h
# Recreate web interface
echo "--------------------------------------------------------------"
echo "Building web interface..."
node node_modules/gulp/bin/gulp.js || exit
# Build all the required firmware images
echo "--------------------------------------------------------------"
echo "Building firmware images..."


BIN
code/espurna/data/index.html.gz View File


BIN
code/espurna/data/index.light.html.gz View File


BIN
code/espurna/data/index.rfbridge.html.gz View File


BIN
code/espurna/data/index.sensor.html.gz View File


BIN
code/espurna/data/index.small.html.gz View File


+ 0
- 3079
code/espurna/static/index.html.gz.h
File diff suppressed because it is too large
View File


+ 2951
- 0
code/espurna/static/index.light.html.gz.h
File diff suppressed because it is too large
View File


+ 2550
- 0
code/espurna/static/index.rfbridge.html.gz.h
File diff suppressed because it is too large
View File


+ 2589
- 0
code/espurna/static/index.sensor.html.gz.h
File diff suppressed because it is too large
View File


+ 2506
- 0
code/espurna/static/index.small.html.gz.h
File diff suppressed because it is too large
View File


+ 15
- 5
code/espurna/web.ino View File

@ -16,7 +16,17 @@ Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
#include <ArduinoJson.h>
#if WEB_EMBEDDED
#include "static/index.html.gz.h"
#if LIGHT_PROVIDER != LIGHT_PROVIDER_NONE
#include "static/index.light.html.gz.h"
#elif SENSOR_SUPPORT
#include "static/index.sensor.html.gz.h"
#elif ITEAD_SONOFF_RFBRIDGE
#include "static/index.rfbridge.html.gz.h"
#else
#include "static/index.small.html.gz.h"
#endif
#endif // WEB_EMBEDDED
#if ASYNC_TCP_SSL_ENABLED & WEB_SSL_ENABLED
@ -161,12 +171,12 @@ void _onHome(AsyncWebServerRequest *request) {
AsyncWebServerResponse *response = request->beginChunkedResponse("text/html", [max](uint8_t *buffer, size_t maxLen, size_t index) -> size_t {
// Get the chunk based on the index and maxLen
size_t len = index_html_gz_len - index;
size_t len = webui_image_len - index;
if (len > maxLen) len = maxLen;
if (len > max) len = max;
if (len > 0) memcpy_P(buffer, index_html_gz + index, len);
if (len > 0) memcpy_P(buffer, webui_image + index, len);
DEBUG_MSG_P(PSTR("[WEB] Sending %d%%%% (max chunk size: %4d)\r"), int(100 * index / index_html_gz_len), max);
DEBUG_MSG_P(PSTR("[WEB] Sending %d%%%% (max chunk size: %4d)\r"), int(100 * index / webui_image_len), max);
if (len == 0) DEBUG_MSG_P(PSTR("\n"));
// Return the actual length of the chunk (0 for end of file)
@ -176,7 +186,7 @@ void _onHome(AsyncWebServerRequest *request) {
#else
AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", index_html_gz, index_html_gz_len);
AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", webui_image, webui_image_len);
#endif


+ 0
- 10
code/extra_scripts.py View File

@ -82,20 +82,10 @@ def check_size(source, target, env):
print_warning("https://github.com/xoseperez/espurna/wiki/TwoStepUpdates", color=Color.LIGHT_CYAN)
print_filler("*", color=Color.LIGHT_YELLOW, err=True)
def build_webui(env):
if distutils.spawn.find_executable("node"):
config = util.load_project_config()
kv = dict(config.items("env:" + env.get('PIOENV')))
modules = kv["modules"] if "modules" in kv else "all"
env.Execute("WEBUI_MODULES=\"%s\" node node_modules/gulp/bin/gulp.js" % modules)
else:
print_warning("Not building the web UI image ('node' does not exist in the path)")
# ------------------------------------------------------------------------------
# Hooks
# ------------------------------------------------------------------------------
remove_float_support()
build_webui(env)
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", check_size)

+ 72
- 38
code/gulpfile.js View File

@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/*eslint-env es6*/
// -----------------------------------------------------------------------------
// File system builder
// Dependencies
// -----------------------------------------------------------------------------
const fs = require('fs');
@ -40,10 +40,20 @@ const crass = require('gulp-crass');
const replace = require('gulp-replace');
const remover = require('gulp-remove-code');
const map = require('map-stream');
const rename = require('gulp-rename');
const runSequence = require('run-sequence');
// -----------------------------------------------------------------------------
// Configuration
// -----------------------------------------------------------------------------
const dataFolder = 'espurna/data/';
const staticFolder = 'espurna/static/';
// -----------------------------------------------------------------------------
// Methods
// -----------------------------------------------------------------------------
var buildHeaderFile = function() {
String.prototype.replaceAll = function(search, replacement) {
@ -56,7 +66,7 @@ var buildHeaderFile = function() {
var parts = file.path.split("/");
var filename = parts[parts.length - 1];
var destination = staticFolder + filename + ".h";
var safename = filename.replaceAll('.', '_');
var safename = "webui_image";
var wstream = fs.createWriteStream(destination);
wstream.on('error', function (err) {
@ -106,43 +116,16 @@ var htmllintReporter = function(filepath, issues) {
}
};
gulp.task('build_certs', function() {
gulp.src(dataFolder + 'server.*').
pipe(buildHeaderFile());
});
gulp.task('csslint', function() {
gulp.src('html/*.css').
pipe(csslint({ids: false})).
pipe(csslint.formatter());
});
gulp.task('buildfs_embeded', ['buildfs_inline'], function() {
gulp.src(dataFolder + 'index.*').
pipe(buildHeaderFile());
});
gulp.task('buildfs_inline', function() {
var buildWebUI = function(module) {
var remover_config = {
sensor: false,
light: false,
rfbridge: false
};
var modules = 'WEBUI_MODULES' in process.env ? process.env.WEBUI_MODULES : false;
if (false === modules || "all" === modules) {
for (var i in remover_config) {
remover_config[i] = true;
}
} else {
var list = modules.split(' ');
for (var i in list) {
if (list[i] != "") {
remover_config[list[i]] = true;
}
}
var modules = {"light": false, "sensor": false, "rfbridge": false};
if ("all" == module) {
modules["light"] = true;
modules["rfbridge"] = true;
modules["sensor"] = true;
} else if ("small" != module) {
modules[module] = true;
}
console.info("Modules " + JSON.stringify(remover_config));
return gulp.src('html/*.html').
pipe(htmllint({
@ -159,7 +142,7 @@ gulp.task('buildfs_inline', function() {
css: [crass, inlineImages],
disabledTypes: ['svg', 'img']
})).
pipe(remover(remover_config)).
pipe(remover(modules)).
pipe(htmlmin({
collapseWhitespace: true,
removeComments: true,
@ -168,7 +151,58 @@ gulp.task('buildfs_inline', function() {
})).
pipe(replace('pure-', 'p-')).
pipe(gzip()).
pipe(rename("index." + module + ".html.gz")).
pipe(gulp.dest(dataFolder));
};
// -----------------------------------------------------------------------------
// Tasks
// -----------------------------------------------------------------------------
gulp.task('build_certs', function() {
gulp.src(dataFolder + 'server.*').
pipe(buildHeaderFile());
});
gulp.task('csslint', function() {
gulp.src('html/*.css').
pipe(csslint({ids: false})).
pipe(csslint.formatter());
});
gulp.task('build_webui_small', function() {
return buildWebUI("small");
})
gulp.task('build_webui_sensor', function() {
return buildWebUI("sensor");
})
gulp.task('build_webui_light', function() {
return buildWebUI("light");
})
gulp.task('build_webui_rfbridge', function() {
return buildWebUI("rfbridge");
})
gulp.task('build_webui_all', function() {
return buildWebUI("all");
})
gulp.task('buildfs_inline', function(cb) {
runSequence([
'build_webui_small',
'build_webui_sensor',
'build_webui_light',
'build_webui_rfbridge'
], cb);
});
gulp.task('buildfs_embeded', ['buildfs_inline'], function() {
gulp.src(dataFolder + 'index.*').
pipe(buildHeaderFile());
});
gulp.task('default', ['buildfs_embeded']);

+ 87
- 0
code/package-lock.json View File

@ -48,6 +48,15 @@
"ansi-wrap": "https://registry.npmjs.org/ansi-wrap/-/ansi-wrap-0.1.0.tgz"
}
},
"ansi-cyan": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/ansi-cyan/-/ansi-cyan-0.1.1.tgz",
"integrity": "sha1-U4rlKK+JgvKK4w2G8vF0VtJgmHM=",
"dev": true,
"requires": {
"ansi-wrap": "https://registry.npmjs.org/ansi-wrap/-/ansi-wrap-0.1.0.tgz"
}
},
"ansi-gray": {
"version": "https://registry.npmjs.org/ansi-gray/-/ansi-gray-0.1.1.tgz",
"integrity": "sha1-KWLPVOyXksSFEKPetSRDaGHvclE=",
@ -56,6 +65,15 @@
"ansi-wrap": "https://registry.npmjs.org/ansi-wrap/-/ansi-wrap-0.1.0.tgz"
}
},
"ansi-red": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/ansi-red/-/ansi-red-0.1.1.tgz",
"integrity": "sha1-jGOPnRCAgAo1PJwoyKgcpHBdlGw=",
"dev": true,
"requires": {
"ansi-wrap": "https://registry.npmjs.org/ansi-wrap/-/ansi-wrap-0.1.0.tgz"
}
},
"ansi-regex": {
"version": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
@ -1829,6 +1847,12 @@
}
}
},
"gulp-rename": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/gulp-rename/-/gulp-rename-1.3.0.tgz",
"integrity": "sha512-nEuZB7/9i0IZ8AXORTizl2QLP9tcC9uWc/s329zElBLJw1CfOhmMXBxwVlCRKjDyrWuhVP0uBKl61KeQ32TiCg==",
"dev": true
},
"gulp-replace": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/gulp-replace/-/gulp-replace-1.0.0.tgz",
@ -3497,6 +3521,69 @@
"glob": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz"
}
},
"run-sequence": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/run-sequence/-/run-sequence-2.2.1.tgz",
"integrity": "sha512-qkzZnQWMZjcKbh3CNly2srtrkaO/2H/SI5f2eliMCapdRD3UhMrwjfOAZJAnZ2H8Ju4aBzFZkBGXUqFs9V0yxw==",
"dev": true,
"requires": {
"chalk": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
"fancy-log": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.2.tgz",
"plugin-error": "0.1.2"
},
"dependencies": {
"arr-diff": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-1.1.0.tgz",
"integrity": "sha1-aHwydYFjWI/vfeezb6vklesaOZo=",
"dev": true,
"requires": {
"arr-flatten": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz",
"array-slice": "0.2.3"
}
},
"arr-union": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/arr-union/-/arr-union-2.1.0.tgz",
"integrity": "sha1-IPnqtexw9cfSFbEHexw5Fh0pLH0=",
"dev": true
},
"array-slice": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/array-slice/-/array-slice-0.2.3.tgz",
"integrity": "sha1-3Tz7gO15c6dRF82sabC5nshhhvU=",
"dev": true
},
"extend-shallow": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-1.1.4.tgz",
"integrity": "sha1-Gda/lN/AnXa6cR85uHLSH/TdkHE=",
"dev": true,
"requires": {
"kind-of": "1.1.0"
}
},
"kind-of": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-1.1.0.tgz",
"integrity": "sha1-FAo9LUGjbS78+pN3tiwk+ElaXEQ=",
"dev": true
},
"plugin-error": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-0.1.2.tgz",
"integrity": "sha1-O5uzM1zPAPQl4HQ34ZJ2ln2kes4=",
"dev": true,
"requires": {
"ansi-cyan": "0.1.1",
"ansi-red": "0.1.1",
"arr-diff": "1.1.0",
"arr-union": "2.1.0",
"extend-shallow": "1.1.4"
}
}
}
},
"safe-buffer": {
"version": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
"integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=",


+ 3
- 1
code/package.json View File

@ -17,8 +17,10 @@
"gulp-htmlmin": "^2.0.0",
"gulp-inline": "^0.1.1",
"gulp-remove-code": "^3.0.2",
"gulp-rename": "^1.3.0",
"gulp-replace": "^1.0.0",
"gulp-uglify": "^1.5.3",
"map-stream": "0.0.7"
"map-stream": "0.0.7",
"run-sequence": "^2.2.1"
}
}

+ 0
- 174
code/platformio.ini
File diff suppressed because it is too large
View File


Loading…
Cancel
Save