Skip to content

Commit

Permalink
[BasicUI] Add build date to resource requests (#2703)
Browse files Browse the repository at this point in the history
The goal is so users don't need to do a force refresh whenever openhab
is updated.

---------

Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
  • Loading branch information
jimtng authored Aug 21, 2024
1 parent 56eea58 commit ca42730
Show file tree
Hide file tree
Showing 45 changed files with 203 additions and 7 deletions.
2 changes: 2 additions & 0 deletions bundles/org.openhab.ui.basic/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
node_modules
node
npm_cache
src/main/resources/snippets/*
!src/main/resources/snippets/readme.txt
src/main/resources/web/smarthome.css
src/main/resources/web/smarthome.js
src/main/resources/web/settings.js
Expand Down
24 changes: 21 additions & 3 deletions bundles/org.openhab.ui.basic/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@

var
gulp = require("gulp"),
replace = require('gulp-replace'),
sass = require('gulp-sass')(require('node-sass')),
uglify = require("gulp-uglify"),
eslint = require("gulp-eslint");

var
sources = {
js: [ "web-src/smarthome.js", "web-src/static.js", "web-src/settings.js" ],
sass: "web-src/smarthome.scss"
sass: "web-src/smarthome.scss",
snippets: {
all: "snippets-src/**",
versioned: [ "snippets-src/main.html", "snippets-src/main_static.html" ]
}
};


var paths = {
FontLibs: [
'./node_modules/material-icons/iconfont/material-icons.woff*',
Expand Down Expand Up @@ -48,5 +52,19 @@
.pipe(gulp.dest("./src/main/resources/web"));
});

gulp.task("default", gulp.parallel("css", "copyFontLibs", gulp.series("eslint", "js")));
gulp.task("snippetsAll", function() {
return gulp.src(sources.snippets.all)
.pipe(gulp.dest("./src/main/resources/snippets"))
});

gulp.task("snippetsVersioned", function() {
// Convert ISO String "2011-10-05T14:48:00.000Z" -> "YYYYMMDDHHmm"
var buildVersion = new Date().toISOString().slice(0, 16).replaceAll(/[T:-]/g, "");
return gulp.src(sources.snippets.versioned)
.pipe(replace("%version%", buildVersion))
.pipe(gulp.dest("./src/main/resources/snippets"))
});

gulp.task("default", gulp.parallel("css", "copyFontLibs", gulp.series("eslint", "js"),
gulp.series("snippetsAll", "snippetsVersioned")));
})();
171 changes: 171 additions & 0 deletions bundles/org.openhab.ui.basic/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bundles/org.openhab.ui.basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"dependencies": {
"gulp": "^4.0.2",
"gulp-replace": "^1.1.4",
"gulp-eslint": "^6.0.0",
"gulp-sass": "^5.0.0",
"gulp-uglify": "^3.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
<link rel="stylesheet" type="text/css" href="mdl/material.min.css" />
<link rel="stylesheet" type="text/css" href="material-icons.css" />
<link rel="stylesheet" type="text/css" href="framework7-icons.css" />
<link rel="stylesheet" type="text/css" href="smarthome.css" />
<link rel="stylesheet" type="text/css" href="smarthome.css?v=%version%" />

<script src="smarthome.js"></script>
<script src="smarthome.js?v=%version%"></script>
<script src="mdl/material.min.js"></script>
<script type="text/html" id="template-modal">
<div class="mdl-modal">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

<link rel="stylesheet" type="text/css" href="%relpath%mdl/material.min.css" />
<link rel="stylesheet" type="text/css" href="%relpath%material-icons.css" />
<link rel="stylesheet" type="text/css" href="%relpath%smarthome.css" />
<link rel="stylesheet" type="text/css" href="%relpath%smarthome.css?v=%version%" />

<script src="%relpath%%script%"></script>
<script src="%relpath%%script%?v=%version%"></script>
<script src="%relpath%mdl/material.min.js"></script>
<script type="text/html" id="template-modal">
<div class="mdl-modal">
Expand Down
Loading

0 comments on commit ca42730

Please sign in to comment.