Skip to content

Commit cf24c7f

Browse files
committed
refactor config domains -> urlBase, urlBaseProduction
1 parent 468b7c7 commit cf24c7f

File tree

11 files changed

+45
-28
lines changed

11 files changed

+45
-28
lines changed

assets/libs/domtree.css

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
.domtree .node rect {
3+
cursor: pointer;
4+
fill: #fff;
5+
}
6+
7+
.domtree .node text {
8+
fill: #333333;
9+
font: 12px "Helvetica Nue", sans-serif;
10+
pointer-events: none;
11+
}
12+
13+
.domtree path.link {
14+
fill: none;
15+
stroke: #BEC3C7;
16+
stroke-width: 1px;
17+
}
18+
*/
19+
.domtree {
20+
border: 1px solid #f5f2f0;
21+
border-radius: 4px;
22+
}

dev

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export NODE_ENV=development
99
export ASSET_VERSIONING=query
1010
export WATCH=1
1111
export SITE_HOST=http://javascript.local
12-
export PORT=3000
1312
export TUTORIAL_EDIT=
1413

1514
npm --silent run gulp dev | bunyan -o short -l debug

dev.cmd

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ set NODE_LANG=%1
44
@set NODE_ENV=development
55
@set ASSET_VERSIONING=query
66
@set WATCH=1
7-
@set SITE_HOST=http://javascript.local
8-
@set PORT=3000
97
@set NODE_PATH=./handlers;./modules
108

119
call gulp dev

edit

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ BRANCH="${1:-$NODE_LANG}"
77
export NODE_LANG=$BRANCH
88
export NODE_ENV=production
99
export TUTORIAL_EDIT=1
10-
export PORT=3000
1110

1211
npm --silent run -- gulp edit
1312

edit.cmd

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
@set TUTORIAL_EDIT=1
66
@set ASSET_VERSIONING=query
77
@set WATCH=1
8-
@set SITE_HOST=http://javascript.local
9-
@set PORT=3000
108
@set NODE_PATH=./handlers;./modules
119

1210
call gulp edit

handlers/render.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function addStandardHelpers(locals, ctx) {
5959

6060
locals.env = process.env;
6161

62-
locals.domain = config.domain;
62+
locals.urlBase = config.urlBase;
6363

6464
// replace lone surrogates in json, </script> -> <\/script>
6565
locals.escapeJSON = function(s) {
@@ -162,7 +162,7 @@ exports.init = function(app) {
162162
loc.canonicalPath = loc.canonicalPath.replace(/\/+$/, '');
163163
}
164164

165-
loc.canonicalUrl = config.server.siteHost + loc.canonicalPath;
165+
loc.canonicalUrl = config.urlBase.main + loc.canonicalPath;
166166

167167
if (ctx.templateDir) {
168168
loc.roots = [ctx.templateDir];

handlers/tutorial/lib/tutorialImporter.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ module.exports = class TutorialImporter {
112112
//this.tree.destroyTree(data.slug);
113113

114114
let options = {
115-
staticHost: config.server.staticHost,
115+
staticHost: config.urlBase.static,
116116
resourceWebRoot: Article.getResourceWebRootBySlug(data.slug)
117117
};
118118

@@ -183,7 +183,7 @@ module.exports = class TutorialImporter {
183183
// this.tree.destroyTree(data.slug);
184184

185185
const options = {
186-
staticHost: config.server.staticHost,
186+
staticHost: config.urlBase.static,
187187
resourceWebRoot: Article.getResourceWebRootBySlug(data.slug)
188188
};
189189

@@ -296,7 +296,7 @@ module.exports = class TutorialImporter {
296296
//this.tree.destroyTree(data.slug);
297297

298298
const options = {
299-
staticHost: config.server.staticHost,
299+
staticHost: config.urlBase.static,
300300
resourceWebRoot: Task.getResourceWebRootBySlug(data.slug)
301301
};
302302

@@ -376,7 +376,7 @@ module.exports = class TutorialImporter {
376376
} else {
377377
view = new TutorialView({
378378
webPath,
379-
description: "Fork from https://" + config.domain.main
379+
description: "Fork from " + config.urlBase.main
380380
});
381381
log.debug("Created new plunk (db empty)", view);
382382
}
@@ -434,7 +434,7 @@ module.exports = class TutorialImporter {
434434
if (!sourceView) {
435435
sourceView = new TutorialView({
436436
webPath: sourceWebPath,
437-
description: "Fork from https://" + config.domain.main
437+
description: "Fork from " + config.urlBase.main
438438
});
439439
TutorialViewStorage.instance().set(sourceWebPath, sourceView);
440440
}
@@ -463,7 +463,7 @@ module.exports = class TutorialImporter {
463463
if (!solutionView) {
464464
solutionView = new TutorialView({
465465
webPath: solutionWebPath,
466-
description: "Fork from https://" + config.domain.main
466+
description: "Fork from " + config.urlBase.main
467467
});
468468
TutorialViewStorage.instance().set(solutionWebPath, solutionView);
469469
}
@@ -491,7 +491,7 @@ module.exports = class TutorialImporter {
491491
function makeSource(sourceJs, testJs) {
492492
let source = "<!DOCTYPE HTML>\n<html>\n<head>\n <meta charset=\"utf-8\">\n";
493493
if (testJs) {
494-
source += " <script src=\"https://" + config.domain.static + "/test/libs.js\"></script>\n";
494+
source += " <script src=\"" + config.urlBase.static + "/test/libs.js\"></script>\n";
495495
source += " <script src=\"test.js\"></script>\n";
496496
}
497497
source += "</head>\n<body>\n\n <script>\n\n";
@@ -506,7 +506,7 @@ function makeSource(sourceJs, testJs) {
506506
function makeSolution(solutionJs, testJs) {
507507
let solution = "<!DOCTYPE html>\n<html>\n<head>\n <meta charset=\"utf-8\">\n";
508508
if (testJs) {
509-
solution += " <script src=\"https://" + config.domain.static + "/test/libs.js\"></script>\n";
509+
solution += " <script src=\"" + config.urlBase.static + "/test/libs.js\"></script>\n";
510510
solution += " <script src=\"test.js\"></script>\n";
511511
}
512512
solution += "</head>\n<body>\n\n <script>\n\n";

handlers/tutorial/renderer/articleRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ module.exports = class ArticleRenderer {
8585

8686
_.uniq(libs).forEach(function (lib) {
8787
if (!~lib.indexOf('://')) {
88-
lib = '//' + config.domain.static + '/libs/' + lib;
88+
lib = config.urlBase.static + '/libs/' + lib;
8989
}
9090

9191
if (lib.slice(-3) == '.js') {

modules/config/index.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,19 @@ if (env.DEV_TRACE) {
2222
}
2323

2424
let config = module.exports = {
25-
// production domain, for tutorial imports, descriptions, etc
26-
// for the places where in-dev we must use a real domain
27-
domain: {
28-
main: 'javascript.local',
29-
static: 'javascript.local'
25+
urlBase: {
26+
// node may be behind nginx, use this in documents
27+
main: env.BASE_CURRENT_MAIN || env.BASE || 'http://localhost:3000',
28+
static: env.BASE_CURRENT_STATIC || env.BASE || 'http://localhost:3000',
29+
},
30+
urlBaseProduction: {
31+
main: env.BASE_PRODUCTION_MAIN || env.BASE || 'http://localhost:3000',
32+
static: env.BASE_PRODUCTION_STATIC || env.BASE || 'http://localhost:3000'
3033
},
3134

3235
server: {
33-
port: env.PORT || 3000,
34-
host: env.HOST || '0.0.0.0',
35-
siteHost: env.SITE_HOST || '',
36-
staticHost: env.STATIC_HOST || ''
36+
port: env.PORT || 3000,
37+
host: env.HOST || 'localhost'
3738
},
3839

3940
appKeys: [secret.sessionKey],

modules/markit/serverParser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module.exports = class ServerParser {
5151
linkHeaderTag: true,
5252
html: true,
5353
publicRoot: config.publicRoot,
54-
staticHost: config.server.staticHost,
54+
staticHost: config.urlBase.static,
5555
quotes: config.lang === 'ru' ? '«»„“' : '“”‘’'
5656
}, options));
5757

0 commit comments

Comments
 (0)