isite 2024.6.9 → 2024.8.3
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/LICENSE +21 -21
- package/README.md +1387 -1387
- package/apps/charts/site_files/html/PieChart.html +35 -35
- package/apps/charts/site_files/html/PieChart2.html +35 -35
- package/apps/charts/site_files/html/XYChart.html +42 -42
- package/apps/charts/site_files/html/column.html +60 -60
- package/apps/charts/site_files/html/gauge.html +44 -44
- package/apps/charts/site_files/html/index.html +92 -92
- package/apps/charts/site_files/html/line-graph.html +42 -42
- package/apps/charts/site_files/html/pie-chart-rounded-corners.html +38 -38
- package/apps/charts/site_files/html/simple-3D-pie-chart.html +43 -43
- package/apps/charts/site_files/js/chart-animated.js +2 -2
- package/apps/charts/site_files/json/PieChart.json +41 -41
- package/apps/charts/site_files/json/PieChart2.json +23 -23
- package/apps/charts/site_files/json/XYChart.json +74 -74
- package/apps/charts/site_files/json/bar-chart.json +99 -99
- package/apps/charts/site_files/json/column-chart.json +80 -80
- package/apps/charts/site_files/json/gauge.json +36 -36
- package/apps/charts/site_files/json/line-graph.json +1867 -1867
- package/apps/charts/site_files/json/pie-chart-rounded-corners.json +42 -42
- package/apps/charts/site_files/json/simple-3D-pie-chart.json +50 -50
- package/apps/client-side/package-lock.json +5 -5
- package/apps/client-side/package.json +21 -21
- package/apps/client-side/site_files/css/bootstrap3.css +5 -5
- package/apps/client-side/site_files/css/bootstrap4.css +6 -6
- package/apps/client-side/site_files/css/bootstrap5-addon.css +2 -2
- package/apps/client-side/site_files/css/bootstrap5.css +6 -6
- package/apps/client-side/site_files/css/checkbox.css +125 -125
- package/apps/client-side/site_files/css/font-awesome.css +4616 -4616
- package/apps/client-side/site_files/css/font-awesome.min.css +4 -4
- package/apps/client-side/site_files/css/fonts.css +85 -85
- package/apps/client-side/site_files/css/help.css +51 -51
- package/apps/client-side/site_files/css/images.css +4 -3
- package/apps/client-side/site_files/css/main-menu.css +66 -66
- package/apps/client-side/site_files/css/print.css +144 -144
- package/apps/client-side/site_files/css/prism.css +139 -139
- package/apps/client-side/site_files/css/progress.css +7 -7
- package/apps/client-side/site_files/css/radio.css +103 -103
- package/apps/client-side/site_files/css/scrollbar.css +13 -13
- package/apps/client-side/site_files/css/semantic.css +363 -363
- package/apps/client-side/site_files/css/table.css +87 -87
- package/apps/client-side/site_files/css/treeview.css +84 -84
- package/apps/client-side/site_files/css/ui.css +28 -28
- package/apps/client-side/site_files/fonts/fontawesome-webfont.svg +2671 -2671
- package/apps/client-side/site_files/fonts/glyphicons-halflings-regular.svg +287 -287
- package/apps/client-side/site_files/fonts/icons.svg +684 -684
- package/apps/client-side/site_files/js/angular-animate.js +4179 -4179
- package/apps/client-side/site_files/js/angular.js +36599 -36599
- package/apps/client-side/site_files/js/angular.min.js +351 -351
- package/apps/client-side/site_files/js/angular.min.js.map +8 -8
- package/apps/client-side/site_files/js/barcode.js +1 -1
- package/apps/client-side/site_files/js/base64.js +319 -319
- package/apps/client-side/site_files/js/bootstrap-5-directive.js +1456 -1456
- package/apps/client-side/site_files/js/bootstrap3.js +6 -6
- package/apps/client-side/site_files/js/bootstrap4.js +6 -6
- package/apps/client-side/site_files/js/bootstrap5.js +6 -6
- package/apps/client-side/site_files/js/custom.js +149 -149
- package/apps/client-side/site_files/js/directive.min.js +1 -1
- package/apps/client-side/site_files/js/hijri.js +965 -965
- package/apps/client-side/site_files/js/jquery.js +2 -2
- package/apps/client-side/site_files/js/moment.js +4511 -4511
- package/apps/client-side/site_files/js/prism.js +6 -6
- package/apps/client-side/site_files/js/qrcode.js +1398 -1398
- package/apps/client-side/site_files/js/semantic.js +10 -10
- package/apps/client-side/site_files/js/xlsx.js +23 -23
- package/apps/client-side/site_files/semantic-themes/default/assets/fonts/brand-icons.svg +1008 -1008
- package/apps/client-side/site_files/semantic-themes/default/assets/fonts/icons.svg +1518 -1518
- package/apps/client-side/site_files/semantic-themes/default/assets/fonts/outline-icons.svg +366 -366
- package/apps/client-side/site_files/webfonts/fa-brands-400.svg +3717 -3717
- package/apps/client-side/site_files/webfonts/fa-regular-400.svg +801 -801
- package/apps/client-side/site_files/webfonts/fa-solid-900.svg +5034 -5034
- package/apps/security/README.md +12 -12
- package/apps/security/app.js +288 -288
- package/apps/security/libs/notifications.js +89 -89
- package/apps/security/site_files/html/add_modal.html +36 -36
- package/apps/security/site_files/html/content.html +36 -36
- package/apps/security/site_files/html/delete_modal.html +31 -31
- package/apps/security/site_files/html/head.html +7 -7
- package/apps/security/site_files/html/index.html +80 -80
- package/apps/security/site_files/html/login_modal.html +24 -24
- package/apps/security/site_files/html/logout_modal.html +21 -21
- package/apps/security/site_files/html/navbar.html +8 -8
- package/apps/security/site_files/html/register_modal.html +32 -32
- package/apps/security/site_files/html/update_modal.html +28 -28
- package/apps/security/site_files/html/view.html +74 -74
- package/apps/security/site_files/html/view_modal.html +32 -32
- package/apps/security/site_files/js/app.js +1 -1
- package/apps/security/site_files/js/index.js +278 -278
- package/apps/security/site_files/js/login.js +35 -35
- package/apps/security/site_files/js/logout.js +22 -22
- package/apps/security/site_files/js/navbar.js +26 -26
- package/apps/security/site_files/js/register.js +30 -30
- package/apps/security/site_files/json/permissions.json +7 -7
- package/apps/security/site_files/json/roles.json +33 -33
- package/apps/security/site_files/json/words.json +28 -28
- package/gulpfile.js +17 -17
- package/index.js +1 -0
- package/isite.postman_collection.json +7 -7
- package/isite_files/css/bootstrap.css +5 -5
- package/isite_files/css/font-awesome.css +4 -4
- package/isite_files/css/prism.css +139 -139
- package/isite_files/fonts/fontawesome-webfont.svg +2671 -2671
- package/isite_files/fonts/glyphicons-halflings-regular.svg +287 -287
- package/isite_files/html/files.html +9 -9
- package/isite_files/html/head.html +12 -12
- package/isite_files/html/index.html +30 -30
- package/isite_files/html/installing.html +27 -27
- package/isite_files/html/navbar.html +51 -51
- package/isite_files/html/routes.html +13 -13
- package/isite_files/html/sessions.html +13 -13
- package/isite_files/html/vars.html +9 -9
- package/isite_files/js/angular.js +334 -334
- package/isite_files/js/bootstrap.js +6 -6
- package/isite_files/js/custom.js +149 -149
- package/isite_files/js/jquery.js +4 -4
- package/isite_files/js/prism.js +6 -6
- package/lib/README.md +1 -1
- package/lib/cookie.js +81 -81
- package/lib/dashboard.js +189 -189
- package/lib/mongodb.js +686 -686
- package/lib/parser.js +910 -910
- package/lib/session.js +158 -158
- package/lib/storage.js +6 -0
- package/lib/ws.js +4 -26
- package/object-options/lib/isite.code-workspace +10 -10
- package/object-options/lib/safty.js +13 -16
- package/package.json +55 -54
- package/ssl/create_ssl.sh +3 -3
package/lib/parser.js
CHANGED
|
@@ -1,910 +1,910 @@
|
|
|
1
|
-
module.exports = function init(req, res, ____0, route) {
|
|
2
|
-
req.features = req.features || [];
|
|
3
|
-
|
|
4
|
-
let parser = {};
|
|
5
|
-
|
|
6
|
-
function renderVar(v) {
|
|
7
|
-
if (v && v == '*') {
|
|
8
|
-
return JSON.stringify(____0.var);
|
|
9
|
-
}
|
|
10
|
-
return ____0.var(v);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function renderParam(v) {
|
|
14
|
-
if (typeof req.paramsRaw[v] !== undefined) {
|
|
15
|
-
if (v && v == '*') {
|
|
16
|
-
return JSON.stringify(req.paramsRaw);
|
|
17
|
-
}
|
|
18
|
-
return req.paramsRaw[v];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return ' ';
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function renderQuery(v) {
|
|
25
|
-
if (typeof req.queryRaw[v] !== undefined) {
|
|
26
|
-
if (v && v == '*') {
|
|
27
|
-
return JSON.stringify(req.queryRaw);
|
|
28
|
-
}
|
|
29
|
-
return req.queryRaw[v];
|
|
30
|
-
}
|
|
31
|
-
return ' ';
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function renderData(d) {
|
|
35
|
-
if (!d) {
|
|
36
|
-
return '';
|
|
37
|
-
}
|
|
38
|
-
let hide = false;
|
|
39
|
-
let out = '';
|
|
40
|
-
if (d.indexOf('#') == 0) {
|
|
41
|
-
d = d.replace('#', '');
|
|
42
|
-
hide = true;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (d == '*') {
|
|
46
|
-
out = JSON.stringify(req.data);
|
|
47
|
-
} else if (d) {
|
|
48
|
-
v = d.split('.');
|
|
49
|
-
|
|
50
|
-
if (v.length > 0) {
|
|
51
|
-
out = req.data[v[0]];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (v.length > 1 && out) {
|
|
55
|
-
out = out[v[1]];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (v.length > 2 && out) {
|
|
59
|
-
out = out[v[2]];
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (v.length > 3 && out) {
|
|
63
|
-
out = out[v[3]];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (v.length > 4 && out) {
|
|
67
|
-
out = out[v[4]];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (v.length > 5 && out) {
|
|
71
|
-
out = out[v[5]];
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (hide) {
|
|
76
|
-
out = ____0.hide(out);
|
|
77
|
-
} else {
|
|
78
|
-
if (typeof out === 'object') {
|
|
79
|
-
out = ____0.toJson(out);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return out || '';
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function renderUser(v) {
|
|
87
|
-
if (!v) {
|
|
88
|
-
return '';
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
let user = req.session.user;
|
|
92
|
-
if (user) {
|
|
93
|
-
let hide = false;
|
|
94
|
-
let out = '';
|
|
95
|
-
if (v.indexOf('#') == 0) {
|
|
96
|
-
v = v.replace('#', '');
|
|
97
|
-
hide = true;
|
|
98
|
-
}
|
|
99
|
-
if (v == '*') {
|
|
100
|
-
out = JSON.stringify(user);
|
|
101
|
-
} else {
|
|
102
|
-
v = v.split('.');
|
|
103
|
-
|
|
104
|
-
if (v.length > 0) {
|
|
105
|
-
out = user[v[0]];
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (v.length > 1 && out) {
|
|
109
|
-
out = out[v[1]];
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (v.length > 2 && out) {
|
|
113
|
-
out = out[v[2]];
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (v.length > 3 && out) {
|
|
117
|
-
out = out[v[3]];
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (v.length > 4 && out) {
|
|
121
|
-
out = out[v[4]];
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (v.length > 5 && out) {
|
|
125
|
-
out = out[v[5]];
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (typeof out === 'object') {
|
|
130
|
-
out = ____0.toJson(out);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (hide) {
|
|
134
|
-
out = ____0.hide(out);
|
|
135
|
-
} else {
|
|
136
|
-
if (typeof out === 'object') {
|
|
137
|
-
out = ____0.toJson(out);
|
|
138
|
-
}
|
|
139
|
-
if (typeof out === 'undefined') {
|
|
140
|
-
out = '';
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return out;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return '';
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
function render_site(v) {
|
|
150
|
-
if (!v) {
|
|
151
|
-
return '';
|
|
152
|
-
}
|
|
153
|
-
let hide = false;
|
|
154
|
-
let out = '';
|
|
155
|
-
if (v.indexOf('#') == 0) {
|
|
156
|
-
v = v.replace('#', '');
|
|
157
|
-
hide = true;
|
|
158
|
-
}
|
|
159
|
-
if (v == '*') {
|
|
160
|
-
out = JSON.stringify(____0);
|
|
161
|
-
} else {
|
|
162
|
-
v = v.split('.');
|
|
163
|
-
|
|
164
|
-
if (v.length > 0) {
|
|
165
|
-
out = ____0[v[0]];
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if (v.length > 1 && out) {
|
|
169
|
-
out = out[v[1]];
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if (v.length > 2 && out) {
|
|
173
|
-
out = out[v[2]];
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if (v.length > 3 && out) {
|
|
177
|
-
out = out[v[3]];
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (v.length > 4 && out) {
|
|
181
|
-
out = out[v[4]];
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (v.length > 5 && out) {
|
|
185
|
-
out = out[v[5]];
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
if (typeof out === 'object') {
|
|
190
|
-
out = ____0.toJson(out);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
if (hide) {
|
|
194
|
-
out = ____0.hide(out);
|
|
195
|
-
} else {
|
|
196
|
-
if (typeof out === 'object') {
|
|
197
|
-
out = ____0.toJson(out);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
return out;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
function renderSetting(v) {
|
|
204
|
-
if (v && v == '*') {
|
|
205
|
-
return JSON.stringify(____0.setting);
|
|
206
|
-
} else {
|
|
207
|
-
return render_site('setting.' + v);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
function renderRequest(v) {
|
|
211
|
-
if (!v) {
|
|
212
|
-
return '';
|
|
213
|
-
}
|
|
214
|
-
let hide = false;
|
|
215
|
-
let out = '';
|
|
216
|
-
if (v.indexOf('#') == 0) {
|
|
217
|
-
v = v.replace('#', '');
|
|
218
|
-
hide = true;
|
|
219
|
-
}
|
|
220
|
-
if (v == '*') {
|
|
221
|
-
out = JSON.stringify(req);
|
|
222
|
-
} else {
|
|
223
|
-
v = v.split('.');
|
|
224
|
-
|
|
225
|
-
if (v.length > 0) {
|
|
226
|
-
out = req[v[0]];
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
if (v.length > 1 && out) {
|
|
230
|
-
out = out[v[1]];
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
if (v.length > 2 && out) {
|
|
234
|
-
out = out[v[2]];
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
if (v.length > 3 && out) {
|
|
238
|
-
out = out[v[3]];
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
if (v.length > 4 && out) {
|
|
242
|
-
out = out[v[4]];
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (v.length > 5 && out) {
|
|
246
|
-
out = out[v[5]];
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
if (hide) {
|
|
251
|
-
out = ____0.hide(out);
|
|
252
|
-
} else {
|
|
253
|
-
if (typeof out === 'object') {
|
|
254
|
-
out = ____0.toJson(out);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
return typeof out !== 'undefined' ? out : '';
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
function renderSession(v) {
|
|
261
|
-
if (v && v == '*') {
|
|
262
|
-
return JSON.stringify({
|
|
263
|
-
accessToken: req.session.accessToken,
|
|
264
|
-
createdTime: req.session.createdTime,
|
|
265
|
-
modifiedTime: req.session.modifiedTime,
|
|
266
|
-
data: req.session.data,
|
|
267
|
-
requestesCount: req.session.requestesCount,
|
|
268
|
-
busy: req.session.$busy,
|
|
269
|
-
ip: req.session.ip,
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
if (v == 'lang') {
|
|
273
|
-
return req.session.lang;
|
|
274
|
-
} else if (v == 'theme') {
|
|
275
|
-
return req.session.theme;
|
|
276
|
-
} else {
|
|
277
|
-
v = v.split('.');
|
|
278
|
-
if (v.length === 1) {
|
|
279
|
-
return req.session[v[0]];
|
|
280
|
-
}
|
|
281
|
-
if (v.length === 2) {
|
|
282
|
-
let s1 = req.session[v[0]];
|
|
283
|
-
if (s1) {
|
|
284
|
-
return s1[v[1]];
|
|
285
|
-
} else {
|
|
286
|
-
return '';
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
function renderJson(name) {
|
|
293
|
-
return ____0.readFileSync(route.parserDir + '/json/' + name + '.json');
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
function renderWord(name) {
|
|
297
|
-
return req.word(name);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
function getContent(name) {
|
|
301
|
-
let path = null;
|
|
302
|
-
let hide = false;
|
|
303
|
-
if (name.startsWith('#')) {
|
|
304
|
-
hide = true;
|
|
305
|
-
name = name.replace('#', '');
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
if (!path || !____0.isFileExistsSync(path)) {
|
|
309
|
-
let arr = name.split('/');
|
|
310
|
-
if (arr.length === 1) {
|
|
311
|
-
path = ____0.path.join(____0.path.dirname(route.parserDir), 'site_files', ____0.path.extname(arr[0]).replace('.', ''), arr[0]);
|
|
312
|
-
} else if (arr.length === 2) {
|
|
313
|
-
path = ____0.path.join(____0.path.dirname(route.parserDir), 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[0], arr[1]);
|
|
314
|
-
} else if (arr.length === 3) {
|
|
315
|
-
path = ____0.path.join(____0.path.dirname(route.parserDir), 'site_files', ____0.path.extname(arr[2]).replace('.', ''), arr[0], arr[1], arr[2]);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
if (!____0.isFileExistsSync(path)) {
|
|
320
|
-
let arr = name.split('/');
|
|
321
|
-
if (arr.length === 1) {
|
|
322
|
-
path = ____0.path.join(route.parserDir, arr[0]);
|
|
323
|
-
} else if (arr.length === 2) {
|
|
324
|
-
path = ____0.path.join(____0.path.dirname(route.parserDir), 'apps', arr[0], 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
|
|
325
|
-
} else if (arr.length === 3) {
|
|
326
|
-
path = ____0.path.join(____0.path.dirname(route.parserDir), 'apps', arr[0], 'site_files', ____0.path.extname(arr[2]).replace('.', ''), arr[1], arr[2]);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
if (!____0.isFileExistsSync(path)) {
|
|
331
|
-
let arr = name.split('/');
|
|
332
|
-
if (arr.length > 1) {
|
|
333
|
-
____0.apps.forEach((ap) => {
|
|
334
|
-
if (arr.length === 2 && ap.name == arr[0]) {
|
|
335
|
-
path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
|
|
336
|
-
} else if (arr.length === 2 && ap.name2 == arr[0]) {
|
|
337
|
-
path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
|
|
338
|
-
} else if (arr.length === 3 && ap.name == arr[0]) {
|
|
339
|
-
path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[2]).replace('.', ''), arr[1], arr[2]);
|
|
340
|
-
}
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
if (!____0.isFileExistsSync(path)) {
|
|
346
|
-
____0.log(path, 'PATH NOT EXISTS parser.getContent()');
|
|
347
|
-
return '';
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
if (name.endsWith('.content.html')) {
|
|
351
|
-
let txt = ____0.readFileSync(path);
|
|
352
|
-
return txt;
|
|
353
|
-
} else if (name.endsWith('.html')) {
|
|
354
|
-
let txt = ____0.readFileSync(path);
|
|
355
|
-
let $ = ____0.$.load(txt, null, false);
|
|
356
|
-
$ = renderHtml($);
|
|
357
|
-
return $.html();
|
|
358
|
-
} else if (name.endsWith('.js')) {
|
|
359
|
-
let txt = ____0.readFileSync(path);
|
|
360
|
-
txt = parser.js(txt);
|
|
361
|
-
if (hide) {
|
|
362
|
-
txt = ____0.hide(txt);
|
|
363
|
-
}
|
|
364
|
-
return txt;
|
|
365
|
-
} else if (name.endsWith('.css')) {
|
|
366
|
-
let txt = ____0.readFileSync(path);
|
|
367
|
-
txt = parser.css(txt);
|
|
368
|
-
return txt;
|
|
369
|
-
} else {
|
|
370
|
-
let txt = ____0.readFileSync(path);
|
|
371
|
-
if (hide) {
|
|
372
|
-
txt = ____0.hide(txt);
|
|
373
|
-
}
|
|
374
|
-
return txt;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
function handleXList1($, el, data) {
|
|
379
|
-
let property = $(el).attr('x-list1').split('.');
|
|
380
|
-
$(el).removeAttr('x-list1');
|
|
381
|
-
let list = null;
|
|
382
|
-
let html2 = '';
|
|
383
|
-
if (property.length > 0) {
|
|
384
|
-
if (property[0] == '*') {
|
|
385
|
-
list = data;
|
|
386
|
-
} else {
|
|
387
|
-
list = data[property[0]];
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
if (list && property.length > 1) {
|
|
391
|
-
list = list[property[1]];
|
|
392
|
-
}
|
|
393
|
-
if (list && property.length > 2) {
|
|
394
|
-
list = list[property[2]];
|
|
395
|
-
}
|
|
396
|
-
if (Array.isArray(list)) {
|
|
397
|
-
let matches = $.html(el).match(/##item1.*?##/g);
|
|
398
|
-
list.forEach((item, i) => {
|
|
399
|
-
$(el).attr('x-item1', i);
|
|
400
|
-
let _html = $.html(el);
|
|
401
|
-
if (matches) {
|
|
402
|
-
for (let i = 0; i < matches.length; i++) {
|
|
403
|
-
let p = matches[i].replace('##item1.', '').replace('##', '').split('.');
|
|
404
|
-
let v = null;
|
|
405
|
-
if (p.length > 0) {
|
|
406
|
-
if (p[0] == '*' || !p[0]) {
|
|
407
|
-
v = item;
|
|
408
|
-
} else {
|
|
409
|
-
v = item[p[0]];
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
if (p.length > 1 && v) {
|
|
413
|
-
v = v[p[1]];
|
|
414
|
-
}
|
|
415
|
-
if (p.length > 2 && v) {
|
|
416
|
-
v = v[p[2]];
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
_html = _html.replace(matches[i], v || '');
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
let $2 = ____0.$.load(_html);
|
|
423
|
-
$2('[x-show-item1]').each(function (i, elem) {
|
|
424
|
-
let property = $(elem).attr('x-show-item1').split('.');
|
|
425
|
-
let out = null;
|
|
426
|
-
if (property.length > 0) {
|
|
427
|
-
if (property.length > 0) {
|
|
428
|
-
out = item[property[0]];
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
if (property.length > 1 && out) {
|
|
432
|
-
out = out[property[1]];
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
if (property.length > 2 && out) {
|
|
436
|
-
out = out[property[2]];
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
if (property.length > 3 && out) {
|
|
440
|
-
out = out[property[3]];
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
if (property.length > 4 && out) {
|
|
444
|
-
out = out[property[4]];
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
if (property.length > 5 && out) {
|
|
448
|
-
out = out[property[5]];
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
if (!out) {
|
|
452
|
-
$(this).remove();
|
|
453
|
-
} else {
|
|
454
|
-
$(this).removeAttr('x-show-item1');
|
|
455
|
-
}
|
|
456
|
-
});
|
|
457
|
-
$2('[x-list2]').each(function (i2, elem2) {
|
|
458
|
-
$(handleXList2($2, elem2, item)).insertAfter($(this));
|
|
459
|
-
$(this).remove();
|
|
460
|
-
});
|
|
461
|
-
html2 += $2.html();
|
|
462
|
-
});
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
return html2;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
function handleXList2($, el, data) {
|
|
469
|
-
let property = $(el).attr('x-list2').split('.');
|
|
470
|
-
$(el).removeAttr('x-list2');
|
|
471
|
-
let list = null;
|
|
472
|
-
let html2 = '';
|
|
473
|
-
if (property.length > 0) {
|
|
474
|
-
if (property[0] == '*') {
|
|
475
|
-
list = data;
|
|
476
|
-
} else {
|
|
477
|
-
list = data[property[0]];
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
if (list && property.length > 1) {
|
|
481
|
-
list = list[property[1]];
|
|
482
|
-
}
|
|
483
|
-
if (Array.isArray(list)) {
|
|
484
|
-
let matches = $.html(el).match(/##item2.*?##/g);
|
|
485
|
-
list.forEach((item, i) => {
|
|
486
|
-
$(el).attr('x-item2', i);
|
|
487
|
-
let _html = $.html(el);
|
|
488
|
-
if (matches) {
|
|
489
|
-
for (let i = 0; i < matches.length; i++) {
|
|
490
|
-
let p = matches[i].replace('##item2.', '').replace('##', '').split('.');
|
|
491
|
-
let v = null;
|
|
492
|
-
if (p.length > 0) {
|
|
493
|
-
if (p[0] == '*' || !p[0]) {
|
|
494
|
-
v = item;
|
|
495
|
-
} else {
|
|
496
|
-
v = item[p[0]];
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
if (p.length > 1 && v) {
|
|
500
|
-
v = v[p[1]];
|
|
501
|
-
}
|
|
502
|
-
if (p.length > 2 && v) {
|
|
503
|
-
v = v[p[2]];
|
|
504
|
-
}
|
|
505
|
-
_html = _html.replace(matches[i], v || '');
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
let $2 = ____0.$.load(_html);
|
|
509
|
-
$2('[x-show-item2]').each(function (i, elem) {
|
|
510
|
-
let property = $(elem).attr('x-show-item2').split('.');
|
|
511
|
-
let out = null;
|
|
512
|
-
if (property.length > 0) {
|
|
513
|
-
if (property.length > 0) {
|
|
514
|
-
out = item[property[0]];
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
if (property.length > 1 && out) {
|
|
518
|
-
out = out[property[1]];
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
if (property.length > 2 && out) {
|
|
522
|
-
out = out[property[2]];
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
if (property.length > 3 && out) {
|
|
526
|
-
out = out[property[3]];
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
if (property.length > 4 && out) {
|
|
530
|
-
out = out[property[4]];
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
if (property.length > 5 && out) {
|
|
534
|
-
out = out[property[5]];
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
if (!out) {
|
|
538
|
-
$(this).remove();
|
|
539
|
-
} else {
|
|
540
|
-
$(this).removeAttr('x-show-item2');
|
|
541
|
-
}
|
|
542
|
-
});
|
|
543
|
-
html2 += $2.html();
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
return html2;
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
function renderHtml($, log) {
|
|
550
|
-
$('[x-setting]').each(function (i, elem) {
|
|
551
|
-
let property = $(elem).attr('x-setting').split('.');
|
|
552
|
-
let out = null;
|
|
553
|
-
if (property.length > 0) {
|
|
554
|
-
if (property.length > 0) {
|
|
555
|
-
out = ____0.setting[property[0]];
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
if (property.length > 1 && out) {
|
|
559
|
-
if (out) {
|
|
560
|
-
out = out[property[1]];
|
|
561
|
-
} else {
|
|
562
|
-
out = null;
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
if (property.length > 2 && out) {
|
|
566
|
-
if (out) {
|
|
567
|
-
out = out[property[2]];
|
|
568
|
-
} else {
|
|
569
|
-
out = null;
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
if (property.length > 3 && out) {
|
|
573
|
-
if (out) {
|
|
574
|
-
out = out[property[3]];
|
|
575
|
-
} else {
|
|
576
|
-
out = null;
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
if (property.length > 4 && out) {
|
|
580
|
-
if (out) {
|
|
581
|
-
out = out[property[4]];
|
|
582
|
-
} else {
|
|
583
|
-
out = null;
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
if (!out) {
|
|
588
|
-
$(this).remove();
|
|
589
|
-
} else {
|
|
590
|
-
$(this).removeAttr('x-setting');
|
|
591
|
-
}
|
|
592
|
-
});
|
|
593
|
-
|
|
594
|
-
$('[x-data]').each(function (i, elem) {
|
|
595
|
-
let property = $(elem).attr('x-data').split('.');
|
|
596
|
-
let out = null;
|
|
597
|
-
if (property.length > 0) {
|
|
598
|
-
if (property.length > 0) {
|
|
599
|
-
out = req.data[property[0]];
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
if (property.length > 1 && out) {
|
|
603
|
-
if (out) {
|
|
604
|
-
out = out[property[1]];
|
|
605
|
-
} else {
|
|
606
|
-
out = null;
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
if (property.length > 2 && out) {
|
|
610
|
-
if (out) {
|
|
611
|
-
out = out[property[2]];
|
|
612
|
-
} else {
|
|
613
|
-
out = null;
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
if (property.length > 3 && out) {
|
|
617
|
-
if (out) {
|
|
618
|
-
out = out[property[3]];
|
|
619
|
-
} else {
|
|
620
|
-
out = null;
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
if (property.length > 4 && out) {
|
|
624
|
-
if (out) {
|
|
625
|
-
out = out[property[4]];
|
|
626
|
-
} else {
|
|
627
|
-
out = null;
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
if (!out) {
|
|
632
|
-
$(this).remove();
|
|
633
|
-
} else {
|
|
634
|
-
$(this).removeAttr('x-data');
|
|
635
|
-
}
|
|
636
|
-
});
|
|
637
|
-
|
|
638
|
-
$('[x-permission]').each(function (i, elem) {
|
|
639
|
-
if (!____0.security.isUserHasPermission(req, res, $(this).attr('x-permission'))) {
|
|
640
|
-
$(this).remove();
|
|
641
|
-
} else {
|
|
642
|
-
$(this).removeAttr('x-permission');
|
|
643
|
-
}
|
|
644
|
-
});
|
|
645
|
-
|
|
646
|
-
$('[x-role]').each(function (i, elem) {
|
|
647
|
-
if (!____0.security.isUserHasRole(req, res, $(this).attr('x-role'))) {
|
|
648
|
-
$(this).remove();
|
|
649
|
-
} else {
|
|
650
|
-
$(this).removeAttr('x-role');
|
|
651
|
-
}
|
|
652
|
-
});
|
|
653
|
-
|
|
654
|
-
$('[x-permissions]').each(function (i, elem) {
|
|
655
|
-
if (!____0.security.isUserHasPermissions(req, res, $(this).attr('x-permissions'))) {
|
|
656
|
-
$(this).remove();
|
|
657
|
-
} else {
|
|
658
|
-
$(this).removeAttr('x-permissions');
|
|
659
|
-
}
|
|
660
|
-
});
|
|
661
|
-
|
|
662
|
-
$('[x-roles]').each(function (i, elem) {
|
|
663
|
-
if (!____0.security.isUserHasRoles(req, res, $(this).attr('x-roles'))) {
|
|
664
|
-
$(this).remove();
|
|
665
|
-
} else {
|
|
666
|
-
$(this).removeAttr('x-roles');
|
|
667
|
-
}
|
|
668
|
-
});
|
|
669
|
-
|
|
670
|
-
$('[x-lang]').each(function (i, elem) {
|
|
671
|
-
if ($(this).attr('x-lang') !== req.session.lang) {
|
|
672
|
-
$(this).remove();
|
|
673
|
-
} else {
|
|
674
|
-
$(this).removeAttr('x-lang');
|
|
675
|
-
}
|
|
676
|
-
});
|
|
677
|
-
|
|
678
|
-
$('[x-feature]').each(function (i, elem) {
|
|
679
|
-
let f = $(this).attr('x-feature');
|
|
680
|
-
let not = !1;
|
|
681
|
-
if (f.startsWith('!')) {
|
|
682
|
-
f = f.replace('!', '');
|
|
683
|
-
not = !0;
|
|
684
|
-
}
|
|
685
|
-
if (!req.features.some((ff) => ff.like(f)) && !not) {
|
|
686
|
-
$(this).remove();
|
|
687
|
-
} else if (req.features.some((ff) => ff.like(f)) && not) {
|
|
688
|
-
$(this).remove();
|
|
689
|
-
} else {
|
|
690
|
-
$(this).removeAttr('x-feature');
|
|
691
|
-
}
|
|
692
|
-
});
|
|
693
|
-
|
|
694
|
-
$('[x-features]').each(function (i, elem) {
|
|
695
|
-
let fs = $(this).attr('x-features');
|
|
696
|
-
if (fs.indexOf('||') > -1) {
|
|
697
|
-
let del = !0;
|
|
698
|
-
fs.split('||').forEach((f) => {
|
|
699
|
-
f = f.trim();
|
|
700
|
-
let not = !1;
|
|
701
|
-
if (f.startsWith('!')) {
|
|
702
|
-
f = f.replace('!', '');
|
|
703
|
-
not = !0;
|
|
704
|
-
}
|
|
705
|
-
if (req.features.some((ff) => ff.like(f)) && !not) {
|
|
706
|
-
del = !1;
|
|
707
|
-
}
|
|
708
|
-
if (!req.features.some((ff) => ff.like(f)) && not) {
|
|
709
|
-
del = !1;
|
|
710
|
-
}
|
|
711
|
-
});
|
|
712
|
-
|
|
713
|
-
if (del) {
|
|
714
|
-
$(this).remove();
|
|
715
|
-
}
|
|
716
|
-
} else if (fs.indexOf('&&') > -1) {
|
|
717
|
-
let ok_list = [];
|
|
718
|
-
fs.split('&&').forEach((f) => {
|
|
719
|
-
f = f.trim();
|
|
720
|
-
let d = !0;
|
|
721
|
-
if (f.startsWith('!')) {
|
|
722
|
-
f = f.replace('!', '');
|
|
723
|
-
d = !1;
|
|
724
|
-
}
|
|
725
|
-
if (!req.features.some((ff) => ff.like(f)) && !d) {
|
|
726
|
-
ok_list.push({});
|
|
727
|
-
}
|
|
728
|
-
if (req.features.some((ff) => ff.like(f)) && d) {
|
|
729
|
-
ok_list.push({});
|
|
730
|
-
}
|
|
731
|
-
});
|
|
732
|
-
if (ok_list.length !== fs.split('&&').length) {
|
|
733
|
-
$(this).remove();
|
|
734
|
-
}
|
|
735
|
-
} else {
|
|
736
|
-
f = fs.trim();
|
|
737
|
-
let d = !0;
|
|
738
|
-
if (f.startsWith('!')) {
|
|
739
|
-
f = f.replace('!', '');
|
|
740
|
-
d = !1;
|
|
741
|
-
}
|
|
742
|
-
if (!req.features.some((ff) => ff.like(f)) && d) {
|
|
743
|
-
$(this).remove();
|
|
744
|
-
}
|
|
745
|
-
if (req.features.some((ff) => ff.like(f)) && !d) {
|
|
746
|
-
$(this).remove();
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
});
|
|
750
|
-
|
|
751
|
-
if (route.parser.like('*css*')) {
|
|
752
|
-
$('style').each(function (i, elem) {
|
|
753
|
-
$(this).html(parser.css($(this).html()));
|
|
754
|
-
});
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
if (route.parser.like('*js*')) {
|
|
758
|
-
$('script').each(function (i, elem) {
|
|
759
|
-
$(this).html(parser.js($(this).html()));
|
|
760
|
-
});
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
$($('[x-import]').get().reverse()).each(function (i, elem) {
|
|
764
|
-
let file = $(this).attr('x-import');
|
|
765
|
-
if (file.endsWith('.html')) {
|
|
766
|
-
$(this).html(getContent(file) + $(this).html());
|
|
767
|
-
} else if (file.endsWith('.css')) {
|
|
768
|
-
$(this).text(getContent(file) + $(this).html());
|
|
769
|
-
} else {
|
|
770
|
-
$(this).text(getContent(file) + $(this).text());
|
|
771
|
-
}
|
|
772
|
-
$(this).removeAttr('x-import');
|
|
773
|
-
});
|
|
774
|
-
|
|
775
|
-
$($('[x-append]').get().reverse()).each(function (i, elem) {
|
|
776
|
-
let file = $(this).attr('x-append');
|
|
777
|
-
$(this).removeAttr('x-append');
|
|
778
|
-
if (file.endsWith('.html')) {
|
|
779
|
-
$(this).html($(this).html() + getContent(file));
|
|
780
|
-
} else if (file.endsWith('.css')) {
|
|
781
|
-
$(this).text($(this).html() + getContent(file));
|
|
782
|
-
} else {
|
|
783
|
-
$(this).text($(this).text() + getContent(file));
|
|
784
|
-
}
|
|
785
|
-
$(this).removeAttr('x-append');
|
|
786
|
-
});
|
|
787
|
-
|
|
788
|
-
$($('[x-replace]').get().reverse()).each(function (i, elem) {
|
|
789
|
-
let file = $(this).attr('x-replace');
|
|
790
|
-
|
|
791
|
-
$(getContent(file)).insertAfter($(this));
|
|
792
|
-
$(this).remove();
|
|
793
|
-
|
|
794
|
-
$(this).removeAttr('x-replace');
|
|
795
|
-
});
|
|
796
|
-
|
|
797
|
-
$('[x-list1]').each(function (i, elem) {
|
|
798
|
-
$(handleXList1($, elem, req.data)).insertAfter($(this));
|
|
799
|
-
$(this).remove();
|
|
800
|
-
});
|
|
801
|
-
$('[x-list2]').each(function (i, elem) {
|
|
802
|
-
$(handleXList2($, elem, req.data)).insertAfter($(this));
|
|
803
|
-
$(this).remove();
|
|
804
|
-
});
|
|
805
|
-
return $;
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
parser.handleMatches = function (txt) {
|
|
809
|
-
let matches = txt.match(/##.*?##/g);
|
|
810
|
-
if (matches) {
|
|
811
|
-
for (let i = 0; i < matches.length; i++) {
|
|
812
|
-
let v = matches[i];
|
|
813
|
-
|
|
814
|
-
if (v.startsWith('##var.')) {
|
|
815
|
-
v = v.replace('##var.', '').replace('##', '');
|
|
816
|
-
txt = txt.replace(matches[i], renderVar(v));
|
|
817
|
-
} else if (v.startsWith('##word.')) {
|
|
818
|
-
v = v.replace('##word.', '').replace('##', '');
|
|
819
|
-
txt = txt.replace(matches[i], renderWord(v));
|
|
820
|
-
} else if (v.startsWith('##user.')) {
|
|
821
|
-
v = v.replace('##user.', '').replace('##', '');
|
|
822
|
-
txt = txt.replace(matches[i], renderUser(v));
|
|
823
|
-
} else if (v.startsWith('##site.')) {
|
|
824
|
-
v = v.replace('##site.', '').replace('##', '');
|
|
825
|
-
txt = txt.replace(matches[i], render_site(v));
|
|
826
|
-
} else if (v.startsWith('##req.')) {
|
|
827
|
-
v = v.replace('##req.', '').replace('##', '');
|
|
828
|
-
txt = txt.replace(matches[i], renderRequest(v));
|
|
829
|
-
} else if (v.startsWith('##session.')) {
|
|
830
|
-
v = v.replace('##session.', '').replace('##', '');
|
|
831
|
-
txt = txt.replace(matches[i], renderSession(v));
|
|
832
|
-
} else if (v.startsWith('##json.')) {
|
|
833
|
-
v = v.replace('##json.', '').replace('##', '');
|
|
834
|
-
txt = txt.replace(matches[i], renderJson(v));
|
|
835
|
-
} else if (v.startsWith('##setting.')) {
|
|
836
|
-
v = v.replace('##setting.', '').replace('##', '');
|
|
837
|
-
txt = txt.replace(matches[i], renderSetting(v));
|
|
838
|
-
} else if (v.startsWith('##params.')) {
|
|
839
|
-
v = v.replace('##params.', '').replace('##', '');
|
|
840
|
-
txt = txt.replace(matches[i], renderParam(v));
|
|
841
|
-
} else if (v.startsWith('##query.')) {
|
|
842
|
-
v = v.replace('##query.', '').replace('##', '');
|
|
843
|
-
txt = txt.replace(matches[i], renderQuery(v));
|
|
844
|
-
} else if (v.startsWith('##data.')) {
|
|
845
|
-
v = v.replace('##data.', '').replace('##', '');
|
|
846
|
-
txt = txt.replace(matches[i], renderData(v));
|
|
847
|
-
} else {
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
return txt;
|
|
852
|
-
};
|
|
853
|
-
|
|
854
|
-
parser.html = function (content) {
|
|
855
|
-
let $ = ____0.$.load(content);
|
|
856
|
-
$ = renderHtml($);
|
|
857
|
-
txt = parser.handleMatches($.html());
|
|
858
|
-
return txt;
|
|
859
|
-
};
|
|
860
|
-
parser.txt = function (content) {
|
|
861
|
-
content = parser.handleMatches(content);
|
|
862
|
-
return content;
|
|
863
|
-
};
|
|
864
|
-
|
|
865
|
-
parser.js = function (content) {
|
|
866
|
-
let matches = content.match(/\/\*##.*?\*\//g);
|
|
867
|
-
if (matches) {
|
|
868
|
-
for (let i = 0; i < matches.length; i++) {
|
|
869
|
-
let v = matches[i];
|
|
870
|
-
v = v.replace('/*##', '').replace('*/', '');
|
|
871
|
-
content = content.replace(matches[i], getContent(v));
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
content = parser.handleMatches(content);
|
|
875
|
-
return content;
|
|
876
|
-
};
|
|
877
|
-
|
|
878
|
-
parser.css = function (content) {
|
|
879
|
-
content = parser.handleMatches(content);
|
|
880
|
-
|
|
881
|
-
let matches = content.match(/var\(---.*?\)/g);
|
|
882
|
-
if (matches) {
|
|
883
|
-
for (let i = 0; i < matches.length; i++) {
|
|
884
|
-
let v = matches[i];
|
|
885
|
-
|
|
886
|
-
v = v.replace('var(---', '').replace(')', '');
|
|
887
|
-
content = content.replace(matches[i], renderVar(v));
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
let matches2 = content.match(/word\(---.*?\)/g);
|
|
892
|
-
if (matches2) {
|
|
893
|
-
for (let i = 0; i < matches2.length; i++) {
|
|
894
|
-
let v = matches2[i];
|
|
895
|
-
|
|
896
|
-
v = v.replace('word(---', '').replace(')', '');
|
|
897
|
-
content = content.replace(matches2[i], renderWord(v));
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
return content;
|
|
902
|
-
};
|
|
903
|
-
|
|
904
|
-
parser.json = function (content) {
|
|
905
|
-
return content;
|
|
906
|
-
};
|
|
907
|
-
|
|
908
|
-
parser.renderHtml = renderHtml;
|
|
909
|
-
return parser;
|
|
910
|
-
};
|
|
1
|
+
module.exports = function init(req, res, ____0, route) {
|
|
2
|
+
req.features = req.features || [];
|
|
3
|
+
|
|
4
|
+
let parser = {};
|
|
5
|
+
|
|
6
|
+
function renderVar(v) {
|
|
7
|
+
if (v && v == '*') {
|
|
8
|
+
return JSON.stringify(____0.var);
|
|
9
|
+
}
|
|
10
|
+
return ____0.var(v);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function renderParam(v) {
|
|
14
|
+
if (typeof req.paramsRaw[v] !== undefined) {
|
|
15
|
+
if (v && v == '*') {
|
|
16
|
+
return JSON.stringify(req.paramsRaw);
|
|
17
|
+
}
|
|
18
|
+
return req.paramsRaw[v];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return ' ';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function renderQuery(v) {
|
|
25
|
+
if (typeof req.queryRaw[v] !== undefined) {
|
|
26
|
+
if (v && v == '*') {
|
|
27
|
+
return JSON.stringify(req.queryRaw);
|
|
28
|
+
}
|
|
29
|
+
return req.queryRaw[v];
|
|
30
|
+
}
|
|
31
|
+
return ' ';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function renderData(d) {
|
|
35
|
+
if (!d) {
|
|
36
|
+
return '';
|
|
37
|
+
}
|
|
38
|
+
let hide = false;
|
|
39
|
+
let out = '';
|
|
40
|
+
if (d.indexOf('#') == 0) {
|
|
41
|
+
d = d.replace('#', '');
|
|
42
|
+
hide = true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (d == '*') {
|
|
46
|
+
out = JSON.stringify(req.data);
|
|
47
|
+
} else if (d) {
|
|
48
|
+
v = d.split('.');
|
|
49
|
+
|
|
50
|
+
if (v.length > 0) {
|
|
51
|
+
out = req.data[v[0]];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (v.length > 1 && out) {
|
|
55
|
+
out = out[v[1]];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (v.length > 2 && out) {
|
|
59
|
+
out = out[v[2]];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (v.length > 3 && out) {
|
|
63
|
+
out = out[v[3]];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (v.length > 4 && out) {
|
|
67
|
+
out = out[v[4]];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (v.length > 5 && out) {
|
|
71
|
+
out = out[v[5]];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (hide) {
|
|
76
|
+
out = ____0.hide(out);
|
|
77
|
+
} else {
|
|
78
|
+
if (typeof out === 'object') {
|
|
79
|
+
out = ____0.toJson(out);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return out || '';
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function renderUser(v) {
|
|
87
|
+
if (!v) {
|
|
88
|
+
return '';
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
let user = req.session.user;
|
|
92
|
+
if (user) {
|
|
93
|
+
let hide = false;
|
|
94
|
+
let out = '';
|
|
95
|
+
if (v.indexOf('#') == 0) {
|
|
96
|
+
v = v.replace('#', '');
|
|
97
|
+
hide = true;
|
|
98
|
+
}
|
|
99
|
+
if (v == '*') {
|
|
100
|
+
out = JSON.stringify(user);
|
|
101
|
+
} else {
|
|
102
|
+
v = v.split('.');
|
|
103
|
+
|
|
104
|
+
if (v.length > 0) {
|
|
105
|
+
out = user[v[0]];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (v.length > 1 && out) {
|
|
109
|
+
out = out[v[1]];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (v.length > 2 && out) {
|
|
113
|
+
out = out[v[2]];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (v.length > 3 && out) {
|
|
117
|
+
out = out[v[3]];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (v.length > 4 && out) {
|
|
121
|
+
out = out[v[4]];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (v.length > 5 && out) {
|
|
125
|
+
out = out[v[5]];
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (typeof out === 'object') {
|
|
130
|
+
out = ____0.toJson(out);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (hide) {
|
|
134
|
+
out = ____0.hide(out);
|
|
135
|
+
} else {
|
|
136
|
+
if (typeof out === 'object') {
|
|
137
|
+
out = ____0.toJson(out);
|
|
138
|
+
}
|
|
139
|
+
if (typeof out === 'undefined') {
|
|
140
|
+
out = '';
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return out;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return '';
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function render_site(v) {
|
|
150
|
+
if (!v) {
|
|
151
|
+
return '';
|
|
152
|
+
}
|
|
153
|
+
let hide = false;
|
|
154
|
+
let out = '';
|
|
155
|
+
if (v.indexOf('#') == 0) {
|
|
156
|
+
v = v.replace('#', '');
|
|
157
|
+
hide = true;
|
|
158
|
+
}
|
|
159
|
+
if (v == '*') {
|
|
160
|
+
out = JSON.stringify(____0);
|
|
161
|
+
} else {
|
|
162
|
+
v = v.split('.');
|
|
163
|
+
|
|
164
|
+
if (v.length > 0) {
|
|
165
|
+
out = ____0[v[0]];
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (v.length > 1 && out) {
|
|
169
|
+
out = out[v[1]];
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (v.length > 2 && out) {
|
|
173
|
+
out = out[v[2]];
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (v.length > 3 && out) {
|
|
177
|
+
out = out[v[3]];
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (v.length > 4 && out) {
|
|
181
|
+
out = out[v[4]];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (v.length > 5 && out) {
|
|
185
|
+
out = out[v[5]];
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (typeof out === 'object') {
|
|
190
|
+
out = ____0.toJson(out);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (hide) {
|
|
194
|
+
out = ____0.hide(out);
|
|
195
|
+
} else {
|
|
196
|
+
if (typeof out === 'object') {
|
|
197
|
+
out = ____0.toJson(out);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return out;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function renderSetting(v) {
|
|
204
|
+
if (v && v == '*') {
|
|
205
|
+
return JSON.stringify(____0.setting);
|
|
206
|
+
} else {
|
|
207
|
+
return render_site('setting.' + v);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
function renderRequest(v) {
|
|
211
|
+
if (!v) {
|
|
212
|
+
return '';
|
|
213
|
+
}
|
|
214
|
+
let hide = false;
|
|
215
|
+
let out = '';
|
|
216
|
+
if (v.indexOf('#') == 0) {
|
|
217
|
+
v = v.replace('#', '');
|
|
218
|
+
hide = true;
|
|
219
|
+
}
|
|
220
|
+
if (v == '*') {
|
|
221
|
+
out = JSON.stringify(req);
|
|
222
|
+
} else {
|
|
223
|
+
v = v.split('.');
|
|
224
|
+
|
|
225
|
+
if (v.length > 0) {
|
|
226
|
+
out = req[v[0]];
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (v.length > 1 && out) {
|
|
230
|
+
out = out[v[1]];
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (v.length > 2 && out) {
|
|
234
|
+
out = out[v[2]];
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (v.length > 3 && out) {
|
|
238
|
+
out = out[v[3]];
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (v.length > 4 && out) {
|
|
242
|
+
out = out[v[4]];
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (v.length > 5 && out) {
|
|
246
|
+
out = out[v[5]];
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (hide) {
|
|
251
|
+
out = ____0.hide(out);
|
|
252
|
+
} else {
|
|
253
|
+
if (typeof out === 'object') {
|
|
254
|
+
out = ____0.toJson(out);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return typeof out !== 'undefined' ? out : '';
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function renderSession(v) {
|
|
261
|
+
if (v && v == '*') {
|
|
262
|
+
return JSON.stringify({
|
|
263
|
+
accessToken: req.session.accessToken,
|
|
264
|
+
createdTime: req.session.createdTime,
|
|
265
|
+
modifiedTime: req.session.modifiedTime,
|
|
266
|
+
data: req.session.data,
|
|
267
|
+
requestesCount: req.session.requestesCount,
|
|
268
|
+
busy: req.session.$busy,
|
|
269
|
+
ip: req.session.ip,
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
if (v == 'lang') {
|
|
273
|
+
return req.session.lang;
|
|
274
|
+
} else if (v == 'theme') {
|
|
275
|
+
return req.session.theme;
|
|
276
|
+
} else {
|
|
277
|
+
v = v.split('.');
|
|
278
|
+
if (v.length === 1) {
|
|
279
|
+
return req.session[v[0]];
|
|
280
|
+
}
|
|
281
|
+
if (v.length === 2) {
|
|
282
|
+
let s1 = req.session[v[0]];
|
|
283
|
+
if (s1) {
|
|
284
|
+
return s1[v[1]];
|
|
285
|
+
} else {
|
|
286
|
+
return '';
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function renderJson(name) {
|
|
293
|
+
return ____0.readFileSync(route.parserDir + '/json/' + name + '.json');
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function renderWord(name) {
|
|
297
|
+
return req.word(name);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function getContent(name) {
|
|
301
|
+
let path = null;
|
|
302
|
+
let hide = false;
|
|
303
|
+
if (name.startsWith('#')) {
|
|
304
|
+
hide = true;
|
|
305
|
+
name = name.replace('#', '');
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (!path || !____0.isFileExistsSync(path)) {
|
|
309
|
+
let arr = name.split('/');
|
|
310
|
+
if (arr.length === 1) {
|
|
311
|
+
path = ____0.path.join(____0.path.dirname(route.parserDir), 'site_files', ____0.path.extname(arr[0]).replace('.', ''), arr[0]);
|
|
312
|
+
} else if (arr.length === 2) {
|
|
313
|
+
path = ____0.path.join(____0.path.dirname(route.parserDir), 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[0], arr[1]);
|
|
314
|
+
} else if (arr.length === 3) {
|
|
315
|
+
path = ____0.path.join(____0.path.dirname(route.parserDir), 'site_files', ____0.path.extname(arr[2]).replace('.', ''), arr[0], arr[1], arr[2]);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if (!____0.isFileExistsSync(path)) {
|
|
320
|
+
let arr = name.split('/');
|
|
321
|
+
if (arr.length === 1) {
|
|
322
|
+
path = ____0.path.join(route.parserDir, arr[0]);
|
|
323
|
+
} else if (arr.length === 2) {
|
|
324
|
+
path = ____0.path.join(____0.path.dirname(route.parserDir), 'apps', arr[0], 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
|
|
325
|
+
} else if (arr.length === 3) {
|
|
326
|
+
path = ____0.path.join(____0.path.dirname(route.parserDir), 'apps', arr[0], 'site_files', ____0.path.extname(arr[2]).replace('.', ''), arr[1], arr[2]);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (!____0.isFileExistsSync(path)) {
|
|
331
|
+
let arr = name.split('/');
|
|
332
|
+
if (arr.length > 1) {
|
|
333
|
+
____0.apps.forEach((ap) => {
|
|
334
|
+
if (arr.length === 2 && ap.name == arr[0]) {
|
|
335
|
+
path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
|
|
336
|
+
} else if (arr.length === 2 && ap.name2 == arr[0]) {
|
|
337
|
+
path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
|
|
338
|
+
} else if (arr.length === 3 && ap.name == arr[0]) {
|
|
339
|
+
path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[2]).replace('.', ''), arr[1], arr[2]);
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (!____0.isFileExistsSync(path)) {
|
|
346
|
+
____0.log(path, 'PATH NOT EXISTS parser.getContent()');
|
|
347
|
+
return '';
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
if (name.endsWith('.content.html')) {
|
|
351
|
+
let txt = ____0.readFileSync(path);
|
|
352
|
+
return txt;
|
|
353
|
+
} else if (name.endsWith('.html')) {
|
|
354
|
+
let txt = ____0.readFileSync(path);
|
|
355
|
+
let $ = ____0.$.load(txt, null, false);
|
|
356
|
+
$ = renderHtml($);
|
|
357
|
+
return $.html();
|
|
358
|
+
} else if (name.endsWith('.js')) {
|
|
359
|
+
let txt = ____0.readFileSync(path);
|
|
360
|
+
txt = parser.js(txt);
|
|
361
|
+
if (hide) {
|
|
362
|
+
txt = ____0.hide(txt);
|
|
363
|
+
}
|
|
364
|
+
return txt;
|
|
365
|
+
} else if (name.endsWith('.css')) {
|
|
366
|
+
let txt = ____0.readFileSync(path);
|
|
367
|
+
txt = parser.css(txt);
|
|
368
|
+
return txt;
|
|
369
|
+
} else {
|
|
370
|
+
let txt = ____0.readFileSync(path);
|
|
371
|
+
if (hide) {
|
|
372
|
+
txt = ____0.hide(txt);
|
|
373
|
+
}
|
|
374
|
+
return txt;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function handleXList1($, el, data) {
|
|
379
|
+
let property = $(el).attr('x-list1').split('.');
|
|
380
|
+
$(el).removeAttr('x-list1');
|
|
381
|
+
let list = null;
|
|
382
|
+
let html2 = '';
|
|
383
|
+
if (property.length > 0) {
|
|
384
|
+
if (property[0] == '*') {
|
|
385
|
+
list = data;
|
|
386
|
+
} else {
|
|
387
|
+
list = data[property[0]];
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
if (list && property.length > 1) {
|
|
391
|
+
list = list[property[1]];
|
|
392
|
+
}
|
|
393
|
+
if (list && property.length > 2) {
|
|
394
|
+
list = list[property[2]];
|
|
395
|
+
}
|
|
396
|
+
if (Array.isArray(list)) {
|
|
397
|
+
let matches = $.html(el).match(/##item1.*?##/g);
|
|
398
|
+
list.forEach((item, i) => {
|
|
399
|
+
$(el).attr('x-item1', i);
|
|
400
|
+
let _html = $.html(el);
|
|
401
|
+
if (matches) {
|
|
402
|
+
for (let i = 0; i < matches.length; i++) {
|
|
403
|
+
let p = matches[i].replace('##item1.', '').replace('##', '').split('.');
|
|
404
|
+
let v = null;
|
|
405
|
+
if (p.length > 0) {
|
|
406
|
+
if (p[0] == '*' || !p[0]) {
|
|
407
|
+
v = item;
|
|
408
|
+
} else {
|
|
409
|
+
v = item[p[0]];
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
if (p.length > 1 && v) {
|
|
413
|
+
v = v[p[1]];
|
|
414
|
+
}
|
|
415
|
+
if (p.length > 2 && v) {
|
|
416
|
+
v = v[p[2]];
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
_html = _html.replace(matches[i], v || '');
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
let $2 = ____0.$.load(_html);
|
|
423
|
+
$2('[x-show-item1]').each(function (i, elem) {
|
|
424
|
+
let property = $(elem).attr('x-show-item1').split('.');
|
|
425
|
+
let out = null;
|
|
426
|
+
if (property.length > 0) {
|
|
427
|
+
if (property.length > 0) {
|
|
428
|
+
out = item[property[0]];
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
if (property.length > 1 && out) {
|
|
432
|
+
out = out[property[1]];
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
if (property.length > 2 && out) {
|
|
436
|
+
out = out[property[2]];
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
if (property.length > 3 && out) {
|
|
440
|
+
out = out[property[3]];
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
if (property.length > 4 && out) {
|
|
444
|
+
out = out[property[4]];
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
if (property.length > 5 && out) {
|
|
448
|
+
out = out[property[5]];
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
if (!out) {
|
|
452
|
+
$(this).remove();
|
|
453
|
+
} else {
|
|
454
|
+
$(this).removeAttr('x-show-item1');
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
$2('[x-list2]').each(function (i2, elem2) {
|
|
458
|
+
$(handleXList2($2, elem2, item)).insertAfter($(this));
|
|
459
|
+
$(this).remove();
|
|
460
|
+
});
|
|
461
|
+
html2 += $2.html();
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
return html2;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
function handleXList2($, el, data) {
|
|
469
|
+
let property = $(el).attr('x-list2').split('.');
|
|
470
|
+
$(el).removeAttr('x-list2');
|
|
471
|
+
let list = null;
|
|
472
|
+
let html2 = '';
|
|
473
|
+
if (property.length > 0) {
|
|
474
|
+
if (property[0] == '*') {
|
|
475
|
+
list = data;
|
|
476
|
+
} else {
|
|
477
|
+
list = data[property[0]];
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
if (list && property.length > 1) {
|
|
481
|
+
list = list[property[1]];
|
|
482
|
+
}
|
|
483
|
+
if (Array.isArray(list)) {
|
|
484
|
+
let matches = $.html(el).match(/##item2.*?##/g);
|
|
485
|
+
list.forEach((item, i) => {
|
|
486
|
+
$(el).attr('x-item2', i);
|
|
487
|
+
let _html = $.html(el);
|
|
488
|
+
if (matches) {
|
|
489
|
+
for (let i = 0; i < matches.length; i++) {
|
|
490
|
+
let p = matches[i].replace('##item2.', '').replace('##', '').split('.');
|
|
491
|
+
let v = null;
|
|
492
|
+
if (p.length > 0) {
|
|
493
|
+
if (p[0] == '*' || !p[0]) {
|
|
494
|
+
v = item;
|
|
495
|
+
} else {
|
|
496
|
+
v = item[p[0]];
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
if (p.length > 1 && v) {
|
|
500
|
+
v = v[p[1]];
|
|
501
|
+
}
|
|
502
|
+
if (p.length > 2 && v) {
|
|
503
|
+
v = v[p[2]];
|
|
504
|
+
}
|
|
505
|
+
_html = _html.replace(matches[i], v || '');
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
let $2 = ____0.$.load(_html);
|
|
509
|
+
$2('[x-show-item2]').each(function (i, elem) {
|
|
510
|
+
let property = $(elem).attr('x-show-item2').split('.');
|
|
511
|
+
let out = null;
|
|
512
|
+
if (property.length > 0) {
|
|
513
|
+
if (property.length > 0) {
|
|
514
|
+
out = item[property[0]];
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
if (property.length > 1 && out) {
|
|
518
|
+
out = out[property[1]];
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
if (property.length > 2 && out) {
|
|
522
|
+
out = out[property[2]];
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
if (property.length > 3 && out) {
|
|
526
|
+
out = out[property[3]];
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
if (property.length > 4 && out) {
|
|
530
|
+
out = out[property[4]];
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
if (property.length > 5 && out) {
|
|
534
|
+
out = out[property[5]];
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
if (!out) {
|
|
538
|
+
$(this).remove();
|
|
539
|
+
} else {
|
|
540
|
+
$(this).removeAttr('x-show-item2');
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
html2 += $2.html();
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
return html2;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
function renderHtml($, log) {
|
|
550
|
+
$('[x-setting]').each(function (i, elem) {
|
|
551
|
+
let property = $(elem).attr('x-setting').split('.');
|
|
552
|
+
let out = null;
|
|
553
|
+
if (property.length > 0) {
|
|
554
|
+
if (property.length > 0) {
|
|
555
|
+
out = ____0.setting[property[0]];
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
if (property.length > 1 && out) {
|
|
559
|
+
if (out) {
|
|
560
|
+
out = out[property[1]];
|
|
561
|
+
} else {
|
|
562
|
+
out = null;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
if (property.length > 2 && out) {
|
|
566
|
+
if (out) {
|
|
567
|
+
out = out[property[2]];
|
|
568
|
+
} else {
|
|
569
|
+
out = null;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
if (property.length > 3 && out) {
|
|
573
|
+
if (out) {
|
|
574
|
+
out = out[property[3]];
|
|
575
|
+
} else {
|
|
576
|
+
out = null;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
if (property.length > 4 && out) {
|
|
580
|
+
if (out) {
|
|
581
|
+
out = out[property[4]];
|
|
582
|
+
} else {
|
|
583
|
+
out = null;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
if (!out) {
|
|
588
|
+
$(this).remove();
|
|
589
|
+
} else {
|
|
590
|
+
$(this).removeAttr('x-setting');
|
|
591
|
+
}
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
$('[x-data]').each(function (i, elem) {
|
|
595
|
+
let property = $(elem).attr('x-data').split('.');
|
|
596
|
+
let out = null;
|
|
597
|
+
if (property.length > 0) {
|
|
598
|
+
if (property.length > 0) {
|
|
599
|
+
out = req.data[property[0]];
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
if (property.length > 1 && out) {
|
|
603
|
+
if (out) {
|
|
604
|
+
out = out[property[1]];
|
|
605
|
+
} else {
|
|
606
|
+
out = null;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
if (property.length > 2 && out) {
|
|
610
|
+
if (out) {
|
|
611
|
+
out = out[property[2]];
|
|
612
|
+
} else {
|
|
613
|
+
out = null;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
if (property.length > 3 && out) {
|
|
617
|
+
if (out) {
|
|
618
|
+
out = out[property[3]];
|
|
619
|
+
} else {
|
|
620
|
+
out = null;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
if (property.length > 4 && out) {
|
|
624
|
+
if (out) {
|
|
625
|
+
out = out[property[4]];
|
|
626
|
+
} else {
|
|
627
|
+
out = null;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
if (!out) {
|
|
632
|
+
$(this).remove();
|
|
633
|
+
} else {
|
|
634
|
+
$(this).removeAttr('x-data');
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
|
|
638
|
+
$('[x-permission]').each(function (i, elem) {
|
|
639
|
+
if (!____0.security.isUserHasPermission(req, res, $(this).attr('x-permission'))) {
|
|
640
|
+
$(this).remove();
|
|
641
|
+
} else {
|
|
642
|
+
$(this).removeAttr('x-permission');
|
|
643
|
+
}
|
|
644
|
+
});
|
|
645
|
+
|
|
646
|
+
$('[x-role]').each(function (i, elem) {
|
|
647
|
+
if (!____0.security.isUserHasRole(req, res, $(this).attr('x-role'))) {
|
|
648
|
+
$(this).remove();
|
|
649
|
+
} else {
|
|
650
|
+
$(this).removeAttr('x-role');
|
|
651
|
+
}
|
|
652
|
+
});
|
|
653
|
+
|
|
654
|
+
$('[x-permissions]').each(function (i, elem) {
|
|
655
|
+
if (!____0.security.isUserHasPermissions(req, res, $(this).attr('x-permissions'))) {
|
|
656
|
+
$(this).remove();
|
|
657
|
+
} else {
|
|
658
|
+
$(this).removeAttr('x-permissions');
|
|
659
|
+
}
|
|
660
|
+
});
|
|
661
|
+
|
|
662
|
+
$('[x-roles]').each(function (i, elem) {
|
|
663
|
+
if (!____0.security.isUserHasRoles(req, res, $(this).attr('x-roles'))) {
|
|
664
|
+
$(this).remove();
|
|
665
|
+
} else {
|
|
666
|
+
$(this).removeAttr('x-roles');
|
|
667
|
+
}
|
|
668
|
+
});
|
|
669
|
+
|
|
670
|
+
$('[x-lang]').each(function (i, elem) {
|
|
671
|
+
if ($(this).attr('x-lang') !== req.session.lang) {
|
|
672
|
+
$(this).remove();
|
|
673
|
+
} else {
|
|
674
|
+
$(this).removeAttr('x-lang');
|
|
675
|
+
}
|
|
676
|
+
});
|
|
677
|
+
|
|
678
|
+
$('[x-feature]').each(function (i, elem) {
|
|
679
|
+
let f = $(this).attr('x-feature');
|
|
680
|
+
let not = !1;
|
|
681
|
+
if (f.startsWith('!')) {
|
|
682
|
+
f = f.replace('!', '');
|
|
683
|
+
not = !0;
|
|
684
|
+
}
|
|
685
|
+
if (!req.features.some((ff) => ff.like(f)) && !not) {
|
|
686
|
+
$(this).remove();
|
|
687
|
+
} else if (req.features.some((ff) => ff.like(f)) && not) {
|
|
688
|
+
$(this).remove();
|
|
689
|
+
} else {
|
|
690
|
+
$(this).removeAttr('x-feature');
|
|
691
|
+
}
|
|
692
|
+
});
|
|
693
|
+
|
|
694
|
+
$('[x-features]').each(function (i, elem) {
|
|
695
|
+
let fs = $(this).attr('x-features');
|
|
696
|
+
if (fs.indexOf('||') > -1) {
|
|
697
|
+
let del = !0;
|
|
698
|
+
fs.split('||').forEach((f) => {
|
|
699
|
+
f = f.trim();
|
|
700
|
+
let not = !1;
|
|
701
|
+
if (f.startsWith('!')) {
|
|
702
|
+
f = f.replace('!', '');
|
|
703
|
+
not = !0;
|
|
704
|
+
}
|
|
705
|
+
if (req.features.some((ff) => ff.like(f)) && !not) {
|
|
706
|
+
del = !1;
|
|
707
|
+
}
|
|
708
|
+
if (!req.features.some((ff) => ff.like(f)) && not) {
|
|
709
|
+
del = !1;
|
|
710
|
+
}
|
|
711
|
+
});
|
|
712
|
+
|
|
713
|
+
if (del) {
|
|
714
|
+
$(this).remove();
|
|
715
|
+
}
|
|
716
|
+
} else if (fs.indexOf('&&') > -1) {
|
|
717
|
+
let ok_list = [];
|
|
718
|
+
fs.split('&&').forEach((f) => {
|
|
719
|
+
f = f.trim();
|
|
720
|
+
let d = !0;
|
|
721
|
+
if (f.startsWith('!')) {
|
|
722
|
+
f = f.replace('!', '');
|
|
723
|
+
d = !1;
|
|
724
|
+
}
|
|
725
|
+
if (!req.features.some((ff) => ff.like(f)) && !d) {
|
|
726
|
+
ok_list.push({});
|
|
727
|
+
}
|
|
728
|
+
if (req.features.some((ff) => ff.like(f)) && d) {
|
|
729
|
+
ok_list.push({});
|
|
730
|
+
}
|
|
731
|
+
});
|
|
732
|
+
if (ok_list.length !== fs.split('&&').length) {
|
|
733
|
+
$(this).remove();
|
|
734
|
+
}
|
|
735
|
+
} else {
|
|
736
|
+
f = fs.trim();
|
|
737
|
+
let d = !0;
|
|
738
|
+
if (f.startsWith('!')) {
|
|
739
|
+
f = f.replace('!', '');
|
|
740
|
+
d = !1;
|
|
741
|
+
}
|
|
742
|
+
if (!req.features.some((ff) => ff.like(f)) && d) {
|
|
743
|
+
$(this).remove();
|
|
744
|
+
}
|
|
745
|
+
if (req.features.some((ff) => ff.like(f)) && !d) {
|
|
746
|
+
$(this).remove();
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
});
|
|
750
|
+
|
|
751
|
+
if (route.parser.like('*css*')) {
|
|
752
|
+
$('style').each(function (i, elem) {
|
|
753
|
+
$(this).html(parser.css($(this).html()));
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
if (route.parser.like('*js*')) {
|
|
758
|
+
$('script').each(function (i, elem) {
|
|
759
|
+
$(this).html(parser.js($(this).html()));
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
$($('[x-import]').get().reverse()).each(function (i, elem) {
|
|
764
|
+
let file = $(this).attr('x-import');
|
|
765
|
+
if (file.endsWith('.html')) {
|
|
766
|
+
$(this).html(getContent(file) + $(this).html());
|
|
767
|
+
} else if (file.endsWith('.css')) {
|
|
768
|
+
$(this).text(getContent(file) + $(this).html());
|
|
769
|
+
} else {
|
|
770
|
+
$(this).text(getContent(file) + $(this).text());
|
|
771
|
+
}
|
|
772
|
+
$(this).removeAttr('x-import');
|
|
773
|
+
});
|
|
774
|
+
|
|
775
|
+
$($('[x-append]').get().reverse()).each(function (i, elem) {
|
|
776
|
+
let file = $(this).attr('x-append');
|
|
777
|
+
$(this).removeAttr('x-append');
|
|
778
|
+
if (file.endsWith('.html')) {
|
|
779
|
+
$(this).html($(this).html() + getContent(file));
|
|
780
|
+
} else if (file.endsWith('.css')) {
|
|
781
|
+
$(this).text($(this).html() + getContent(file));
|
|
782
|
+
} else {
|
|
783
|
+
$(this).text($(this).text() + getContent(file));
|
|
784
|
+
}
|
|
785
|
+
$(this).removeAttr('x-append');
|
|
786
|
+
});
|
|
787
|
+
|
|
788
|
+
$($('[x-replace]').get().reverse()).each(function (i, elem) {
|
|
789
|
+
let file = $(this).attr('x-replace');
|
|
790
|
+
|
|
791
|
+
$(getContent(file)).insertAfter($(this));
|
|
792
|
+
$(this).remove();
|
|
793
|
+
|
|
794
|
+
$(this).removeAttr('x-replace');
|
|
795
|
+
});
|
|
796
|
+
|
|
797
|
+
$('[x-list1]').each(function (i, elem) {
|
|
798
|
+
$(handleXList1($, elem, req.data)).insertAfter($(this));
|
|
799
|
+
$(this).remove();
|
|
800
|
+
});
|
|
801
|
+
$('[x-list2]').each(function (i, elem) {
|
|
802
|
+
$(handleXList2($, elem, req.data)).insertAfter($(this));
|
|
803
|
+
$(this).remove();
|
|
804
|
+
});
|
|
805
|
+
return $;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
parser.handleMatches = function (txt) {
|
|
809
|
+
let matches = txt.match(/##.*?##/g);
|
|
810
|
+
if (matches) {
|
|
811
|
+
for (let i = 0; i < matches.length; i++) {
|
|
812
|
+
let v = matches[i];
|
|
813
|
+
|
|
814
|
+
if (v.startsWith('##var.')) {
|
|
815
|
+
v = v.replace('##var.', '').replace('##', '');
|
|
816
|
+
txt = txt.replace(matches[i], renderVar(v));
|
|
817
|
+
} else if (v.startsWith('##word.')) {
|
|
818
|
+
v = v.replace('##word.', '').replace('##', '');
|
|
819
|
+
txt = txt.replace(matches[i], renderWord(v));
|
|
820
|
+
} else if (v.startsWith('##user.')) {
|
|
821
|
+
v = v.replace('##user.', '').replace('##', '');
|
|
822
|
+
txt = txt.replace(matches[i], renderUser(v));
|
|
823
|
+
} else if (v.startsWith('##site.')) {
|
|
824
|
+
v = v.replace('##site.', '').replace('##', '');
|
|
825
|
+
txt = txt.replace(matches[i], render_site(v));
|
|
826
|
+
} else if (v.startsWith('##req.')) {
|
|
827
|
+
v = v.replace('##req.', '').replace('##', '');
|
|
828
|
+
txt = txt.replace(matches[i], renderRequest(v));
|
|
829
|
+
} else if (v.startsWith('##session.')) {
|
|
830
|
+
v = v.replace('##session.', '').replace('##', '');
|
|
831
|
+
txt = txt.replace(matches[i], renderSession(v));
|
|
832
|
+
} else if (v.startsWith('##json.')) {
|
|
833
|
+
v = v.replace('##json.', '').replace('##', '');
|
|
834
|
+
txt = txt.replace(matches[i], renderJson(v));
|
|
835
|
+
} else if (v.startsWith('##setting.')) {
|
|
836
|
+
v = v.replace('##setting.', '').replace('##', '');
|
|
837
|
+
txt = txt.replace(matches[i], renderSetting(v));
|
|
838
|
+
} else if (v.startsWith('##params.')) {
|
|
839
|
+
v = v.replace('##params.', '').replace('##', '');
|
|
840
|
+
txt = txt.replace(matches[i], renderParam(v));
|
|
841
|
+
} else if (v.startsWith('##query.')) {
|
|
842
|
+
v = v.replace('##query.', '').replace('##', '');
|
|
843
|
+
txt = txt.replace(matches[i], renderQuery(v));
|
|
844
|
+
} else if (v.startsWith('##data.')) {
|
|
845
|
+
v = v.replace('##data.', '').replace('##', '');
|
|
846
|
+
txt = txt.replace(matches[i], renderData(v));
|
|
847
|
+
} else {
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
return txt;
|
|
852
|
+
};
|
|
853
|
+
|
|
854
|
+
parser.html = function (content) {
|
|
855
|
+
let $ = ____0.$.load(content);
|
|
856
|
+
$ = renderHtml($);
|
|
857
|
+
txt = parser.handleMatches($.html());
|
|
858
|
+
return txt;
|
|
859
|
+
};
|
|
860
|
+
parser.txt = function (content) {
|
|
861
|
+
content = parser.handleMatches(content);
|
|
862
|
+
return content;
|
|
863
|
+
};
|
|
864
|
+
|
|
865
|
+
parser.js = function (content) {
|
|
866
|
+
let matches = content.match(/\/\*##.*?\*\//g);
|
|
867
|
+
if (matches) {
|
|
868
|
+
for (let i = 0; i < matches.length; i++) {
|
|
869
|
+
let v = matches[i];
|
|
870
|
+
v = v.replace('/*##', '').replace('*/', '');
|
|
871
|
+
content = content.replace(matches[i], getContent(v));
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
content = parser.handleMatches(content);
|
|
875
|
+
return content;
|
|
876
|
+
};
|
|
877
|
+
|
|
878
|
+
parser.css = function (content) {
|
|
879
|
+
content = parser.handleMatches(content);
|
|
880
|
+
|
|
881
|
+
let matches = content.match(/var\(---.*?\)/g);
|
|
882
|
+
if (matches) {
|
|
883
|
+
for (let i = 0; i < matches.length; i++) {
|
|
884
|
+
let v = matches[i];
|
|
885
|
+
|
|
886
|
+
v = v.replace('var(---', '').replace(')', '');
|
|
887
|
+
content = content.replace(matches[i], renderVar(v));
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
let matches2 = content.match(/word\(---.*?\)/g);
|
|
892
|
+
if (matches2) {
|
|
893
|
+
for (let i = 0; i < matches2.length; i++) {
|
|
894
|
+
let v = matches2[i];
|
|
895
|
+
|
|
896
|
+
v = v.replace('word(---', '').replace(')', '');
|
|
897
|
+
content = content.replace(matches2[i], renderWord(v));
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
return content;
|
|
902
|
+
};
|
|
903
|
+
|
|
904
|
+
parser.json = function (content) {
|
|
905
|
+
return content;
|
|
906
|
+
};
|
|
907
|
+
|
|
908
|
+
parser.renderHtml = renderHtml;
|
|
909
|
+
return parser;
|
|
910
|
+
};
|