tina4js 0.0.3 → 0.0.6
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/bin/tina4.js +1 -1
- package/package.json +1 -1
- package/readme.md +8 -53
- package/tina4/Router.ts +3 -0
package/bin/tina4.js
CHANGED
|
@@ -7,7 +7,7 @@ const currentDir = process.cwd();
|
|
|
7
7
|
if (args) {
|
|
8
8
|
switch (args[0]) {
|
|
9
9
|
case 'install':
|
|
10
|
-
let installPath = path.join(currentDir, '/test');
|
|
10
|
+
let installPath = currentDir; //path.join(currentDir, '/test');
|
|
11
11
|
console.log(`Installing to ${installPath}...`);
|
|
12
12
|
install(installPath);
|
|
13
13
|
break;
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -1,69 +1,24 @@
|
|
|
1
1
|
# Tina4js - This is not another Framework for Javascript #
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Begin your Tina4 journey by following these steps
|
|
4
4
|
|
|
5
|
-
####
|
|
5
|
+
#### Install Parcel
|
|
6
|
+
Parcel is a great tool to use whilst developing your project, not only does it allow you to use type script but it will bundle your project into a dist folder automatically.
|
|
6
7
|
```
|
|
7
8
|
npm install --save-dev parcel
|
|
8
9
|
```
|
|
9
10
|
|
|
10
11
|
#### Installing Tina4js
|
|
12
|
+
We've tried to make installing Tina4js as easy as possible, this should result in a working project.
|
|
11
13
|
```
|
|
12
14
|
npm install tina4js
|
|
15
|
+
npm install -g tina4js
|
|
16
|
+
tina4 install
|
|
13
17
|
```
|
|
14
18
|
|
|
15
|
-
####
|
|
16
|
-
Linux / MacOS
|
|
19
|
+
#### Running your project
|
|
17
20
|
```
|
|
18
|
-
|
|
19
|
-
mkdir src/routes
|
|
20
|
-
mkdir src/templates
|
|
21
|
-
```
|
|
22
|
-
Windows
|
|
23
|
-
```
|
|
24
|
-
mkdir src
|
|
25
|
-
mkdir src\routes
|
|
26
|
-
mkdir src\templates
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
#### Create .parcelrc file
|
|
30
|
-
```
|
|
31
|
-
echo {"extends": "@parcel/config-default","resolvers": ["@parcel/resolver-glob", "..."],"reporters": ["...", "parcel-reporter-static-files-copy"]} > .parcelrc
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
#### Create index.html
|
|
35
|
-
|
|
36
|
-
```html
|
|
37
|
-
<!DOCTYPE html>
|
|
38
|
-
<html>
|
|
39
|
-
<head>
|
|
40
|
-
<title>Tina4 JS</title>
|
|
41
|
-
</head>
|
|
42
|
-
<body>
|
|
43
|
-
<tina4-api url="https://randomuser.me/api/" token=""></tina4-api>
|
|
44
|
-
<div id="root"></div>
|
|
45
|
-
<script type="module" src="node_modules/tina4js/tina4.ts"></script>
|
|
46
|
-
</body>
|
|
47
|
-
</html>
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
#### Add static paths & scripts
|
|
51
|
-
```json
|
|
52
|
-
{
|
|
53
|
-
"devDependencies": {
|
|
54
|
-
},
|
|
55
|
-
"dependencies": {
|
|
56
|
-
"tina4js": "^0.0.1"
|
|
57
|
-
},
|
|
58
|
-
"staticFiles": {
|
|
59
|
-
"staticPath": "src/templates",
|
|
60
|
-
"staticOutPath": "templates"
|
|
61
|
-
},
|
|
62
|
-
"scripts": {
|
|
63
|
-
"start": "parcel index.html",
|
|
64
|
-
"build": "parcel build"
|
|
65
|
-
}
|
|
66
|
-
}
|
|
21
|
+
npm run start
|
|
67
22
|
```
|
|
68
23
|
|
|
69
24
|
#### Examples of routes
|
package/tina4/Router.ts
CHANGED
|
@@ -115,6 +115,9 @@ export class Router {
|
|
|
115
115
|
}.bind(this));
|
|
116
116
|
|
|
117
117
|
if (!rendered) {
|
|
118
|
+
if (url === '/') {
|
|
119
|
+
url = 'index';
|
|
120
|
+
}
|
|
118
121
|
//See if we can find a twig file
|
|
119
122
|
Tina4.renderTemplate(`${url}.twig`, {}, function (html) {
|
|
120
123
|
callback(target, Router.response(html, 200, 'text/html'));
|