laraflask-core 1.0.0__py3-none-any.whl

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.
laraflask/__init__.py ADDED
@@ -0,0 +1 @@
1
+ from .helpers import env, config, view, route, url, asset, css, js
laraflask/core.py ADDED
@@ -0,0 +1,100 @@
1
+ import os
2
+ import sys
3
+ from flask import url_for, render_template, request
4
+ from markupsafe import Markup
5
+ import importlib.util
6
+ from pathlib import Path
7
+
8
+ _env_cache = None
9
+ CONFIG_CACHE = {}
10
+
11
+ def _find_project_root():
12
+ current = Path.cwd()
13
+ for parent in [current] + list(current.parents):
14
+ if (parent / ".env").exists() or (parent / "config").exists():
15
+ return str(parent)
16
+ return str(current)
17
+
18
+ PROJECT_ROOT = _find_project_root()
19
+
20
+ def _load_env():
21
+ global _env_cache
22
+ if _env_cache is None:
23
+ _env_cache = {}
24
+ env_path = os.path.join(PROJECT_ROOT, ".env")
25
+ if os.path.exists(env_path):
26
+ with open(env_path, "r", encoding="utf-8") as f:
27
+ for line in f:
28
+ line = line.strip()
29
+ if not line or line.startswith("#"):
30
+ continue
31
+ if "=" in line:
32
+ key, value = line.split("=", 1)
33
+ value = value.strip().strip('"').strip("'")
34
+ _env_cache[key.strip()] = value
35
+ return _env_cache
36
+
37
+ def env(key, default=None):
38
+ return _load_env().get(key, default)
39
+
40
+ def config(key, default=None):
41
+ parts = key.split(".")
42
+ if not parts:
43
+ return default
44
+
45
+ file_name = parts[0]
46
+
47
+ if file_name not in CONFIG_CACHE:
48
+ file_path = os.path.join(PROJECT_ROOT, "config", f"{file_name}.py")
49
+ if not os.path.exists(file_path):
50
+ return default
51
+
52
+ spec = importlib.util.spec_from_file_location(file_name, file_path)
53
+ module = importlib.util.module_from_spec(spec)
54
+ spec.loader.exec_module(module)
55
+
56
+ CONFIG_CACHE[file_name] = getattr(module, file_name, {})
57
+
58
+ value = CONFIG_CACHE[file_name]
59
+ for part in parts[1:]:
60
+ if isinstance(value, dict):
61
+ value = value.get(part, default)
62
+ else:
63
+ return default
64
+
65
+ return value
66
+
67
+ def view(template_name, data=None):
68
+ if data is None:
69
+ data = {}
70
+ template_path = template_name.replace(".", "/")
71
+ if not os.path.splitext(template_path)[1]:
72
+ template_path += ".html"
73
+
74
+ return render_template(template_path, **data)
75
+
76
+ def route(name, **kwargs):
77
+ return url_for(name, **kwargs)
78
+
79
+ def url(path=""):
80
+ base = request.url_root.rstrip("/")
81
+ return f"{base}/{path.lstrip('/')}" if path else base
82
+
83
+ def asset(path):
84
+ return url_for("static", filename=path)
85
+
86
+ def css(filename):
87
+ file_path = os.path.join(PROJECT_ROOT, "resources", "css", filename)
88
+ version = int(os.path.getmtime(file_path)) if os.path.exists(file_path) else 1
89
+ url_path = f"resources/css/{filename}"
90
+ return Markup(
91
+ f'<link rel="stylesheet" href="{request.url_root.rstrip("/")}/{url_path}?v={version}">'
92
+ )
93
+
94
+ def js(filename):
95
+ file_path = os.path.join(PROJECT_ROOT, "resources", "js", filename)
96
+ version = int(os.path.getmtime(file_path)) if os.path.exists(file_path) else 1
97
+ url_path = f"resources/js/{filename}"
98
+ return Markup(
99
+ f'<script src="{request.url_root.rstrip("/")}/{url_path}?v={version}"></script>'
100
+ )
@@ -0,0 +1,55 @@
1
+ Metadata-Version: 2.4
2
+ Name: laraflask-core
3
+ Version: 1.0.0
4
+ Summary: Laraflask ecosystem init root.
5
+ Home-page: https://github.com/riodevnet/laraflask
6
+ Author: Rio Agung Purnomo
7
+ Author-email: laraflask@ryucode.com
8
+ Classifier: Development Status :: 5 - Production/Stable
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Framework :: Flask
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.7
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: Flask
17
+ Requires-Dist: MarkupSafe
18
+ Requires-Dist: python-dotenv
19
+ Requires-Dist: click
20
+ Dynamic: author
21
+ Dynamic: author-email
22
+ Dynamic: classifier
23
+ Dynamic: description
24
+ Dynamic: description-content-type
25
+ Dynamic: home-page
26
+ Dynamic: license-file
27
+ Dynamic: requires-dist
28
+ Dynamic: requires-python
29
+ Dynamic: summary
30
+
31
+ ## About Laraflask
32
+
33
+ Laraflask is a web application framework designed with clean, expressive, and easy-to-read syntax. Our goal is to make development an enjoyable and creative process. With Laraflask, many common tasks in web development can be handled quickly and efficiently
34
+
35
+ Laraflask is suitable for building anything from small projects to large-scale applications with strong performance and stability.
36
+
37
+ ## Laraflask Sponsors
38
+
39
+ We’re grateful to our sponsors for supporting Laraflask development. If you’d like to join them, please visit the [Laraflask Partners](https://laraflask.vercel.app/partners) page.
40
+
41
+ ### Premium Partners
42
+
43
+ - **[RyuCode Digital Solution](https://ryucode.com)**
44
+
45
+ ## Contributing
46
+
47
+ We welcome contributions from anyone who wants to help improve Laraflask. You can find the contribution guide in the [Laraflask documentation](https://laraflask.vercel.app/docs/contributions).
48
+
49
+ ## Security Vulnerabilities
50
+
51
+ If you discover a security issue in Laraflask, please email [riodev@ryucode.com](mailto:laraflask@ryucode.com). All reports will be addressed promptly.
52
+
53
+ ## License
54
+
55
+ Laraflask is open-source software licensed under the [MIT license](https://opensource.org/licenses/MIT).
@@ -0,0 +1,7 @@
1
+ laraflask/__init__.py,sha256=0RwaorllHJS6imbA03AcS-_BlfsKD3fe9SL2R1-11ig,68
2
+ laraflask/core.py,sha256=ZNnCBTTFmA9qXHyKrJ1jqZgkETfopEZHIUgDJBKWR_U,3190
3
+ laraflask_core-1.0.0.dist-info/licenses/LICENSE,sha256=kCEFZg42or42IhL8Vc7pmWc5tfDM76RvCASISE6rfoA,1087
4
+ laraflask_core-1.0.0.dist-info/METADATA,sha256=UCIYgS5xTDEJUKh33L364osHmugceie1KBS_OxmZoe8,2106
5
+ laraflask_core-1.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
+ laraflask_core-1.0.0.dist-info/top_level.txt,sha256=PjEoN5F212AdL63pLrTFv6Fj0xVsGzwdSNkL78Mkfu4,10
7
+ laraflask_core-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Laraflask
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ laraflask