From 3be590beacd8f86e028177ed01b615238e74d60d Mon Sep 17 00:00:00 2001 From: hackyminer Date: Fri, 31 Aug 2018 00:59:19 +0900 Subject: [PATCH 1/3] support configurable settings * separate configurable variables to the config.default.json * read local config.json to override default variables --- app/includes/footer.tpl | 58 ++++++++++++++++++++++------- app/includes/header.tpl | 81 ++++++++++++++++++----------------------- config.default.json | 42 +++++++++++++++++++++ gulpfile.js | 18 ++++++++- package.json | 1 + 5 files changed, 140 insertions(+), 60 deletions(-) create mode 100644 config.default.json diff --git a/app/includes/footer.tpl b/app/includes/footer.tpl index f7b31e6937..8a8bedc1e0 100644 --- a/app/includes/footer.tpl +++ b/app/includes/footer.tpl @@ -1,4 +1,5 @@ -@@if (site === 'mew' ) { @@include( './footer-disclaimer-modal.tpl', { "site": "mew" } ) } -@@if (site === 'cx' ) { @@include( './footer-disclaimer-modal.tpl', { "site": "cx" } ) } +@@if (site === 'mew' || site === 'cx') { @@include( './footer-disclaimer-modal.tpl', { "site": "@@site" } ) } -@@if (site === 'mew' ) { @@include( './onboardingModal.tpl', { "site": "mew" } ) } -@@if (site === 'cx' ) { @@include( './onboardingModal.tpl', { "site": "cx" } ) } +@@if (site === 'mew' || site === 'cx') { @@include( './onboardingModal.tpl', { "site": "@@site" } ) } diff --git a/app/includes/header.tpl b/app/includes/header.tpl index a9b5634832..c6eccf580a 100644 --- a/app/includes/header.tpl +++ b/app/includes/header.tpl @@ -3,36 +3,38 @@ -MyEtherWallet.com - - - - - - - +@@sitehost + + + + + + + - - - + + + - +@@if (!custom || googleSiteVerification) { + +} - + - - + + - - - - + + + + @@ -40,34 +42,24 @@ - - + + @@ -75,12 +67,12 @@ diff --git a/config.default.json b/config.default.json new file mode 100644 index 0000000000..d70b019bcd --- /dev/null +++ b/config.default.json @@ -0,0 +1,42 @@ +{ + "selected": "mew", + "mew": { + "custom": true, + "showDontGetPhished": true, + "showPrefooterWarning": true, + "showMewAdSites": true, + "showDonation": true, + "showTranslators": true, + "showMewSites": true, + "showGithub": true, + "showExtensions": true, + "googleSiteVerification": "IpChQ00NYUQuNs_7Xs6xlnSdzalOlTUYbBsr8f7OpvM", + "legalname": "MyEtherWallet Inc", + "sitename": "MyEtherWallet", + "sitetitle": "Your Key to Ethereum", + "sitehost": "MyEtherWallet.com", + "siteurl": "https://www.myetherwallet.com", + "email": "support@myetherwallet.com", + "description": "MyEtherWallet (MEW) is a free, open-source, client-side interface for generating Ethereum wallets & more. Interact with the Ethereum blockchain easily & securely.", + "descriptionFixed": "MyEtherWallet.com is a free, open-source, client-side interface for generating Ethereum wallets & more. Interact with the Ethereum blockchain easily & securely.", + "shortDescription": "Free, open-source, client-side Ethereum wallet. Enabling you to interact with the blockchain easily & securely.", + "appTitle": "MyEtherWallet · Your Key to Ethereum", + "themecolor": "#1d6986", + "maskcolor": "#2f99b0", + "twitterid": "@MyEtherWallet", + "sitelogo": "logo-myetherwallet.svg", + "sitelogocx": "logo-myetherwalletcx.svg", + "poweredby": "logo-myetherwallet.svg", + "logourl" : "https://www.myetherwallet.com/images/myetherwallet-logo.png", + "copyright": "© 2018 MyEtherWallet, Inc", + "instagram": "https://instagram.com/myetherwallet", + "reddit": "https://www.reddit.com/r/MyEtherWallet/", + "twitter": "https://twitter.com/myetherwallet", + "facebook": "https://www.facebook.com/MyEtherWallet/", + "medium": "https://medium.com/@myetherwallet", + "linkedin": "https://www.linkedin.com/company/myetherwallet", + "support": "mailto:support@myetherwallet.com", + "github": "https://github.com/MyEtherWallet", + "sameAs": "[\n \"https://www.myetherwallet.com/\",\n \"https://chrome.google.com/webstore/detail/myetherwallet-cx/nlbmnnijcnlegkjjpcfjclmcfggfefdm\",\n \"https://www.facebook.com/MyEtherWallet/\",\n \"https://twitter.com/myetherwallet\",\n \"https://medium.com/@myetherwallet\",\n \"https://kb.myetherwallet.com/\",\n \"https://github.com/kvhnuke/etherwallet\",\n \"https://github.com/MyEtherWallet\",\n \"https://kvhnuke.github.io/etherwallet/\",\"https://myetherwallet.slack.com/\"\n]" + } +} diff --git a/gulpfile.js b/gulpfile.js index 123345d9ff..a890f16cde 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,5 +1,6 @@ const fs = require("fs"); +const _ = require('lodash'); const autoprefixer = require("gulp-autoprefixer"); const archiver = require("archiver"); const bump = require("gulp-bump"); @@ -26,6 +27,21 @@ const app = "./app/"; const dist = "./dist/"; const dist_CX = "./chrome-extension/"; +// default Settings +const Settings = require('./config.default.json'); + +// load custom settings +try { + let local = require('./config.json'); + _.extend(Settings, local); +} catch (e) { + if (e.code == 'MODULE_NOT_FOUND') { + console.log('No config file found. Using default configuration...'); + } +} + +let configs = Settings[Settings.selected]; + // Error / Success Handling let onError = function(err) { notify.onError({ @@ -56,7 +72,7 @@ gulp.task("html", function(done) { return gulp .src(htmlFiles) .pipe(plumber({ errorHandler: onError })) - .pipe(fileinclude({ prefix: "@@", basepath: "@file" })) + .pipe(fileinclude({ prefix: '@@', basepath: '@file', context: configs })) .pipe(gulp.dest(dist)) .pipe(gulp.dest(dist_CX)) .pipe(notify(onSuccess("HTML"))); diff --git a/package.json b/package.json index 98f4466996..a237ee0d95 100644 --- a/package.json +++ b/package.json @@ -63,6 +63,7 @@ "idna-uts46": "^1.0.1", "install": "^0.10.1", "levenshtein": "^1.0.5", + "lodash": "^4.17.4", "marked": "^0.3.6", "punycode": "^2.1.0", "scryptsy": "^2.0.0", From 9a59e486b57f75268a3bb4ed247a6cae4b699799 Mon Sep 17 00:00:00 2001 From: hackyminer Date: Fri, 31 Aug 2018 06:49:58 +0900 Subject: [PATCH 2/3] customLess option added --- gulpfile.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index a890f16cde..d4d2fb932f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -33,7 +33,7 @@ const Settings = require('./config.default.json'); // load custom settings try { let local = require('./config.json'); - _.extend(Settings, local); + _.merge(Settings, local); } catch (e) { if (e.code == 'MODULE_NOT_FOUND') { console.log('No config file found. Using default configuration...'); @@ -86,6 +86,14 @@ let less_destFolder_CX = dist_CX + "css"; let less_destFile = "etherwallet-master.css"; let less_destFileMin = "etherwallet-master.min.css"; +// custom less file +if (configs['customLess']) { + let localLess = []; + localLess.push(less_srcFile); + localLess.push(app + 'styles/' + configs['customLess']); + less_srcFile = localLess; +} + gulp.task("styles", function() { return ( gulp @@ -98,7 +106,7 @@ gulp.task("styles", function() { remove: false }) ) - .pipe(rename(less_destFile)) + .pipe(concat(less_destFile)) // concat less files //.pipe( gulp.dest ( less_destFolder )) // unminified css //.pipe( gulp.dest ( less_destFolder_CX )) // unminified css .pipe(cssnano({ autoprefixer: false, safe: true })) From 499fcc6e7bfa9e534cc5f016e4d07ecee8efe801 Mon Sep 17 00:00:00 2001 From: hackyminer Date: Fri, 31 Aug 2018 21:00:40 +0900 Subject: [PATCH 3/3] support configurable network list * use `gulp prep --networks eth_mew,blah,blah` command to show selected networks only --- app/includes/header-node-modal.tpl | 10 +++++----- app/scripts/main.js | 16 ++++++++++++++++ gulpfile.js | 26 ++++++++++++++++++++++---- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/app/includes/header-node-modal.tpl b/app/includes/header-node-modal.tpl index 45b361747b..54e6938185 100644 --- a/app/includes/header-node-modal.tpl +++ b/app/includes/header-node-modal.tpl @@ -48,11 +48,11 @@
- - - - - + + + + +
diff --git a/app/scripts/main.js b/app/scripts/main.js index fdc3e5054a..5355b474fd 100644 --- a/app/scripts/main.js +++ b/app/scripts/main.js @@ -131,6 +131,22 @@ if (IS_CX) { var mainPopCtrl = require("./controllers/CX/mainPopCtrl"); var quickSendCtrl = require("./controllers/CX/quickSendCtrl"); } + +// prepare some variables +var nodeList = {}; +if (typeof selectedNetworks !== 'undefined') { + var found = 0; + selectedNetworks.forEach(function(n) { + if (nodes.nodeList[n]) { + nodeList[n] = nodes.nodeList[n]; + found++; + } + }); + if (found > 0) { + nodes.nodeList = nodeList; + } +} + var app = angular.module("mewApp", [ "pascalprecht.translate", "ngSanitize", diff --git a/gulpfile.js b/gulpfile.js index d4d2fb932f..56bfe1884e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -30,6 +30,13 @@ const dist_CX = "./chrome-extension/"; // default Settings const Settings = require('./config.default.json'); +// get selected nodeList to override the nodes.nodeList +let selectedNetworks, i = process.argv.indexOf("--networks"); +if (i > -1 && process.argv[i + 1]) { + selectedNetworks = process.argv[i + 1].split(","); + console.log("Selected networks =", selectedNetworks); +} + // load custom settings try { let local = require('./config.json'); @@ -123,12 +130,22 @@ let js_srcFile = app + "scripts/main.js"; let js_destFolder = dist + "js/"; let js_destFolder_CX = dist_CX + "js/"; let js_destFile = "etherwallet-master.js"; -let browseOpts = { debug: true }; // generates inline source maps - only in js-debug +let js_opts = {}; // browserify opts let babelOpts = { presets: ["env"], compact: false }; +// have selected nodes ? +if (selectedNetworks) { + // setup browserify opts + js_opts.insertGlobalVars = { + selectedNetworks: function() { + return JSON.stringify(selectedNetworks); + } + }; +} + function bundle_js(bundler) { return bundler .bundle() @@ -154,21 +171,22 @@ function bundle_js_debug(bundler) { } gulp.task("js", function() { - let bundler = browserify(js_srcFile) + let bundler = browserify(js_srcFilei, js_opts) .transform(babelify) .transform(html2js); bundle_js(bundler); }); gulp.task("js-production", function() { - let bundler = browserify(js_srcFile) + let bundler = browserify(js_srcFile, js_opts) .transform(babelify, babelOpts) .transform(html2js); bundle_js(bundler); }); gulp.task("js-debug", function() { - let bundler = browserify(js_srcFile, browseOpts) + js_opts.debug = true; // generates inline source maps - only in js-debug + let bundler = browserify(js_srcFile, js_opts) .transform(babelify, babelOpts) .transform(html2js); bundle_js_debug(bundler);