isite 2023.8.10 → 2023.9.30

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.
@@ -108,6 +108,14 @@ module.exports = function (site) {
108
108
  res.render('client-side/words.html', {}, { parser: 'html css js', public: true });
109
109
  }
110
110
  );
111
+ site.get(
112
+ {
113
+ name: '/x-words-old',
114
+ },
115
+ (req, res) => {
116
+ res.render('client-side/words-old.html', {}, { parser: 'html css js', public: true });
117
+ }
118
+ );
111
119
 
112
120
  site.get({
113
121
  name: '/x-css',
@@ -151,16 +151,22 @@ i-datetime input {
151
151
 
152
152
  .modal-content {
153
153
  width: 75vw;
154
- height: 100vh;
154
+ height: auto;
155
+ max-height: 100vh;
156
+ }
157
+ .modal-content:has(i-list) {
158
+ min-height: 75vh;
155
159
  }
156
160
  .full .modal-content {
157
161
  width: 95vw;
158
- height: 100vh;
162
+ height: auto;
163
+ max-height: 100vh;
159
164
  }
160
165
  .modal-body {
161
166
  padding: 1rem;
162
167
  display: block;
163
- overflow: visible !important;
168
+ overflow: hidden;
169
+ overflow-y: auto;
164
170
  }
165
171
  .modal-footer {
166
172
  display: block;
@@ -14,7 +14,7 @@
14
14
  </div>
15
15
 
16
16
  <div class="row center padding pointer">
17
- <a class="btn red" ng-click="updateModel({})"> <i class="fa fa-trash"></i> Clear </a>
17
+ <a class="btn red" ng-click="updateModel(null)"> <i class="fa fa-trash"></i> Clear </a>
18
18
  </div>
19
19
  </div>
20
20
  </div>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en" ng-app="myApp">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Document</title>
7
+ <link rel="stylesheet" href="/x-css/bootstrap-5-support.css" />
8
+ </head>
9
+ <body ng-controller="mainController" class="container loaded">
10
+ <h1 class="center">##word.counts## : {{words.length}}</h1>
11
+ <div class="row padding margin border">
12
+ <div class="col9">
13
+ <i-control ng-model="nameSearch" label="Search Words"></i-control>
14
+ </div>
15
+ <div class="col3">
16
+ <i-button type="save" ng-click="saveWords()" label="Save All Words"></i-button>
17
+ </div>
18
+ </div>
19
+
20
+ <table class="table">
21
+ <tr>
22
+ <th>ID</th>
23
+ <th>Name</th>
24
+ <th>En</th>
25
+ <th>Ar</th>
26
+ </tr>
27
+ <tr ng-repeat="word in words | filter:nameSearch">
28
+ <td>{{$index+1}}</td>
29
+ <td>{{word.name}}</td>
30
+ <td>
31
+ <i-control ng-model="word.en"></i-control>
32
+ </td>
33
+ <td><i-control ng-model="word.ar"></i-control></td>
34
+ </tr>
35
+ </table>
36
+
37
+ <script src="/x-js/bootstrap-5-support.js"></script>
38
+ <script>
39
+ site.connectScope({}, ($scope, $http) => {
40
+ $scope.name = 'Amr Barakat';
41
+ $scope.loadWords = function () {
42
+ $http({
43
+ method: 'get',
44
+ url: '/x-api/words',
45
+ }).then(function (response) {
46
+ if (response.data.done) {
47
+ $scope.words = response.data.words;
48
+ }
49
+ });
50
+ };
51
+ $scope.saveWords = function () {
52
+ $http({
53
+ method: 'POST',
54
+ url: '/x-api/words/save',
55
+ data: $scope.words,
56
+ }).then(function (response) {
57
+ if (response.data.done) {
58
+ console.log(response.data);
59
+ }
60
+ });
61
+ };
62
+ $scope.loadWords();
63
+ });
64
+ </script>
65
+ </body>
66
+ </html>
@@ -3,6 +3,10 @@ app.config(function ($sceDelegateProvider) {
3
3
  $sceDelegateProvider.resourceUrlWhitelist(['self', 'https://www.youtube.com/**']);
4
4
  });
5
5
 
6
+ app.config(function ($sceProvider) {
7
+ $sceProvider.enabled(false);
8
+ });
9
+
6
10
  site.connectScope = app.connectScope = function (_scope, callback) {
7
11
  if (!_scope) {
8
12
  _scope = {};
@@ -465,12 +465,18 @@ app.directive('iList', [
465
465
  });
466
466
 
467
467
  $scope.updateModel = function (item) {
468
- $scope.ngModel = $scope.getNgValue(item, $scope.ngValue);
469
- if ($scope.display2) {
470
- input.val($scope.getNgModelValue($scope.ngModel) + $scope.space + $scope.getNgModelValue2($scope.ngModel));
468
+ if (item) {
469
+ $scope.ngModel = $scope.getNgValue(item, $scope.ngValue);
470
+ if ($scope.display2) {
471
+ input.val($scope.getNgModelValue($scope.ngModel) + $scope.space + $scope.getNgModelValue2($scope.ngModel));
472
+ } else {
473
+ input.val($scope.getNgModelValue($scope.ngModel));
474
+ }
471
475
  } else {
472
- input.val($scope.getNgModelValue($scope.ngModel));
476
+ $scope.ngModel = null;
477
+ input.val('');
473
478
  }
479
+
474
480
  $timeout(() => {
475
481
  if ($scope.ngChange) {
476
482
  $scope.ngChange();
@@ -115,9 +115,6 @@
115
115
  localStorage.setItem('zoomNumber', site.zoomNumber.toString());
116
116
  document.body.style.zoom = site.zoomNumber + '%';
117
117
  };
118
- site.onLoad(() => {
119
- site.zoom('0');
120
- });
121
118
 
122
119
  site.printerList = [];
123
120
  site.getPrinters = function () {
@@ -366,7 +363,7 @@
366
363
  op.mode = 'cors';
367
364
  op.url = site.handle_url(op.url);
368
365
 
369
- if (false && window.SOCIALBROWSER && window.SOCIALBROWSER.fetchJson) {
366
+ if (window.SOCIALBROWSER && window.SOCIALBROWSER.fetchJson) {
370
367
  SOCIALBROWSER.fetchJson(op, (data) => {
371
368
  callback(data);
372
369
  });
@@ -1299,5 +1296,62 @@
1299
1296
  XLSX.writeFile(excelFile, (data.id || data.tagName) + '.' + type);
1300
1297
  };
1301
1298
 
1299
+ site.isSPA = false;
1300
+ site.routeContainer = '[router]';
1301
+ site.routeList = [];
1302
+ site.getRoute = (name) => {
1303
+ return site.routeList.find((r) => r.name == name) || { name: name, url: name };
1304
+ };
1305
+ site.route = (event) => {
1306
+ event.preventDefault();
1307
+ site.setRoute(site.getRoute(event.target.href));
1308
+ };
1309
+ site.setRoute = function (route) {
1310
+ if (typeof route === 'string') {
1311
+ route = site.getRoute(route);
1312
+ }
1313
+ window.history.pushState({}, '', route.name);
1314
+ };
1315
+ site.getRouteContent = async (route) => {
1316
+ if (typeof route === 'string') {
1317
+ route = site.getRoute(route);
1318
+ }
1319
+ return await fetch(route.url).then((data) => data.text());
1320
+ };
1321
+ site.showRouteContent = function (selector, route) {
1322
+ if (typeof route === 'string') {
1323
+ route = site.getRoute(route);
1324
+ }
1325
+
1326
+ site.setRoute(route.name);
1327
+ site.getRouteContent(route.url).then((html) => {
1328
+ document.querySelector(selector).innerHTML = html;
1329
+ });
1330
+ };
1331
+
1332
+ document.addEventListener('click', (e) => {
1333
+ if (!site.isSPA) {
1334
+ return;
1335
+ }
1336
+ if (e.target.hasAttribute('route')) {
1337
+ e.preventDefault();
1338
+ let route = e.target.getAttribute('route') || e.target.getAttribute('href');
1339
+ site.showRouteContent(site.routeContainer, route);
1340
+ }
1341
+ });
1342
+ window.addEventListener('hashchange', (e) => {
1343
+ if (!site.isSPA) {
1344
+ return;
1345
+ }
1346
+ let route = window.location.hash.replace('#', '');
1347
+ if (!route) {
1348
+ route = '/';
1349
+ }
1350
+ site.showRouteContent(site.routeContainer, route);
1351
+ });
1352
+
1353
+ if (document.querySelector('html').hasAttribute('spa')) {
1354
+ site.isSPA = true;
1355
+ }
1302
1356
  window.site = site;
1303
1357
  })(window, document, 'undefined', jQuery);
@@ -25,7 +25,5 @@
25
25
  {"name" : "file_name" , "en" : "File Name" , "ar":"أسم الملف"},
26
26
  {"name" : "ar_lang" , "en" : "اللغة العربية" , "ar":"اللغة العربية"},
27
27
  {"name" : "en_lang" , "en" : "English" , "ar":"English"},
28
- {"name" : "brand_title" , "en" : "Private Site" , "ar":"موقع شخصى"},
29
- {"name" : "brand_tag" , "en" : "Just Template" , "ar":"تصميم مؤقت"},
30
28
  {"name" : "close" , "en" : "Close" , "ar":"أغلاق"}
31
29
  ]
package/index.js CHANGED
@@ -10,7 +10,9 @@ module.exports = function init(options) {
10
10
  ____0.strings = [];
11
11
  ____0.Module = require('module');
12
12
  ____0.http = require('http');
13
+ ____0.http2 = require('http2');
13
14
  ____0.https = require('https');
15
+ ____0.net = require('net');
14
16
  ____0.url = require('url');
15
17
  ____0.fs = require('fs');
16
18
  ____0.path = require('path');
@@ -44,6 +46,21 @@ module.exports = function init(options) {
44
46
  ____0.require = function (file_path) {
45
47
  return require(file_path)(____0);
46
48
  };
49
+ ____0.cmd = function (cmd, callback) {
50
+ callback = callback || {};
51
+ let exec = ____0.child_process.exec;
52
+ return exec(cmd, function (error, stdout, stderr) {
53
+ if (error) {
54
+ callback(error);
55
+ }
56
+ if (stdout) {
57
+ callback(stdout);
58
+ }
59
+ if (stderr) {
60
+ callback(stderr);
61
+ }
62
+ });
63
+ };
47
64
  ____0.close = function (callback) {
48
65
  callback = callback || function () {};
49
66
 
package/lib/parser.js CHANGED
@@ -84,57 +84,62 @@ module.exports = function init(req, res, ____0, route) {
84
84
  }
85
85
 
86
86
  function renderUser(v) {
87
+ if (!v) {
88
+ return '';
89
+ }
90
+
87
91
  let user = req.session.user;
88
92
  if (user) {
89
- if (v && v == '*') {
90
- return JSON.stringify(user);
91
- } else if (v == 'email') {
92
- return user.email;
93
- } else if (v == 'name') {
94
- if (user.profile) {
95
- return user.profile.name || user.email;
96
- }
97
- return user.email;
98
- } else if (v == 'id') {
99
- return user.id;
100
- } else if (v == '_id') {
101
- return user._id;
93
+ let hide = false;
94
+ let out = '';
95
+ if (v.indexOf('#') == 0) {
96
+ v = v.replace('#', '');
97
+ hide = true;
98
+ }
99
+ if (v == '*') {
100
+ out = JSON.stringify(user);
102
101
  } else {
103
- let out = '';
104
- if (v) {
105
- v = v.split('.');
102
+ v = v.split('.');
106
103
 
107
- if (v.length > 0) {
108
- out = user[v[0]];
109
- }
104
+ if (v.length > 0) {
105
+ out = user[v[0]];
106
+ }
110
107
 
111
- if (v.length > 1 && out) {
112
- out = out[v[1]];
113
- }
108
+ if (v.length > 1 && out) {
109
+ out = out[v[1]];
110
+ }
114
111
 
115
- if (v.length > 2 && out) {
116
- out = out[v[2]];
117
- }
112
+ if (v.length > 2 && out) {
113
+ out = out[v[2]];
114
+ }
118
115
 
119
- if (v.length > 3 && out) {
120
- out = out[v[3]];
121
- }
116
+ if (v.length > 3 && out) {
117
+ out = out[v[3]];
118
+ }
122
119
 
123
- if (v.length > 4 && out) {
124
- out = out[v[4]];
125
- }
120
+ if (v.length > 4 && out) {
121
+ out = out[v[4]];
122
+ }
126
123
 
127
- if (v.length > 5 && out) {
128
- out = out[v[5]];
129
- }
124
+ if (v.length > 5 && out) {
125
+ out = out[v[5]];
130
126
  }
127
+ }
131
128
 
129
+ if (typeof out === 'object') {
130
+ out = ____0.toJson(out);
131
+ }
132
+
133
+ if (hide) {
134
+ out = ____0.hide(out);
135
+ } else {
132
136
  if (typeof out === 'object') {
133
137
  out = ____0.toJson(out);
138
+ }if (typeof out === 'undefined') {
139
+ out = '';
134
140
  }
135
-
136
- return out;
137
141
  }
142
+ return out;
138
143
  }
139
144
 
140
145
  return '';
package/lib/routing.js CHANGED
@@ -634,6 +634,7 @@ module.exports = function init(____0) {
634
634
 
635
635
  _0xrrxo.handleServer = async function (req, res) {
636
636
  req.host = '';
637
+ req.origin = '';
637
638
  req.domain = '';
638
639
  req.subDomain = '';
639
640
  req.obj = {};
@@ -1126,7 +1127,7 @@ module.exports = function init(____0) {
1126
1127
 
1127
1128
  for (let i = 0; i < req.route.map.length; i++) {
1128
1129
  let map = req.route.map[i];
1129
- req.params[map.name] = req.urlParser.arr[map.index];
1130
+ req.params[map.name] = decodeURIComponent(req.urlParser.arr[map.index]);
1130
1131
  req.paramsRaw[map.name] = req.urlParserRaw.arr[map.index];
1131
1132
  }
1132
1133
 
@@ -1277,14 +1278,33 @@ module.exports = function init(____0) {
1277
1278
 
1278
1279
  ports.forEach((p, i) => {
1279
1280
  try {
1280
- let server = ____0.http.createServer(_0xrrxo.handleServer);
1281
- server.listen(p, function () {
1282
- let index = ____0.servers.length;
1283
- ____0.servers[index] = server;
1284
- ____0.log('\n-----------------------------------------');
1285
- ____0.log(` ( ${____0.options.name} ) Running on : http://${____0.options.hostname}:${p} `);
1286
- ____0.log('-----------------------------------------\n');
1287
- });
1281
+ if (____0.options.http2) {
1282
+ let server = ____0.http2.createServer();
1283
+ server.on('error', (err) => console.error(err));
1284
+ server.on('stream', (stream, headers) => {
1285
+ // _0xrrxo.handleStream(stream , headers , server);
1286
+ let path = headers[':path'];
1287
+ let method = headers[':method'];
1288
+ if (stream.closed) {
1289
+ return;
1290
+ }
1291
+ stream.respond({
1292
+ ':status': 200,
1293
+ });
1294
+ stream.write('isite http2 worked but not implement routes ...');
1295
+ stream.end();
1296
+ });
1297
+ server.listen(p);
1298
+ } else {
1299
+ let server = ____0.http.createServer(_0xrrxo.handleServer);
1300
+ server.listen(p, function () {
1301
+ let index = ____0.servers.length;
1302
+ ____0.servers[index] = server;
1303
+ ____0.log('\n-----------------------------------------');
1304
+ ____0.log(` ( ${____0.options.name} ) Running on : http://${____0.options.hostname}:${p} `);
1305
+ ____0.log('-----------------------------------------\n');
1306
+ });
1307
+ }
1288
1308
  } catch (error) {
1289
1309
  console.error(error);
1290
1310
  }
@@ -1309,9 +1329,8 @@ module.exports = function init(____0) {
1309
1329
  s.timeout = 1000 * 30;
1310
1330
  });
1311
1331
 
1312
- ____0.server = ____0.servers[0];
1313
-
1314
1332
  setTimeout(() => {
1333
+ ____0.server = ____0.servers[0];
1315
1334
  if (callback) {
1316
1335
  callback(____0.servers);
1317
1336
  }
package/lib/security.js CHANGED
@@ -100,7 +100,7 @@ module.exports = function init(____0) {
100
100
  security.users.push({
101
101
  id: key,
102
102
  key: key,
103
- is_admin: !0,
103
+ isAdmin: !0,
104
104
  email: key,
105
105
  password: key,
106
106
  $psermissions: ['*'],
@@ -110,68 +110,23 @@ module.exports = function init(____0) {
110
110
  name: '*',
111
111
  },
112
112
  ],
113
- branch_list: [
113
+ branchList: [
114
114
  {
115
115
  company: {
116
116
  id: 1000000,
117
- name_ar: ____0._x0f1xo('3758577347381765211627694539135245595691'),
118
- name_en: ____0._x0f1xo('3758577347381765211627694539135245595691'),
119
117
  },
120
118
  branch: {
121
119
  id: 1000000,
122
- name_ar: ____0._x0f1xo('3758577347381765211623734138825443129191'),
123
- name_en: ____0._x0f1xo('3758577347381765211623734138825443129191'),
124
120
  },
125
121
  },
126
122
  ],
127
- profile: {
128
- name: key,
129
- },
130
- ref_info: {
131
- _id: '',
132
- },
133
123
  });
134
124
  };
135
125
  ____0.options.security.keys.forEach((key) => {
136
126
  if (!key) {
137
127
  return;
138
128
  }
139
- security.users.push({
140
- id: key,
141
- key: key,
142
- is_admin: !0,
143
- email: key,
144
- password: key,
145
- $psermissions: ['*'],
146
- roles: ['*'],
147
- permissions: [
148
- {
149
- name: '*',
150
- },
151
- ],
152
- branch_list: [
153
- {
154
- company: {
155
- id: 1000000,
156
- name_ar: ____0._x0f1xo('3758577347381765211627694539135245595691'),
157
- name_en: ____0._x0f1xo('3758577347381765211627694539135245595691'),
158
- users_count: 100,
159
- branch_count: 100,
160
- },
161
- branch: {
162
- id: 1000000,
163
- name_ar: ____0._x0f1xo('3758577347381765211623734138825443129191'),
164
- name_en: ____0._x0f1xo('3758577347381765211623734138825443129191'),
165
- },
166
- },
167
- ],
168
- profile: {
169
- name: key,
170
- },
171
- ref_info: {
172
- _id: '',
173
- },
174
- });
129
+ security.addKey(key);
175
130
  });
176
131
  ____0.options.security.users.forEach((user, i) => {
177
132
  if (!user.id) {
package/lib/session.js CHANGED
@@ -58,6 +58,7 @@ module.exports = function init(req, res, ____0, callback) {
58
58
  }
59
59
  }
60
60
  }
61
+ req.origin = req.headers['origin'] || req.host;
61
62
 
62
63
  if (req.cookies.obj && req.cookies.obj['_ga'] && req.cookies.obj['_ga'].contains('sb')) {
63
64
  req.features.push('browser.social');
@@ -183,7 +184,7 @@ module.exports = function init(req, res, ____0, callback) {
183
184
  }
184
185
 
185
186
  AssignFeatures();
186
-
187
+
187
188
  if (____0.security && session.user_id) {
188
189
  ____0.security.getUser(
189
190
  {
package/lib/words.js CHANGED
@@ -27,7 +27,14 @@ module.exports = function init(____0) {
27
27
  }
28
28
  };
29
29
 
30
- app.add = app.set = function (word) {
30
+ app.add = function (word) {
31
+ let index = app.list.findIndex((w) => w.name === word.name);
32
+ if (index === -1) {
33
+ app.list.push(word);
34
+ }
35
+ return word;
36
+ };
37
+ app.set = function (word) {
31
38
  let index = app.list.findIndex((w) => w.name === word.name);
32
39
  if (index === -1) {
33
40
  app.list.push(word);
@@ -36,7 +43,6 @@ module.exports = function init(____0) {
36
43
  }
37
44
  return word;
38
45
  };
39
-
40
46
  app.addList = function (list) {
41
47
  if (Array.isArray(list)) {
42
48
  list.forEach((doc) => {
@@ -23,6 +23,7 @@ function setOptions(_options, ____0) {
23
23
 
24
24
  let template = {
25
25
  port: port,
26
+ http2 : false,
26
27
  cwd: ____0.cwd,
27
28
  dir: ____0.cwd + '/site_files',
28
29
  apps: !0,
@@ -134,7 +135,6 @@ function setOptions(_options, ____0) {
134
135
  } else {
135
136
  userOptions = {};
136
137
  }
137
- console.log('User Template From .options.json', userOptions);
138
138
  }
139
139
  } catch (error) {
140
140
  console.error(error);
@@ -159,6 +159,7 @@ function setOptions(_options, ____0) {
159
159
  }
160
160
 
161
161
  _x0oo[____0._x0f1xo('4815136426151271')] = _x0oo.key || template.key;
162
+ _x0oo.http2 = _x0oo.http2 ?? template.http2;
162
163
  _x0oo.cwd = _x0oo.cwd || template.cwd;
163
164
  _x0oo.dir = _x0oo.dir || template.dir;
164
165
  _x0oo.upload_dir = _x0oo.upload_dir || template.upload_dir;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isite",
3
- "version": "2023.08.10",
3
+ "version": "2023.09.30",
4
4
  "description": "Create Secure Multi-Language Web Site [Fast and Easy] ",
5
5
  "main": "index.js",
6
6
  "repository": {