Skip to content

Commit 6ae73b6

Browse files
committed
build improvements
1 parent 9c4194d commit 6ae73b6

17 files changed

Lines changed: 224 additions & 212 deletions

File tree

INSTALL.md

Lines changed: 0 additions & 99 deletions
This file was deleted.

gulpfile.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ gulp.task("client:livereload", lazyRequireTask("./tasks/livereload", {
7474

7575
watch: [
7676
"public/pack/**/*.*",
77-
// not using this file, using only styles.css (extracttextplugin)
78-
"!public/pack/styles.js",
7977
// this file changes every time we update styles
8078
// don't watch it, so that the page won't reload fully on style change
8179
"!public/pack/head.js"

handlers/render.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ const t = require('i18n');
1212
const pugResolve = require('pugResolve');
1313
const url = require('url');
1414
const validate = require('validate');
15-
const pluralize = require('textUtil/pluralize');
1615
const BasicParser = require('markit').BasicParser;
1716

1817
// public.versions.json is regenerated and THEN node is restarted on redeploy
@@ -60,7 +59,6 @@ function addStandardHelpers(locals, ctx) {
6059

6160
locals.env = process.env;
6261

63-
locals.pluralize = pluralize;
6462
locals.domain = config.domain;
6563

6664
// replace lone surrogates in json, </script> -> <\/script>

handlers/tutorial/controller/article.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ exports.get = async function(ctx, next) {
8484
}
8585

8686
section2.links.push({
87-
title: t('config.comments'),
87+
title: t('locales.comments'),
8888
url: '#comments'
8989
});
9090

@@ -236,7 +236,7 @@ async function renderArticle(ctx) {
236236
parent = a.parent;
237237
}
238238
path.push({
239-
title: t('config.tutorial'),
239+
title: t('locales.tutorial'),
240240
url: '/'
241241
});
242242
path = path.reverse();

handlers/tutorial/controller/task.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ exports.get = async function(ctx, next) {
3434
parentSlug = parent.parent;
3535
}
3636
breadcrumbs.push({
37-
title: t('config.tutorial'),
37+
title: t('locales.tutorial'),
3838
url: '/'
3939
});
4040

handlers/tutorial/templates/frontpage.pug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ block append variables
1313

1414
block append head
1515
!=js("tutorial", {defer: true})
16-
meta(name="description" content=t("config.meta.description"))
16+
meta(name="description" content=t('locales.meta.description'))
1717

1818
block content
1919
+frontpage-content({

modules/client/localeExample.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// client-side locale example
2+
// can be used as require('client/test') from server-side
3+
// and from client side too
4+
const t = require('i18n/t');
5+
6+
t.i18n.add('test', require('../../locales/' + require('config').lang + '.yml'));
7+
8+
console.log(t('test.ilya_kantor'));

modules/config/index.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
// make sure Promise is wrapped early,
2-
// to assign mongoose.Promise = global.Promise the wrapped variant any time later
31
let path = require('path');
42
let fs = require('fs');
3+
let yaml = require('js-yaml');
54
let env = process.env;
65

7-
86
// NODE_ENV = development || test || production
97
env.NODE_ENV = env.NODE_ENV || 'development';
108

@@ -68,11 +66,17 @@ let config = module.exports = {
6866
handlers: require('./handlers')
6967
};
7068

69+
require.extensions['.yml'] = function(module, filename) {
70+
module.exports = yaml.safeLoad(fs.readFileSync(filename, 'utf-8'));
71+
};
72+
73+
74+
// after module.exports for circle dep w/ config
75+
const t = require('i18n');
76+
77+
t.requirePhrase(''); // root locales
7178

7279
// webpack config uses general config
7380
// we have a loop dep here
7481
config.webpack = require('./webpack')(config);
7582

76-
const t = require('i18n');
77-
t.requirePhrase('config');
78-

0 commit comments

Comments
 (0)