isite 2021.11.17 → 2021.11.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +486 -475
- package/apps/client-side/app.js +27 -1
- package/apps/client-side/site_files/css/btn.css +98 -0
- package/apps/client-side/site_files/css/checkbox.css +12 -7
- package/apps/client-side/site_files/css/dropdown.css +61 -0
- package/apps/client-side/site_files/css/effect.css +283 -280
- package/apps/client-side/site_files/css/font-awesome.css +4615 -3
- package/apps/client-side/site_files/css/font-awesome.min.css +5 -0
- package/apps/client-side/site_files/css/form.css +5 -100
- package/apps/client-side/site_files/css/modal.css +184 -164
- package/apps/client-side/site_files/css/tabs.css +3 -3
- package/apps/client-side/site_files/css/theme.css +1 -1
- package/apps/client-side/site_files/css/theme_dark.css +1 -1
- package/apps/client-side/site_files/css/theme_paper.css +175 -151
- package/apps/client-side/site_files/html/sub/i-date2.content.html +64 -0
- package/apps/client-side/site_files/html/sub/i-list.content.html +31 -0
- package/apps/client-side/site_files/html/sub/i-list2.content.html +22 -0
- package/apps/client-side/site_files/js/directive.js +1570 -1650
- package/apps/client-side/site_files/js/directive.min.js +2 -2
- package/apps/client-side/site_files/js/site.js +6 -0
- package/apps/client-side/site_files/js/site.min.js +1 -1
- package/apps/client-side/site_files/webfonts/fa-brands-400.eot +0 -0
- package/apps/client-side/site_files/webfonts/fa-brands-400.svg +3717 -0
- package/apps/client-side/site_files/webfonts/fa-brands-400.ttf +0 -0
- package/apps/client-side/site_files/webfonts/fa-brands-400.woff +0 -0
- package/apps/client-side/site_files/webfonts/fa-brands-400.woff2 +0 -0
- package/apps/client-side/site_files/webfonts/fa-regular-400.eot +0 -0
- package/apps/client-side/site_files/webfonts/fa-regular-400.svg +801 -0
- package/apps/client-side/site_files/webfonts/fa-regular-400.ttf +0 -0
- package/apps/client-side/site_files/webfonts/fa-regular-400.woff +0 -0
- package/apps/client-side/site_files/webfonts/fa-regular-400.woff2 +0 -0
- package/apps/client-side/site_files/webfonts/fa-solid-900.eot +0 -0
- package/apps/client-side/site_files/webfonts/fa-solid-900.svg +5034 -0
- package/apps/client-side/site_files/webfonts/fa-solid-900.ttf +0 -0
- package/apps/client-side/site_files/webfonts/fa-solid-900.woff +0 -0
- package/apps/client-side/site_files/webfonts/fa-solid-900.woff2 +0 -0
- package/lib/parser.js +24 -12
- package/lib/routing.js +21 -2
- package/object-options/index.js +1 -1
- package/object-options/lib/fn.js +1 -1
- 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
|
-
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
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
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
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
|
-
-
|
|
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
|
-
-
|
|
50
|
-
-
|
|
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
|
-
-
|
|
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
|
-
-
|
|
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
|
-
-
|
|
78
|
+
- Default Options.
|
|
79
79
|
|
|
80
80
|
```js
|
|
81
81
|
var isite = require('isite');
|
|
82
82
|
site = isite({
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
},
|
|
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: '',
|
|
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,
|
|
117
104
|
},
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
-
-
|
|
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
|
-
-
|
|
171
|
-
-
|
|
172
|
-
|
|
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
|
-
-
|
|
178
|
-
-
|
|
179
|
-
-
|
|
180
|
-
-
|
|
181
|
-
-
|
|
182
|
-
-
|
|
183
|
-
-
|
|
184
|
-
-
|
|
185
|
-
-
|
|
186
|
-
-
|
|
187
|
-
-
|
|
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.
|
|
198
|
-
site.
|
|
199
|
-
site.
|
|
200
|
-
site.
|
|
201
|
-
site.
|
|
202
|
-
site.
|
|
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.
|
|
209
|
-
|
|
210
|
-
|
|
208
|
+
site.onGET({
|
|
209
|
+
name: '/css/style.css',
|
|
210
|
+
path: [site.dir + '/css/bootstrap.css', site.dir + '/css/custom.css'],
|
|
211
211
|
});
|
|
212
|
-
site.
|
|
213
|
-
|
|
214
|
-
|
|
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.
|
|
223
|
-
site.callRoute('/home' , req , res)
|
|
224
|
-
})
|
|
223
|
+
site.onREQUEST('get', { name: '/' }, (req, res) => {});
|
|
225
224
|
|
|
226
|
-
site.
|
|
227
|
-
|
|
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.
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
229
|
+
site.onGET({
|
|
230
|
+
name: 'api/user/add',
|
|
231
|
+
content: {
|
|
232
|
+
done: true,
|
|
233
|
+
id: 1,
|
|
234
|
+
},
|
|
239
235
|
});
|
|
240
236
|
|
|
241
|
-
site.
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
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.
|
|
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
|
-
|
|
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.
|
|
265
|
-
site.
|
|
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.
|
|
272
|
-
|
|
282
|
+
site.onGET('/post/*', function (req, res) {
|
|
283
|
+
res.end('Any Route like /post/11212154545 ');
|
|
273
284
|
});
|
|
274
|
-
site.
|
|
275
|
-
|
|
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.
|
|
284
|
-
|
|
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.
|
|
288
|
-
|
|
298
|
+
site.onGET('/api', function (req, res) {
|
|
299
|
+
res.end('GET | name : ' + req.queryRaw.name);
|
|
289
300
|
});
|
|
290
301
|
|
|
291
|
-
site.
|
|
292
|
-
|
|
302
|
+
site.onPOST('/api', function (req, res) {
|
|
303
|
+
res.end('POST | id : ' + req.body.id + ' , Name : ' + req.body.name);
|
|
293
304
|
});
|
|
294
|
-
site.
|
|
295
|
-
|
|
305
|
+
site.onPUT('/api', function (req, res) {
|
|
306
|
+
res.end('PUT | id : ' + req.body.id + ' , Name : ' + req.body.name);
|
|
296
307
|
});
|
|
297
|
-
site.
|
|
298
|
-
|
|
308
|
+
site.onDELETE('/api', function (req, res) {
|
|
309
|
+
res.end('Delete | id : ' + req.body.id);
|
|
299
310
|
});
|
|
300
|
-
site.
|
|
301
|
-
|
|
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.
|
|
310
|
-
|
|
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.
|
|
314
|
-
|
|
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.
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
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
|
-
-
|
|
350
|
+
- To Easy Read File Contents From "site_files" Folder
|
|
340
351
|
|
|
341
352
|
```js
|
|
342
353
|
site.html('index', function (err, content) {
|
|
343
|
-
|
|
354
|
+
site.log(content);
|
|
344
355
|
});
|
|
345
356
|
site.css('bootstrap', function (err, content) {
|
|
346
|
-
|
|
357
|
+
site.log(content);
|
|
347
358
|
});
|
|
348
359
|
site.js('jquery', function (err, content) {
|
|
349
|
-
|
|
360
|
+
site.log(content);
|
|
350
361
|
});
|
|
351
362
|
site.json('items', function (err, content) {
|
|
352
|
-
|
|
363
|
+
site.log(content);
|
|
353
364
|
});
|
|
354
365
|
site.xml('rss', function (err, content) {
|
|
355
|
-
|
|
366
|
+
site.log(content);
|
|
356
367
|
});
|
|
357
368
|
```
|
|
358
369
|
|
|
359
|
-
-
|
|
370
|
+
- Custom Read Files
|
|
360
371
|
|
|
361
|
-
|
|
362
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
394
|
+
site.onGET("/", function(req, res) {
|
|
384
395
|
site.readFiles(
|
|
385
396
|
[
|
|
386
397
|
__dirname + "/site_files/html/head.html",
|
|
@@ -433,21 +444,21 @@ site.createDir(path , (err , path)=>{
|
|
|
433
444
|
|
|
434
445
|
## WebSocket
|
|
435
446
|
|
|
436
|
-
-
|
|
447
|
+
- Server Side
|
|
437
448
|
|
|
438
449
|
```js
|
|
439
450
|
site.onWS('/chat', (client) => {
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
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
|
-
-
|
|
461
|
+
- Client Side
|
|
451
462
|
|
|
452
463
|
```html
|
|
453
464
|
<script src="/x-js/all.js"></script>
|
|
@@ -455,13 +466,13 @@ site.onWS('/chat', (client) => {
|
|
|
455
466
|
|
|
456
467
|
```js
|
|
457
468
|
site.ws('ws://localhost/chat', (server) => {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
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
|
|
@@ -472,78 +483,78 @@ ws.onerror = function (error) {};
|
|
|
472
483
|
ws.onclose = function () {};
|
|
473
484
|
|
|
474
485
|
ws.onopen = function () {
|
|
475
|
-
|
|
486
|
+
ws.send(JSON.stringify({ type: 'connect' }));
|
|
476
487
|
};
|
|
477
488
|
|
|
478
489
|
ws.onmessage = function (msg) {
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
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
|
-
-
|
|
489
|
-
-
|
|
490
|
-
-
|
|
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.
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
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.
|
|
501
|
-
|
|
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
|
-
-
|
|
508
|
-
-
|
|
509
|
-
-
|
|
510
|
-
-
|
|
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.
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
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.
|
|
521
|
-
|
|
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
|
-
-
|
|
528
|
-
-
|
|
529
|
-
-
|
|
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
|
-
-
|
|
534
|
-
-
|
|
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
|
-
|
|
549
|
+
// write here your custom code
|
|
539
550
|
};
|
|
540
551
|
```
|
|
541
552
|
|
|
542
|
-
-
|
|
553
|
+
- App Will Be Auto Register And Integerated With Your Site
|
|
543
554
|
|
|
544
555
|
### add App From github
|
|
545
556
|
|
|
546
|
-
-
|
|
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
|
-
-
|
|
563
|
-
-
|
|
564
|
-
-
|
|
565
|
-
-
|
|
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
|
-
|
|
570
|
-
|
|
571
|
-
|
|
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
|
-
|
|
576
|
-
|
|
577
|
-
|
|
586
|
+
name: 'masterPage2',
|
|
587
|
+
header: site.dir + '/html/header2.html',
|
|
588
|
+
footer: site.dir + '/html/footer2.html',
|
|
578
589
|
});
|
|
579
590
|
|
|
580
|
-
site.
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
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
|
-
-
|
|
591
|
-
-
|
|
592
|
-
-
|
|
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.
|
|
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
|
-
|
|
605
|
-
|
|
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
|
-
-
|
|
611
|
-
-
|
|
612
|
-
-
|
|
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
|
-
-
|
|
987
|
+
- upload File using HTML
|
|
977
988
|
|
|
978
989
|
```html
|
|
979
990
|
<form action="uploadFile" method="post" enctype="multipart/form-data">
|
|
980
|
-
|
|
981
|
-
|
|
991
|
+
<input type="file" name="fileToUpload" /><br />
|
|
992
|
+
<input type="submit" />
|
|
982
993
|
</form>
|
|
983
994
|
```
|
|
984
995
|
|
|
985
|
-
-
|
|
996
|
+
- Upload File Using Angular js
|
|
986
997
|
|
|
987
998
|
```html
|
|
988
999
|
<form class="form">
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
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
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
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
|
-
-
|
|
1039
|
+
- Recive Uploading File from [html , angular , jquery , ...]
|
|
1029
1040
|
|
|
1030
1041
|
```js
|
|
1031
|
-
site.
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
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
|
-
-
|
|
1048
|
-
-
|
|
1049
|
-
-
|
|
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.
|
|
1054
|
-
|
|
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.
|
|
1058
|
-
|
|
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
|
-
-
|
|
1065
|
-
-
|
|
1066
|
-
-
|
|
1067
|
-
-
|
|
1068
|
-
-
|
|
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
|
-
-
|
|
1085
|
+
- Words Json File Structure Like This
|
|
1075
1086
|
|
|
1076
1087
|
```json
|
|
1077
1088
|
[
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
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
|
-
-
|
|
1095
|
+
- Use in html Like This
|
|
1085
1096
|
|
|
1086
1097
|
```html
|
|
1087
1098
|
<form>
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1099
|
+
<label> ##word.user_name## </label>
|
|
1100
|
+
<input />
|
|
1101
|
+
<br />
|
|
1091
1102
|
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1103
|
+
<label> ##word.user_email## </label>
|
|
1104
|
+
<input />
|
|
1105
|
+
<br />
|
|
1095
1106
|
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1107
|
+
<label> ##word.user_password## </label>
|
|
1108
|
+
<input />
|
|
1109
|
+
<br />
|
|
1099
1110
|
</form>
|
|
1100
1111
|
```
|
|
1101
1112
|
|
|
1102
|
-
-
|
|
1113
|
+
- Cahnge Site Language
|
|
1103
1114
|
|
|
1104
1115
|
```js
|
|
1105
1116
|
$scope.changeLang = function (lang) {
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
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
|
-
-
|
|
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
|
-
-
|
|
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
|
-
-
|
|
1165
|
+
- Server Side
|
|
1155
1166
|
|
|
1156
1167
|
```js
|
|
1157
1168
|
site.loadLocalApp('charts');
|
|
1158
1169
|
```
|
|
1159
1170
|
|
|
1160
|
-
-
|
|
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
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
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
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
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
|
-
-
|
|
1207
|
-
-
|
|
1208
|
-
-
|
|
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
|
-
-
|
|
1226
|
+
- Manage users From This Route [ /security ]
|
|
1216
1227
|
|
|
1217
1228
|
## Helper Functions
|
|
1218
1229
|
|
|
1219
1230
|
```js
|
|
1220
|
-
site.
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
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
|
-
|
|
1304
|
+
site.log('yes');
|
|
1294
1305
|
}
|
|
1295
1306
|
```
|
|
1296
1307
|
|
|
1297
1308
|
## Events
|
|
1298
1309
|
|
|
1299
|
-
-
|
|
1310
|
+
- Events Are Global Actions Across Site
|
|
1300
1311
|
|
|
1301
1312
|
```js
|
|
1302
1313
|
site.on('event name', function (obj) {
|
|
1303
|
-
|
|
1314
|
+
console.log('name : ' + obj.name);
|
|
1304
1315
|
});
|
|
1305
1316
|
|
|
1306
1317
|
site.on('event name 2', function (list) {
|
|
1307
|
-
|
|
1308
|
-
|
|
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
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
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
|
-
|
|
1320
|
-
|
|
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
|
-
|
|
1324
|
-
|
|
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
|
-
|
|
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
|
-
-
|
|
1349
|
+
- You Must Update This Lib Every Month ( npm i isite )
|
|
1339
1350
|
|
|
1340
1351
|
## Hints
|
|
1341
1352
|
|
|
1342
|
-
-
|
|
1343
|
-
-
|
|
1344
|
-
-
|
|
1345
|
-
-
|
|
1346
|
-
-
|
|
1347
|
-
-
|
|
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
|
-
-
|
|
1352
|
-
-
|
|
1353
|
-
-
|
|
1354
|
-
-
|
|
1355
|
-
-
|
|
1356
|
-
-
|
|
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
|