tina4-python 0.1.45__tar.gz → 0.1.47__tar.gz

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.
Files changed (30) hide show
  1. {tina4_python-0.1.45 → tina4_python-0.1.47}/PKG-INFO +26 -19
  2. {tina4_python-0.1.45 → tina4_python-0.1.47}/README.md +25 -18
  3. {tina4_python-0.1.45 → tina4_python-0.1.47}/pyproject.toml +1 -4
  4. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/Webserver.py +2 -2
  5. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/__init__.py +31 -23
  6. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/Auth.py +0 -0
  7. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/Constant.py +0 -0
  8. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/Debug.py +0 -0
  9. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/Env.py +0 -0
  10. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/Localization.py +0 -0
  11. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/Messages.py +0 -0
  12. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/Request.py +0 -0
  13. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/Response.py +0 -0
  14. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/Router.py +0 -0
  15. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/Template.py +0 -0
  16. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/messages.pot +0 -0
  17. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/public/css/readme.md +0 -0
  18. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/public/favicon.ico +0 -0
  19. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/public/images/403.png +0 -0
  20. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/public/images/404.png +0 -0
  21. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/public/images/logo.png +0 -0
  22. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/public/images/readme.md +0 -0
  23. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/public/js/readme.md +0 -0
  24. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/templates/errors/403.twig +0 -0
  25. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/templates/errors/404.twig +0 -0
  26. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/templates/readme.md +0 -0
  27. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/translations/en/LC_MESSAGES/messages.mo +0 -0
  28. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/translations/en/LC_MESSAGES/messages.po +0 -0
  29. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/translations/fr/LC_MESSAGES/messages.mo +0 -0
  30. {tina4_python-0.1.45 → tina4_python-0.1.47}/tina4_python/translations/fr/LC_MESSAGES/messages.po +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tina4-python
3
- Version: 0.1.45
3
+ Version: 0.1.47
4
4
  Summary: Tina4Python - This is not another framework for Python
5
5
  Author: Andre van Zuydam
6
6
  Author-email: andrevanzuydam@gmail.com
@@ -40,6 +40,7 @@ After installing poetry you can do the following:
40
40
  poetry new project-name
41
41
  cd project-name
42
42
  poetry add tina4_python
43
+ poetry add jurigged
43
44
  ```
44
45
  Create an entry point for Tina4 called ```app.py``` and add the following to the file
45
46
  ```python
@@ -85,30 +86,33 @@ After defining templates and routes, run the Tina4Python server:
85
86
 
86
87
  - **Normal Server**:
87
88
  ```bash
88
- poetry run
89
+ poetry run python app.py
89
90
  ```
90
91
 
91
92
  - **Server with Hot Reloading**:
92
93
  ```bash
93
- poetry run jurigged main.py
94
+ poetry run jurigged app.py
94
95
  ```
95
96
 
96
97
  - **Server on a Specific Port**:
97
98
  ```bash
98
- poetry run app.py 7777
99
+ poetry run python app.py 7777
100
+ ```
101
+
102
+ - **Server to not autostart **:
103
+ ```bash
104
+ poetry run python app.py manual
99
105
  ```
100
106
 
101
107
  - **Server with alternate language** (for example fr = French):
102
108
  ```bash
103
- poetry run main.py fr
109
+ poetry run python app.py fr
104
110
  ```
105
111
 
106
112
  Add more translations by going [here](TRANSLATIONS.md)
107
113
 
108
114
  ### Templating
109
-
110
-
111
- Tina4 uses [Twig](https://twig.symfony.com/) templating to provide a simple and efficient way to create web pages.
115
+ Tina4 uses Jinja2 (Twig) templating to provide a simple and efficient way to create web pages.
112
116
 
113
117
  1.) **Twig Files**: Add your Twig files within the `src/templates` folder. For instance, you might create files like `index.twig`, `base.twig`, etc., containing your HTML structure with Twig templating syntax for dynamic content.
114
118
 
@@ -219,18 +223,21 @@ For ease of use you can supply an `API_KEY` param to your .env with a secret of
219
223
  API_KEY=somehash
220
224
  ```
221
225
 
226
+
222
227
  ### Features
223
- | Completed | To Do |
224
- |----------------------------|----------------------------------|
225
- | Python pip package | Implement JWT for token handling |
226
- | Basic environment handling | |
227
- | Basic routing | OpenAPI (Swagger) |
228
- | Enhanced routing | |
229
- | CSS Support | |
230
- | Image Support | |
231
- | Localization | |
232
- | Error Pages | |
233
- | Template handling | |
228
+ | Completed | To Do |
229
+ |----------------------------|-------------------|
230
+ | Python pip package | |
231
+ | Basic environment handling | |
232
+ | Basic routing | OpenAPI (Swagger) |
233
+ | Enhanced routing | |
234
+ | CSS Support | |
235
+ | Image Support | |
236
+ | Localization | |
237
+ | Error Pages | |
238
+ | Template handling | |
239
+ | Form posting | |
240
+ | JWT tokens & security | |
234
241
 
235
242
  ### Building and Deployment
236
243
 
@@ -21,6 +21,7 @@ After installing poetry you can do the following:
21
21
  poetry new project-name
22
22
  cd project-name
23
23
  poetry add tina4_python
24
+ poetry add jurigged
24
25
  ```
25
26
  Create an entry point for Tina4 called ```app.py``` and add the following to the file
26
27
  ```python
@@ -66,30 +67,33 @@ After defining templates and routes, run the Tina4Python server:
66
67
 
67
68
  - **Normal Server**:
68
69
  ```bash
69
- poetry run
70
+ poetry run python app.py
70
71
  ```
71
72
 
72
73
  - **Server with Hot Reloading**:
73
74
  ```bash
74
- poetry run jurigged main.py
75
+ poetry run jurigged app.py
75
76
  ```
76
77
 
77
78
  - **Server on a Specific Port**:
78
79
  ```bash
79
- poetry run app.py 7777
80
+ poetry run python app.py 7777
81
+ ```
82
+
83
+ - **Server to not autostart **:
84
+ ```bash
85
+ poetry run python app.py manual
80
86
  ```
81
87
 
82
88
  - **Server with alternate language** (for example fr = French):
83
89
  ```bash
84
- poetry run main.py fr
90
+ poetry run python app.py fr
85
91
  ```
86
92
 
87
93
  Add more translations by going [here](TRANSLATIONS.md)
88
94
 
89
95
  ### Templating
90
-
91
-
92
- Tina4 uses [Twig](https://twig.symfony.com/) templating to provide a simple and efficient way to create web pages.
96
+ Tina4 uses Jinja2 (Twig) templating to provide a simple and efficient way to create web pages.
93
97
 
94
98
  1.) **Twig Files**: Add your Twig files within the `src/templates` folder. For instance, you might create files like `index.twig`, `base.twig`, etc., containing your HTML structure with Twig templating syntax for dynamic content.
95
99
 
@@ -200,18 +204,21 @@ For ease of use you can supply an `API_KEY` param to your .env with a secret of
200
204
  API_KEY=somehash
201
205
  ```
202
206
 
207
+
203
208
  ### Features
204
- | Completed | To Do |
205
- |----------------------------|----------------------------------|
206
- | Python pip package | Implement JWT for token handling |
207
- | Basic environment handling | |
208
- | Basic routing | OpenAPI (Swagger) |
209
- | Enhanced routing | |
210
- | CSS Support | |
211
- | Image Support | |
212
- | Localization | |
213
- | Error Pages | |
214
- | Template handling | |
209
+ | Completed | To Do |
210
+ |----------------------------|-------------------|
211
+ | Python pip package | |
212
+ | Basic environment handling | |
213
+ | Basic routing | OpenAPI (Swagger) |
214
+ | Enhanced routing | |
215
+ | CSS Support | |
216
+ | Image Support | |
217
+ | Localization | |
218
+ | Error Pages | |
219
+ | Template handling | |
220
+ | Form posting | |
221
+ | JWT tokens & security | |
215
222
 
216
223
  ### Building and Deployment
217
224
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "tina4-python"
3
- version = "0.1.45"
3
+ version = "0.1.47"
4
4
  description = "Tina4Python - This is not another framework for Python"
5
5
  authors = ["Andre van Zuydam <andrevanzuydam@gmail.com>"]
6
6
  readme = "README.md"
@@ -18,9 +18,6 @@ cryptography = "^42.0.5"
18
18
  pytest = "^7.2.0"
19
19
  jurigged = "^0.5.3"
20
20
 
21
- [tool.poetry.scripts]
22
- run = "main:main"
23
-
24
21
  [build-system]
25
22
  requires = ["poetry-core>=1.0.0"]
26
23
  build-backend = "poetry.core.masonry.api"
@@ -196,8 +196,8 @@ class Webserver:
196
196
  self.router_handler = None
197
197
  self.running = False
198
198
 
199
- def serve_forever(self):
200
- asyncio.run(self.run_server())
199
+ async def serve_forever(self):
200
+ await self.run_server()
201
201
 
202
202
  def server_close(self):
203
203
  self.running = False
@@ -3,11 +3,14 @@
3
3
  # Copy-right 2007 - current Tina4
4
4
  # License: MIT https://opensource.org/licenses/MIT
5
5
  #
6
+ import asyncio
6
7
  import gettext
7
8
  import os
8
9
  import shutil
9
10
  import importlib
10
11
  import sys
12
+ import sass
13
+
11
14
  from tina4_python.Env import load_env
12
15
  from tina4_python.Webserver import Webserver
13
16
  from tina4_python.Router import Router
@@ -26,7 +29,7 @@ MSG_STARTING_WEBSERVER = _('Starting webserver on {port}')
26
29
  MSG_ENTRY_POINT_NAME = _('Entry point name ... {name}')
27
30
 
28
31
  if os.getenv('environment') is not None:
29
- environment = ".env."+os.getenv('environment')
32
+ environment = ".env." + os.getenv('environment')
30
33
  else:
31
34
  environment = ".env"
32
35
 
@@ -48,7 +51,7 @@ tina4_auth = Auth(root_path)
48
51
 
49
52
  token = tina4_auth.get_token({"name": "Tina4"})
50
53
  print("TEST TOKEN", token)
51
- print("VALID TOKEN", tina4_auth.valid(token+"a"))
54
+ print("VALID TOKEN", tina4_auth.valid(token + "a"))
52
55
  print("VALID TOKEN", tina4_auth.valid(token))
53
56
  print("PAYLOAD", tina4_auth.get_payload(token))
54
57
 
@@ -87,30 +90,33 @@ if not os.path.exists(root_path + os.sep + "src" + os.sep + "public"):
87
90
  destination_dir = root_path + os.sep + "src" + os.sep + "public"
88
91
  shutil.copytree(source_dir, destination_dir)
89
92
 
90
- # please keep in place otherwise auto loading files does not work nicely
93
+ # please keep in place otherwise autoloading of files does not work nicely
91
94
  from src import *
95
+ from src.routes import *
96
+ from src.app import *
97
+ from . import *
92
98
 
93
- def initialize():
94
- print(Messages.MSG_LOAD_ALL_THINGS)
99
+ # compile sass
100
+ if os.path.exists(root_path + os.sep + "src" + os.sep + "scss"):
101
+ print("Compiling scss")
102
+ sass.compile(dirname=(root_path + os.sep + 'src' + os.sep + 'scss',
103
+ root_path + os.sep + 'src' + os.sep + 'public' + os.sep + 'css'), output_style='compressed')
95
104
 
96
105
 
97
106
  def webserver(host_name, port):
98
107
  web_server = Webserver(host_name, int(port)) # HTTPServer((host_name, int(port)), Webserver)
99
108
  web_server.router_handler = Router()
100
109
  print(Messages.MSG_SERVER_STARTED.format(host_name=host_name, port=port))
101
-
102
110
  try:
103
- web_server.serve_forever()
111
+ asyncio.run(web_server.serve_forever())
104
112
  except KeyboardInterrupt:
105
113
  pass
106
-
107
114
  web_server.server_close()
108
115
  print(Messages.MSG_SERVER_STOPPED)
109
116
 
110
117
 
111
- def main(in_hostname="localhost", in_port=7145):
118
+ def run_web_server(in_hostname="localhost", in_port=7145):
112
119
  print(Messages.MSG_STARTING_WEBSERVER.format(port=in_port))
113
- initialize()
114
120
  webserver(in_hostname, in_port)
115
121
 
116
122
 
@@ -118,17 +124,19 @@ if importlib.util.find_spec("jurigged"):
118
124
  print("Jurigged enabled")
119
125
  jurigged.watch("./")
120
126
 
121
- print(Messages.MSG_ENTRY_POINT_NAME.format(name=__name__))
122
- if __name__ == '__main__' or __name__ == 'tina4_python':
123
- # Start up a webserver based on params passed on the command line
124
- HOSTNAME = "localhost"
125
- PORT = 7145
126
- if len(sys.argv) > 1:
127
- PORT = sys.argv[1]
128
- if ":" in PORT:
129
- SERVER_CONFIG = PORT.split(":")
130
- HOSTNAME = SERVER_CONFIG[0]
131
- PORT = SERVER_CONFIG[1]
132
-
127
+ # Start up a webserver based on params passed on the command line
128
+ HOSTNAME = "localhost"
129
+ PORT = 7145
130
+ if len(sys.argv) > 1:
131
+ PORT = sys.argv[1]
132
+ if ":" in PORT:
133
+ SERVER_CONFIG = PORT.split(":")
134
+ HOSTNAME = SERVER_CONFIG[0]
135
+ PORT = SERVER_CONFIG[1]
136
+
137
+ if PORT != "stop" and PORT != "manual":
133
138
  PORT = int(PORT)
134
- main(HOSTNAME, PORT)
139
+ print("Threading")
140
+ run_web_server(HOSTNAME, PORT)
141
+ else:
142
+ print("Webserver is set to manual start, please call run_web_server(HOSTNAME, PORT)")