@opengis/fastify-table 1.3.71 → 1.3.73
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/README.md +86 -86
- package/index.js +9 -0
- package/package.json +1 -1
- package/server/helpers/format/formatAuto.js +13 -13
- package/server/helpers/format/formatDate.js +258 -258
- package/server/helpers/format/formatDigit.js +20 -20
- package/server/helpers/format/formatNum.js +361 -361
- package/server/helpers/format/formatNumber.js +54 -54
- package/server/helpers/format/formatRelative.js +106 -106
- package/server/helpers/format/formatUnit.js +38 -38
- package/server/helpers/format/num_format.js +41 -41
- package/server/helpers/funcs/_math.js +49 -49
- package/server/helpers/funcs/empty.js +21 -21
- package/server/helpers/funcs/ifCond.js +106 -106
- package/server/helpers/funcs/ifCondAnd.js +96 -96
- package/server/helpers/funcs/ifCondOr.js +98 -98
- package/server/helpers/funcs/inc.js +20 -20
- package/server/helpers/funcs/json.js +2 -2
- package/server/helpers/funcs/round.js +27 -27
- package/server/helpers/string/coalesce.js +31 -31
- package/server/helpers/string/concat.js +28 -28
- package/server/helpers/string/split.js +19 -19
- package/server/helpers/string/str_replace.js +60 -60
- package/server/helpers/string/substr.js +31 -31
- package/server/helpers/string/translit.js +23 -23
- package/server/helpers/string/utils/alphabet.js +75 -75
- package/server/plugins/cron/funcs/addCron.js +52 -52
- package/server/plugins/cron/index.js +76 -76
- package/server/plugins/crud/funcs/getOpt.js +14 -14
- package/server/plugins/crud/funcs/setOpt.js +21 -21
- package/server/plugins/crud/funcs/setToken.js +43 -43
- package/server/plugins/crud/funcs/utils/getFolder.js +11 -11
- package/server/plugins/crud/index.js +23 -23
- package/server/plugins/hook/index.js +8 -8
- package/server/plugins/logger/errorStatus.js +19 -19
- package/server/plugins/logger/index.js +26 -26
- package/server/plugins/migration/index.js +7 -7
- package/server/plugins/pg/index.js +11 -2
- package/server/plugins/policy/sqlInjection.js +33 -33
- package/server/plugins/redis/client.js +8 -8
- package/server/plugins/redis/funcs/redisClients.js +3 -3
- package/server/plugins/redis/index.js +17 -17
- package/server/plugins/table/funcs/getFilterSQL/util/getCustomQuery.js +13 -13
- package/server/plugins/table/funcs/getFilterSQL/util/getTableSql.js +34 -34
- package/server/plugins/table/funcs/getTemplates.js +19 -19
- package/server/plugins/table/funcs/gisIRColumn.js +82 -82
- package/server/plugins/table/funcs/loadTemplate.js +1 -1
- package/server/plugins/table/funcs/loadTemplatePath.js +1 -1
- package/server/plugins/table/funcs/userTemplateDir.js +1 -1
- package/server/plugins/table/index.js +13 -13
- package/server/plugins/util/index.js +7 -7
- package/server/routes/cron/index.js +16 -14
- package/server/routes/crud/index.js +8 -7
- package/server/routes/data/controllers/cardData.js +144 -0
- package/server/routes/data/controllers/cardTabData.js +58 -0
- package/server/routes/data/controllers/funcs/getFilterSQL/index.js +92 -0
- package/server/routes/data/controllers/funcs/getFilterSQL/util/formatValue.js +170 -0
- package/server/routes/data/controllers/funcs/getFilterSQL/util/getCustomQuery.js +13 -0
- package/server/routes/data/controllers/funcs/getFilterSQL/util/getFilterQuery.js +64 -0
- package/server/routes/data/controllers/funcs/getFilterSQL/util/getOptimizedQuery.js +12 -0
- package/server/routes/data/controllers/funcs/getFilterSQL/util/getTableSql.js +34 -0
- package/server/routes/data/controllers/tableData.js +55 -0
- package/server/routes/data/controllers/tableFilter.js +16 -0
- package/server/routes/data/controllers/tableInfo.js +110 -0
- package/server/routes/data/controllers/tokenInfo.js +12 -0
- package/server/routes/data/controllers/utils/assignTokens.js +31 -0
- package/server/routes/data/controllers/utils/conditions.js +19 -0
- package/server/routes/data/controllers/utils/getColumns.js +9 -0
- package/server/routes/data/index.mjs +22 -0
- package/server/routes/data/schema.js +54 -0
- package/server/routes/dblist/index.mjs +9 -7
- package/server/routes/logger/controllers/logger.file.js +93 -93
- package/server/routes/logger/controllers/utils/checkUserAccess.js +19 -19
- package/server/routes/logger/controllers/utils/getRootDir.js +26 -26
- package/server/routes/logger/index.js +17 -17
- package/server/routes/menu/controllers/getMenu.js +97 -0
- package/server/routes/menu/controllers/interfaces.js +21 -0
- package/server/routes/menu/index.mjs +8 -0
- package/server/routes/menu/schema.js +0 -0
- package/server/routes/properties/controllers/properties.add.js +55 -55
- package/server/routes/properties/controllers/properties.get.js +17 -17
- package/server/routes/properties/index.js +16 -16
- package/server/routes/table/controllers/form.js +42 -42
- package/server/routes/table/controllers/search.js +74 -74
- package/server/routes/table/controllers/suggest.js +28 -14
- package/server/routes/table/index.js +10 -10
- package/server/routes/table/schema.js +65 -64
- package/server/routes/templates/controllers/getTemplate.js +51 -0
- package/server/routes/templates/index.mjs +10 -0
- package/server/routes/templates/schema.js +9 -0
- package/server/routes/util/controllers/status.monitor.js +8 -8
- package/server/routes/util/index.js +2 -2
- package/utils.js +2 -0
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Округлення числа до певної точності
|
|
3
|
-
*
|
|
4
|
-
* @summary Округлення числа до певної точності. Є можливість округлення до низу.
|
|
5
|
-
* @priority 3
|
|
6
|
-
* @type helper
|
|
7
|
-
* @alias round
|
|
8
|
-
* @tag format
|
|
9
|
-
* @example
|
|
10
|
-
* {{round 3.14159265359 dec="6"}}
|
|
11
|
-
* @descr Округлення числа із змінної x до 6 знаків після роздільника
|
|
12
|
-
* @param {Number} dec Підрахування числа після роздільника
|
|
13
|
-
* @param {Any} floor False - округлення до низу
|
|
14
|
-
* @param {Number} data Передане число
|
|
15
|
-
* @returns {String} Returns HTML
|
|
16
|
-
*/
|
|
17
|
-
export default function round(data, options) {
|
|
18
|
-
const _data = parseFloat(data);
|
|
19
|
-
if (isNaN(_data)) return '';
|
|
20
|
-
|
|
21
|
-
const dec = options.hash.dec ? parseInt(options.hash.dec, 10) : 0;
|
|
22
|
-
|
|
23
|
-
if (options.hash.floor) {
|
|
24
|
-
return Math.floor(_data).toFixed(dec);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return _data.toFixed(dec);
|
|
1
|
+
/**
|
|
2
|
+
* Округлення числа до певної точності
|
|
3
|
+
*
|
|
4
|
+
* @summary Округлення числа до певної точності. Є можливість округлення до низу.
|
|
5
|
+
* @priority 3
|
|
6
|
+
* @type helper
|
|
7
|
+
* @alias round
|
|
8
|
+
* @tag format
|
|
9
|
+
* @example
|
|
10
|
+
* {{round 3.14159265359 dec="6"}}
|
|
11
|
+
* @descr Округлення числа із змінної x до 6 знаків після роздільника
|
|
12
|
+
* @param {Number} dec Підрахування числа після роздільника
|
|
13
|
+
* @param {Any} floor False - округлення до низу
|
|
14
|
+
* @param {Number} data Передане число
|
|
15
|
+
* @returns {String} Returns HTML
|
|
16
|
+
*/
|
|
17
|
+
export default function round(data, options) {
|
|
18
|
+
const _data = parseFloat(data);
|
|
19
|
+
if (isNaN(_data)) return '';
|
|
20
|
+
|
|
21
|
+
const dec = options.hash.dec ? parseInt(options.hash.dec, 10) : 0;
|
|
22
|
+
|
|
23
|
+
if (options.hash.floor) {
|
|
24
|
+
return Math.floor(_data).toFixed(dec);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return _data.toFixed(dec);
|
|
28
28
|
};
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Повертає перший елемент, який не є пустим або відсутнім
|
|
3
|
-
*
|
|
4
|
-
* @summary Повертає перший не null елемент. Є можливість застосування разом із іншими хелперами.
|
|
5
|
-
* @priority 4
|
|
6
|
-
* @type helper
|
|
7
|
-
* @alias coalesce
|
|
8
|
-
* @tag string
|
|
9
|
-
* @example
|
|
10
|
-
* {{coalesce color '#337ab7'}}
|
|
11
|
-
* @descr Повертає значення змінної color або '#337ab7', якщо така змінна відсутня
|
|
12
|
-
* @example
|
|
13
|
-
* {{coalesce @root.lang 'ua'}}
|
|
14
|
-
* @example
|
|
15
|
-
* {{coalesce (select uid data="user_id") (select uid data="uid")}}
|
|
16
|
-
* @descr За відсутості співпадіння в межах пошуку по першому класифікатору, виводить результат другого селекту
|
|
17
|
-
* @param {Array} args Масив аргументів для фільтрування
|
|
18
|
-
* @returns {String} Return Html
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
export default function coalesce(...args) {
|
|
22
|
-
const options = args.pop();
|
|
23
|
-
|
|
24
|
-
for (const arg of args) {
|
|
25
|
-
if (arg != null && arg !== '') {
|
|
26
|
-
return arg;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return options.fn ? options.fn(this) : (options.inverse ? options.inverse(this) : '');
|
|
31
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Повертає перший елемент, який не є пустим або відсутнім
|
|
3
|
+
*
|
|
4
|
+
* @summary Повертає перший не null елемент. Є можливість застосування разом із іншими хелперами.
|
|
5
|
+
* @priority 4
|
|
6
|
+
* @type helper
|
|
7
|
+
* @alias coalesce
|
|
8
|
+
* @tag string
|
|
9
|
+
* @example
|
|
10
|
+
* {{coalesce color '#337ab7'}}
|
|
11
|
+
* @descr Повертає значення змінної color або '#337ab7', якщо така змінна відсутня
|
|
12
|
+
* @example
|
|
13
|
+
* {{coalesce @root.lang 'ua'}}
|
|
14
|
+
* @example
|
|
15
|
+
* {{coalesce (select uid data="user_id") (select uid data="uid")}}
|
|
16
|
+
* @descr За відсутості співпадіння в межах пошуку по першому класифікатору, виводить результат другого селекту
|
|
17
|
+
* @param {Array} args Масив аргументів для фільтрування
|
|
18
|
+
* @returns {String} Return Html
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
export default function coalesce(...args) {
|
|
22
|
+
const options = args.pop();
|
|
23
|
+
|
|
24
|
+
for (const arg of args) {
|
|
25
|
+
if (arg != null && arg !== '') {
|
|
26
|
+
return arg;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return options.fn ? options.fn(this) : (options.inverse ? options.inverse(this) : '');
|
|
31
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Об'єднання декількох вихідних змінних в одній строці
|
|
3
|
-
*
|
|
4
|
-
* @summary Об'єднання в одну строку декількох архументів. Можна використовувати для побудови посилань.
|
|
5
|
-
* @priority 4
|
|
6
|
-
* @alias concat
|
|
7
|
-
* @type helper
|
|
8
|
-
* @tag string
|
|
9
|
-
* @example
|
|
10
|
-
* {{concat 'https://spending.gov.ua/new/disposers/' edrpou '/agreements/' id}}
|
|
11
|
-
* @descr Результат: https://spending.gov.ua/new/disposers/1234567890/agreements/3721893718937819 (edrpou та id - змінні)
|
|
12
|
-
* @param {Array} args Масив аргуметів, які потрібно з'єднати
|
|
13
|
-
* @returns {String} Returns HTML
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
export default function concat(...args) {
|
|
17
|
-
if (args.length === 0) return '';
|
|
18
|
-
|
|
19
|
-
let result = '';
|
|
20
|
-
|
|
21
|
-
for (let i = 0; i < args.length; i += 1) {
|
|
22
|
-
if (['string', 'number'].includes(typeof args[i])) {
|
|
23
|
-
result += args[i];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return result;
|
|
28
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Об'єднання декількох вихідних змінних в одній строці
|
|
3
|
+
*
|
|
4
|
+
* @summary Об'єднання в одну строку декількох архументів. Можна використовувати для побудови посилань.
|
|
5
|
+
* @priority 4
|
|
6
|
+
* @alias concat
|
|
7
|
+
* @type helper
|
|
8
|
+
* @tag string
|
|
9
|
+
* @example
|
|
10
|
+
* {{concat 'https://spending.gov.ua/new/disposers/' edrpou '/agreements/' id}}
|
|
11
|
+
* @descr Результат: https://spending.gov.ua/new/disposers/1234567890/agreements/3721893718937819 (edrpou та id - змінні)
|
|
12
|
+
* @param {Array} args Масив аргуметів, які потрібно з'єднати
|
|
13
|
+
* @returns {String} Returns HTML
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export default function concat(...args) {
|
|
17
|
+
if (args.length === 0) return '';
|
|
18
|
+
|
|
19
|
+
let result = '';
|
|
20
|
+
|
|
21
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
22
|
+
if (['string', 'number'].includes(typeof args[i])) {
|
|
23
|
+
result += args[i];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Метод split() разбивает объект String на массив строк путём разделения строки указанной подстрокой.
|
|
3
|
-
*
|
|
4
|
-
* @summary Метод split() разбивает объект String на массив строк путём разделения строки указанной подстрокой.
|
|
5
|
-
* @priority 4
|
|
6
|
-
* @alias split
|
|
7
|
-
* @tag string
|
|
8
|
-
* @type helper
|
|
9
|
-
* @example
|
|
10
|
-
|
|
11
|
-
* @param {String} separator Символ по якому ділиться объект String
|
|
12
|
-
* @param {String} data Строка або число яке обрізається
|
|
13
|
-
* @returns {Array} Returns HTML
|
|
14
|
-
*/
|
|
15
|
-
export default function split(data, options) {
|
|
16
|
-
const fullString = data ? `${data}` : '';
|
|
17
|
-
const separator = options || ',';
|
|
18
|
-
|
|
19
|
-
return fullString.split(separator);
|
|
1
|
+
/**
|
|
2
|
+
* Метод split() разбивает объект String на массив строк путём разделения строки указанной подстрокой.
|
|
3
|
+
*
|
|
4
|
+
* @summary Метод split() разбивает объект String на массив строк путём разделения строки указанной подстрокой.
|
|
5
|
+
* @priority 4
|
|
6
|
+
* @alias split
|
|
7
|
+
* @tag string
|
|
8
|
+
* @type helper
|
|
9
|
+
* @example
|
|
10
|
+
|
|
11
|
+
* @param {String} separator Символ по якому ділиться объект String
|
|
12
|
+
* @param {String} data Строка або число яке обрізається
|
|
13
|
+
* @returns {Array} Returns HTML
|
|
14
|
+
*/
|
|
15
|
+
export default function split(data, options) {
|
|
16
|
+
const fullString = data ? `${data}` : '';
|
|
17
|
+
const separator = options || ',';
|
|
18
|
+
|
|
19
|
+
return fullString.split(separator);
|
|
20
20
|
};
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Виконує заміну символів у строці. Є можливість заміни регулярного виразу нової строки на тег <br>
|
|
3
|
-
*
|
|
4
|
-
* @summary Виконання заміни частини строки на значення з останнього аргументу.
|
|
5
|
-
* @priority 3
|
|
6
|
-
* @type helper
|
|
7
|
-
* @alias strReplace
|
|
8
|
-
* @tag string
|
|
9
|
-
* @example
|
|
10
|
-
* {{str_replace 'This Is Alias' ' ' ''}}
|
|
11
|
-
* @example
|
|
12
|
-
* {{{str_replace '<p>Перший рядок</p><p>Наступний рядок</p>' br=1}}}
|
|
13
|
-
* @example
|
|
14
|
-
* {{{str_replace 'Перший рядок<br>Наступний рядок' br=1}}}
|
|
15
|
-
* @param {Object} br
|
|
16
|
-
* @param {Object} newline
|
|
17
|
-
* @param {Object} html
|
|
18
|
-
* @param {Object} last
|
|
19
|
-
* @param {Array} args[0]]
|
|
20
|
-
* @param {Array} args[1]]
|
|
21
|
-
* @param {Array} args[2]]
|
|
22
|
-
* @returns {String} Returns HTML
|
|
23
|
-
*/
|
|
24
|
-
export default function strReplace(...args) {
|
|
25
|
-
const options = args.pop();
|
|
26
|
-
const [str, from, to] = args;
|
|
27
|
-
|
|
28
|
-
if (!str) return '';
|
|
29
|
-
|
|
30
|
-
if (options.hash.br) {
|
|
31
|
-
return str.replace(/\n/g, '<br>');
|
|
32
|
-
}
|
|
33
|
-
if (options.hash.newline) {
|
|
34
|
-
return str.replace(/\n/g, ' ');
|
|
35
|
-
}
|
|
36
|
-
if (options.hash.html) {
|
|
37
|
-
return str
|
|
38
|
-
.replace(/<br>/g, '\n')
|
|
39
|
-
.replace(/<\/p>/g, '\n')
|
|
40
|
-
.replace(/<\/li>/g, '\n')
|
|
41
|
-
.replace(/(<[^>]+>|<[^>]>|<\/[^>]>)/g, '')
|
|
42
|
-
.replace(/\n/g, ' ');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (options.hash.last) {
|
|
46
|
-
return replaceLast(str, from, to);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (typeof from !== 'string' || typeof to !== 'string') {
|
|
50
|
-
return 'Invalid replacement parameters';
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return str.replace(new RegExp(from, 'g'), to);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function replaceLast(str, what, replacement) {
|
|
57
|
-
if (!str?.split) return str;
|
|
58
|
-
const pcs = str?.split(what);
|
|
59
|
-
const lastPc = pcs.pop();
|
|
60
|
-
return pcs.join(what) + replacement + lastPc;
|
|
1
|
+
/**
|
|
2
|
+
* Виконує заміну символів у строці. Є можливість заміни регулярного виразу нової строки на тег <br>
|
|
3
|
+
*
|
|
4
|
+
* @summary Виконання заміни частини строки на значення з останнього аргументу.
|
|
5
|
+
* @priority 3
|
|
6
|
+
* @type helper
|
|
7
|
+
* @alias strReplace
|
|
8
|
+
* @tag string
|
|
9
|
+
* @example
|
|
10
|
+
* {{str_replace 'This Is Alias' ' ' ''}}
|
|
11
|
+
* @example
|
|
12
|
+
* {{{str_replace '<p>Перший рядок</p><p>Наступний рядок</p>' br=1}}}
|
|
13
|
+
* @example
|
|
14
|
+
* {{{str_replace 'Перший рядок<br>Наступний рядок' br=1}}}
|
|
15
|
+
* @param {Object} br
|
|
16
|
+
* @param {Object} newline
|
|
17
|
+
* @param {Object} html
|
|
18
|
+
* @param {Object} last
|
|
19
|
+
* @param {Array} args[0]]
|
|
20
|
+
* @param {Array} args[1]]
|
|
21
|
+
* @param {Array} args[2]]
|
|
22
|
+
* @returns {String} Returns HTML
|
|
23
|
+
*/
|
|
24
|
+
export default function strReplace(...args) {
|
|
25
|
+
const options = args.pop();
|
|
26
|
+
const [str, from, to] = args;
|
|
27
|
+
|
|
28
|
+
if (!str) return '';
|
|
29
|
+
|
|
30
|
+
if (options.hash.br) {
|
|
31
|
+
return str.replace(/\n/g, '<br>');
|
|
32
|
+
}
|
|
33
|
+
if (options.hash.newline) {
|
|
34
|
+
return str.replace(/\n/g, ' ');
|
|
35
|
+
}
|
|
36
|
+
if (options.hash.html) {
|
|
37
|
+
return str
|
|
38
|
+
.replace(/<br>/g, '\n')
|
|
39
|
+
.replace(/<\/p>/g, '\n')
|
|
40
|
+
.replace(/<\/li>/g, '\n')
|
|
41
|
+
.replace(/(<[^>]+>|<[^>]>|<\/[^>]>)/g, '')
|
|
42
|
+
.replace(/\n/g, ' ');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (options.hash.last) {
|
|
46
|
+
return replaceLast(str, from, to);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (typeof from !== 'string' || typeof to !== 'string') {
|
|
50
|
+
return 'Invalid replacement parameters';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return str.replace(new RegExp(from, 'g'), to);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function replaceLast(str, what, replacement) {
|
|
57
|
+
if (!str?.split) return str;
|
|
58
|
+
const pcs = str?.split(what);
|
|
59
|
+
const lastPc = pcs.pop();
|
|
60
|
+
return pcs.join(what) + replacement + lastPc;
|
|
61
61
|
}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Зменшення строки за значеням із змінної. Можна отримати частину строки за першим та останнім символом.
|
|
3
|
-
*
|
|
4
|
-
* @summary Обрізання строки. За замовчуванням до 100 символів. Є можливість вказання точної кількості.
|
|
5
|
-
* @priority 4
|
|
6
|
-
* @alias substr
|
|
7
|
-
* @tag string
|
|
8
|
-
* @type helper
|
|
9
|
-
* @example
|
|
10
|
-
* {{substr @root.domain from=5}}
|
|
11
|
-
* @example
|
|
12
|
-
* {{substr req.headers.host max=15}}
|
|
13
|
-
* @param {Object} from Число з якого обрізати строку
|
|
14
|
-
* @param {Object} max Число до якого обрізати строку
|
|
15
|
-
* @param {Object} args[1]] Використовуэться, якщо не дано opt.max
|
|
16
|
-
* @param {String|Number} data Строка або число яке обрізається
|
|
17
|
-
* @returns {String} Returns HTML
|
|
18
|
-
*/
|
|
19
|
-
export default function substr(data, { hash }) {
|
|
20
|
-
const fullString = data ? String(data) : '';
|
|
21
|
-
|
|
22
|
-
const max = typeof hash?.max === 'number' ? hash.max : 100;
|
|
23
|
-
const from = typeof hash?.from === 'number' ? hash.from : 0;
|
|
24
|
-
|
|
25
|
-
const result = fullString.substr(from, max);
|
|
26
|
-
|
|
27
|
-
if (hash?.unit && fullString.length > max) {
|
|
28
|
-
return `${result}${hash.unit}`;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return result;
|
|
1
|
+
/**
|
|
2
|
+
* Зменшення строки за значеням із змінної. Можна отримати частину строки за першим та останнім символом.
|
|
3
|
+
*
|
|
4
|
+
* @summary Обрізання строки. За замовчуванням до 100 символів. Є можливість вказання точної кількості.
|
|
5
|
+
* @priority 4
|
|
6
|
+
* @alias substr
|
|
7
|
+
* @tag string
|
|
8
|
+
* @type helper
|
|
9
|
+
* @example
|
|
10
|
+
* {{substr @root.domain from=5}}
|
|
11
|
+
* @example
|
|
12
|
+
* {{substr req.headers.host max=15}}
|
|
13
|
+
* @param {Object} from Число з якого обрізати строку
|
|
14
|
+
* @param {Object} max Число до якого обрізати строку
|
|
15
|
+
* @param {Object} args[1]] Використовуэться, якщо не дано opt.max
|
|
16
|
+
* @param {String|Number} data Строка або число яке обрізається
|
|
17
|
+
* @returns {String} Returns HTML
|
|
18
|
+
*/
|
|
19
|
+
export default function substr(data, { hash }) {
|
|
20
|
+
const fullString = data ? String(data) : '';
|
|
21
|
+
|
|
22
|
+
const max = typeof hash?.max === 'number' ? hash.max : 100;
|
|
23
|
+
const from = typeof hash?.from === 'number' ? hash.from : 0;
|
|
24
|
+
|
|
25
|
+
const result = fullString.substr(from, max);
|
|
26
|
+
|
|
27
|
+
if (hash?.unit && fullString.length > max) {
|
|
28
|
+
return `${result}${hash.unit}`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return result;
|
|
32
32
|
};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import L from './utils/alphabet.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Форматування символів з кирилиці на латиницю
|
|
5
|
-
*
|
|
6
|
-
* @summary Форматування символів з кирилиці на латиницю
|
|
7
|
-
* @priority 0
|
|
8
|
-
* @deprecated true
|
|
9
|
-
* @tag string
|
|
10
|
-
* @type helper
|
|
11
|
-
* @alias translit
|
|
12
|
-
* @example
|
|
13
|
-
* {{translit data_name}}
|
|
14
|
-
* @param {String} data Перетворення букв з строки з укр на англ
|
|
15
|
-
* @returns {String} Returns HTML
|
|
16
|
-
*/
|
|
17
|
-
export default function translit({ data }) {
|
|
18
|
-
const rKey = Object.keys(L).join('');
|
|
19
|
-
|
|
20
|
-
const reg = new RegExp(`[${rKey}]`, 'g');
|
|
21
|
-
|
|
22
|
-
return (data || '').replace(reg, (a) => (a in L ? L[a] : ''));
|
|
23
|
-
};
|
|
1
|
+
import L from './utils/alphabet.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Форматування символів з кирилиці на латиницю
|
|
5
|
+
*
|
|
6
|
+
* @summary Форматування символів з кирилиці на латиницю
|
|
7
|
+
* @priority 0
|
|
8
|
+
* @deprecated true
|
|
9
|
+
* @tag string
|
|
10
|
+
* @type helper
|
|
11
|
+
* @alias translit
|
|
12
|
+
* @example
|
|
13
|
+
* {{translit data_name}}
|
|
14
|
+
* @param {String} data Перетворення букв з строки з укр на англ
|
|
15
|
+
* @returns {String} Returns HTML
|
|
16
|
+
*/
|
|
17
|
+
export default function translit({ data }) {
|
|
18
|
+
const rKey = Object.keys(L).join('');
|
|
19
|
+
|
|
20
|
+
const reg = new RegExp(`[${rKey}]`, 'g');
|
|
21
|
+
|
|
22
|
+
return (data || '').replace(reg, (a) => (a in L ? L[a] : ''));
|
|
23
|
+
};
|
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
А: 'A',
|
|
3
|
-
а: 'a',
|
|
4
|
-
Б: 'B',
|
|
5
|
-
б: 'b',
|
|
6
|
-
В: 'V',
|
|
7
|
-
в: 'v',
|
|
8
|
-
Г: 'H',
|
|
9
|
-
г: 'h',
|
|
10
|
-
Д: 'D',
|
|
11
|
-
д: 'd',
|
|
12
|
-
Е: 'E',
|
|
13
|
-
е: 'e',
|
|
14
|
-
Ё: 'Yo',
|
|
15
|
-
ё: 'yo',
|
|
16
|
-
Ж: 'Zh',
|
|
17
|
-
ж: 'zh',
|
|
18
|
-
З: 'Z',
|
|
19
|
-
з: 'z',
|
|
20
|
-
И: 'Y',
|
|
21
|
-
и: 'y',
|
|
22
|
-
Й: 'Y',
|
|
23
|
-
й: 'i',
|
|
24
|
-
К: 'K',
|
|
25
|
-
к: 'k',
|
|
26
|
-
Л: 'L',
|
|
27
|
-
л: 'l',
|
|
28
|
-
М: 'M',
|
|
29
|
-
м: 'm',
|
|
30
|
-
Н: 'N',
|
|
31
|
-
н: 'n',
|
|
32
|
-
О: 'O',
|
|
33
|
-
о: 'o',
|
|
34
|
-
П: 'P',
|
|
35
|
-
п: 'p',
|
|
36
|
-
Р: 'R',
|
|
37
|
-
р: 'r',
|
|
38
|
-
С: 'S',
|
|
39
|
-
с: 's',
|
|
40
|
-
Т: 'T',
|
|
41
|
-
т: 't',
|
|
42
|
-
У: 'U',
|
|
43
|
-
у: 'u',
|
|
44
|
-
Ф: 'F',
|
|
45
|
-
ф: 'f',
|
|
46
|
-
Х: 'Kh',
|
|
47
|
-
х: 'kh',
|
|
48
|
-
Ц: 'Ts',
|
|
49
|
-
ц: 'ts',
|
|
50
|
-
Ч: 'Ch',
|
|
51
|
-
ч: 'ch',
|
|
52
|
-
Ш: 'Sh',
|
|
53
|
-
ш: 'sh',
|
|
54
|
-
Щ: 'Shch',
|
|
55
|
-
щ: 'shch',
|
|
56
|
-
Ъ: '',
|
|
57
|
-
ъ: '',
|
|
58
|
-
Ы: 'Y',
|
|
59
|
-
ы: 'y',
|
|
60
|
-
Ь: '',
|
|
61
|
-
ь: '',
|
|
62
|
-
Э: 'E',
|
|
63
|
-
э: 'e',
|
|
64
|
-
Ю: 'Yu',
|
|
65
|
-
ю: 'yu',
|
|
66
|
-
Я: 'Ya',
|
|
67
|
-
я: 'ia',
|
|
68
|
-
І: 'I',
|
|
69
|
-
і: 'i',
|
|
70
|
-
Ї: 'Yi',
|
|
71
|
-
ї: 'i',
|
|
72
|
-
Є: 'Ye',
|
|
73
|
-
є: 'ie',
|
|
74
|
-
Ґ: 'G',
|
|
75
|
-
ґ: 'g',
|
|
1
|
+
export default {
|
|
2
|
+
А: 'A',
|
|
3
|
+
а: 'a',
|
|
4
|
+
Б: 'B',
|
|
5
|
+
б: 'b',
|
|
6
|
+
В: 'V',
|
|
7
|
+
в: 'v',
|
|
8
|
+
Г: 'H',
|
|
9
|
+
г: 'h',
|
|
10
|
+
Д: 'D',
|
|
11
|
+
д: 'd',
|
|
12
|
+
Е: 'E',
|
|
13
|
+
е: 'e',
|
|
14
|
+
Ё: 'Yo',
|
|
15
|
+
ё: 'yo',
|
|
16
|
+
Ж: 'Zh',
|
|
17
|
+
ж: 'zh',
|
|
18
|
+
З: 'Z',
|
|
19
|
+
з: 'z',
|
|
20
|
+
И: 'Y',
|
|
21
|
+
и: 'y',
|
|
22
|
+
Й: 'Y',
|
|
23
|
+
й: 'i',
|
|
24
|
+
К: 'K',
|
|
25
|
+
к: 'k',
|
|
26
|
+
Л: 'L',
|
|
27
|
+
л: 'l',
|
|
28
|
+
М: 'M',
|
|
29
|
+
м: 'm',
|
|
30
|
+
Н: 'N',
|
|
31
|
+
н: 'n',
|
|
32
|
+
О: 'O',
|
|
33
|
+
о: 'o',
|
|
34
|
+
П: 'P',
|
|
35
|
+
п: 'p',
|
|
36
|
+
Р: 'R',
|
|
37
|
+
р: 'r',
|
|
38
|
+
С: 'S',
|
|
39
|
+
с: 's',
|
|
40
|
+
Т: 'T',
|
|
41
|
+
т: 't',
|
|
42
|
+
У: 'U',
|
|
43
|
+
у: 'u',
|
|
44
|
+
Ф: 'F',
|
|
45
|
+
ф: 'f',
|
|
46
|
+
Х: 'Kh',
|
|
47
|
+
х: 'kh',
|
|
48
|
+
Ц: 'Ts',
|
|
49
|
+
ц: 'ts',
|
|
50
|
+
Ч: 'Ch',
|
|
51
|
+
ч: 'ch',
|
|
52
|
+
Ш: 'Sh',
|
|
53
|
+
ш: 'sh',
|
|
54
|
+
Щ: 'Shch',
|
|
55
|
+
щ: 'shch',
|
|
56
|
+
Ъ: '',
|
|
57
|
+
ъ: '',
|
|
58
|
+
Ы: 'Y',
|
|
59
|
+
ы: 'y',
|
|
60
|
+
Ь: '',
|
|
61
|
+
ь: '',
|
|
62
|
+
Э: 'E',
|
|
63
|
+
э: 'e',
|
|
64
|
+
Ю: 'Yu',
|
|
65
|
+
ю: 'yu',
|
|
66
|
+
Я: 'Ya',
|
|
67
|
+
я: 'ia',
|
|
68
|
+
І: 'I',
|
|
69
|
+
і: 'i',
|
|
70
|
+
Ї: 'Yi',
|
|
71
|
+
ї: 'i',
|
|
72
|
+
Є: 'Ye',
|
|
73
|
+
є: 'ie',
|
|
74
|
+
Ґ: 'G',
|
|
75
|
+
ґ: 'g',
|
|
76
76
|
};
|