Skip to content

Commit 7d4f639

Browse files
committed
feat/docs: create static files manageer, improve docs
1 parent 2f84555 commit 7d4f639

30 files changed

+625
-39
lines changed

Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ PROJECT_NAME = "pyEchoNext"
4848
# could be handy for archiving the generated documentation or if some version
4949
# control system is used.
5050

51-
PROJECT_NUMBER = "0.5.7"
51+
PROJECT_NUMBER = "0.5.9"
5252

5353
# Using the PROJECT_BRIEF tag one can provide an optional one line description
5454
# for a project that appears at the top of each page and should give viewer a

README.md

Lines changed: 136 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ Welcome to **EchoNext**, where innovation meets simplicity! Are you tired of the
4141

4242
**Imagine** a lightweight framework that empowers you to create modern web applications with lightning speed and flexibility. With EchoNext, you're not just coding; you're building a masterpiece!
4343

44-
> Last stable version: 0.5.7 alpha
44+
> Last stable version: 0.5.9 alpha
45+
46+
> Next Big Update: ASYNC & unicorn support
4547
4648
## Check Other My Projects
4749

@@ -105,13 +107,16 @@ Welcome to **EchoNext**, where innovation meets simplicity! Are you tired of the
105107

106108
## ⚙️ Functionality
107109

108-
+ i18n localization
110+
+ i18n/l10n localization
109111
+ basic project documentation generator
110112
+ request/response
111113
+ middlewares (with basic session cookie middleware)
112114
+ views and routes
113115
+ settings and config loader
114116
+ built-in template engine and Jinja2
117+
+ basic security and hashing
118+
+ static files management
119+
+ cache response bodies
115120

116121
<p align="right">(<a href="#readme-top">back to top</a>)</p>
117122

@@ -141,9 +146,73 @@ exampleapp/
141146

142147
<p align="right">(<a href="#readme-top">back to top</a>)</p>
143148

149+
## 🚀 Run app with BurnBuild
150+
[burn-build](https://github.com/alexeev-prog/burn-build) - build system written in python for projects in C, C++, python.
151+
152+
burn-build is available on [PyPI](https://pypi.org/project/pyburn_build). Simply install the package into your project environment with PIP:
153+
154+
```bash
155+
pip install pyburn_build
156+
```
157+
158+
Create project_config.json:
159+
160+
```json
161+
{
162+
"metadata": {
163+
"name": "WebApp",
164+
"version": "0.1.0",
165+
"description": "WebApp app",
166+
"language": "python",
167+
"use_cmake": false,
168+
"cache_file": "cache.json",
169+
"features": ["pyechonext"]
170+
},
171+
172+
"compiler": {
173+
"name": "python",
174+
"base_compiler_flags": []
175+
}
176+
}
177+
```
178+
179+
And create toolchain_config.json:
180+
181+
```json
182+
{
183+
"prelude_commands": [],
184+
"targets": {
185+
"target1": {
186+
"compiler_options": [],
187+
"sources": ["app.py"],
188+
"output": "",
189+
"objects": [],
190+
"compiler": "python3"
191+
},
192+
},
193+
"post_commands": []
194+
}
195+
```
196+
197+
And create project:
198+
199+
```bash
200+
python3 -m pyburn_build create --project-config example_configs/project_config.json --toolchain-config example_configs/toolchain_config.json
201+
```
202+
203+
And build project:
204+
205+
```bash
206+
python3 -m pyburn_build build --project-config example_configs/project_config.json --toolchain-config example_configs/toolchain_config.json
207+
```
208+
209+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
210+
144211
## 💻 Usage Examples
212+
You can view examples at [examples directory](./examples).
145213

146-
### Localization i18n & OpenAPI specification generation & Settings loader from python module
214+
### FullApp with locale, static files, docs generation
215+
Also see in [examples](./examples/example_locale.py)
147216

148217
```python
149218
import os
@@ -156,7 +225,8 @@ from pyechonext.response import Response
156225
from pyechonext.template_engine.jinja import render_template
157226
from pyechonext.middleware import middlewares
158227
from pyechonext.docsgen import ProjDocumentation
159-
from pyechonext.apidoc_ui import APIDocumentation
228+
from pyechonext.apidoc_ui import APIDocumentation, APIDocUI
229+
from pyechonext.static import StaticFile
160230

161231

162232
class UsersView(View):
@@ -174,23 +244,25 @@ class UsersView(View):
174244

175245

176246
url_patterns = [URL(url="/", view=IndexView), URL(url="/users", view=UsersView)]
177-
178247
config_loader = SettingsLoader(SettingsConfigType.PYMODULE, 'el_config.py')
179248
settings = config_loader.get_settings()
249+
static_files = [StaticFile(settings, 'styles.css')]
180250
echonext = EchoNext(
181251
__name__,
182252
settings,
183253
middlewares,
184254
urls=url_patterns,
185255
application_type=ApplicationType.HTML,
256+
static_files=static_files
186257
)
187258
apidoc = APIDocumentation(echonext)
188259
projdoc = ProjDocumentation(echonext)
189260

190261

191262
@echonext.route_page('/api-docs')
192263
def api_docs(request, response):
193-
return Response(request, content_type='application/json', body=apidoc.generate_spec())
264+
ui = APIDocUI(apidoc.generate_spec())
265+
return ui.generate_html_page()
194266

195267

196268
@echonext.route_page("/book")
@@ -214,7 +286,7 @@ class BooksResource(View):
214286
:returns: result
215287
:rtype: str
216288
"""
217-
return Response(request, body="title %{name}", use_i18n=True, name='Localization Site')
289+
return echonext.i18n_loader.get_string('title %{name}', name=str(request.GET))
218290

219291
def post(self, request, response, **kwargs):
220292
"""
@@ -230,13 +302,23 @@ class BooksResource(View):
230302
:returns: result
231303
:rtype: str
232304
"""
233-
return echonext.locale_loader.get_string('title %{name}', name='Localization Site')
305+
return echonext.l10n_loader.format_currency(1305.50)
234306

235307

236308
projdoc.generate_documentation()
237309
```
238310

239-
`el_config.py`:
311+
Create file `static/styles.css`:
312+
313+
```css
314+
body {
315+
color: #f8f2f2;
316+
background: #1f1f1f;
317+
font-family: monospace;
318+
}
319+
```
320+
321+
Create file `el_config.py`:
240322

241323
```python
242324
import os
@@ -248,9 +330,30 @@ LOCALE = 'RU_RU'
248330
LOCALE_DIR = 'locales'
249331
VERSION = "0.1.0"
250332
DESCRIPTION = 'Example echonext webapp'
333+
STATIC_DIR = 'static'
251334
```
252335

253-
### Advanced app with flask-like and django-like routes
336+
Create file `locales/RU_RU.json`:
337+
338+
```python
339+
{
340+
"i18n": {
341+
"title": "pyEchoNext Веб-приложение с локалью",
342+
"example one": "пример один"
343+
},
344+
"l10n": {
345+
"date_format": "%Y-%m-%d",
346+
"time_format": "%H:%M",
347+
"date_time_fromat": "%Y-%m-%d %H:%M",
348+
"thousands_separator": ",",
349+
"decimal_separator": ".",
350+
"currency_symbol": "$",
351+
"currency_format": "{symbol}{amount}"
352+
}
353+
}
354+
```
355+
356+
### App with flask-like and django-like routes
254357
Django-line classes with get-post methods and routing pages. And with the built-in template engine!
255358

256359
```python
@@ -554,6 +657,29 @@ class IndexView(View):
554657
return Response(request, body="Message has accepted!")
555658
```
556659

660+
## Documentation 🌍
661+
Extended documentation and framework specifications are available at the following links:
662+
663+
### English
664+
665+
1. [Index](./docs/en/index.md)
666+
2. [Web framework design](./docs/en/webframework_design.md)
667+
3. [Creating a web application](./docs/en/webapp_creation.md)
668+
4. [Creating routes (routes&views)](./docs/en/routes_and_views.md)
669+
5. [Request/Response](./docs/en/requests_responses.md)
670+
6. [Localization i18n/l10n](./docs/en/i18n_locales.md)
671+
7. [Security](./docs/en/security.md)
672+
673+
### Russian / Русский
674+
675+
1. [Содержание](./docs/ru/index.md)
676+
2. [Устройство веб-фреймворка](./docs/ru/webframework_design.md)
677+
3. [Создание веб-приложения](./docs/ru/webapp_creation.md)
678+
4. [Создание маршрутов (routes&views)](./docs/ru/routes_and_views.md)
679+
5. [Request/Response](./docs/ru/requests_responses.md)
680+
6. [Локализация i18n/l10n](./docs/ru/i18n_locales.md)
681+
7. [Безопасность](./docs/ru/security.md)
682+
557683
## 💬 Support
558684
If you encounter any issues or have questions about pyEchoNext, please:
559685

@@ -595,27 +721,6 @@ Unlock your potential as a developer with Echonext. Don’t just build applicati
595721

596722
This README is designed to grab attention from the very first lines. It emphasizes the framework's strengths and makes a compelling case for why developers should choose Echonext for their projects. Feel free to adjust any specific links or images to fit your project!
597723

598-
## Documentation 🌍
599-
Extended documentation and framework specifications are available at the following links:
600-
601-
### English
602-
603-
1. [Index](./docs/en/index.md)
604-
2. [Web framework design](./docs/en/webframework_design.md)
605-
3. [Creating a web application](./docs/en/webapp_creation.md)
606-
4. [Creating routes (routes&views)](./docs/en/routes_and_views.md)
607-
5. [Request/Response](./docs/en/requests_responses.md)
608-
6. [Localization i18n/l10n](./docs/en/i18n_locales.md)
609-
610-
### Russian / Русский
611-
612-
1. [Содержание](./docs/ru/index.md)
613-
2. [Устройство веб-фреймворка](./docs/ru/webframework_design.md)
614-
3. [Создание веб-приложения](./docs/ru/webapp_creation.md)
615-
4. [Создание маршрутов (routes&views)](./docs/ru/routes_and_views.md)
616-
5. [Request/Response](./docs/ru/requests_responses.md)
617-
6. [Локализация i18n/l10n](./docs/ru/i18n_locales.md)
618-
619724
## License
620725
Distributed under the GNU LGPL 2.1 License. See [LICENSE](https://github.com/alexeev-prog/pyEchoNext/blob/main/LICENSE) for more information.
621726

SECURITY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ currently being supported with security updates.
77

88
| Version | Supported |
99
| ------- | ------------------ |
10+
| 0.5.9 | :white_check_mark: |
11+
| 0.5.8 | :white_check_mark: |
1012
| 0.5.7 | :white_check_mark: |
1113
| 0.5.6 | :white_check_mark: |
1214
| 0.5.5 | :white_check_mark: |

docs/en/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
3. [Creating routes (routes&views)](./routes_and_views.md)
88
4. [Request/Response](./requests_responses.md)
99
5. [i18n](./i18n_locales.md)
10+
6. [Security](./security.md)
1011

1112
## Additional materials
1213

0 commit comments

Comments
 (0)