Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Krustacea
### *Create, serve and manage websites* ###
------------------------------------------------
|------- Developped by Kuadrado Software ------|
------------------------------------------------
_______
Krustacea is a package that contains a web server written in Rust (Actix based) and a web application to build a static website.
The web server loads a website as a single JSON document, the html contents is built in memory by the server at start, and the website is served without the need of any static html file. It also handles the necessary static files such as images, or additional source code like css or javascript.
Modifications to the website object will be done through the use of a REST API and the web application on client side.
_________________
## **/!\\** WIP ##
This package is a work in progress I have just begun.
More features and documentation should become visible soon.
_______
## CLI Syntax
```
krustacea [OPTIONS]
```
### Options
- `-c` | `--ctx` : The execution context. Can be `debug` (DEFAULT) or `production`.
- `-d` | `--dir` : Any Linux directory path to hold the Krustacea static files. DEFAULT : In a `debug` context, the `$HOME` directory will be used (i.e. a krusteacea directory will be created in the HOME dir and krustacea will use it to store static assets, backups, config files, etc). In `production` context, the `/var` directory will be used.
- `--load` [OPTIONAL]: The path to the website to load as a JSON file. If no file is provided, a new website will be created from a blank template.
- `-h` | `--host` : The host name. DEFAULT: `localhost`.
- `-p` | `--port` : The HTTP port to use. DEFAULT: `8080`
- `--ptls` : The TLS port to use. DEFAULT: `8443`
- `--certs_dir`: The directory containing the SSL certificates. DEFAULT : `/etc/letsencrypt/live`. (The host name will be joined to this path to find the right certificates)
___________
## Website data
A website data is store as a JSON file with the following structure
```json
// example.json
{
"root_page": {
"template_name": "A Custom Template",
"metadata": {
"title": "Hello Krustcea !",
"description": "An example website",
"image": "https://example.com/static/images/ex_pic.png",
"css": [],
"js": [],
"url_slug": "",
"lang": "en"
},
"body": [
{
"tag": "h1",
"text": "Example Story"
},
{
"tag": "p",
"text": "Hello,<br />How are you?",
"attrs": {
"class": "p_class"
}
},
{
"tag": "img",
"attrs": {
"src": "/img/url.png"
}
}
],
"sub_pages": []
},
"templates": [
{
"name": "Custom template",
"layout": {
"display": "grid"
},
"contents": [
{
"tag": "div",
"attrs": {
"id": "custom-template",
"class":"page-template"
},
"contents": [
{
"tag": "nav",
"contents": [
{
"tag": "ul",
"contents": [
{
"tag": "li",
"text": "menu item 1"
},
{
"tag": "li",
"text": "menu item 2"
}
]
}
]
},
{
"tag": "footer",
"contents": []
}
]
}
]
}
],
"assets_index": {
"images": [
"/static/images/toto.jpg"
],
"sounds": [
"/static/sounds/toto.mp3"
],
"video": [
"/static/video/toto.mp4"
],
"docs": [
"/static/docs/toto.xcf"
],
"source_code": [
"/static/source_code/toto.js"
]
}
}
```