webfast 0.0.8 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -24,7 +24,7 @@ WebFast! provides a flexible and intuitive platform for creating web application
24
24
  1. Clone the repository:
25
25
 
26
26
  ```bash
27
- git clone https://github.com/ThePhotoCodeGrapher/WebFast!.git
27
+ git clone https://github.com/ThePhotoCodeGrapher/webfast.git
28
28
  ```
29
29
 
30
30
  2. Navigate to the project directory:
@@ -84,6 +84,12 @@ module.exports = {
84
84
  }
85
85
  }
86
86
 
87
+ ```
88
+ ## Important!
89
+
90
+ The folder [/app] is for your custom project, your custom github and code but can be used in combination with Webfast. Don't wory to contribute.
91
+ ```
92
+
87
93
  ```
88
94
  ## License
89
95
 
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title><%= title %></title>
7
+ </head>
8
+ <body>
9
+
10
+ <h1>Hello, <%= name %>!</h1>
11
+
12
+ <ul>
13
+ <% fruits.forEach(function(fruit) { %>
14
+ <li><%= fruit %></li>
15
+ <% }); %>
16
+ </ul>
17
+
18
+ </body>
19
+ </html>
package/index.js CHANGED
@@ -3,7 +3,8 @@ const { readdirSync } = require("fs");
3
3
  console.log(`WebFast!! Program`);
4
4
  let program = {
5
5
  ts : Date.now(),
6
- modules : {}
6
+ modules : {},
7
+ tmp : {}
7
8
  }
8
9
 
9
10
  // Setup The Requirements
@@ -154,7 +155,7 @@ program.modules.fetch = async function(folder,program) {
154
155
  case `object`:
155
156
  // It's a object so check for dependend things etc.
156
157
  console.log(`Depending object`);
157
- await program.modules.dependOn(reqFunc,program,fileNameWithoutExtension,function(program,name){
158
+ return await program.modules.dependOn(reqFunc,program,fileNameWithoutExtension,function(program,name){
158
159
  console.log(`Setup `,name)
159
160
  });
160
161
  break;
@@ -173,70 +174,70 @@ program.modules.fetch = async function(folder,program) {
173
174
  }
174
175
  }
175
176
 
176
- program.modules.walkDirectory = async function (directoryPath, callback, forward) {
177
+ // Create tmp file path
178
+ program.modules.walkDirectory = async function (directoryPath, callback, forward, parentFileData) {
179
+ let allFiles = [];
177
180
  try {
178
181
  // Read the contents of the current directory
179
182
  const files = await program.fs.readdirSync(directoryPath);
180
183
 
181
- let allFiles = [];
182
-
183
184
  // Iterate through the files in the directory
184
- for (let f in files) {
185
+ for (const file of files) {
185
186
  // Construct the full path of the current file or directory
186
- let file = files[f];
187
- const fullPath = await program.path.join(directoryPath, file);
187
+ const fullPath = program.path.join(directoryPath, file);
188
188
 
189
189
  // Check if the current item is a directory
190
190
  const pathSync = await program.fs.statSync(fullPath);
191
191
  const isDirectoryPath = await pathSync.isDirectory();
192
- const fileExtension = await program.path.extname(fullPath);
192
+ const fileExtension = program.path.extname(fullPath);
193
193
 
194
194
  // Get the filename without the extension
195
- const fileName = await program.path.basename(fullPath, fileExtension);
195
+ const fileName = program.path.basename(fullPath, fileExtension);
196
+
197
+ // Create a new fileData object for each file or directory
198
+ const currentFileData = {
199
+ extension: fileExtension,
200
+ name: fileName,
201
+ path: fullPath,
202
+ sub: [],
203
+ };
196
204
 
197
205
  if (isDirectoryPath) {
198
206
  // If it's a directory, recursively walk through it
199
- let pushData = await program.modules.walkDirectory(fullPath, callback, fileName);
207
+ let pushData = await program.modules.walkDirectory(fullPath, callback, fileName, currentFileData);
200
208
  if (pushData.length !== 0) {
201
- allFiles = allFiles.concat(pushData); // Concatenate arrays instead of pushing an array
209
+ // Concatenate arrays instead of pushing an array
210
+ allFiles.push(currentFileData);
211
+ allFiles = allFiles.concat(pushData);
212
+ } else {
213
+ allFiles.push(currentFileData);
202
214
  }
203
215
  } else {
204
216
  // If it's a file, print the path
205
217
  console.log('File Extension:', fileExtension);
206
218
  console.log('File Name:', fileName);
207
219
 
208
- // Make Key from fileName extension
209
- const fileData = {
210
- extension: fileExtension,
211
- name: fileName,
212
- path: fullPath,
213
- sub: [],
214
- };
215
-
216
220
  if (forward !== undefined) {
217
221
  // Push it to sub
218
- fileData.sub.push(forward);
222
+ parentFileData.sub.push(currentFileData);
219
223
  } else {
220
- allFiles.push(fileData);
224
+ allFiles.push(currentFileData);
221
225
  }
222
226
  }
223
227
  }
224
228
 
225
- if (forward !== undefined) {
226
- // Return data
227
- return allFiles;
228
- }
229
-
230
229
  if (callback && forward === undefined) {
231
230
  await callback(allFiles);
232
- } else {
233
- return allFiles;
234
231
  }
232
+
233
+ return allFiles;
235
234
  } catch (error) {
236
235
  console.error('Error:', error.message);
237
236
  }
238
237
  };
239
238
 
239
+
240
+
240
241
 
241
242
 
242
243
  // Run program fetch
@@ -1,8 +1,25 @@
1
- module.exports = async function(program,message,id) {
1
+ module.exports = async function(program,message,id,buttons) {
2
2
  console.log(`Telegram Send`);
3
3
  // Create Request for send
4
4
  const telegramURL = `https://api.telegram.org/bot${process.env.telegram}/sendMessage`;
5
5
 
6
+ // Check if buttons is send as []
7
+ let options;
8
+ if (buttons != undefined) {
9
+ console.log(`Loop Through Buttons`);
10
+ const keyboard = {
11
+ inline_keyboard: buttons,
12
+
13
+ resize_keyboard: true,
14
+ one_time_keyboard: true
15
+ };
16
+
17
+ options = {
18
+ reply_markup: JSON.stringify(keyboard)
19
+ };
20
+ }
21
+
22
+
6
23
  const body = {
7
24
  text: message,
8
25
  disable_web_page_preview: false,
@@ -12,6 +29,11 @@ module.exports = async function(program,message,id) {
12
29
  parse_mode : 'HTML'
13
30
  }
14
31
 
32
+ // If options is there add as
33
+ if (options != undefined) {
34
+ body.reply_markup = options.reply_markup;
35
+ }
36
+
15
37
  const madeRequest = await program.modules.request.post(program,telegramURL,body)
16
38
  console.log(`Send Message`);
17
39
  return madeRequest;
@@ -143,7 +143,12 @@ module.exports = async function(program,folder) {
143
143
  } catch (err) {
144
144
  //console.error(err);
145
145
  //console.error(`Error For Telegram Function`);
146
- await program.modules.telegram.functions.send(program,`${command}`,middleValue.chat.id);
146
+ await program.modules.telegram.functions.send(program,`${command}`,middleValue.chat.id,[
147
+ [
148
+ { text: 'EventGO!', web_app : { url : 'https://cloud.eventgo.today/events/list'}},
149
+ { text: 'Create Event', callback_data: 'create_event' },
150
+ ]
151
+ ]);
147
152
  }
148
153
 
149
154
 
@@ -225,8 +230,18 @@ module.exports = async function(program,folder) {
225
230
 
226
231
  // Try to load it
227
232
  try {
228
- telegram.functions[key] = require(module.path);
229
- console.log(`Having The Module`,module);
233
+ const pathSync = await program.fs.statSync(module.path);
234
+ const isDirectoryPath = await pathSync.isDirectory();
235
+ const fileExtension = program.path.extname(module.path);
236
+
237
+ // Check if directory
238
+ if (isDirectoryPath) {
239
+ // It's directory so don't do anything yet
240
+ console.log(`It's Directory fo something`);
241
+ } else {
242
+ telegram.functions[key] = require(module.path);
243
+ console.log(`Having The Module`,module);
244
+ }
230
245
  } catch (err) {
231
246
  console.error(err);
232
247
  console.error(`Error Setting Up Telegram Module`);
@@ -20,8 +20,19 @@ module.exports = {
20
20
  // Create module in setModule
21
21
  try {
22
22
  // We have set module
23
- const runModule = await require(module.path)(program,module);
24
- setModule[module.name] = runModule;
23
+ const pathSync = await program.fs.statSync(module.path);
24
+ const isDirectoryPath = await pathSync.isDirectory();
25
+ const fileExtension = program.path.extname(module.path);
26
+
27
+ // Check if directory
28
+ if (isDirectoryPath) {
29
+ // It's directory so don't do anything yet
30
+ console.log(`It's Directory init bots`);
31
+ } else {
32
+ const runModule = await require(module.path)(program,module);
33
+ setModule[module.name] = runModule;
34
+ }
35
+
25
36
  } catch (err) {
26
37
  console.error(err);
27
38
  console.error(`Error Setting Module Data`,module.name);
@@ -47,11 +47,10 @@ module.exports = async function(program) {
47
47
  let route = routesData[rI];
48
48
  //console.log(`Route : `,route.path);
49
49
 
50
- let routePath = `${basePath}`
50
+ let routePath = `${basePath}/${route.name}`
51
51
  // Loop Through sub and create path with basePath
52
- for (let s in route.sub) {
53
- routePath = `${routePath}/${route.sub[s]}`
54
- }
52
+
53
+ console.log(`Set Route Name`);
55
54
 
56
55
  // Check to split name
57
56
  const split = route.name.split(`.`);
@@ -63,7 +62,7 @@ module.exports = async function(program) {
63
62
  }
64
63
 
65
64
  // FUll Route
66
- routePath = `${routePath}/${route.name}`;
65
+ //routePath = `${routePath}/${route.name}`;
67
66
 
68
67
  // Create Route UUID for easy findable
69
68
  const routeID = program.uuid.v4();
@@ -73,7 +72,40 @@ module.exports = async function(program) {
73
72
 
74
73
  // Setup the function
75
74
  try {
76
- route.func = require(route.path);
75
+ const pathSync = await program.fs.statSync(route.path);
76
+ const isDirectoryPath = await pathSync.isDirectory();
77
+ const fileExtension = program.path.extname(route.path);
78
+ console.log(`If it's directory or not`);
79
+
80
+ // Check if directory
81
+ if (isDirectoryPath) {
82
+ console.log(`It's directoyr`);
83
+ // Create routes now
84
+ for (let s in route.sub) {
85
+ const subData = route.sub[rI];
86
+ if (subData != undefined) {
87
+ const routeName = subData.name.replace(`.get`,``).replace(`.post`,``);
88
+ routePath = `${routePath}/${routeName}`
89
+
90
+ // Create type
91
+ const subDataSplit = subData.name.split(`.`);
92
+ const type = subDataSplit[subDataSplit.length-1];
93
+
94
+ subData.name = routeName;
95
+ delete subData.sub;
96
+ subData.type = type;
97
+
98
+ // Create func
99
+ subData.func = require(subData.path);
100
+ // Set route
101
+ exprs[routePath] = subData;
102
+ }
103
+ }
104
+
105
+
106
+ } else {
107
+ route.func = require(route.path);
108
+ }
77
109
  } catch(err) {
78
110
  console.error(`Error Route Func`,routePath);
79
111
  console.error(err);
@@ -81,7 +113,6 @@ module.exports = async function(program) {
81
113
 
82
114
  // Save route for path
83
115
  route.webwalk = 0;
84
- exprs[routePath] = route;
85
116
 
86
117
  console.log(`Setting Up Route`);
87
118
  }
@@ -96,6 +127,7 @@ module.exports = async function(program) {
96
127
  let routeData = exprs[route];
97
128
  console.log(`Setup Route`,route);
98
129
  let state = false;
130
+
99
131
  try {
100
132
  // This is where the magic happens when we receive an incomming request it will
101
133
  // route it through the dynamice route folder
@@ -0,0 +1,12 @@
1
+ module.exports = async function(program,req,res,route) {
2
+ console.log(`Create`);
3
+ const fullPath = program.path.join(__dirname, `..`,`..`,`..`,`..`,`ejs`,`example`,`list.ejs`);
4
+
5
+ // Render the EJS template
6
+ res.render(fullPath, {
7
+ title: 'EJS Example',
8
+ name: 'John Doe',
9
+ isAdmin: true,
10
+ fruits: ['Apple', 'Banana', 'Orange']
11
+ });
12
+ }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "webfast",
3
- "version": "0.0.8",
4
- "description": "WebFast!! Bot Application, including TON mini-apps",
3
+ "version": "0.1.12",
4
+ "description": "WebFast! Bot Application, including TON mini-apps",
5
5
  "main": "index.js",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "https://github.com/ThePhotoCodeGrapher/WebFast!"
8
+ "url": "https://github.com/ThePhotoCodeGrapher/webfast"
9
9
  },
10
10
  "scripts": {
11
11
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -16,7 +16,13 @@
16
16
  "mini",
17
17
  "app",
18
18
  "ton",
19
- "telegram"
19
+ "telegram",
20
+ "fast",
21
+ "framework",
22
+ "lowcode",
23
+ "kaigartner",
24
+ "bots",
25
+ "generator"
20
26
  ],
21
27
  "author": "Kai Gartner",
22
28
  "license": "ISC",