isite 1.14.92 → 2021.11.3-0.1

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.
Files changed (59) hide show
  1. package/README.md +488 -477
  2. package/apps/client-side/app.js +28 -1
  3. package/apps/client-side/site_files/css/btn.css +98 -0
  4. package/apps/client-side/site_files/css/checkbox.css +10 -7
  5. package/apps/client-side/site_files/css/dropdown.css +61 -0
  6. package/apps/client-side/site_files/css/effect.css +283 -280
  7. package/apps/client-side/site_files/css/font-awesome.css +4615 -3
  8. package/apps/client-side/site_files/css/font-awesome.min.css +5 -0
  9. package/apps/client-side/site_files/css/font-cairo.css +14 -0
  10. package/apps/client-side/site_files/css/font-droid.css +19 -0
  11. package/apps/client-side/site_files/css/fonts.css +6 -34
  12. package/apps/client-side/site_files/css/form.css +31 -131
  13. package/apps/client-side/site_files/css/layout.css +27 -13
  14. package/apps/client-side/site_files/css/modal.css +184 -164
  15. package/apps/client-side/site_files/css/tabs.css +3 -3
  16. package/apps/client-side/site_files/css/theme.css +2 -2
  17. package/apps/client-side/site_files/css/theme_dark.css +1 -1
  18. package/apps/client-side/site_files/css/theme_paper.css +175 -151
  19. package/apps/client-side/site_files/html/sub/i-date2.content.html +64 -0
  20. package/apps/client-side/site_files/html/sub/i-list.content.html +31 -0
  21. package/apps/client-side/site_files/html/sub/i-list2.content.html +22 -0
  22. package/apps/client-side/site_files/js/directive.js +1570 -1650
  23. package/apps/client-side/site_files/js/directive.min.js +2 -2
  24. package/apps/client-side/site_files/js/site.js +59 -17
  25. package/apps/client-side/site_files/js/site.min.js +1 -1
  26. package/apps/client-side/site_files/webfonts/fa-brands-400.eot +0 -0
  27. package/apps/client-side/site_files/webfonts/fa-brands-400.svg +3717 -0
  28. package/apps/client-side/site_files/webfonts/fa-brands-400.ttf +0 -0
  29. package/apps/client-side/site_files/webfonts/fa-brands-400.woff +0 -0
  30. package/apps/client-side/site_files/webfonts/fa-brands-400.woff2 +0 -0
  31. package/apps/client-side/site_files/webfonts/fa-regular-400.eot +0 -0
  32. package/apps/client-side/site_files/webfonts/fa-regular-400.svg +801 -0
  33. package/apps/client-side/site_files/webfonts/fa-regular-400.ttf +0 -0
  34. package/apps/client-side/site_files/webfonts/fa-regular-400.woff +0 -0
  35. package/apps/client-side/site_files/webfonts/fa-regular-400.woff2 +0 -0
  36. package/apps/client-side/site_files/webfonts/fa-solid-900.eot +0 -0
  37. package/apps/client-side/site_files/webfonts/fa-solid-900.svg +5034 -0
  38. package/apps/client-side/site_files/webfonts/fa-solid-900.ttf +0 -0
  39. package/apps/client-side/site_files/webfonts/fa-solid-900.woff +0 -0
  40. package/apps/client-side/site_files/webfonts/fa-solid-900.woff2 +0 -0
  41. package/apps/ui-print/site_files/js/index.js +194 -191
  42. package/index.js +2 -2
  43. package/isite_files/html/browser.html +1 -1
  44. package/isite_files/html/installing.html +1 -1
  45. package/lib/collection.js +14 -7
  46. package/lib/fsm.js +389 -346
  47. package/lib/logs.js +1 -1
  48. package/lib/mongodb.js +9 -7
  49. package/lib/parser.js +495 -475
  50. package/lib/routing.js +61 -17
  51. package/lib/security.js +4 -4
  52. package/lib/session.js +8 -22
  53. package/lib/sessions.js +1 -1
  54. package/lib/storage.js +1 -1
  55. package/lib/temp.js +1 -1
  56. package/lib/ws.js +3 -0
  57. package/object-options/index.js +4 -4
  58. package/object-options/lib/fn.js +1 -1
  59. package/package.json +1 -1
package/README.md CHANGED
@@ -3,37 +3,37 @@ so your site work on Social Browser by default
3
3
 
4
4
  ## Create [ Node Js Web Site ] Supporting Many Development features
5
5
 
6
- - More Secure
7
- - Multi Language
8
- - Custom Apps [Modules]
9
- - Best Performance
10
- - Less Time
11
- - Less Cost
12
- - Fast Development
6
+ - More Secure
7
+ - Multi Language
8
+ - Custom Apps [Modules]
9
+ - Best Performance
10
+ - Less Time
11
+ - Less Cost
12
+ - Fast Development
13
13
 
14
14
  # Features
15
15
 
16
- - Auto Routes [Simple & Advanced & Custom]
17
- - Auto Handle File Types Encoding [Fonts - Images - ...]
18
- - Merge Multi Files Contents in One Route
19
- - Auto Handle Request & Response Headers [Cookies - Parameters - params]
20
- - Auto Detect & Configer User Session
21
- - Built-in Security System [Users , Roles, Permissions]
22
- - Easy Creating Master Pages
23
- - Auto Caching All Routes & Management Site Files in Memory
24
- - Fast Read Files Content [Site Folder Structure]
25
- - [ Upload / Download ] Files
26
- - Custom Html Attributes [Server side Tags]
27
- - MongoDB Full Integration
28
- - Client libraries [jquery - bootstrap - font-awesome - angular]
29
- - Local Multi Charts Apps
30
- - Development Helper Functions
31
- - Site Dynamic Events Callback
32
- - Auto WebSocket Handle
16
+ - Auto Routes [Simple & Advanced & Custom]
17
+ - Auto Handle File Types Encoding [Fonts - Images - ...]
18
+ - Merge Multi Files Contents in One Route
19
+ - Auto Handle Request & Response Headers [Cookies - Parameters - params]
20
+ - Auto Detect & Configer User Session
21
+ - Built-in Security System [Users , Roles, Permissions]
22
+ - Easy Creating Master Pages
23
+ - Auto Caching All Routes & Management Site Files in Memory
24
+ - Fast Read Files Content [Site Folder Structure]
25
+ - [ Upload / Download ] Files
26
+ - Custom Html Attributes [Server side Tags]
27
+ - MongoDB Full Integration
28
+ - Client libraries [jquery - bootstrap - font-awesome - angular]
29
+ - Local Multi Charts Apps
30
+ - Development Helper Functions
31
+ - Site Dynamic Events Callback
32
+ - Auto WebSocket Handle
33
33
 
34
34
  ## Fast Startup
35
35
 
36
- - Download Startup Template
36
+ - Download Startup Template
37
37
 
38
38
  ```sh
39
39
  git clone https://github.com/absunstar/isite-template
@@ -46,12 +46,12 @@ so your site work on Social Browser by default
46
46
 
47
47
  `npm install isite`
48
48
 
49
- - Works Stand-Alone or With Other Libs
50
- - updated every 1 month at least ( npm i isite ) for production apps
49
+ - Works Stand-Alone or With Other Libs
50
+ - updated every 1 month at least ( npm i isite ) for production apps
51
51
 
52
52
  ## Using
53
53
 
54
- - Fast Startup Web Server.
54
+ - Fast Startup Web Server.
55
55
 
56
56
  ```js
57
57
  var isite = require('isite');
@@ -63,7 +63,7 @@ site.loadLocalApp('security');
63
63
  site.run();
64
64
  ```
65
65
 
66
- - Multi port opens
66
+ - Multi port opens
67
67
 
68
68
  ```js
69
69
  var isite = require('isite');
@@ -75,84 +75,84 @@ site.loadLocalApp('security');
75
75
  site.run([8080, 5555, 9090, 12345]);
76
76
  ```
77
77
 
78
- - Default Options.
78
+ - Default Options.
79
79
 
80
80
  ```js
81
81
  var isite = require('isite');
82
82
  site = isite({
83
- port: process.env.port || 80,
84
- cwd: process.cwd(),
85
- dir: process.cwd() + '/site_files',
86
- upload_dir: process.cwd() + '/../uploads',
87
- download_dir: process.cwd() + '/../downloads',
88
- apps: !0,
89
- apps_dir: process.cwd() + '/apps',
90
- name: 'Your Site',
91
- dynamic: false, // (auto set )dynamic db & prot based on folder name [ smart-pos-3000 ]
92
- saving_time: 60,
93
- log: !0,
94
- lang: 'ar',
95
- theme: 'default',
96
- help: !0,
97
- stdin: !0,
98
- https: {
99
- enabled: false,
100
- port: null,
101
- ports: [],
102
- key: null,
103
- cert: null,
104
- },
105
- mongodb: {
106
- enabled: !0,
107
- host: '127.0.0.1',
108
- port: '27017',
109
- userName: null,
110
- password: null,
111
- db: 'default_db',
112
- collection: 'default_collection',
113
- limit: 10,
114
- prefix: {
115
- db: '',
116
- collection: '',
83
+ port: process.env.port || 80,
84
+ cwd: process.cwd(),
85
+ dir: process.cwd() + '/site_files',
86
+ upload_dir: process.cwd() + '/../uploads',
87
+ download_dir: process.cwd() + '/../downloads',
88
+ apps: !0,
89
+ apps_dir: process.cwd() + '/apps',
90
+ name: 'Your Site',
91
+ dynamic: false, // (auto set )dynamic db & prot based on folder name [ smart-pos-3000 ]
92
+ savingTime: 60,
93
+ log: !0,
94
+ lang: 'ar',
95
+ theme: 'default',
96
+ help: !0,
97
+ stdin: !0,
98
+ https: {
99
+ enabled: false,
100
+ port: null,
101
+ ports: [],
102
+ key: null,
103
+ cert: null,
117
104
  },
118
- identity: {
119
- enabled: !0,
120
- start: 1,
121
- step: 1,
105
+ mongodb: {
106
+ enabled: !0,
107
+ host: 'localhost',
108
+ port: '27017',
109
+ userName: null,
110
+ password: null,
111
+ db: 'default_db',
112
+ collection: 'default_collection',
113
+ limit: 10,
114
+ prefix: {
115
+ db: '',
116
+ collection: '',
117
+ },
118
+ identity: {
119
+ enabled: !0,
120
+ start: 1,
121
+ step: 1,
122
+ },
122
123
  },
123
- },
124
- session: {
125
- timeout: 60 * 24 * 30,
126
- enabled: !0,
127
- storage: 'mongodb',
128
- db: null,
129
- collection: 'users_sessions',
130
- },
131
- security: {
132
- enabled: !0,
133
- db: null,
134
- users_collection: 'users_info',
135
- roles_collection: 'users_roles',
136
- admin: {
137
- email: 'admin@isite',
138
- password: 'P@$$w0rd',
124
+ session: {
125
+ timeout: 60 * 24 * 30,
126
+ enabled: !0,
127
+ storage: 'mongodb',
128
+ db: null,
129
+ collection: 'users_sessions',
130
+ },
131
+ security: {
132
+ enabled: !0,
133
+ db: null,
134
+ users_collection: 'users_info',
135
+ roles_collection: 'users_roles',
136
+ admin: {
137
+ email: 'admin@isite',
138
+ password: 'P@$$w0rd',
139
+ },
140
+ users: [],
141
+ },
142
+ cache: {
143
+ enabled: !0,
144
+ html: 0,
145
+ txt: 60 * 24 * 30,
146
+ js: 60 * 24 * 30,
147
+ css: 60 * 24 * 30,
148
+ fonts: 60 * 24 * 30,
149
+ images: 60 * 24 * 30,
150
+ json: 60 * 24 * 30,
151
+ xml: 60 * 24 * 30,
152
+ },
153
+ proto: {
154
+ object: !0,
139
155
  },
140
- users: [],
141
- },
142
- cache: {
143
- enabled: !0,
144
- html: 0,
145
- txt: 60 * 24 * 30,
146
- js: 60 * 24 * 30,
147
- css: 60 * 24 * 30,
148
- fonts: 60 * 24 * 30,
149
- images: 60 * 24 * 30,
150
- json: 60 * 24 * 30,
151
- xml: 60 * 24 * 30,
152
- },
153
- proto: {
154
- object: !0,
155
- },
156
156
  });
157
157
 
158
158
  site.run();
@@ -160,31 +160,31 @@ site.run();
160
160
 
161
161
  ## Site Folder Structure
162
162
 
163
- - site stucture help you to manage you site easy and fast
163
+ - site stucture help you to manage you site easy and fast
164
164
 
165
165
  ```html
166
166
  - server.js - package.json - README.md -- apps -- site_files --- css - bootstrap.css - custom.css --- js - jquery.js - bootstrap.js - custom.js --- html - index.html --- fonts --- images - logo.png
167
167
  --- json - items.json - words.json - roles.json - permissions.json --- xml - rss.xml
168
168
  ```
169
169
 
170
- - Create Folder Name "site_files"
171
- - inside it create these Sub folders [
172
- html , css , js , json , fonts , images , xml , ...
173
- ]
170
+ - Create Folder Name "site_files"
171
+ - inside it create these Sub folders [
172
+ html , css , js , json , fonts , images , xml , ...
173
+ ]
174
174
 
175
175
  ## Routes
176
176
 
177
- - Auto Convert All Routes URL & Parameters to Lower Case
178
- - Auto Manage Reponse Headers and Files Types
179
- - Support Multi Files in One Route
180
- - Save Route Response in Memory to Reuse for Fast Response
181
- - Auto Handle URL parametes
182
- - Auto Handle Body Parameters in not get header [post , put , delete , ...]
183
- - Auto Handle URL params [custom parameters from url structure]
184
- - Auto cache Files Content in memory
185
- - support compress to remove unwanted spaces and tabs and empty lines ...etc
186
- - support parser to handle custom html server side tags
187
- - Call Route From Other Route [ Server Side ]
177
+ - Auto Convert All Routes URL & Parameters to Lower Case
178
+ - Auto Manage Reponse Headers and Files Types
179
+ - Support Multi Files in One Route
180
+ - Save Route Response in Memory to Reuse for Fast Response
181
+ - Auto Handle URL parametes
182
+ - Auto Handle Body Parameters in not get header [post , put , delete , ...]
183
+ - Auto Handle URL params [custom parameters from url structure]
184
+ - Auto cache Files Content in memory
185
+ - support compress to remove unwanted spaces and tabs and empty lines ...etc
186
+ - support parser to handle custom html server side tags
187
+ - Call Route From Other Route [ Server Side ]
188
188
 
189
189
  Easy and Auto Site Routing
190
190
 
@@ -194,85 +194,96 @@ Easy and Auto Site Routing
194
194
  or set site.dir = new path
195
195
  */
196
196
 
197
- site.get({ name: ['/', '/home', '/index'], path: site.dir + '/html/index.html' });
198
- site.get({ name: '/css/bootstrap.css', path: site.dir + '/css/bootstrap.min.css' });
199
- site.get({ name: '/js/jquery.js', path: site.dir + '/js/jquery.js' });
200
- site.get({ name: '/js/bootstrap.js', path: site.dir + '/js/bootstrap.js' });
201
- site.get({ name: '/favicon.png', path: site.dir + '/images/logo.png' });
202
- site.post({ name: '/api', path: site.dir + '/json/employees.json' });
197
+ site.onGET({ name: ['/', '/home', '/index'], path: site.dir + '/html/index.html' });
198
+ site.onGET({ name: '/css/bootstrap.css', path: site.dir + '/css/bootstrap.min.css' });
199
+ site.onGET({ name: '/js/jquery.js', path: site.dir + '/js/jquery.js' });
200
+ site.onGET({ name: '/js/bootstrap.js', path: site.dir + '/js/bootstrap.js' });
201
+ site.onGET({ name: '/favicon.png', path: site.dir + '/images/logo.png' });
202
+ site.onPOST({ name: '/api', path: site.dir + '/json/employees.json' });
203
203
  ```
204
204
 
205
205
  Merge Multi Files in one route
206
206
 
207
207
  ```js
208
- site.get({
209
- name: '/css/style.css',
210
- path: [site.dir + '/css/bootstrap.css', site.dir + '/css/custom.css'],
208
+ site.onGET({
209
+ name: '/css/style.css',
210
+ path: [site.dir + '/css/bootstrap.css', site.dir + '/css/custom.css'],
211
211
  });
212
- site.get({
213
- name: '/js/script.js',
214
- path: [site.dir + '/js/jquery.js', site.dir + '/js/bootstrap.js', site.dir + '/js/custom.js'],
212
+ site.onGET({
213
+ name: '/js/script.js',
214
+ path: [site.dir + '/js/jquery.js', site.dir + '/js/bootstrap.js', site.dir + '/js/custom.js'],
215
215
  });
216
216
  ```
217
217
 
218
218
  Advanced Site Routing
219
219
 
220
220
  ```js
221
+ site.onREQUEST('get', '/', (req, res) => {});
221
222
 
222
- site.onGET('/home2' , (req , res)=>{
223
- site.callRoute('/home' , req , res)
224
- })
223
+ site.onREQUEST('get', { name: '/' }, (req, res) => {});
225
224
 
226
- site.get('/', (req, res) => {
227
- site.readFile(site.dir + '/html/index.html', function (err, content, file) {
228
- res.set('Content-type', 'text/html');
229
- res.set('Content-size', file.stat.size);
230
- res.status(200).end(content);
231
- });
225
+ site.onGET('/home2', (req, res) => {
226
+ site.callRoute('/home', req, res);
232
227
  });
233
228
 
234
- site.get('/', (req, res) => {
235
- site.html('index', function (err, content) {
236
- res.set('Content-type', 'text/html');
237
- res.status(200).end(content);
238
- });
229
+ site.onGET({
230
+ name: 'api/user/add',
231
+ content: {
232
+ done: true,
233
+ id: 1,
234
+ },
239
235
  });
240
236
 
241
- site.get({
242
- // can use [get , post , put , delete , all]
243
- name: '/',
244
- path: site.dir + '/html/index.html', //Required
245
- parser: 'html', // default static [not paresed]
246
- compress: !0, // default false
247
- cache: false, // default !0
237
+ site.onGET('/', (req, res) => {
238
+ site.readFile(site.dir + '/html/index.html', function (err, content, file) {
239
+ res.set('Content-type', 'text/html');
240
+ res.set('Content-size', file.stat.size);
241
+ res.status(200).end(content);
242
+ });
248
243
  });
249
244
 
250
- site.get({
251
- name: '/',
252
- callback: function (req, res) {
253
- res.set('Content-type', 'text/html');
245
+ site.onGET('/', (req, res) => {
254
246
  site.html('index', function (err, content) {
255
- res.status(200).end(content);
247
+ res.set('Content-type', 'text/html');
248
+ res.status(200).end(content);
256
249
  });
257
- },
250
+ });
251
+
252
+ site.onGET({
253
+ // can use [get , post , put , delete , all]
254
+ name: '/',
255
+ path: site.dir + '/html/index.html', //Required
256
+ parser: 'html', // default static [not paresed]
257
+ compress: !0, // default false
258
+ cache: false, // default !0
259
+ });
260
+
261
+ site.onGET({
262
+ name: '/',
263
+ callback: function (req, res) {
264
+ res.set('Content-type', 'text/html');
265
+ site.html('index', function (err, content) {
266
+ res.status(200).end(content);
267
+ });
268
+ },
258
269
  });
259
270
  ```
260
271
 
261
272
  Auto Route All Files in Folder
262
273
 
263
274
  ```js
264
- site.get({ name: '/js', path: site.dir + '/js' });
265
- site.get({ name: '/css', path: site.dir + '/css' });
275
+ site.onGET({ name: '/js', path: site.dir + '/js' });
276
+ site.onGET({ name: '/css', path: site.dir + '/css' });
266
277
  ```
267
278
 
268
279
  Custom Route - Using \* [any letters]
269
280
 
270
281
  ```js
271
- site.get('/post/*', function (req, res) {
272
- res.end('Any Route like /post/11212154545 ');
282
+ site.onGET('/post/*', function (req, res) {
283
+ res.end('Any Route like /post/11212154545 ');
273
284
  });
274
- site.get('*', function (req, res) {
275
- res.end('Any Route Requested Not Handled Before This Code');
285
+ site.onGET('*', function (req, res) {
286
+ res.end('Any Route Requested Not Handled Before This Code');
276
287
  });
277
288
  ```
278
289
 
@@ -280,25 +291,25 @@ Request Parameters [GET , POST | PUT | Delete] Restful API
280
291
 
281
292
  ```js
282
293
  // read query parameter lower case
283
- site.get('/api', function (req, res) {
284
- res.end('GET | name : ' + req.query.name);
294
+ site.onGET('/api', function (req, res) {
295
+ res.end('GET | name : ' + req.query.name);
285
296
  });
286
297
  // read query parameter default case as requested
287
- site.get('/api', function (req, res) {
288
- res.end('GET | name : ' + req.queryRaw.name);
298
+ site.onGET('/api', function (req, res) {
299
+ res.end('GET | name : ' + req.queryRaw.name);
289
300
  });
290
301
 
291
- site.post('/api', function (req, res) {
292
- res.end('POST | id : ' + req.body.id + ' , Name : ' + req.body.name);
302
+ site.onPOST('/api', function (req, res) {
303
+ res.end('POST | id : ' + req.body.id + ' , Name : ' + req.body.name);
293
304
  });
294
- site.put('/api', function (req, res) {
295
- res.end('PUT | id : ' + req.body.id + ' , Name : ' + req.body.name);
305
+ site.onPUT('/api', function (req, res) {
306
+ res.end('PUT | id : ' + req.body.id + ' , Name : ' + req.body.name);
296
307
  });
297
- site.delete('/api', function (req, res) {
298
- res.end('Delete | id : ' + req.body.id);
308
+ site.onDELETE('/api', function (req, res) {
309
+ res.end('Delete | id : ' + req.body.id);
299
310
  });
300
- site.all('/api', function (req, res) {
301
- res.end('Any Request Routing Type Not Handled Yet : ' + req.method);
311
+ site.onALL('/api', function (req, res) {
312
+ res.end('Any Request Routing Type Not Handled Yet : ' + req.method);
302
313
  });
303
314
  ```
304
315
 
@@ -306,12 +317,12 @@ Dynamic Parameters
306
317
 
307
318
  ```js
308
319
  // read params lower case
309
- site.get('/post/:id/category/:cat_id', function (req, res) {
310
- res.end('GET | Id : ' + req.params.id + ', catId : ' + req.params.cat_id);
320
+ site.onGET('/post/:id/category/:cat_id', function (req, res) {
321
+ res.end('GET | Id : ' + req.params.id + ', catId : ' + req.params.cat_id);
311
322
  });
312
323
  // read params default case as requested
313
- site.get('/post/:id/category/:cat_id', function (req, res) {
314
- res.end('GET | Id : ' + req.paramsRaw.id + ', catId : ' + req.paramsRaw.cat_id);
324
+ site.onGET('/post/:id/category/:cat_id', function (req, res) {
325
+ res.end('GET | Id : ' + req.paramsRaw.id + ', catId : ' + req.paramsRaw.cat_id);
315
326
  });
316
327
  //example : /post/AbCdEf/category/DDDDD
317
328
  ```
@@ -319,51 +330,51 @@ site.get('/post/:id/category/:cat_id', function (req, res) {
319
330
  MVC Custom Route
320
331
 
321
332
  ```js
322
- site.get('/:controller/:Action/:Arg1', function (req, res) {
323
- res.end(
324
- 'GET | Controller : ' +
325
- req.params.controller +
326
- ', Action : ' +
327
- req.params.Action /* Normal case*/ +
328
- ', action : ' +
329
- req.params.action /* lower case*/ +
330
- ', Arg 1 : ' +
331
- req.params.Arg1 /* Normal case*/ +
332
- ', arg 1 : ' +
333
- req.params.arg1 /* lower case*/,
334
- );
333
+ site.onGET('/:controller/:Action/:Arg1', function (req, res) {
334
+ res.end(
335
+ 'GET | Controller : ' +
336
+ req.params.controller +
337
+ ', Action : ' +
338
+ req.params.Action /* Normal case*/ +
339
+ ', action : ' +
340
+ req.params.action /* lower case*/ +
341
+ ', Arg 1 : ' +
342
+ req.params.Arg1 /* Normal case*/ +
343
+ ', arg 1 : ' +
344
+ req.params.arg1 /* lower case*/,
345
+ );
335
346
  });
336
347
  //example : /facebook/post/xxxxxxxxxx
337
348
  ```
338
349
 
339
- - To Easy Read File Contents From "site_files" Folder
350
+ - To Easy Read File Contents From "site_files" Folder
340
351
 
341
352
  ```js
342
353
  site.html('index', function (err, content) {
343
- site.log(content);
354
+ site.log(content);
344
355
  });
345
356
  site.css('bootstrap', function (err, content) {
346
- site.log(content);
357
+ site.log(content);
347
358
  });
348
359
  site.js('jquery', function (err, content) {
349
- site.log(content);
360
+ site.log(content);
350
361
  });
351
362
  site.json('items', function (err, content) {
352
- site.log(content);
363
+ site.log(content);
353
364
  });
354
365
  site.xml('rss', function (err, content) {
355
- site.log(content);
366
+ site.log(content);
356
367
  });
357
368
  ```
358
369
 
359
- - Custom Read Files
370
+ - Custom Read Files
360
371
 
361
- - Read From Local File in First Time and save in memory
362
- - next time Read Will be From Memory
372
+ - Read From Local File in First Time and save in memory
373
+ - next time Read Will be From Memory
363
374
 
364
375
  ```js
365
376
  //read file with custom header
366
- site.get("/rss", function(req, res) {
377
+ site.onGET("/rss", function(req, res) {
367
378
  site.readFile(__dirname + "/site_files/xml/rss.xml", function(err, content , file) {
368
379
  res.set("content-type" , "text/xml")
369
380
  res.set("content-size" , file.stat.size)
@@ -371,7 +382,7 @@ site.get("/rss", function(req, res) {
371
382
  })
372
383
  })
373
384
  // or [ if file in site_files/xml folder]
374
- site.get("/rss", function(req, res) {
385
+ site.onGET("/rss", function(req, res) {
375
386
  site.xml("rss", function(err, content , file) {
376
387
  res.set("content-type" , "text/xml")
377
388
  res.set("content-size" , file.stat.size)
@@ -380,7 +391,7 @@ site.get("/rss", function(req, res) {
380
391
  })
381
392
 
382
393
  // Read and Merge multi files with custom header
383
- site.get("/", function(req, res) {
394
+ site.onGET("/", function(req, res) {
384
395
  site.readFiles(
385
396
  [
386
397
  __dirname + "/site_files/html/head.html",
@@ -433,117 +444,117 @@ site.createDir(path , (err , path)=>{
433
444
 
434
445
  ## WebSocket
435
446
 
436
- - Server Side
447
+ - Server Side
437
448
 
438
449
  ```js
439
450
  site.onWS('/chat', (client) => {
440
- client.onMessage = function (message) {
441
- console.log(message);
442
- if (message.type === 'connected') {
443
- client.send({ type: 'ready' });
444
- }
445
- };
446
- console.log('New Client ...' + client.ip);
451
+ client.onMessage = function (message) {
452
+ console.log(message);
453
+ if (message.type === 'connected') {
454
+ client.send({ type: 'ready' });
455
+ }
456
+ };
457
+ console.log('New Client ...' + client.ip);
447
458
  });
448
459
  ```
449
460
 
450
- - Client Side
461
+ - Client Side
451
462
 
452
463
  ```html
453
464
  <script src="/x-js/all.js"></script>
454
465
  ```
455
466
 
456
467
  ```js
457
- site.ws('ws://127.0.0.1/chat', (server) => {
458
- window.server = server;
459
- server.onOpen = () => {
460
- server.send({ type: 'accessToken', content: '##session.accessToken##' });
461
- };
462
- server.onMessage = (msg) => {
463
- console.log(msg);
464
- };
468
+ site.ws('ws://localhost/chat', (server) => {
469
+ window.server = server;
470
+ server.onOpen = () => {
471
+ server.send({ type: 'accessToken', content: '##session.accessToken##' });
472
+ };
473
+ server.onMessage = (msg) => {
474
+ console.log(msg);
475
+ };
465
476
  });
466
477
 
467
478
  // or
468
479
 
469
- var ws = new WebSocket('ws://127.0.0.1/chat');
480
+ var ws = new WebSocket('ws://localhost/chat');
470
481
 
471
482
  ws.onerror = function (error) {};
472
483
  ws.onclose = function () {};
473
484
 
474
485
  ws.onopen = function () {
475
- ws.send(JSON.stringify({ type: 'connect' }));
486
+ ws.send(JSON.stringify({ type: 'connect' }));
476
487
  };
477
488
 
478
489
  ws.onmessage = function (msg) {
479
- msg = JSON.parse(msg.data);
480
- if (msg.type === 'ready') {
481
- ws.send(JSON.stringify({ type: 'ready' }));
482
- }
490
+ msg = JSON.parse(msg.data);
491
+ if (msg.type === 'ready') {
492
+ ws.send(JSON.stringify({ type: 'ready' }));
493
+ }
483
494
  };
484
495
  ```
485
496
 
486
497
  ## Cookies
487
498
 
488
- - Cookie is Client Side Data Per User
489
- - Cookie is Enabled by Default
490
- - Support Multi Keys
499
+ - Cookie is Client Side Data Per User
500
+ - Cookie is Enabled by Default
501
+ - Support Multi Keys
491
502
 
492
503
  ```js
493
- site.get('/testSetCookie', function (req, res) {
494
- res.cookie('name', req.query.name);
495
- res.cookie('ip', req.ip);
496
- res.cookie('more', 'any data');
497
- res.end('cookie set');
504
+ site.onGET('/testSetCookie', function (req, res) {
505
+ res.cookie('name', req.query.name);
506
+ res.cookie('ip', req.ip);
507
+ res.cookie('more', 'any data');
508
+ res.end('cookie set');
498
509
  }); //example : /testSetCookie?name=amr
499
510
 
500
- site.get('/testGetCookie', function (req, res) {
501
- res.end('name from cookie : ' + req.cookie('name'));
511
+ site.onGET('/testGetCookie', function (req, res) {
512
+ res.end('name from cookie : ' + req.cookie('name'));
502
513
  }); //example : /testGetCookie
503
514
  ```
504
515
 
505
516
  ## Sessions
506
517
 
507
- - Session is Server Side Data Per User
508
- - Every User has Unique Access Token
509
- - Session Management Automatic
510
- - Session Store in Database by Default
518
+ - Session is Server Side Data Per User
519
+ - Every User has Unique Access Token
520
+ - Session Management Automatic
521
+ - Session Store in Database by Default
511
522
 
512
523
  ```js
513
- site.get('/testSetSession', function (req, res) {
514
- req.session('user_name', req.query.user_name);
515
- res.session('ip', req.ip);
516
- res.session('more', 'any data');
517
- res.end('Session Set ok !! ');
524
+ site.onGET('/testSetSession', function (req, res) {
525
+ req.session('user_name', req.query.user_name);
526
+ res.session('ip', req.ip);
527
+ res.session('more', 'any data');
528
+ res.end('Session Set ok !! ');
518
529
  }); //example : /testSetSession?user_name=absunstar
519
530
 
520
- site.get('/testGetSession', function (req, res) {
521
- res.end('User Name from session : ' + req.session('user_name'));
531
+ site.onGET('/testGetSession', function (req, res) {
532
+ res.end('User Name from session : ' + req.session('user_name'));
522
533
  }); //example : /testGetSession
523
534
  ```
524
535
 
525
536
  ## Custom App
526
537
 
527
- - Custom App Help you to Easy Management Site Life-Cycle
528
- - Easy Register & Integrated
529
- - Best Solution when work with Team
538
+ - Custom App Help you to Easy Management Site Life-Cycle
539
+ - Easy Register & Integrated
540
+ - Best Solution when work with Team
530
541
 
531
542
  ### How to make it
532
543
 
533
- - Create your app folder in global apps folder
534
- - Add app.js file with this code
544
+ - Create your app folder in global apps folder
545
+ - Add app.js file with this code
535
546
 
536
547
  ```js
537
548
  module.exports = function (site) {
538
- // write here your custom code
549
+ // write here your custom code
539
550
  };
540
551
  ```
541
552
 
542
- - App Will Be Auto Register And Integerated With Your Site
553
+ - App Will Be Auto Register And Integerated With Your Site
543
554
 
544
555
  ### add App From github
545
556
 
546
- - Add Apps from github to Your Site
557
+ - Add Apps from github to Your Site
547
558
 
548
559
  ```sh
549
560
  cd apps
@@ -559,57 +570,57 @@ site.importApp(FOLDER_PATH);
559
570
 
560
571
  ## Master Pages
561
572
 
562
- - Master Page put content between header and footer
563
- - Master Page help you to not repate you code
564
- - Master Page make site layout look good with less code
565
- - Master Page has tow parts header and footer
573
+ - Master Page put content between header and footer
574
+ - Master Page help you to not repate you code
575
+ - Master Page make site layout look good with less code
576
+ - Master Page has tow parts header and footer
566
577
 
567
578
  ```js
568
579
  site.addMasterPage({
569
- name: 'masterPage1',
570
- header: site.dir + '/html/header.html',
571
- footer: site.dir + '/html/footer.html',
580
+ name: 'masterPage1',
581
+ header: site.dir + '/html/header.html',
582
+ footer: site.dir + '/html/footer.html',
572
583
  });
573
584
 
574
585
  site.addMasterPage({
575
- name: 'masterPage2',
576
- header: site.dir + '/html/header2.html',
577
- footer: site.dir + '/html/footer2.html',
586
+ name: 'masterPage2',
587
+ header: site.dir + '/html/header2.html',
588
+ footer: site.dir + '/html/footer2.html',
578
589
  });
579
590
 
580
- site.get({
581
- name: '/ContactUs',
582
- masterPage: 'masterPage1',
583
- path: site.dir + '/html/contact.html',
584
- parser: 'html',
591
+ site.onGET({
592
+ name: '/ContactUs',
593
+ masterPage: 'masterPage1',
594
+ path: site.dir + '/html/contact.html',
595
+ parser: 'html',
585
596
  });
586
597
  ```
587
598
 
588
599
  ## HTML Server Tags & Attributes
589
600
 
590
- - html server tags is html tags run in server side
591
- - html server tags make html structure easy management
592
- - html server tags is the next generation of html
601
+ - html server tags is html tags run in server side
602
+ - html server tags make html structure easy management
603
+ - html server tags is the next generation of html
593
604
 
594
605
  Add Custom Html Content
595
606
 
596
607
  ```js
597
- site.get({ name: '/', path: site.dir + '/html/index.html', parser: 'html' });
608
+ site.onGET({ name: '/', path: site.dir + '/html/index.html', parser: 'html' });
598
609
  ```
599
610
 
600
611
  ```html
601
612
  <style x-import="page2.css"></style>
602
613
  <div x-import="navbar.html"></div>
603
614
  <div class="container">
604
- <h2>Page Heading 2</h2>
605
- <p x-import="info.html"></p>
615
+ <h2>Page Heading 2</h2>
616
+ <p x-import="info.html"></p>
606
617
  </div>
607
618
  <script x-import="custom.js"></script>
608
619
  ```
609
620
 
610
- - Pages "navbar.html" & "info.html" Must Be In HTML Site Folder ['/site_files/html/']
611
- - Style "page2.css" Must Be In HTML Site Folder ['/site_files/css/']
612
- - Script "custom.js" Must Be In HTML Site Folder ['/site_files/js/']
621
+ - Pages "navbar.html" & "info.html" Must Be In HTML Site Folder ['/site_files/html/']
622
+ - Style "page2.css" Must Be In HTML Site Folder ['/site_files/css/']
623
+ - Script "custom.js" Must Be In HTML Site Folder ['/site_files/js/']
613
624
 
614
625
  Dynamic Varibles Sets
615
626
 
@@ -973,145 +984,145 @@ site.mongodb.client.connect(url, function(err, db) {
973
984
 
974
985
  ## Upload File
975
986
 
976
- - upload File using HTML
987
+ - upload File using HTML
977
988
 
978
989
  ```html
979
990
  <form action="uploadFile" method="post" enctype="multipart/form-data">
980
- <input type="file" name="fileToUpload" /><br />
981
- <input type="submit" />
991
+ <input type="file" name="fileToUpload" /><br />
992
+ <input type="submit" />
982
993
  </form>
983
994
  ```
984
995
 
985
- - Upload File Using Angular js
996
+ - Upload File Using Angular js
986
997
 
987
998
  ```html
988
999
  <form class="form">
989
- <label>Select File To Upload</label>
990
- <input type="file" name="fileToUpload" onchange="angular.element(this).scope().uploadFile(this.files)" />
991
- <p>{{uploadStatus}}</p>
1000
+ <label>Select File To Upload</label>
1001
+ <input type="file" name="fileToUpload" onchange="angular.element(this).scope().uploadFile(this.files)" />
1002
+ <p>{{uploadStatus}}</p>
992
1003
  </form>
993
1004
  ```
994
1005
 
995
1006
  ```js
996
1007
  $scope.uploadFile = function (files) {
997
- var fd = new FormData();
998
- fd.append('fileToUpload', files[0]);
999
- $http
1000
- .post('/uploadFile', fd, {
1001
- withCredentials: !0,
1002
- headers: {
1003
- 'Content-Type': undefined,
1004
- },
1005
- uploadEventHandlers: {
1006
- progress: function (e) {
1007
- $scope.uploadStatus = 'Uploading : ' + Math.round((e.loaded * 100) / e.total) + ' %';
1008
- if (e.loaded == e.total) {
1009
- $scope.uploadStatus = '100%';
1010
- }
1011
- },
1012
- },
1013
- transformRequest: angular.identity,
1014
- })
1015
- .then(
1016
- function (res) {
1017
- if (res.data && res.data.done) {
1018
- $scope.uploadStatus = 'File Uploaded';
1019
- }
1020
- },
1021
- function (error) {
1022
- $scope.uploadStatus = error;
1023
- },
1024
- );
1008
+ var fd = new FormData();
1009
+ fd.append('fileToUpload', files[0]);
1010
+ $http
1011
+ .post('/uploadFile', fd, {
1012
+ withCredentials: !0,
1013
+ headers: {
1014
+ 'Content-Type': undefined,
1015
+ },
1016
+ uploadEventHandlers: {
1017
+ progress: function (e) {
1018
+ $scope.uploadStatus = 'Uploading : ' + Math.round((e.loaded * 100) / e.total) + ' %';
1019
+ if (e.loaded == e.total) {
1020
+ $scope.uploadStatus = '100%';
1021
+ }
1022
+ },
1023
+ },
1024
+ transformRequest: angular.identity,
1025
+ })
1026
+ .then(
1027
+ function (res) {
1028
+ if (res.data && res.data.done) {
1029
+ $scope.uploadStatus = 'File Uploaded';
1030
+ }
1031
+ },
1032
+ function (error) {
1033
+ $scope.uploadStatus = error;
1034
+ },
1035
+ );
1025
1036
  };
1026
1037
  ```
1027
1038
 
1028
- - Recive Uploading File from [html , angular , jquery , ...]
1039
+ - Recive Uploading File from [html , angular , jquery , ...]
1029
1040
 
1030
1041
  ```js
1031
- site.post('uploadFile', (req, res) => {
1032
- var response = { done: !0 };
1033
- var file = req.files.fileToUpload;
1034
- var newpath = site.dir + '/../../uploads/' + file.name;
1035
- site.mv(file.path, newpath, function (err) {
1036
- if (err) {
1037
- response.error = err;
1038
- response.done = false;
1039
- }
1040
- res.end(JSON.stringify(response));
1041
- });
1042
+ site.onPOST('uploadFile', (req, res) => {
1043
+ var response = { done: !0 };
1044
+ var file = req.files.fileToUpload;
1045
+ var newpath = site.dir + '/../../uploads/' + file.name;
1046
+ site.mv(file.path, newpath, function (err) {
1047
+ if (err) {
1048
+ response.error = err;
1049
+ response.done = false;
1050
+ }
1051
+ res.end(JSON.stringify(response));
1052
+ });
1042
1053
  });
1043
1054
  ```
1044
1055
 
1045
1056
  ## Download File
1046
1057
 
1047
- - download any file from server
1048
- - auto handle file content and size
1049
- - force client browser to download file
1058
+ - download any file from server
1059
+ - auto handle file content and size
1060
+ - force client browser to download file
1050
1061
 
1051
1062
  ```js
1052
1063
  // download any file
1053
- site.get('/files/file1.zip', (req, res) => {
1054
- res.download(site.dir + '/downloads/file1.zip');
1064
+ site.onGET('/files/file1.zip', (req, res) => {
1065
+ res.download(site.dir + '/downloads/file1.zip');
1055
1066
  });
1056
1067
  //download and change file name
1057
- site.get('/files/file1.zip', (req, res) => {
1058
- res.download(site.dir + '/downloads/file1.zip', 'info.zip');
1068
+ site.onGET('/files/file1.zip', (req, res) => {
1069
+ res.download(site.dir + '/downloads/file1.zip', 'info.zip');
1059
1070
  });
1060
1071
  ```
1061
1072
 
1062
1073
  ## Multi Languages
1063
1074
 
1064
- - Can Add Any Custom Language You Want
1065
- - Can Change Default Language on Site Options
1066
- - Stores Words in Diffrent Language in words json file
1067
- - Auto Detect Words.json
1068
- - Folder Structure Like This
1075
+ - Can Add Any Custom Language You Want
1076
+ - Can Change Default Language on Site Options
1077
+ - Stores Words in Diffrent Language in words json file
1078
+ - Auto Detect Words.json
1079
+ - Folder Structure Like This
1069
1080
 
1070
1081
  ```html
1071
1082
  - apps - server.js - package.json - README.md -- site_files --- json - words.json
1072
1083
  ```
1073
1084
 
1074
- - Words Json File Structure Like This
1085
+ - Words Json File Structure Like This
1075
1086
 
1076
1087
  ```json
1077
1088
  [
1078
- { "name": "user_name", "en": "User Name", "ar": "أسم المستخدم" },
1079
- { "name": "user_email", "en": "Email", "ar": "البريد الالكترونى" },
1080
- { "name": "user_password", "en": "Password", "ar": "كلمة المرور" }
1089
+ { "name": "user_name", "en": "User Name", "ar": "أسم المستخدم" },
1090
+ { "name": "user_email", "en": "Email", "ar": "البريد الالكترونى" },
1091
+ { "name": "user_password", "en": "Password", "ar": "كلمة المرور" }
1081
1092
  ]
1082
1093
  ```
1083
1094
 
1084
- - Use in html Like This
1095
+ - Use in html Like This
1085
1096
 
1086
1097
  ```html
1087
1098
  <form>
1088
- <label> ##word.user_name## </label>
1089
- <input />
1090
- <br />
1099
+ <label> ##word.user_name## </label>
1100
+ <input />
1101
+ <br />
1091
1102
 
1092
- <label> ##word.user_email## </label>
1093
- <input />
1094
- <br />
1103
+ <label> ##word.user_email## </label>
1104
+ <input />
1105
+ <br />
1095
1106
 
1096
- <label> ##word.user_password## </label>
1097
- <input />
1098
- <br />
1107
+ <label> ##word.user_password## </label>
1108
+ <input />
1109
+ <br />
1099
1110
  </form>
1100
1111
  ```
1101
1112
 
1102
- - Cahnge Site Language
1113
+ - Cahnge Site Language
1103
1114
 
1104
1115
  ```js
1105
1116
  $scope.changeLang = function (lang) {
1106
- $http({
1107
- method: 'POST',
1108
- url: '/@language/change',
1109
- data: { name: lang },
1110
- }).then(function (response) {
1111
- if (response.data.done) {
1112
- window.location.reload(!0);
1113
- }
1114
- });
1117
+ $http({
1118
+ method: 'POST',
1119
+ url: '/@language/change',
1120
+ data: { name: lang },
1121
+ }).then(function (response) {
1122
+ if (response.data.done) {
1123
+ window.location.reload(!0);
1124
+ }
1125
+ });
1115
1126
  };
1116
1127
  ```
1117
1128
 
@@ -1119,7 +1130,7 @@ $scope.changeLang = function (lang) {
1119
1130
  <a ng-click="changeLang('ar')"> Change To Arabic </a> <a ng-click="changeLang('en')"> Change To English </a>
1120
1131
  ```
1121
1132
 
1122
- - Show Content Depended on Language
1133
+ - Show Content Depended on Language
1123
1134
 
1124
1135
  ```html
1125
1136
  <div x-lang="ar">This Content Will Display When Site Language is Arabic</div>
@@ -1128,7 +1139,7 @@ $scope.changeLang = function (lang) {
1128
1139
 
1129
1140
  ## Client libraries
1130
1141
 
1131
- - install Custom App From https://github.com/absunstar/isite-client
1142
+ - install Custom App From https://github.com/absunstar/isite-client
1132
1143
 
1133
1144
  ```sh
1134
1145
  cd apps
@@ -1151,13 +1162,13 @@ $scope.changeLang = function (lang) {
1151
1162
 
1152
1163
  ## Charts
1153
1164
 
1154
- - Server Side
1165
+ - Server Side
1155
1166
 
1156
1167
  ```js
1157
1168
  site.loadLocalApp('charts');
1158
1169
  ```
1159
1170
 
1160
- - Client Site
1171
+ - Client Site
1161
1172
 
1162
1173
  ```html
1163
1174
  <div id="chart1"></div>
@@ -1166,109 +1177,109 @@ site.loadLocalApp('charts');
1166
1177
 
1167
1178
  ```js
1168
1179
  var data = [
1169
- {
1170
- item: 'item 1',
1171
- count: 500,
1172
- },
1173
- {
1174
- item: 'item 2',
1175
- count: 200,
1176
- },
1177
- {
1178
- item: 'item 3',
1179
- count: 700,
1180
- },
1181
- {
1182
- item: 'item 4',
1183
- count: 300,
1184
- },
1185
- {
1186
- item: 'item 5',
1187
- count: 800,
1188
- },
1189
- {
1190
- item: 'item 6',
1191
- count: 60,
1192
- },
1180
+ {
1181
+ item: 'item 1',
1182
+ count: 500,
1183
+ },
1184
+ {
1185
+ item: 'item 2',
1186
+ count: 200,
1187
+ },
1188
+ {
1189
+ item: 'item 3',
1190
+ count: 700,
1191
+ },
1192
+ {
1193
+ item: 'item 4',
1194
+ count: 300,
1195
+ },
1196
+ {
1197
+ item: 'item 5',
1198
+ count: 800,
1199
+ },
1200
+ {
1201
+ item: 'item 6',
1202
+ count: 60,
1203
+ },
1193
1204
  ];
1194
1205
 
1195
1206
  site.create_chart({
1196
- type: 'xy',
1197
- x: 'item',
1198
- y: 'count',
1199
- data: data,
1200
- selector: '#chart1',
1207
+ type: 'xy',
1208
+ x: 'item',
1209
+ y: 'count',
1210
+ data: data,
1211
+ selector: '#chart1',
1201
1212
  });
1202
1213
  ```
1203
1214
 
1204
1215
  ## Security
1205
1216
 
1206
- - Bulit-in Users Management System
1207
- - Auto Detect Users Sessions & Permissions
1208
- - install Custom Security App From https://github.com/absunstar/isite-security
1217
+ - Bulit-in Users Management System
1218
+ - Auto Detect Users Sessions & Permissions
1219
+ - install Custom Security App From https://github.com/absunstar/isite-security
1209
1220
 
1210
1221
  ```sh
1211
1222
  cd apps
1212
1223
  git clone https://github.com/absunstar/isite-security
1213
1224
  ```
1214
1225
 
1215
- - Manage users From This Route [ /security ]
1226
+ - Manage users From This Route [ /security ]
1216
1227
 
1217
1228
  ## Helper Functions
1218
1229
 
1219
1230
  ```js
1220
- site.get('/', (req, res) => {
1221
- res.render('index.html', { name: 'amr', age: '36' }, { compress: !0, cache: false, parser: 'html css js' });
1222
- res.render('custom.css', { 'font-size': '18px' }, { parser: 'css' });
1223
- res.render('custom.js', { 'allow-ads': !0 }, { parser: 'js' });
1224
- res.code = 301; // set response code to 301
1225
- res.status(301); // set response code if not set to 301 and return response object
1226
- res.set('Content-Type', 'text/plain'); // add response header
1227
- res.remove('Content-Type'); // remove response header
1228
- res.delete('Content-Type'); // remove response header
1229
- res.redirect('/URL'); // Any URL
1230
- res.send('HTML CONTENT'); // Any HTML Content or object
1231
- res.send(obj); // Any HTML Content or object
1232
- res.htmlContent('HTML CONTENT'); // Any HTML Content
1233
- res.html('index'); // like res.render
1234
- res.css('bootstrap'); // css file name
1235
- res.js('jquery'); // js file name
1236
- res.json('items'); // json file name or object
1237
- res.json(obj); // json file name or object
1238
-
1239
- if (req.hasFeature('browser.chrome')) {
1240
- }
1241
- if (req.hasFeature('browser.firefox')) {
1242
- }
1243
- if (req.hasFeature('browser.edge')) {
1244
- }
1245
- if (req.hasFeature('browser.opera')) {
1246
- }
1247
- if (req.hasFeature('browser.ucbrowser')) {
1248
- }
1249
- if (req.hasFeature('browser.baidu')) {
1250
- }
1251
- if (req.hasFeature('browser.chromium')) {
1252
- }
1253
- if (req.hasFeature('browser.unknown')) {
1254
- }
1255
-
1256
- if (req.hasFeature('os.windows')) {
1257
- }
1258
- if (req.hasFeature('os.linux')) {
1259
- }
1260
- if (req.hasFeature('os.mac')) {
1261
- }
1262
- if (req.hasFeature('os.android')) {
1263
- }
1264
- if (req.hasFeature('os.unknown')) {
1265
- }
1266
-
1267
- req.ip; // user ip
1268
- req.port; // user port
1269
- req.ip2; // server ip
1270
- req.port2; // server port
1271
- req.features; // array of user info [os , browser]
1231
+ site.onGET('/', (req, res) => {
1232
+ res.render('index.html', { name: 'amr', age: '36' }, { compress: !0, cache: false, parser: 'html css js' });
1233
+ res.render('custom.css', { 'font-size': '18px' }, { parser: 'css' });
1234
+ res.render('custom.js', { 'allow-ads': !0 }, { parser: 'js' });
1235
+ res.code = 301; // set response code to 301
1236
+ res.status(301); // set response code if not set to 301 and return response object
1237
+ res.set('Content-Type', 'text/plain'); // add response header
1238
+ res.remove('Content-Type'); // remove response header
1239
+ res.delete('Content-Type'); // remove response header
1240
+ res.redirect('/URL'); // Any URL
1241
+ res.send('HTML CONTENT'); // Any HTML Content or object
1242
+ res.send(obj); // Any HTML Content or object
1243
+ res.htmlContent('HTML CONTENT'); // Any HTML Content
1244
+ res.html('index'); // like res.render
1245
+ res.css('bootstrap'); // css file name
1246
+ res.js('jquery'); // js file name
1247
+ res.json('items'); // json file name or object
1248
+ res.json(obj); // json file name or object
1249
+
1250
+ if (req.hasFeature('browser.chrome')) {
1251
+ }
1252
+ if (req.hasFeature('browser.firefox')) {
1253
+ }
1254
+ if (req.hasFeature('browser.edge')) {
1255
+ }
1256
+ if (req.hasFeature('browser.opera')) {
1257
+ }
1258
+ if (req.hasFeature('browser.ucbrowser')) {
1259
+ }
1260
+ if (req.hasFeature('browser.baidu')) {
1261
+ }
1262
+ if (req.hasFeature('browser.chromium')) {
1263
+ }
1264
+ if (req.hasFeature('browser.unknown')) {
1265
+ }
1266
+
1267
+ if (req.hasFeature('os.windows')) {
1268
+ }
1269
+ if (req.hasFeature('os.linux')) {
1270
+ }
1271
+ if (req.hasFeature('os.mac')) {
1272
+ }
1273
+ if (req.hasFeature('os.android')) {
1274
+ }
1275
+ if (req.hasFeature('os.unknown')) {
1276
+ }
1277
+
1278
+ req.ip; // user ip
1279
+ req.port; // user port
1280
+ req.ip2; // server ip
1281
+ req.port2; // server port
1282
+ req.features; // array of user info [os , browser]
1272
1283
  });
1273
1284
 
1274
1285
  var person = { name: 'amr', email: 'absunstar' };
@@ -1290,43 +1301,43 @@ site.log(jsonObj);
1290
1301
 
1291
1302
  var name = 'absunstar';
1292
1303
  if (name.like('*sun*')) {
1293
- site.log('yes');
1304
+ site.log('yes');
1294
1305
  }
1295
1306
  ```
1296
1307
 
1297
1308
  ## Events
1298
1309
 
1299
- - Events Are Global Actions Across Site
1310
+ - Events Are Global Actions Across Site
1300
1311
 
1301
1312
  ```js
1302
1313
  site.on('event name', function (obj) {
1303
- console.log('name : ' + obj.name);
1314
+ console.log('name : ' + obj.name);
1304
1315
  });
1305
1316
 
1306
1317
  site.on('event name 2', function (list) {
1307
- console.log('name : ' + list[0].name);
1308
- console.log('name : ' + list[1].name);
1318
+ console.log('name : ' + list[0].name);
1319
+ console.log('name : ' + list[1].name);
1309
1320
  });
1310
1321
 
1311
1322
  site.on('event name 3', function (obj, callback) {
1312
- console.log('try long code : ' + obj.name);
1313
- setTimeout(function () {
1314
- callback();
1315
- }, 3000);
1323
+ console.log('try long code : ' + obj.name);
1324
+ setTimeout(function () {
1325
+ callback();
1326
+ }, 3000);
1316
1327
  });
1317
1328
 
1318
1329
  site.on('sync event name 1', function (obj, callback, next) {
1319
- console.log('name : ' + obj.name);
1320
- next(); // to run next event
1330
+ console.log('name : ' + obj.name);
1331
+ next(); // to run next event
1321
1332
  });
1322
1333
  site.on('sync event name 2', function (obj, callback, next) {
1323
- console.log('name : ' + obj.name);
1324
- next(); // to run next event
1334
+ console.log('name : ' + obj.name);
1335
+ next(); // to run next event
1325
1336
  });
1326
1337
  site.call('event name', { name: 'x1' });
1327
1338
  site.call('event name 2', [{ name: 'n1' }, { name: 'n2' }]);
1328
1339
  site.call('event name 3', { name: 'some long code' }, () => {
1329
- console.log('after excute some long code');
1340
+ console.log('after excute some long code');
1330
1341
  });
1331
1342
 
1332
1343
  site.quee('sync event name 1', { name: 'x1' });
@@ -1335,22 +1346,22 @@ site.quee('sync event name 2', { name: 'x2' });
1335
1346
 
1336
1347
  ## Must Update
1337
1348
 
1338
- - You Must Update This Lib Every Month ( npm i isite )
1349
+ - You Must Update This Lib Every Month ( npm i isite )
1339
1350
 
1340
1351
  ## Hints
1341
1352
 
1342
- - This Framework Make Security and Safty in the First Place
1343
- - This Framework From Developer to Developers
1344
- - This Framework Free for Education and Supported For Ever
1345
- - This Framework Upgraded Arround the Clock
1346
- - This Framework Development by One Developer
1347
- - For Producation Contract what's up (+201090061266)
1353
+ - This Framework Make Security and Safty in the First Place
1354
+ - This Framework From Developer to Developers
1355
+ - This Framework Free for Education and Supported For Ever
1356
+ - This Framework Upgraded Arround the Clock
1357
+ - This Framework Development by One Developer
1358
+ - For Producation Contract what's up (+201090061266)
1348
1359
 
1349
1360
  # Contact Me
1350
1361
 
1351
- - Patreon : https://www.patreon.com/next_corporation
1352
- - Email : Absunstar@gmail.com
1353
- - Linkedin : https://www.linkedin.com/in/absunstar
1354
- - Github : https://github.com/absunstar
1355
- - Paypal : https://paypal.me/absunstar
1356
- - What's up: +201090061266
1362
+ - Patreon : https://www.patreon.com/next_corporation
1363
+ - Email : Absunstar@gmail.com
1364
+ - Linkedin : https://www.linkedin.com/in/absunstar
1365
+ - Github : https://github.com/absunstar
1366
+ - Paypal : https://paypal.me/absunstar
1367
+ - What's up: +201090061266