@videinfra/static-website-builder 1.15.3 → 1.15.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/init/test/.env +1 -0
- package/init/test/config/config.js +4 -0
- package/init/test/src/html/preposition.twig +4 -0
- package/init/test/src/stylesheets/env-test.scss +4 -3
- package/package.json +1 -1
- package/plugins/twig/symfony-filters/filters.js +16 -0
- package/plugins/twig/symfony-filters/preposition_nbsp.js +28 -0
- package/tasks/env/get-env.js +1 -1
- package/tasks/html/task.js +3 -1
- package/tests/build/build.test.js +1 -0
- package/tests/preposition_nbsp.test.js +28 -0
package/init/test/.env
CHANGED
|
@@ -31,6 +31,9 @@ exports.plugins = [
|
|
|
31
31
|
|
|
32
32
|
// Enables TwigJS engine .twig file compilation
|
|
33
33
|
require('../../../plugins/twig'),
|
|
34
|
+
|
|
35
|
+
// Enables TWIG Symfony filters
|
|
36
|
+
require('../../../plugins/twig/symfony-filters'),
|
|
34
37
|
];
|
|
35
38
|
|
|
36
39
|
exports.env = {
|
|
@@ -41,6 +44,7 @@ exports.env = {
|
|
|
41
44
|
'TYPE_BOOL_TRUE': 'typeBoolTrue',
|
|
42
45
|
'TYPE_BOOL_FALSE': 'typeBoolFalse',
|
|
43
46
|
'TYPE_NUMBER': 'typeNumber',
|
|
47
|
+
'TYPE_EMPTY': 'typeEmpty',
|
|
44
48
|
},
|
|
45
49
|
};
|
|
46
50
|
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
:root {
|
|
6
|
-
#{ --env-test-type-number }: map-get($env,
|
|
6
|
+
#{ --env-test-type-number }: map-get($env, typeNumber);
|
|
7
|
+
#{ --env-test-type-empty }: map-get($env, typeEmpty);
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
@if map-get($env,
|
|
10
|
+
@if map-get($env, typeBoolTrue) {
|
|
10
11
|
:root {
|
|
11
12
|
--env-test-bool-true: true;
|
|
12
13
|
}
|
|
@@ -16,7 +17,7 @@
|
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
@if map-get($env,
|
|
20
|
+
@if map-get($env, typeBoolFalse) {
|
|
20
21
|
:root {
|
|
21
22
|
--env-test-bool-false: true;
|
|
22
23
|
}
|
package/package.json
CHANGED
|
@@ -78,5 +78,21 @@ module.exports.push({
|
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Preposition filter
|
|
83
|
+
* Adds a non-breaking space between prepositions and other words
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* {{ 'hello at world' | preposition_nbsp }}
|
|
87
|
+
* Output: hello at world
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
const preposition_nbsp = require('./preposition_nbsp');
|
|
81
91
|
|
|
92
|
+
module.exports.push({
|
|
93
|
+
name: 'preposition_nbsp',
|
|
94
|
+
func: function (text) {
|
|
95
|
+
return preposition_nbsp(text);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
82
98
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const prepositions = [
|
|
2
|
+
'about', 'above', 'across', 'after', 'against', 'along', 'amid', 'among', 'around', 'as', 'at', 'before', 'behind', 'below', 'beneath', 'beside', 'besides', 'between', 'beyond', 'by', 'concerning', 'despite', 'down', 'during', 'except', 'for', 'from', 'in', 'inside', 'into', 'like', 'near', 'of', 'off', 'on', 'onto', 'out', 'outside', 'over', 'past', 'regarding', 'round', 'since', 'through', 'throughout', 'to', 'toward', 'towards', 'under', 'underneath', 'until', 'unto', 'up', 'upon', 'with', 'within', 'without', 'a', 'an', 'the',
|
|
3
|
+
'в', 'на', 'по', 'к', 'у', 'от', 'из', 'с', 'над', 'под', 'при', 'без', 'до', 'для', 'за', 'через', 'перед', 'около', 'вокруг', 'о', 'об', 'обо', 'про', 'среди', 'между', 'ради', 'вдоль', 'вне', 'кроме', 'сквозь', 'вследствие', 'благодаря', 'согласно', 'вопреки', 'вроде', 'насчёт', 'касательно', 'против', 'со', 'во', 'ко', 'ото', 'изо', 'надо', 'подо', 'передо', 'передо', 'и'
|
|
4
|
+
];
|
|
5
|
+
|
|
6
|
+
// Word boundary regex
|
|
7
|
+
// (?<= # Lookbehind, but don't consume
|
|
8
|
+
// (^| # Start of string or
|
|
9
|
+
// [^\\p{L}] # Non-letter, works with unicode characters too
|
|
10
|
+
const regexWordBoundary = '(?<=(^|[^\\p{L}]))';
|
|
11
|
+
const regexEscape = /[.*+?^${}()|[\]\\]/g;
|
|
12
|
+
|
|
13
|
+
let prepositionsRegex = null;
|
|
14
|
+
|
|
15
|
+
function escapeRegExp(string) {
|
|
16
|
+
return string.replace(regexEscape, '\\$&'); // $& means the whole matched string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function prepositionNbsp(text) {
|
|
20
|
+
if (!prepositionsRegex) {
|
|
21
|
+
const prepositionsEscaped = prepositions.map(preposition => escapeRegExp(preposition));
|
|
22
|
+
prepositionsRegex = new RegExp(`${regexWordBoundary}(${prepositionsEscaped.join('|')})\\s+`, 'uig');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return text.replace(prepositionsRegex, '$2 ');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = prepositionNbsp;
|
package/tasks/env/get-env.js
CHANGED
|
@@ -46,7 +46,7 @@ function getEnvData () {
|
|
|
46
46
|
if (key in envVariables) {
|
|
47
47
|
const value = envVariables[key];
|
|
48
48
|
const camelCase = map[key];
|
|
49
|
-
const kebabCase = map[key]
|
|
49
|
+
const kebabCase = map[key];
|
|
50
50
|
twigVariables[camelCase] = normalizeTwigVariable(value);
|
|
51
51
|
envOutVariables[camelCase] = value;
|
|
52
52
|
jsVariables[`process.env.${ camelCase }`] = escapeJSVariable(value);
|
package/tasks/html/task.js
CHANGED
|
@@ -40,10 +40,12 @@ const getWatchGlobPaths = memoize(function () {
|
|
|
40
40
|
const sourcePaths = getPaths.getSourcePaths('html');
|
|
41
41
|
const extensions = getConfig.getTaskConfig('html', 'extensions');
|
|
42
42
|
const dataExtensions = getConfig.getTaskConfig('data', 'extensions');
|
|
43
|
+
const envFiles = getPaths.getPathConfig().env.map((path) => getPaths.getProjectPath(path))
|
|
43
44
|
|
|
44
45
|
return globs.generate(
|
|
45
46
|
globs.paths(sourcePaths).filesWithExtensions(extensions), // HTML / TWIG files
|
|
46
|
-
globs.paths(sourcePaths).filesWithExtensions(dataExtensions) // Data files
|
|
47
|
+
globs.paths(sourcePaths).filesWithExtensions(dataExtensions), // Data files
|
|
48
|
+
envFiles, // env files
|
|
47
49
|
);
|
|
48
50
|
});
|
|
49
51
|
|
|
@@ -114,6 +114,7 @@ test('.env and .env.local files loaded', () => {
|
|
|
114
114
|
expect(css.indexOf('--env-test-bool-true:true')).not.toBe(-1);
|
|
115
115
|
expect(css.indexOf('--env-test-bool-false:false')).not.toBe(-1);
|
|
116
116
|
expect(css.indexOf('--env-test-type-number:123.456')).not.toBe(-1);
|
|
117
|
+
expect(css.indexOf('--env-test-type-empty:""')).not.toBe(-1);
|
|
117
118
|
}),
|
|
118
119
|
]);
|
|
119
120
|
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const publicPath = path.resolve(__dirname, 'build', 'public');
|
|
3
|
+
const fs = require('fs')
|
|
4
|
+
const fsPromises = fs.promises;
|
|
5
|
+
|
|
6
|
+
const preposition_nbsp = require('../plugins/twig/symfony-filters/preposition_nbsp');
|
|
7
|
+
|
|
8
|
+
test('preposition_nbsp english', () => {
|
|
9
|
+
expect(preposition_nbsp('hello world')).toEqual('hello world');
|
|
10
|
+
expect(preposition_nbsp('hello at')).toEqual('hello at');
|
|
11
|
+
expect(preposition_nbsp('hello at. world')).toEqual('hello at. world');
|
|
12
|
+
expect(preposition_nbsp('hello at world')).toEqual('hello at world');
|
|
13
|
+
expect(preposition_nbsp('hello before at world')).toEqual('hello before at world');
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test('preposition_nbsp russian', () => {
|
|
17
|
+
expect(preposition_nbsp('ппппп дддд')).toEqual('ппппп дддд');
|
|
18
|
+
expect(preposition_nbsp('ппппп над')).toEqual('ппппп над');
|
|
19
|
+
expect(preposition_nbsp('ппппп над. дддд')).toEqual('ппппп над. дддд');
|
|
20
|
+
expect(preposition_nbsp('ппппп над дддд')).toEqual('ппппп над дддд');
|
|
21
|
+
expect(preposition_nbsp('ппппп before над дддд')).toEqual('ппппп before над дддд');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('Preposition TWIG filter applied', () => {
|
|
25
|
+
return fsPromises.readFile(path.resolve(publicPath, 'preposition.html'), {'encoding': 'utf8'}).then((html) => {
|
|
26
|
+
expect(html).toBe('<html><body>hello at world</body></html>');
|
|
27
|
+
});
|
|
28
|
+
});
|