From 4180991e1b2523ce0484e140c020977b50e4c7f8 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Mon, 12 Jun 2017 16:25:46 +0200 Subject: [PATCH 01/22] some basics for the brand choosing front end --- api/branding/index.js | 75 +++++++++++ config.js | 10 +- helpers/index.js | 41 ++++++ public/img/cncf-logo.png | Bin 0 -> 5607 bytes public/img/logo.png | Bin 8483 -> 0 bytes public/img/{logo-small.png => weave-logo.png} | Bin public/welcome.html | 122 ++++++++++++++++++ server.js | 32 ++++- 8 files changed, 278 insertions(+), 2 deletions(-) create mode 100644 api/branding/index.js create mode 100644 public/img/cncf-logo.png delete mode 100644 public/img/logo.png rename public/img/{logo-small.png => weave-logo.png} (100%) create mode 100644 public/welcome.html diff --git a/api/branding/index.js b/api/branding/index.js new file mode 100644 index 000000000..0460a41e4 --- /dev/null +++ b/api/branding/index.js @@ -0,0 +1,75 @@ +(function (){ + 'use strict'; + + var async = require("async") + , express = require("express") + , request = require("request") + , helpers = require("../../helpers") + , config = require("../../config") + , endpoints = require("../endpoints") + , app = express() + , fs = require('fs') + , busyboy = require('express-busboy'); + + busyboy.extend(app, + { + upload: true, + path: '/tmp/logo', + allowedPath: /./ + + } + ); + + app.post("/branding", function (req, res, next) { + if (config.branding.set === true) { + res.redirect("/") + return + } + if (req.body.brand !== undefined) { + var brand = req.body.brand + var image + if (brand == "cncf") { + config.branding.set = true + config.branding.values.name = "cncf" + image = "./public/img/cncf-logo.png" + } else if (brand == "weave") { + config.branding.set = true + config.branding.values.name = "weave" + image = "./public/img/weave-logo.png" + } else if (brand == "other") { + config.branding.set = true + config.branding.values.name = "other" + console.log(req.files.logo.file); + if (req.files.logo == undefined) { + res.redirect("/welcome.html") + return + } + image = req.files.logo.file + } + else { + res.redirect("/welcome.html") + return + } + config.branding.values.logo = fs.readFileSync(image).toString("base64") + } + helpers.setBrandingConfig() + res.redirect("/") + }); + + + app.get("/img/logo*", function (req, res, next) { + var buf; + console.log("fired") + buf = new Buffer(config.branding.values.logo, 'base64'); + res.writeHead(200, { + 'Content-Type': "image/png", + 'Content-disposition': 'attachment;filename=logo.png', + 'Content-Length': buf.length + }); + res.end(new Buffer(buf, 'binary')); + }); + + module.exports = app; + + +}()); diff --git a/config.js b/config.js index 274fc8ec6..1a4738d14 100644 --- a/config.js +++ b/config.js @@ -3,7 +3,7 @@ var session = require("express-session"), RedisStore = require('connect-redis')(session) - + ,redis = require("redis") module.exports = { session: { name: 'md.sid', @@ -18,6 +18,14 @@ secret: 'sooper secret', resave: false, saveUninitialized: true + }, + redis_client: null, + branding :{ + set: false, + values: { + name: "", + logo: "", + } } }; }()); diff --git a/helpers/index.js b/helpers/index.js index 348e785db..1143e1ce7 100644 --- a/helpers/index.js +++ b/helpers/index.js @@ -2,6 +2,10 @@ 'use strict'; var request = require("request"); + var config = require("../config"); + var fs = require('fs'); + var redis = require("redis") + var helpers = {}; /* Public: errorHandler is a middleware that handles your errors @@ -102,5 +106,42 @@ return req.session.customerId; } + + + helpers.getBrandingConfig = function(callback) { + if(process.env.SESSION_REDIS) { + config.redis_client = redis.createClient(); + var test = config.redis_client.get("branding_info") + console.log("fired") + config.redis_client.get("branding_info", function(err, reply) { + if (reply !== null) { + config.branding.values = JSON.parse(reply) + config.branding.set = true + callback(config.branding) + } else { + callback(config.branding) + } + }) + } else { + if (fs.existsSync("./branding.json")) { + config.branding.values = JSON.parse(fs.readFileSync('./branding.json')) + config.branding.set = true + callback(config.branding) + } else { + callback(config.branding) + } + } + } + + helpers.setBrandingConfig = function() { + if(process.env.SESSION_REDIS) { + return config.redis_client.set("branding_info", JSON.stringify(config.branding.values)) + } else { + fs.writeFile("./branding.json", JSON.stringify(config.branding.values, null, 2), function(err) { + return err; + }); + } + } + module.exports = helpers; }()); diff --git a/public/img/cncf-logo.png b/public/img/cncf-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..2fe93ec41013b489d5128fed90c7403cfff7fb91 GIT binary patch literal 5607 zcmV(lwH^h*Uj#om9Kol=Jngi4xGyuOd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nr8~!70+}3p?hvqDO~GvT;a;^@_;Gcd)xIOEh9`_7`LQOgoO3&dSf@ zQ=+X&gX{+{vT(akKQqnK{_@Ov>=|%^=DGxM{}0DrJ+oga8nOTY002ovPDHLkV1gf~ B3f2Gs literal 0 HcmV?d00001 diff --git a/public/img/logo.png b/public/img/logo.png deleted file mode 100644 index ef0521bc76887f1c96713e3846285b2c4ca0cd31..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8483 zcmV+;A>7`HP) z02wQTwh{mU010qNS#tmY3ljhU3ljkVnw%H_000McNliru;06s24H0rW@9F>mAOJ~3 zK~#9!?VWj;6xG%LKewu9dKMU9fMI$-a77dy#TXY4$B6lI%=`U-%(rjrsoQ?C{mhrK98**0Qr z<>#3$u6w~RdhCRw^wR=8j|JS{1MZjK z+kmOg#Brw=r=%#`LbTQjC>IQLIF6I~kG9|@9vf-mv5$a1eCfd*JK+}ra3ceKnjSl$ zy=c*kvW=uSFdJA1octe6(M>#d7w{A?=u6eMH?4Z?g!_S?=P3~dZqs8Y%+zBi)D+iX zQNBX4fxbXLF);rpCDH}3D}Z-_fm=hBH2nD9H-WkWN*@f=0LzQ(uqZ|O3IJ~6u}WYy zP_h;3F^41`r`x)UzqzVA{5}^E> z3~sHpk^s&ZzW0mXzct!kgv5UkMc)e2G1B>mRlTf9(KWcIITOb? z_c)I8c_(ePfFq>610)WC*18q=Tw)(jW~01X>k+`Afxazq9Ou3~&)x|*9Y0d6gpo~h z9LEck*%vrX>Mqw>w*g6D3hd3@4k(rHbAdkvo^urN8=2r-9lcy@eKqhv7!X?P0l>}pQCvGuU&aG7 zwAMdx9A`054crj8zFKSjXr4ts3ix&4`|q-C&|233*8vygsryRcFIwwsvI02sRimjM4QL9pPsuG3oI2K>o!oFzHxJ_Yz2 z&<<2Kx_Rw$8i>Jj}-k2 zOSHYsJK^5H*cHvqh4}B+f$7~aiJqwHlx|?|H$pV}3A+RFweQ#igP??@$y@O+M zY>sE0834Bd{tjfV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39`>yTW@5jZ0-*cTnl{6`Qd*tFh^2uc7vSrPTK=xGcEC zD#-m_%2*F|pSi>hQNxvfS}JR;#^m}O&%MlTsD0m3>QZ*7p$cFmp?%uh?dL<$0reCLZgFe>S*~pun*zk(|-#VUxn- zU(~A;i?I0y0zF=PFsNgIB!-hwtXKZ|_GgU$&bC>=CmF1%rHLi0H`3kMnU>;#5D4cR zV;-~{n||G8kfxz_yn_EmsaBu^!&Iv=c}>3ZZKL{Dm6b%MxyJk~(%6(Y$34?fyT7f} zBy#*=M`O&Yb(xY_&l#Vl{5I6=2=*CDu?+w0`Y@nB#;irDsrYZQnT272)tG!{Th2?T zVS5vgy@>xZfP9h$zO53;xe`44G627idUbXYDn&&tEkytT0HjGoK~yQqR}^I14E>4Z zq4=+U%_S|sP8-1e<>ZG&a2KU0+Zf;i@*m;<>6rG742mQ$NF|a>wn7^ks8@e3PDN3Q zvh}5)Ae%}gX9DFW9{a2K7yDAco>&30Gxch5aTQx;6q7>z8 zrs!XREG&Y%C`H+hDEbyi3vfUF) + + + + + + + + + + + + + + WeaveSocks + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+
+ Welcome! +
+
+
+
+
+
Branding
+
+
+ +
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+
+
+
+ +
+
+
+ + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + diff --git a/server.js b/server.js index 929f7a403..efeb9635c 100644 --- a/server.js +++ b/server.js @@ -12,16 +12,45 @@ var request = require("request") , catalogue = require("./api/catalogue") , orders = require("./api/orders") , user = require("./api/user") + , branding = require("./api/branding") , metrics = require("./api/metrics") , app = express() + +app.use(function (req, res, next) { + if (config.branding.set == false) { + helpers.getBrandingConfig(function(cfg){ + if (!cfg.set) { + ext = req.url.split('.').pop(); + if ((["js", "css", "png", "map"].indexOf(ext) > -1) || + (["/welcome.html", "/branding"].indexOf(req.url) > -1)) { + next() + return + + } else { + res.redirect("/welcome.html") + return + } + } else { + next() + return + } + }); + } else { + helpers.setBrandingConfig() + next() + } + return +}); + +app.use(express.static("public")); app.use(helpers.rewriteSlash); app.use(metrics); -app.use(express.static("public")); if(process.env.SESSION_REDIS) { console.log('Using the redis based session manager'); app.use(session(config.session_redis)); + } else { console.log('Using local session manager'); @@ -49,6 +78,7 @@ app.use(cart); app.use(catalogue); app.use(orders); app.use(user); +app.use(branding); app.use(helpers.errorHandler); From 52fad639201fd804008afc7e27fac36ce6735fb1 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Mon, 12 Jun 2017 16:33:29 +0200 Subject: [PATCH 02/22] updated package.json --- package.json | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index ad0d695f5..74a7d0f5d 100644 --- a/package.json +++ b/package.json @@ -20,15 +20,17 @@ "dependencies": { "async": "^1.5.2", "body-parser": "^1.15.1", + "connect-busboy": "0.0.2", + "connect-redis": "^3.2.0", "cookie-parser": "^1.4.3", "express": "^4.13.4", "express-session": "^1.13.0", "finalhandler": "^0.4.1", - "request": "^2.72.0", - "serve-static": "^1.10.2", - "prom-client": "^6.3.0", "morgan": "^1.7.0", - "connect-redis": "^3.2.0" + "prom-client": "^6.3.0", + "redis": "^2.7.1", + "request": "^2.72.0", + "serve-static": "^1.10.2" }, "devDependencies": { "chai": "^3.5.0", From 07aa11572f8b89a1f7914ac1305b57c7134335a6 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Mon, 12 Jun 2017 16:54:32 +0200 Subject: [PATCH 03/22] changed build for better feedback --- scripts/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build.sh b/scripts/build.sh index 42d203b66..d51f1b17b 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -24,5 +24,5 @@ CODE_DIR=$(cd $SCRIPT_DIR/..; pwd) echo $CODE_DIR REPO=${GROUP}/$(basename front-end); - +echo $REPO $DOCKER_CMD build -t ${REPO}:${COMMIT} . From 9de89d37969e185e71a47f7474ced558744aa923 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Mon, 12 Jun 2017 17:12:34 +0200 Subject: [PATCH 04/22] added welcome so no redirects --- test/container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/container.sh b/test/container.sh index 210a84069..b15f1b73b 100755 --- a/test/container.sh +++ b/test/container.sh @@ -23,7 +23,7 @@ CID=$($DOCKER_CMD run -d --name testcontainer -p 8080:8079 ${REPO}:${COMMIT}) for i in 1 2 3 4 5 do - curl -s --head http://localhost:8080/ > /dev/null + curl -s --head http://localhost:8080/welcome.html > /dev/null if [ $? -eq "0" ] then PASS=0 From 08fbfc2dd287ee53d5bdc027e202059aee61479e Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Mon, 12 Jun 2017 17:22:00 +0200 Subject: [PATCH 05/22] dumping logs to test --- test/container.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/container.sh b/test/container.sh index b15f1b73b..97b6d931d 100755 --- a/test/container.sh +++ b/test/container.sh @@ -24,6 +24,7 @@ CID=$($DOCKER_CMD run -d --name testcontainer -p 8080:8079 ${REPO}:${COMMIT}) for i in 1 2 3 4 5 do curl -s --head http://localhost:8080/welcome.html > /dev/null + docker logs testcontainer if [ $? -eq "0" ] then PASS=0 From 4a82e3e978bd89fa8272fb720ae7eb5cbf7d4bfc Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Mon, 12 Jun 2017 17:28:19 +0200 Subject: [PATCH 06/22] removed logs dump added more time for service to come up? --- test/container.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/container.sh b/test/container.sh index 97b6d931d..e36ccb4bd 100755 --- a/test/container.sh +++ b/test/container.sh @@ -21,10 +21,9 @@ REPO=${GROUP}/$(basename front-end); CID=$($DOCKER_CMD run -d --name testcontainer -p 8080:8079 ${REPO}:${COMMIT}) -for i in 1 2 3 4 5 +for i in 1 2 3 4 5 6 7 8 9 do curl -s --head http://localhost:8080/welcome.html > /dev/null - docker logs testcontainer if [ $? -eq "0" ] then PASS=0 From 7519faa2a3007e69671147b9f07ca6bd76b38fef Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Mon, 12 Jun 2017 17:34:40 +0200 Subject: [PATCH 07/22] user error --- test/container.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/container.sh b/test/container.sh index e36ccb4bd..4fce539b6 100755 --- a/test/container.sh +++ b/test/container.sh @@ -21,7 +21,7 @@ REPO=${GROUP}/$(basename front-end); CID=$($DOCKER_CMD run -d --name testcontainer -p 8080:8079 ${REPO}:${COMMIT}) -for i in 1 2 3 4 5 6 7 8 9 +for i in 1 2 3 4 5 do curl -s --head http://localhost:8080/welcome.html > /dev/null if [ $? -eq "0" ] @@ -29,10 +29,11 @@ do PASS=0 break else - sleep 1 + sleep fi done +docker logs testcontainer $DOCKER_CMD rm -f $CID > /dev/null if [ $PASS -eq "0" ] From ecaee9ea6001f94a68de428e1d551fdfbb352fdf Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Mon, 12 Jun 2017 17:43:49 +0200 Subject: [PATCH 08/22] accidentaly removed sleep --- test/container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/container.sh b/test/container.sh index 4fce539b6..d5f221fd2 100755 --- a/test/container.sh +++ b/test/container.sh @@ -29,7 +29,7 @@ do PASS=0 break else - sleep + sleep 1 fi done From 70a414b7ca3a336af80a03d36920923cbae20396 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Mon, 12 Jun 2017 17:46:24 +0200 Subject: [PATCH 09/22] switched to DOCKER_CMD --- test/container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/container.sh b/test/container.sh index d5f221fd2..d56fd8fcd 100755 --- a/test/container.sh +++ b/test/container.sh @@ -33,7 +33,7 @@ do fi done -docker logs testcontainer +$DOCKER_CMD logs testcontainer $DOCKER_CMD rm -f $CID > /dev/null if [ $PASS -eq "0" ] From 373d42e86889fca9ce7e7e7180f9493eb77a2e18 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Mon, 12 Jun 2017 17:52:46 +0200 Subject: [PATCH 10/22] updated to express-busboy --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 74a7d0f5d..1bef8ecd8 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "connect-redis": "^3.2.0", "cookie-parser": "^1.4.3", "express": "^4.13.4", + "express-busboy": "^6.0.1", "express-session": "^1.13.0", "finalhandler": "^0.4.1", "morgan": "^1.7.0", From ab233a8a74d199575e8eccc260793f3d96da7f5e Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Mon, 12 Jun 2017 17:56:50 +0200 Subject: [PATCH 11/22] removed logs dump --- test/container.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/test/container.sh b/test/container.sh index d56fd8fcd..b9d1e5653 100755 --- a/test/container.sh +++ b/test/container.sh @@ -33,7 +33,6 @@ do fi done -$DOCKER_CMD logs testcontainer $DOCKER_CMD rm -f $CID > /dev/null if [ $PASS -eq "0" ] From 1455e31bef7e0eadcbfd3a4c741f0b14aad7ed6d Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Thu, 15 Jun 2017 11:51:10 +0200 Subject: [PATCH 12/22] added check before trying to set value, in attempt to stop crashing --- helpers/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/helpers/index.js b/helpers/index.js index 1143e1ce7..a35b260e4 100644 --- a/helpers/index.js +++ b/helpers/index.js @@ -110,7 +110,7 @@ helpers.getBrandingConfig = function(callback) { if(process.env.SESSION_REDIS) { - config.redis_client = redis.createClient(); + config.redis_client = redis.createClient("redis://session-db:6379"); var test = config.redis_client.get("branding_info") console.log("fired") config.redis_client.get("branding_info", function(err, reply) { @@ -135,7 +135,9 @@ helpers.setBrandingConfig = function() { if(process.env.SESSION_REDIS) { - return config.redis_client.set("branding_info", JSON.stringify(config.branding.values)) + if (config.redis_client.connected) { + config.redis_client.set("branding_info", JSON.stringify(config.branding.values)) + } } else { fs.writeFile("./branding.json", JSON.stringify(config.branding.values, null, 2), function(err) { return err; From 0c5b0514d6cac9a84b53ef07e59fd2135831b2d3 Mon Sep 17 00:00:00 2001 From: Jason Richard Smith Date: Thu, 15 Jun 2017 13:26:55 +0200 Subject: [PATCH 13/22] added disconnect functions to avoid crashing --- helpers/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/helpers/index.js b/helpers/index.js index a35b260e4..f4ff0476b 100644 --- a/helpers/index.js +++ b/helpers/index.js @@ -111,8 +111,13 @@ helpers.getBrandingConfig = function(callback) { if(process.env.SESSION_REDIS) { config.redis_client = redis.createClient("redis://session-db:6379"); - var test = config.redis_client.get("branding_info") - console.log("fired") + config.redis_client.on("error", function (err) { + console.log("Redis error encountered", err); + }); + + config.redis_client.on("end", function() { + console.log("Redis connection closed"); + }); config.redis_client.get("branding_info", function(err, reply) { if (reply !== null) { config.branding.values = JSON.parse(reply) From c8a94cd26248ff1b5e2737ea9596963a31faf6d4 Mon Sep 17 00:00:00 2001 From: Jason Richard Smith Date: Mon, 19 Jun 2017 10:55:58 +0200 Subject: [PATCH 14/22] added default branding so staging doesnt have to update --- server.js | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/server.js b/server.js index efeb9635c..53577c322 100644 --- a/server.js +++ b/server.js @@ -14,34 +14,44 @@ var request = require("request") , user = require("./api/user") , branding = require("./api/branding") , metrics = require("./api/metrics") + , fs = require('fs') , app = express() app.use(function (req, res, next) { if (config.branding.set == false) { - helpers.getBrandingConfig(function(cfg){ - if (!cfg.set) { - ext = req.url.split('.').pop(); - if ((["js", "css", "png", "map"].indexOf(ext) > -1) || - (["/welcome.html", "/branding"].indexOf(req.url) > -1)) { - next() - return - - } else { - res.redirect("/welcome.html") - return - } + if(process.env.DEFAULT_BRANDING) { + config.branding.set = true + config.branding.values.name = "weave" + image = "./public/img/weave-logo.png" + config.branding.values.logo = fs.readFileSync(image).toString("base64") + next() } else { - next() - return + + helpers.getBrandingConfig(function(cfg){ + if (!cfg.set) { + ext = req.url.split('.').pop(); + if ((["js", "css", "png", "map"].indexOf(ext) > -1) || + (["/welcome.html", "/branding"].indexOf(req.url) > -1)) { + next() + return + + } else { + res.redirect("/welcome.html") + return + } + } else { + next() + return + } + }); } - }); } else { - helpers.setBrandingConfig() - next() + helpers.setBrandingConfig() + next() } - return + return }); app.use(express.static("public")); From eb14aa673bb2831f68e840b7d5d852d927a458b0 Mon Sep 17 00:00:00 2001 From: Jason Richard Smith Date: Tue, 20 Jun 2017 07:36:02 +0200 Subject: [PATCH 15/22] fixed default branding --- helpers/index.js | 29 ++++++++++++++++++++--------- server.js | 42 ++++++++++++++++-------------------------- 2 files changed, 36 insertions(+), 35 deletions(-) diff --git a/helpers/index.js b/helpers/index.js index f4ff0476b..ace0ef659 100644 --- a/helpers/index.js +++ b/helpers/index.js @@ -118,15 +118,26 @@ config.redis_client.on("end", function() { console.log("Redis connection closed"); }); - config.redis_client.get("branding_info", function(err, reply) { - if (reply !== null) { - config.branding.values = JSON.parse(reply) - config.branding.set = true - callback(config.branding) - } else { - callback(config.branding) - } - }) + + if(process.env.DEFAULT_BRANDING) { + config.branding.set = true + config.branding.values.name = "weave" + var image + image = "./public/img/weave-logo.png" + config.branding.values.logo = fs.readFileSync(image).toString("base64") + callback(config.branding) + return + } else { + config.redis_client.get("branding_info", function(err, reply) { + if (reply !== null) { + config.branding.values = JSON.parse(reply) + config.branding.set = true + callback(config.branding) + } else { + callback(config.branding) + } + }) + } } else { if (fs.existsSync("./branding.json")) { config.branding.values = JSON.parse(fs.readFileSync('./branding.json')) diff --git a/server.js b/server.js index 53577c322..19e59ccfd 100644 --- a/server.js +++ b/server.js @@ -14,39 +14,29 @@ var request = require("request") , user = require("./api/user") , branding = require("./api/branding") , metrics = require("./api/metrics") - , fs = require('fs') , app = express() app.use(function (req, res, next) { if (config.branding.set == false) { - if(process.env.DEFAULT_BRANDING) { - config.branding.set = true - config.branding.values.name = "weave" - image = "./public/img/weave-logo.png" - config.branding.values.logo = fs.readFileSync(image).toString("base64") - next() - } else { - - helpers.getBrandingConfig(function(cfg){ - if (!cfg.set) { - ext = req.url.split('.').pop(); - if ((["js", "css", "png", "map"].indexOf(ext) > -1) || - (["/welcome.html", "/branding"].indexOf(req.url) > -1)) { - next() - return + helpers.getBrandingConfig(function(cfg){ + if (!cfg.set) { + ext = req.url.split('.').pop(); + if ((["js", "css", "png", "map"].indexOf(ext) > -1) || + (["/welcome.html", "/branding"].indexOf(req.url) > -1)) { + next() + return - } else { - res.redirect("/welcome.html") - return - } - } else { - next() - return - } - }); - } + } else { + res.redirect("/welcome.html") + return + } + } else { + next() + return + } + }); } else { helpers.setBrandingConfig() next() From d04eb9680c73959894e2bb64e73faeb584dbfa86 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Tue, 20 Jun 2017 14:32:33 +0200 Subject: [PATCH 16/22] made some logic changes to insure user sets branding --- api/branding/index.js | 65 +++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/api/branding/index.js b/api/branding/index.js index 0460a41e4..c6cd661db 100644 --- a/api/branding/index.js +++ b/api/branding/index.js @@ -21,39 +21,44 @@ ); app.post("/branding", function (req, res, next) { - if (config.branding.set === true) { + if (config.branding.set == true) { res.redirect("/") return + } else { + console.log(req.body.brand) + if (req.body.brand !== undefined) { + var brand = req.body.brand + var image + if (brand == "cncf") { + config.branding.set = true + config.branding.values.name = "cncf" + image = "./public/img/cncf-logo.png" + } else if (brand == "weave") { + config.branding.set = true + config.branding.values.name = "weave" + image = "./public/img/weave-logo.png" + } else if (brand == "other") { + config.branding.set = true + config.branding.values.name = "other" + console.log(req.files.logo.file); + if (req.files.logo == undefined) { + res.redirect("/welcome.html") + return + } + image = req.files.logo.file + } + else { + res.redirect("/welcome.html") + return + } + config.branding.values.logo = fs.readFileSync(image).toString("base64") + res.redirect("/") + return + } else { + res.redirect("/welcome.html") + return + } } - if (req.body.brand !== undefined) { - var brand = req.body.brand - var image - if (brand == "cncf") { - config.branding.set = true - config.branding.values.name = "cncf" - image = "./public/img/cncf-logo.png" - } else if (brand == "weave") { - config.branding.set = true - config.branding.values.name = "weave" - image = "./public/img/weave-logo.png" - } else if (brand == "other") { - config.branding.set = true - config.branding.values.name = "other" - console.log(req.files.logo.file); - if (req.files.logo == undefined) { - res.redirect("/welcome.html") - return - } - image = req.files.logo.file - } - else { - res.redirect("/welcome.html") - return - } - config.branding.values.logo = fs.readFileSync(image).toString("base64") - } - helpers.setBrandingConfig() - res.redirect("/") }); From 4f209501a7702d9402fec2393f6ed5a9df39ce5e Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Tue, 20 Jun 2017 16:47:41 +0200 Subject: [PATCH 17/22] started adding some additional fields for more branding, needs templating on the footer --- api/branding/index.js | 11 +++++++++++ config.js | 6 ++++++ public/welcome.html | 38 +++++++++++++++++++++++++++++++++++--- 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/api/branding/index.js b/api/branding/index.js index c6cd661db..67e0ac42e 100644 --- a/api/branding/index.js +++ b/api/branding/index.js @@ -33,10 +33,21 @@ config.branding.set = true config.branding.values.name = "cncf" image = "./public/img/cncf-logo.png" + config.branding.values.company = "Cloud Native Computing Foundation c/o The Linux Foundation" + config.branding.values.street = "1 Letterman Drive
Suite D4700" + config.branding.values.city = "San Francisco" + config.branding.values.state = "CA" + config.branding.values.zip = "94129" + config.branding.values.country = "USA" } else if (brand == "weave") { config.branding.set = true config.branding.values.name = "weave" image = "./public/img/weave-logo.png" + config.branding.values.company = "Weaveworks Ltd." + config.branding.values.street = "32 – 38 Scrutton Street" + config.branding.values.city = "London" + config.branding.values.zip = "EC2A 4RQ" + config.branding.values.country = "UK" } else if (brand == "other") { config.branding.set = true config.branding.values.name = "other" diff --git a/config.js b/config.js index 1a4738d14..41fbda395 100644 --- a/config.js +++ b/config.js @@ -25,6 +25,12 @@ values: { name: "", logo: "", + company: "", + street: "", + city: "", + zip: "", + state: "", + country: "", } } }; diff --git a/public/welcome.html b/public/welcome.html index d50fe415f..b8eb72da6 100644 --- a/public/welcome.html +++ b/public/welcome.html @@ -60,20 +60,44 @@
Branding
- +
- +
+ Other
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +