isite 2023.1.10 → 2023.8.11

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/lib/fsm.js CHANGED
@@ -1,412 +1,423 @@
1
1
  module.exports = function init(____0) {
2
- const fsm = function () {};
3
- const fs = require('fs');
4
-
5
- ____0.on('0x0000', (_) => {
6
- if (!_) {
7
- fsm.list = [];
8
- }
2
+ const fsm = function () {};
3
+ const fs = require('fs');
4
+
5
+ ____0.on('0x0000', (_) => {
6
+ if (!_) {
7
+ fsm.list = [];
8
+ }
9
+ });
10
+
11
+ fsm.dir = ____0.dir;
12
+ fsm.list = [];
13
+
14
+ fsm.isFileExistsSync = (path) => {
15
+ for (let i = 0; i < fsm.list.length; i++) {
16
+ let f = fsm.list[i];
17
+ if (f.path === path) {
18
+ return !0;
19
+ }
20
+ }
21
+ return fs.existsSync(path);
22
+ };
23
+
24
+ fsm.isFileExists = (path, callback) => {
25
+ callback = callback || function () {};
26
+ if (fsm.isFileExistsSync(path)) {
27
+ callback(!0);
28
+ } else {
29
+ callback(!1);
30
+ }
31
+ };
32
+
33
+ fsm.statSync = function (path) {
34
+ if (fsm.isFileExistsSync(path)) {
35
+ return fs.statSync(path);
36
+ }
37
+ };
38
+
39
+ fsm.stat = function (path, callback) {
40
+ callback = callback || function () {};
41
+ fsm.isFileExists(path, function (yes) {
42
+ if (yes) {
43
+ fs.stat(path, callback);
44
+ } else {
45
+ callback({
46
+ message: 'file not exists',
47
+ });
48
+ }
9
49
  });
10
-
11
- fsm.dir = ____0.dir;
12
- fsm.list = [];
13
-
14
- fsm.isFileExistsSync = (path) => {
15
- for (let i = 0; i < fsm.list.length; i++) {
16
- let f = fsm.list[i];
17
- if (f.path === path) {
18
- return !0;
19
- }
20
- }
21
- return fs.existsSync(path);
22
- };
23
-
24
- fsm.isFileExists = (path, callback) => {
25
- callback = callback || function () {};
26
- if (fsm.isFileExistsSync(path)) {
27
- callback(!0);
28
- } else {
29
- callback(!1);
50
+ };
51
+
52
+ fsm.createDirSync = fsm.mkdirSync = function (path) {
53
+ try {
54
+ fs.mkdirSync(path);
55
+ return !0;
56
+ } catch (error) {
57
+ return !1;
58
+ }
59
+ };
60
+
61
+ fsm.createDir = fsm.mkDir = (dir, callback) => {
62
+ callback = callback || function () {};
63
+
64
+ fs.exists(____0.path.dirname(dir), (ok) => {
65
+ if (ok) {
66
+ fs.mkdir(dir, (err) => {
67
+ callback(err, dir);
68
+ });
69
+ } else {
70
+ let parentDir = ____0.path.dirname(dir);
71
+ fsm.mkDir(parentDir, () => {
72
+ fs.mkdir(dir, (err) => {
73
+ callback(err, dir);
74
+ });
75
+ });
76
+ }
77
+ });
78
+ };
79
+
80
+ fsm.removeFileSync = fsm.deleteFileSync = function (path) {
81
+ if (fs.existsSync(path)) {
82
+ return fs.unlinkSync(path);
83
+ }
84
+ return null;
85
+ };
86
+
87
+ fsm.removeFile = fsm.deleteFile = function (path, callback) {
88
+ callback =
89
+ callback ||
90
+ function (err) {
91
+ if (err) {
92
+ ____0.log(err);
30
93
  }
31
- };
94
+ };
32
95
 
33
- fsm.statSync = function (path) {
34
- if (fsm.isFileExistsSync(path)) {
35
- return fs.statSync(path);
36
- }
37
- };
38
-
39
- fsm.stat = function (path, callback) {
40
- callback = callback || function () {};
41
- fsm.isFileExists(path, function (yes) {
42
- if (yes) {
43
- fs.stat(path, callback);
44
- } else {
45
- callback({
46
- message: 'file not exists',
47
- });
48
- }
96
+ fsm.isFileExists(path, (yes) => {
97
+ if (yes) {
98
+ fs.unlink(path, (err) => {
99
+ callback(err);
49
100
  });
50
- };
51
-
52
- fsm.createDirSync = fsm.mkdirSync = function (path) {
53
- try {
54
- fs.mkdirSync(path);
55
- return !0;
56
- } catch (error) {
57
- return !1;
58
- }
59
- };
60
-
61
- fsm.createDir = fsm.mkDir = (dir, callback) => {
62
- callback = callback || function () {};
63
-
64
- fs.exists(____0.path.dirname(dir), (ok) => {
65
- if (ok) {
66
- fs.mkdir(dir, (err) => {
67
- callback(err, dir);
68
- });
69
- } else {
70
- let parentDir = ____0.path.dirname(dir);
71
- fsm.mkDir(parentDir, () => {
72
- fs.mkdir(dir, (err) => {
73
- callback(err, dir);
74
- });
75
- });
76
- }
101
+ } else {
102
+ callback({
103
+ message: path + ' :: Error Deleting :: file not exists',
77
104
  });
78
- };
79
-
80
- fsm.removeFileSync = fsm.deleteFileSync = function (path) {
81
- if (fs.existsSync(path)) {
82
- return fs.unlinkSync(path);
105
+ }
106
+ });
107
+ };
108
+
109
+ fsm.writeFileSync = function (path, data, encode, callback) {
110
+ callback =
111
+ callback ||
112
+ function (err) {
113
+ if (err) {
114
+ ____0.log(err);
83
115
  }
84
- return null;
85
- };
86
-
87
- fsm.removeFile = fsm.deleteFile = function (path, callback) {
88
- callback =
89
- callback ||
90
- function (err) {
91
- if (err) {
92
- ____0.log(err);
93
- }
94
- };
95
-
96
- fsm.isFileExists(path, (yes) => {
97
- if (yes) {
98
- fs.unlink(path, (err) => {
99
- callback(err);
100
- });
101
- } else {
102
- callback({
103
- message: path + ' :: Error Deleting :: file not exists',
104
- });
105
- }
116
+ };
117
+
118
+ try {
119
+ let path2 = path + '_tmp';
120
+ fsm.deleteFileSync(path2);
121
+ fs.writeFileSync(path2, data, {
122
+ encoding: encode || 'utf8',
123
+ });
124
+ fsm.deleteFileSync(path);
125
+ fs.renameSync(path2, path);
126
+ fsm.deleteFileSync(path2);
127
+ callback();
128
+ } catch (err) {
129
+ callback(err);
130
+ }
131
+ };
132
+
133
+ fsm.writeFile = function (path, data, callback) {
134
+ setTimeout(() => {
135
+ fsm.writeFileSync(path, data, null, callback);
136
+ }, 100);
137
+ };
138
+
139
+ fsm.readFile = function (path, callback) {
140
+ setTimeout(() => {
141
+ fsm.readFileSync(path, callback);
142
+ }, 100);
143
+ };
144
+
145
+ fsm.getFilePath = function (name) {
146
+ if (____0.isFileExistsSync(name)) {
147
+ return name;
148
+ }
149
+
150
+ let path = null;
151
+
152
+ if (!path || !____0.isFileExistsSync(path)) {
153
+ let arr = name.split('/');
154
+ if (arr.length === 1) {
155
+ path = ____0.path.join(____0.path.dirname(____0.dir), ____0.path.extname(arr[0]).replace('.', ''), arr[0]);
156
+ } else if (arr.length === 2) {
157
+ path = ____0.path.join(____0.path.dirname(____0.dir), ____0.path.extname(arr[1]).replace('.', ''), arr[0], arr[1]);
158
+ } else if (arr.length === 3) {
159
+ path = ____0.path.join(____0.path.dirname(____0.dir), ____0.path.extname(arr[2]).replace('.', ''), arr[0], arr[1], arr[2]);
160
+ }
161
+ }
162
+
163
+ if (!____0.isFileExistsSync(path)) {
164
+ let arr = name.split('/');
165
+ if (arr.length === 2) {
166
+ path = ____0.path.join(____0.path.dirname(____0.cwd), 'apps', arr[0], 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
167
+ } else if (arr.length === 3) {
168
+ path = ____0.path.join(____0.path.dirname(____0.cwd), 'apps', arr[0], 'site_files', ____0.path.extname(arr[2]).replace('.', ''), arr[1], arr[2]);
169
+ }
170
+ }
171
+
172
+ if (!____0.isFileExistsSync(path) && ____0.apps) {
173
+ let arr = name.split('/');
174
+ if (arr.length > 1) {
175
+ ____0.apps.forEach((ap) => {
176
+ if (arr.length === 2 && ap.name == arr[0]) {
177
+ path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
178
+ } else if (arr.length === 2 && ap.name2 == arr[0]) {
179
+ path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
180
+ } else if (arr.length === 3 && ap.name == arr[0]) {
181
+ path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[2]).replace('.', ''), arr[1], arr[2]);
182
+ }
106
183
  });
107
- };
108
-
109
- fsm.writeFileSync = function (path, data, encode, callback) {
110
- callback =
111
- callback ||
112
- function (err) {
113
- if (err) {
114
- ____0.log(err);
115
- }
116
- };
117
-
118
- try {
119
- let path2 = path + '_tmp';
120
- fsm.deleteFileSync(path2);
121
- fs.writeFileSync(path2, data, {
122
- encoding: encode || 'utf8',
123
- });
124
- fsm.deleteFileSync(path);
125
- fs.renameSync(path2, path);
126
- fsm.deleteFileSync(path2);
127
- callback();
128
- } catch (err) {
129
- callback(err);
130
- }
131
- };
132
-
133
- fsm.writeFile = function (path, data, callback) {
134
- setTimeout(() => {
135
- fsm.writeFileSync(path, data, null, callback);
136
- }, 100);
137
- };
138
-
139
- fsm.readFile = function (path, callback) {
140
- setTimeout(() => {
141
- fsm.readFileSync(path, callback);
142
- }, 100);
143
- };
144
-
145
- fsm.getFilePath = function (name) {
146
- if (____0.isFileExistsSync(name)) {
147
- return name;
148
- }
149
-
150
- let path = null;
151
-
152
- if (!path || !____0.isFileExistsSync(path)) {
153
- let arr = name.split('/');
154
- if (arr.length === 1) {
155
- path = ____0.path.join(____0.path.dirname(____0.dir), ____0.path.extname(arr[0]).replace('.', ''), arr[0]);
156
- } else if (arr.length === 2) {
157
- path = ____0.path.join(____0.path.dirname(____0.dir), ____0.path.extname(arr[1]).replace('.', ''), arr[0], arr[1]);
158
- } else if (arr.length === 3) {
159
- path = ____0.path.join(____0.path.dirname(____0.dir), ____0.path.extname(arr[2]).replace('.', ''), arr[0], arr[1], arr[2]);
160
- }
161
- }
162
-
163
- if (!____0.isFileExistsSync(path)) {
164
- let arr = name.split('/');
165
- if (arr.length === 2) {
166
- path = ____0.path.join(____0.path.dirname(____0.cwd), 'apps', arr[0], 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
167
- } else if (arr.length === 3) {
168
- path = ____0.path.join(____0.path.dirname(____0.cwd), 'apps', arr[0], 'site_files', ____0.path.extname(arr[2]).replace('.', ''), arr[1], arr[2]);
169
- }
170
- }
171
-
172
- if (!____0.isFileExistsSync(path) && ____0.apps) {
173
- let arr = name.split('/');
174
- if (arr.length > 1) {
175
- ____0.apps.forEach((ap) => {
176
- if (arr.length === 2 && ap.name == arr[0]) {
177
- path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
178
- } else if (arr.length === 2 && ap.name2 == arr[0]) {
179
- path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
180
- } else if (arr.length === 3 && ap.name == arr[0]) {
181
- path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[2]).replace('.', ''), arr[1], arr[2]);
182
- }
183
- });
184
- }
184
+ }
185
+ }
186
+
187
+ if (!____0.isFileExistsSync(path)) {
188
+ // ____0.log(name, 'PATH NOT EXISTS fsm.getFilePath()');
189
+ return null;
190
+ }
191
+
192
+ return path;
193
+ };
194
+
195
+ fsm.off = function (path) {
196
+ if (path && typeof path == 'string') {
197
+ for (let i = fsm.list.length; i--; ) {
198
+ if (fsm.list[i] && fsm.list[i].path.like(path)) {
199
+ fsm.list.splice(i, 1);
185
200
  }
186
-
187
- if (!____0.isFileExistsSync(path)) {
188
- // ____0.log(name, 'PATH NOT EXISTS fsm.getFilePath()');
189
- return null;
201
+ }
202
+ } else if (path && Array.isArray(path)) {
203
+ path.forEach((p) => {
204
+ fsm.off(p);
205
+ });
206
+ }
207
+ };
208
+
209
+ fsm.readFileSync = function (path, callback) {
210
+ callback =
211
+ callback ||
212
+ function (err) {
213
+ if (err) {
214
+ ____0.log(err);
190
215
  }
191
-
192
- return path;
193
- };
194
-
195
- fsm.off = function (path) {
196
- if (path && typeof path == 'string') {
197
- for (let i = fsm.list.length; i--; ) {
198
- if (fsm.list[i] && fsm.list[i].path.like(path)) {
199
- fsm.list.splice(i, 1);
200
- }
201
- }
202
- } else if (path && Array.isArray(path)) {
203
- path.forEach((p) => {
204
- fsm.off(p);
205
- });
216
+ };
217
+
218
+ path = fsm.getFilePath(path);
219
+ if (!path) {
220
+ return '';
221
+ }
222
+ let path2 = path + '_tmp';
223
+
224
+ for (let index = 0; index < fsm.list.length; index++) {
225
+ let file = fsm.list[index];
226
+ if (file.path == path) {
227
+ file.count++;
228
+ callback(null, file.content, file);
229
+ return file.content;
230
+ }
231
+ }
232
+
233
+ let encode = 'utf8';
234
+ encode = ____0.fn.getFileEncode(path);
235
+ if (fsm.isFileExistsSync(path)) {
236
+ let data = fs.readFileSync(path, encode);
237
+ let file = {
238
+ path: path,
239
+ content: data,
240
+ etag: ____0.x0md50x(data),
241
+ count: 1,
242
+ stat: fsm.statSync(path),
243
+ encode: encode,
244
+ time: Date.now(),
245
+ };
246
+ fsm.list.push(file);
247
+ callback(null, file.content, file);
248
+ return data;
249
+ } else if (fsm.isFileExistsSync(path2)) {
250
+ let data = fs.readFileSync(path2, encode);
251
+ let file = {
252
+ path: path,
253
+ content: data,
254
+ etag: ____0.x0md50x(data),
255
+ count: 1,
256
+ stat: fsm.statSync(path),
257
+ encode: encode,
258
+ time: Date.now(),
259
+ };
260
+ fsm.list.push(file);
261
+ callback(null, file.content, file);
262
+ return data;
263
+ } else {
264
+ callback({
265
+ message: path + ' :: Error Read File Not Exists',
266
+ });
267
+ return '';
268
+ }
269
+ };
270
+
271
+ fsm.readFiles = function (paths, callback) {
272
+ callback = callback || function () {};
273
+ var content = '';
274
+ for (var index = 0; index < paths.length; index++) {
275
+ let p = paths[index];
276
+ let exists = !1;
277
+ for (let i = 0; i < fsm.list.length; i++) {
278
+ let file = fsm.list[i];
279
+ if (file.path == p) {
280
+ content += file.content;
281
+ file.count++;
282
+ exists = !0;
206
283
  }
207
- };
208
-
209
- fsm.readFileSync = function (path, callback) {
210
- callback =
211
- callback ||
212
- function (err) {
213
- if (err) {
214
- ____0.log(err);
215
- }
216
- };
217
-
218
- path = fsm.getFilePath(path);
219
- if (!path) {
220
- return '';
284
+ }
285
+ if (!exists) {
286
+ data = fsm.readFileSync(p);
287
+ content += data;
288
+ }
289
+ }
290
+ callback(null, content);
291
+ };
292
+
293
+ fsm.isImage = function(extname){
294
+ if (extname == 'png' || extname == 'jpg' || extname == 'jpeg' || extname == 'bmp' || extname == 'ico'|| extname == 'webp') {
295
+ return true
296
+ }
297
+ return false
298
+ }
299
+
300
+ fsm.getContent = function (name, callback) {
301
+ callback = callback || function () {};
302
+ let extname = ____0.path.extname(name).replace('.', '');
303
+ if (fsm.isImage(extname)) {
304
+ extname = 'images';
305
+ }
306
+
307
+ let path = name;
308
+ if (!____0.isFileExistsSync(path)) {
309
+ path = ____0.path.join(____0.dir, extname, name);
310
+ }
311
+
312
+ if (!____0.isFileExistsSync(path)) {
313
+ let arr = name.split('/');
314
+ if (arr.length === 2) {
315
+ let extname = ____0.path.extname(arr[1]).replace('.', '');
316
+ if (fsm.isImage(extname)) {
317
+ extname = 'images';
221
318
  }
222
- let path2 = path + '_tmp';
223
-
224
- for (let index = 0; index < fsm.list.length; index++) {
225
- let file = fsm.list[index];
226
- if (file.path == path) {
227
- file.count++;
228
- callback(null, file.content, file);
229
- return file.content;
230
- }
231
- }
232
-
233
- let encode = 'utf8';
234
- encode = ____0.fn.getFileEncode(path);
235
- if (fsm.isFileExistsSync(path)) {
236
- let data = fs.readFileSync(path, encode);
237
- let file = {
238
- path: path,
239
- content: data,
240
- etag: ____0.x0md50x(data),
241
- count: 1,
242
- stat: fsm.statSync(path),
243
- encode: encode,
244
- time: Date.now(),
245
- };
246
- fsm.list.push(file);
247
- callback(null, file.content, file);
248
- return data;
249
- } else if (fsm.isFileExistsSync(path2)) {
250
- let data = fs.readFileSync(path2, encode);
251
- let file = {
252
- path: path,
253
- content: data,
254
- etag: ____0.x0md50x(data),
255
- count: 1,
256
- stat: fsm.statSync(path),
257
- encode: encode,
258
- time: Date.now(),
259
- };
260
- fsm.list.push(file);
261
- callback(null, file.content, file);
262
- return data;
263
- } else {
264
- callback({
265
- message: path + ' :: Error Read File Not Exists',
266
- });
267
- return '';
319
+ path = ____0.path.join(____0.path.dirname(____0.dir), 'apps', arr[0], 'site_files', extname, arr[1]);
320
+ } else if (arr.length === 3) {
321
+ let extname = ____0.path.extname(arr[2]).replace('.', '');
322
+ if (fsm.isImage(extname)) {
323
+ extname = 'images';
268
324
  }
269
- };
270
-
271
- fsm.readFiles = function (paths, callback) {
272
- callback = callback || function () {};
273
- var content = '';
274
- for (var index = 0; index < paths.length; index++) {
275
- let p = paths[index];
276
- let exists = !1;
277
- for (let i = 0; i < fsm.list.length; i++) {
278
- let file = fsm.list[i];
279
- if (file.path == p) {
280
- content += file.content;
281
- file.count++;
282
- exists = !0;
283
- }
325
+ path = ____0.path.join(____0.path.dirname(____0.dir), 'apps', arr[0], 'site_files', extname, arr[1], arr[2]);
326
+ }
327
+ }
328
+
329
+ if (!____0.isFileExistsSync(path)) {
330
+ let arr = name.split('/');
331
+ if (arr.length > 1) {
332
+ ____0.apps.forEach((ap) => {
333
+ if (arr.length === 2 && ap.name == arr[0]) {
334
+ let extname = ____0.path.extname(arr[1]).replace('.', '');
335
+ if (fsm.isImage(extname)) {
336
+ extname = 'images';
284
337
  }
285
- if (!exists) {
286
- data = fsm.readFileSync(p);
287
- content += data;
338
+ path = ____0.path.join(ap.path, 'site_files', extname, arr[1]);
339
+ } else if (arr.length === 2 && ap.name2 == arr[0]) {
340
+ let extname = ____0.path.extname(arr[1]).replace('.', '');
341
+ if (fsm.isImage(extname)) {
342
+ extname = 'images';
288
343
  }
289
- }
290
- callback(null, content);
291
- };
292
-
293
- fsm.getContent = function (name, callback) {
294
- callback = callback || function () {};
295
- let extname = ____0.path.extname(name).replace('.', '');
296
- if (extname == 'png' || extname == 'jpg' || extname == 'jpeg' || extname == 'bmp' || extname == 'ico') {
297
- extname = 'images';
298
- }
299
- let path = ____0.path.join(____0.dir, extname, name);
300
-
301
- if (!____0.isFileExistsSync(path)) {
302
- let arr = name.split('/');
303
- if (arr.length === 2) {
304
- let extname = ____0.path.extname(arr[1]).replace('.', '');
305
- if (extname == 'png' || extname == 'jpg' || extname == 'jpeg' || extname == 'bmp' || extname == 'ico') {
306
- extname = 'images';
307
- }
308
- path = ____0.path.join(____0.path.dirname(____0.dir), 'apps', arr[0], 'site_files', extname, arr[1]);
309
- } else if (arr.length === 3) {
310
- let extname = ____0.path.extname(arr[2]).replace('.', '');
311
- if (extname == 'png' || extname == 'jpg' || extname == 'jpeg' || extname == 'bmp' || extname == 'ico') {
312
- extname = 'images';
313
- }
314
- path = ____0.path.join(____0.path.dirname(____0.dir), 'apps', arr[0], 'site_files', extname, arr[1], arr[2]);
344
+ path = ____0.path.join(ap.path, 'site_files', extname, arr[1]);
345
+ } else if (arr.length === 3 && ap.name == arr[0]) {
346
+ let extname = ____0.path.extname(arr[2]).replace('.', '');
347
+ if (fsm.isImage(extname)) {
348
+ extname = 'images';
315
349
  }
316
- }
317
-
318
- if (!____0.isFileExistsSync(path)) {
319
- let arr = name.split('/');
320
- if (arr.length > 1) {
321
- ____0.apps.forEach((ap) => {
322
- if (arr.length === 2 && ap.name == arr[0]) {
323
- let extname = ____0.path.extname(arr[1]).replace('.', '');
324
- if (extname == 'png' || extname == 'jpg' || extname == 'jpeg' || extname == 'bmp' || extname == 'ico') {
325
- extname = 'images';
326
- }
327
- path = ____0.path.join(ap.path, 'site_files', extname, arr[1]);
328
- } else if (arr.length === 2 && ap.name2 == arr[0]) {
329
- let extname = ____0.path.extname(arr[1]).replace('.', '');
330
- if (extname == 'png' || extname == 'jpg' || extname == 'jpeg' || extname == 'bmp' || extname == 'ico') {
331
- extname = 'images';
332
- }
333
- path = ____0.path.join(ap.path, 'site_files', extname, arr[1]);
334
- } else if (arr.length === 3 && ap.name == arr[0]) {
335
- let extname = ____0.path.extname(arr[2]).replace('.', '');
336
- if (extname == 'png' || extname == 'jpg' || extname == 'jpeg' || extname == 'bmp' || extname == 'ico') {
337
- extname = 'images';
338
- }
339
- path = ____0.path.join(ap.path, 'site_files', extname, arr[1], arr[2]);
340
- }
341
- });
342
- }
343
- }
344
-
345
- if (!____0.isFileExistsSync(path)) {
346
- ____0.log(path, 'PATH NOT EXISTS fsm.getContent()');
347
- callback('');
348
- return '';
349
- }
350
-
351
- let txt = ____0.readFileSync(path);
352
- callback(txt);
353
- return txt;
354
- };
355
-
356
- fsm.css = function (name, callback) {
357
- callback = callback || function () {};
358
- fsm.readFile(fsm.dir + '/css/' + name + '.css', function (err, data, file) {
359
- callback(err, data, file);
350
+ path = ____0.path.join(ap.path, 'site_files', extname, arr[1], arr[2]);
351
+ }
360
352
  });
361
- };
353
+ }
354
+ }
355
+
356
+ if (!____0.isFileExistsSync(path)) {
357
+ ____0.log(path, 'PATH NOT EXISTS fsm.getContent()');
358
+ callback('');
359
+ return '';
360
+ }
361
+
362
+ let txt = ____0.readFileSync(path);
363
+ callback(txt);
364
+ return txt;
365
+ };
366
+
367
+ fsm.css = function (name, callback) {
368
+ callback = callback || function () {};
369
+ fsm.readFile(fsm.dir + '/css/' + name + '.css', function (err, data, file) {
370
+ callback(err, data, file);
371
+ });
372
+ };
362
373
 
363
- fsm.js = function (name, callback) {
364
- callback = callback || function () {};
365
- fsm.readFile(fsm.dir + '/js/' + name + '.js', function (err, data, file) {
366
- callback(err, data, file);
367
- });
368
- };
374
+ fsm.js = function (name, callback) {
375
+ callback = callback || function () {};
376
+ fsm.readFile(fsm.dir + '/js/' + name + '.js', function (err, data, file) {
377
+ callback(err, data, file);
378
+ });
379
+ };
369
380
 
370
- fsm.html = function (name, callback) {
371
- callback = callback || function () {};
372
- fsm.readFile(fsm.dir + '/html/' + name + '.html', function (err, data, file) {
373
- callback(err, data, file);
374
- });
375
- };
381
+ fsm.html = function (name, callback) {
382
+ callback = callback || function () {};
383
+ fsm.readFile(fsm.dir + '/html/' + name + '.html', function (err, data, file) {
384
+ callback(err, data, file);
385
+ });
386
+ };
376
387
 
377
- fsm.json = function (name, callback) {
378
- callback = callback || function () {};
379
- fsm.readFile(fsm.dir + '/json/' + name + '.json', function (err, data, file) {
380
- callback(err, data, file);
381
- });
382
- };
388
+ fsm.json = function (name, callback) {
389
+ callback = callback || function () {};
390
+ fsm.readFile(fsm.dir + '/json/' + name + '.json', function (err, data, file) {
391
+ callback(err, data, file);
392
+ });
393
+ };
383
394
 
384
- fsm.xml = function (name, callback) {
385
- callback = callback || function () {};
386
- fsm.readFile(fsm.dir + '/xml/' + name + '.xml', function (err, data, file) {
387
- callback(err, data, file);
388
- });
389
- };
390
-
391
- fsm.downloadFile = function (path, req, res) {
392
- fsm.stat(path, (err, stats) => {
393
- if (!err) {
394
- res.writeHead(200, {
395
- 'Content-Type': ____0.fn.contentType(path),
396
- 'Content-Length': stats.size,
397
- 'Content-Disposition': 'attachment; filename=' + ____0.path.basename(path),
398
- });
399
- var readStream = fs.createReadStream(path);
400
- readStream.pipe(res);
401
- } else {
402
- res.error();
403
- }
395
+ fsm.xml = function (name, callback) {
396
+ callback = callback || function () {};
397
+ fsm.readFile(fsm.dir + '/xml/' + name + '.xml', function (err, data, file) {
398
+ callback(err, data, file);
399
+ });
400
+ };
401
+
402
+ fsm.downloadFile = function (path, req, res) {
403
+ fsm.stat(path, (err, stats) => {
404
+ if (!err) {
405
+ res.writeHead(200, {
406
+ 'Content-Type': ____0.fn.contentType(path),
407
+ 'Content-Length': stats.size,
408
+ 'Content-Disposition': 'attachment; filename=' + ____0.path.basename(path),
404
409
  });
405
- };
410
+ var readStream = fs.createReadStream(path);
411
+ readStream.pipe(res);
412
+ } else {
413
+ res.error();
414
+ }
415
+ });
416
+ };
406
417
 
407
- fsm.download = function (name, req, res) {
408
- return fsm.downloadFile(fsm.dir + '/downloads/' + name, req, res);
409
- };
418
+ fsm.download = function (name, req, res) {
419
+ return fsm.downloadFile(fsm.dir + '/downloads/' + name, req, res);
420
+ };
410
421
 
411
- return fsm;
422
+ return fsm;
412
423
  };