Banners and template options added through webpack

This commit is contained in:
n1474335 2017-03-22 16:55:21 +00:00
parent df15826912
commit c9910a8ddb
5 changed files with 21 additions and 44 deletions

View File

@ -60,7 +60,8 @@ module.exports = function(grunt) {
grunt.loadNpmTasks("grunt-contrib-watch"); grunt.loadNpmTasks("grunt-contrib-watch");
var banner = '/**\n\ var compileTime = grunt.template.today("dd/mm/yyyy HH:MM:ss") + " UTC",
banner = '/**\n\
* CyberChef - The Cyber Swiss Army Knife\n\ * CyberChef - The Cyber Swiss Army Knife\n\
*\n\ *\n\
* @copyright Crown Copyright 2016\n\ * @copyright Crown Copyright 2016\n\
@ -83,7 +84,7 @@ module.exports = function(grunt) {
var templateOptions = { var templateOptions = {
data: { data: {
compileTime: grunt.template.today("dd/mm/yyyy HH:MM:ss") + " UTC", compileTime: compileTime,
compileMsg: grunt.option("compile-msg") || grunt.option("msg") || "", compileMsg: grunt.option("compile-msg") || grunt.option("msg") || "",
codebaseStats: grunt.file.read("src/static/stats.txt").split("\n").join("<br>") codebaseStats: grunt.file.read("src/static/stats.txt").split("\n").join("<br>")
} }
@ -131,7 +132,16 @@ module.exports = function(grunt) {
$: "jquery", $: "jquery",
jQuery: "jquery", jQuery: "jquery",
moment: "moment-timezone" moment: "moment-timezone"
}) }),
new webpack.BannerPlugin({
"banner": banner,
"raw": true,
"entryOnly": true
}),
new webpack.DefinePlugin({
COMPILE_TIME: JSON.stringify(compileTime),
COMPILE_MSG: JSON.stringify(grunt.option("compile-msg") || grunt.option("msg") || "")
}),
], ],
resolve: { resolve: {
alias: { alias: {
@ -233,10 +243,6 @@ module.exports = function(grunt) {
src: "src/html/index.html", src: "src/html/index.html",
dest: "build/dev/index.html" dest: "build/dev/index.html"
}, },
htmlTest: {
src: "test/test.html",
dest: "build/test/index.html"
},
htmlProd: { htmlProd: {
options: { options: {
process: function(content, srcpath) { process: function(content, srcpath) {
@ -446,7 +452,7 @@ module.exports = function(grunt) {
}, },
watch: { watch: {
css: { css: {
files: "src/css/**/*.css", files: ["src/css/**/*.css", "src/css/**/*.less"],
tasks: ["webpack:web", "chmod:build"] tasks: ["webpack:web", "chmod:build"]
}, },
js: { js: {

View File

@ -29,7 +29,7 @@
@import "~bootstrap/less/dropdowns.less"; @import "~bootstrap/less/dropdowns.less";
@import "~bootstrap/less/button-groups.less"; @import "~bootstrap/less/button-groups.less";
@import "~bootstrap/less/input-groups.less"; @import "~bootstrap/less/input-groups.less";
// @import "~bootstrap/less/navs.less"; @import "~bootstrap/less/navs.less";
// @import "~bootstrap/less/navbar.less"; // @import "~bootstrap/less/navbar.less";
// @import "~bootstrap/less/breadcrumbs.less"; // @import "~bootstrap/less/breadcrumbs.less";
// @import "~bootstrap/less/pagination.less"; // @import "~bootstrap/less/pagination.less";

View File

@ -91,36 +91,7 @@
"jQuery": false, "jQuery": false,
"moment": false, "moment": false,
/* core/* */ "COMPILE_TIME": false,
"Chef": false, "COMPILE_MSG": false
"Dish": false,
"Recipe": false,
"Ingredient": false,
"Operation": false,
"Utils": false,
/* config/* */
"Categories": false,
"OperationConfig": false,
/* views/html/* */
"HTMLApp": false,
"HTMLCategory": false,
"HTMLOperation": false,
"HTMLIngredient": false,
"Manager": false,
"ControlsWaiter": false,
"HighlighterWaiter": false,
"InputWaiter": false,
"OperationsWaiter": false,
"OptionsWaiter": false,
"OutputWaiter": false,
"RecipeWaiter": false,
"SeasonalWaiter": false,
"WindowWaiter": false,
/* test/* */
"TestRegister": false,
"TestRunner": false
} }
} }

View File

@ -354,7 +354,7 @@ ControlsWaiter.prototype.supportButtonClick = function() {
var reportBugInfo = document.getElementById("report-bug-info"), var reportBugInfo = document.getElementById("report-bug-info"),
saveLink = this.generateStateUrl(true, true, null, "https://gchq.github.io/CyberChef/"); saveLink = this.generateStateUrl(true, true, null, "https://gchq.github.io/CyberChef/");
reportBugInfo.innerHTML = "* CyberChef compile time: <%= compileTime %>\n" + reportBugInfo.innerHTML = "* CyberChef compile time: " + COMPILE_TIME + "\n" +
"* User-Agent: \n" + navigator.userAgent + "\n" + "* User-Agent: \n" + navigator.userAgent + "\n" +
"* [Link to reproduce](" + saveLink + ")\n\n"; "* [Link to reproduce](" + saveLink + ")\n\n";
}; };

View File

@ -7,7 +7,7 @@
var HTMLApp = require("./HTMLApp.js"), var HTMLApp = require("./HTMLApp.js"),
Categories = require("../../config/Categories.js"), Categories = require("../../config/Categories.js"),
OperationConfig = require("../../config/OperationConfig.js"), OperationConfig = require("../../config/OperationConfig.js"),
CanvasComponents = require("../../lib/canvascomponents.js");; CanvasComponents = require("../../lib/canvascomponents.js");
/** /**
* Main function used to build the CyberChef web app. * Main function used to build the CyberChef web app.
@ -45,7 +45,7 @@ var main = function() {
// Fix issues with browsers that don't support console.log() // Fix issues with browsers that don't support console.log()
window.console = console || {log: function() {}, error: function() {}}; window.console = console || {log: function() {}, error: function() {}};
window.compileTime = moment.tz("<%= compileTime %>", "DD/MM/YYYY HH:mm:ss z", "UTC").valueOf(); window.compileTime = moment.tz(COMPILE_TIME, "DD/MM/YYYY HH:mm:ss z", "UTC").valueOf();
window.compileMessage = "<%= compileMsg %>"; window.compileMessage = COMPILE_MSG;
document.addEventListener("DOMContentLoaded", main, false); document.addEventListener("DOMContentLoaded", main, false);