mirror of
https://github.com/rjNemo/vf-site
synced 2026-06-06 01:16:38 +00:00
use rich
This commit is contained in:
parent
5e39e5920a
commit
24632b08f0
5 changed files with 43 additions and 13 deletions
1
Makefile
1
Makefile
|
|
@ -2,6 +2,7 @@ build:
|
|||
@pipenv run python -m lib.main
|
||||
|
||||
run: build
|
||||
@echo ""
|
||||
@cd dist && pipenv run python -m http.server
|
||||
|
||||
lint:
|
||||
|
|
|
|||
2
Pipfile
2
Pipfile
|
|
@ -5,7 +5,7 @@ name = "pypi"
|
|||
|
||||
[packages]
|
||||
jinja2 = "*"
|
||||
loguru = "*"
|
||||
rich = "*"
|
||||
|
||||
[dev-packages]
|
||||
black = "*"
|
||||
|
|
|
|||
36
Pipfile.lock
generated
36
Pipfile.lock
generated
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "4c4b43f1ede1c6a64f569dbd3bbfdc2c6aabfe004db06d43fe42496847026061"
|
||||
"sha256": "bef80c03c82a5024d5fd39621dcbdf6fb13cdcf4f3765b97214d0d0cfa7c99b1"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
|
|
@ -24,13 +24,13 @@
|
|||
"index": "pypi",
|
||||
"version": "==3.1.2"
|
||||
},
|
||||
"loguru": {
|
||||
"markdown-it-py": {
|
||||
"hashes": [
|
||||
"sha256:1612053ced6ae84d7959dd7d5e431a0532642237ec21f7fd83ac73fe539e03e1",
|
||||
"sha256:b93aa30099fa6860d4727f1b81f8718e965bb96253fa190fab2077aaad6d15d3"
|
||||
"sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1",
|
||||
"sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==0.7.0"
|
||||
"markers": "python_version >= '3.8'",
|
||||
"version": "==3.0.0"
|
||||
},
|
||||
"markupsafe": {
|
||||
"hashes": [
|
||||
|
|
@ -87,6 +87,30 @@
|
|||
],
|
||||
"markers": "python_version >= '3.7'",
|
||||
"version": "==2.1.3"
|
||||
},
|
||||
"mdurl": {
|
||||
"hashes": [
|
||||
"sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8",
|
||||
"sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba"
|
||||
],
|
||||
"markers": "python_version >= '3.7'",
|
||||
"version": "==0.1.2"
|
||||
},
|
||||
"pygments": {
|
||||
"hashes": [
|
||||
"sha256:8ace4d3c1dd481894b2005f560ead0f9f19ee64fe983366be1a21e171d12775c",
|
||||
"sha256:db2db3deb4b4179f399a09054b023b6a586b76499d36965813c71aa8ed7b5fd1"
|
||||
],
|
||||
"markers": "python_version >= '3.7'",
|
||||
"version": "==2.15.1"
|
||||
},
|
||||
"rich": {
|
||||
"hashes": [
|
||||
"sha256:8f87bc7ee54675732fa66a05ebfe489e27264caeeff3728c945d25971b6485ec",
|
||||
"sha256:d653d6bccede5844304c605d5aac802c7cf9621efd700b46c7ec2b51ea914898"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==13.4.2"
|
||||
}
|
||||
},
|
||||
"develop": {
|
||||
|
|
|
|||
|
|
@ -74,6 +74,8 @@ You can then deploy the site on any platform supporting static sites (Netlify,
|
|||
- [ ] Create a template for the rooms
|
||||
- [ ] Build script before commit
|
||||
- [ ] Lit parapluie, barbecue et machine à laver
|
||||
- [x] Use rich instead of logger
|
||||
- [ ] Add file watching mode
|
||||
|
||||
## Excluded
|
||||
|
||||
|
|
|
|||
15
lib/main.py
15
lib/main.py
|
|
@ -5,7 +5,7 @@ import tomllib
|
|||
from distutils.dir_util import copy_tree
|
||||
from time import perf_counter
|
||||
|
||||
from loguru import logger
|
||||
from rich import print
|
||||
|
||||
from lib.config import Config, load
|
||||
from lib.engine import FileSystemRenderer
|
||||
|
|
@ -17,28 +17,31 @@ def main():
|
|||
|
||||
fs = FileSystemRenderer(config)
|
||||
|
||||
logger.info(f"🏁 Start building {config.name}")
|
||||
print(f"🏁 Start building [italic red]{config.name}[/italic red]")
|
||||
clean_dist(config.out_dir)
|
||||
|
||||
for page in os.scandir(config.templates_dir):
|
||||
if page.is_file():
|
||||
with open(os.path.join(config.out_dir, page.name), "w") as fd:
|
||||
data = parse_data(page, config.data_dir)
|
||||
logger.info(f"📃 Render '{page.name}'")
|
||||
print(f"📃 Render [italic cyan]{page.name}[/italic cyan]")
|
||||
fd.write(fs.render(page.name, data))
|
||||
|
||||
logger.info("⏩ Copy static assets to build")
|
||||
print("⏩ Copy static assets to build")
|
||||
copy_tree(config.static_dir, os.path.join(config.out_dir))
|
||||
|
||||
end = perf_counter()
|
||||
logger.info(f"🎉 Done… in {(end - start) * 1000:.2f} ms")
|
||||
print(f"🎉 Done… in [italic red]{(end - start) * 1000:.2f} ms[/italic red]")
|
||||
|
||||
|
||||
def parse_config() -> Config:
|
||||
try:
|
||||
config = load()
|
||||
except FileNotFoundError:
|
||||
logger.error("the configuration file 'config.toml' was not found. Please verify it exists at the root level")
|
||||
print(
|
||||
"🛑 configuration file [italic red]'config.toml'[/italic red] was not found. "
|
||||
"Please verify it exists at the root level"
|
||||
)
|
||||
sys.exit(1)
|
||||
else:
|
||||
return config
|
||||
|
|
|
|||
Loading…
Reference in a new issue