began implementation
This commit is contained in:
parent
a05f63bf26
commit
53f09b72db
6 changed files with 87 additions and 2 deletions
|
@ -8,11 +8,12 @@ authors = [
|
||||||
]
|
]
|
||||||
requires-python = ">=3.12"
|
requires-python = ">=3.12"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"frontmatter>=3.0.8",
|
||||||
"typer>=0.16.0",
|
"typer>=0.16.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.scripts]
|
[project.scripts]
|
||||||
zona = "zona:main"
|
zona = "zona.cli:main"
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["hatchling"]
|
requires = ["hatchling"]
|
||||||
|
|
23
src/zona/builder.py
Normal file
23
src/zona/builder.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
from zona.models import Item
|
||||||
|
from pathlib import Path
|
||||||
|
import frontmatter
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
def discover(root: str, out_dir: str) -> list[Item]:
|
||||||
|
root_path = Path(root)
|
||||||
|
required_dirs = {"content", "static", "templates"}
|
||||||
|
found_dirs = {p.name for p in root_path.iterdir() if p.is_dir()}
|
||||||
|
missing = required_dirs - found_dirs
|
||||||
|
assert not missing, f"Missing required directories: {', '.join(missing)}"
|
||||||
|
|
||||||
|
items: list[Item] = []
|
||||||
|
|
||||||
|
for subdir in required_dirs:
|
||||||
|
base = root_path / subdir
|
||||||
|
for path in base.rglob("*"):
|
||||||
|
if path.is_file():
|
||||||
|
print(f"{subdir}: {path.relative_to(root_path)}")
|
||||||
|
# TODO: build Item here
|
||||||
|
# items.append(...)
|
||||||
|
return items
|
23
src/zona/cli.py
Normal file
23
src/zona/cli.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import typer
|
||||||
|
from zona import builder
|
||||||
|
|
||||||
|
app = typer.Typer()
|
||||||
|
|
||||||
|
|
||||||
|
@app.command()
|
||||||
|
def discover(in_dir: str | None = None):
|
||||||
|
out_dir = ""
|
||||||
|
if in_dir is None:
|
||||||
|
in_dir = "."
|
||||||
|
_ = builder.discover(in_dir, out_dir)
|
||||||
|
|
||||||
|
|
||||||
|
@app.command()
|
||||||
|
def init():
|
||||||
|
# init will populate the current directory with
|
||||||
|
# the required folders and their default values
|
||||||
|
print("Init logic here...")
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
app()
|
19
src/zona/models.py
Normal file
19
src/zona/models.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
from pathlib import Path
|
||||||
|
from datetime import datetime
|
||||||
|
from dataclasses import dataclass
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Metadata:
|
||||||
|
title: str
|
||||||
|
date: datetime
|
||||||
|
description: str
|
||||||
|
# add more options later...
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Item:
|
||||||
|
source: Path
|
||||||
|
destination: Path
|
||||||
|
url: str # relative to site root
|
||||||
|
metadata: Metadata | None # frontmatter
|
0
src/zona/parser.py
Normal file
0
src/zona/parser.py
Normal file
21
uv.lock
generated
21
uv.lock
generated
|
@ -23,6 +23,15 @@ wheels = [
|
||||||
{ url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" },
|
{ url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "frontmatter"
|
||||||
|
version = "3.0.8"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "pyyaml" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/8b/de/7425e1c97db39ca6615ccf89d8c3b47f2ee8dfdabb754fc99f925ee1a702/frontmatter-3.0.8.tar.gz", hash = "sha256:d913619d20f607e03557d52a8bf9b249e0b3093c770c5213c0f1231d2c97fe73", size = 5254, upload-time = "2024-03-08T07:55:51.023Z" }
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "markdown-it-py"
|
name = "markdown-it-py"
|
||||||
version = "3.0.0"
|
version = "3.0.0"
|
||||||
|
@ -53,6 +62,12 @@ wheels = [
|
||||||
{ url = "https://files.pythonhosted.org/packages/8a/0b/9fcc47d19c48b59121088dd6da2488a49d5f72dacf8262e2790a1d2c7d15/pygments-2.19.1-py3-none-any.whl", hash = "sha256:9ea1544ad55cecf4b8242fab6dd35a93bbce657034b0611ee383099054ab6d8c", size = 1225293, upload-time = "2025-01-06T17:26:25.553Z" },
|
{ url = "https://files.pythonhosted.org/packages/8a/0b/9fcc47d19c48b59121088dd6da2488a49d5f72dacf8262e2790a1d2c7d15/pygments-2.19.1-py3-none-any.whl", hash = "sha256:9ea1544ad55cecf4b8242fab6dd35a93bbce657034b0611ee383099054ab6d8c", size = 1225293, upload-time = "2025-01-06T17:26:25.553Z" },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pyyaml"
|
||||||
|
version = "5.1"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/9f/2c/9417b5c774792634834e730932745bc09a7d36754ca00acf1ccd1ac2594d/PyYAML-5.1.tar.gz", hash = "sha256:436bc774ecf7c103814098159fbb84c2715d25980175292c648f2da143909f95", size = 274244, upload-time = "2019-03-13T16:35:50.361Z" }
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rich"
|
name = "rich"
|
||||||
version = "14.0.0"
|
version = "14.0.0"
|
||||||
|
@ -104,8 +119,12 @@ name = "zona"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = { editable = "." }
|
source = { editable = "." }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
{ name = "frontmatter" },
|
||||||
{ name = "typer" },
|
{ name = "typer" },
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.metadata]
|
[package.metadata]
|
||||||
requires-dist = [{ name = "typer", specifier = ">=0.16.0" }]
|
requires-dist = [
|
||||||
|
{ name = "frontmatter", specifier = ">=3.0.8" },
|
||||||
|
{ name = "typer", specifier = ">=0.16.0" },
|
||||||
|
]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue