Compare commits

..

No commits in common. "07152a37468309a57e9fef6698f5bed65807e4bd" and "faac8f63bbf960bb41fb99924db46533cd7c203d" have entirely different histories.

8 changed files with 9 additions and 24 deletions

View file

@ -317,7 +317,6 @@ available:
| `template` | `str \| none` = `none` | Template to use for this page. Relative to `templates/`, `.html` extension optional. | | `template` | `str \| none` = `none` | Template to use for this page. Relative to `templates/`, `.html` extension optional. |
| `post` | `bool \| none` = `none` | Whether this page is a **post**. `true`/`false` is _absolute_. Leave it unset for automatic detection. | | `post` | `bool \| none` = `none` | Whether this page is a **post**. `true`/`false` is _absolute_. Leave it unset for automatic detection. |
| `draft` | `bool` = `false` | Whether this page is a draft. See [drafts](#drafts) for more. | | `draft` | `bool` = `false` | Whether this page is a draft. See [drafts](#drafts) for more. |
| `ignore` | `bool` = `false` | Whether this page should be ignored in _both_ `final` and `draft` contexts. |
| `math` | `bool` = `true` | Whether the LaTeX extension should be enabled for this page. | | `math` | `bool` = `true` | Whether the LaTeX extension should be enabled for this page. |
**Note**: you can specify the date in any format that can be parsed by **Note**: you can specify the date in any format that can be parsed by

View file

@ -62,7 +62,7 @@ allowedUntypedLibraries = ["frontmatter", "pygments", "pymdownx", "l2m4m"]
[tool.ruff] [tool.ruff]
line-length = 70 line-length = 70
indent-width = 4 indent-width = 4
target-version = "py312" target-version = "py311"
[tool.ruff.lint] [tool.ruff.lint]
fixable = ["ALL"] fixable = ["ALL"]

View file

@ -53,7 +53,7 @@ class ZonaBuilder:
): ):
logger.debug(f"Parsing {path.name}.") logger.debug(f"Parsing {path.name}.")
item.metadata, item.content = parse_metadata(path) item.metadata, item.content = parse_metadata(path)
if item.metadata.ignore or ( if (
item.metadata.draft item.metadata.draft
and not self.config.build.include_drafts and not self.config.build.include_drafts
): ):

View file

@ -59,9 +59,7 @@ def build(
""" """
if draft: if draft:
print("Option override: including drafts.") print("Option override: including drafts.")
builder = ZonaBuilder( builder = ZonaBuilder(cli_root=root, cli_output=output, draft=draft)
cli_root=root, cli_output=output, draft=draft
)
builder.build() builder.build()
@ -75,9 +73,7 @@ def serve(
] = None, ] = None,
host: Annotated[ host: Annotated[
str, str,
typer.Option( typer.Option("--host", help="Hostname for live preview server."),
"--host", help="Hostname for live preview server."
),
] = "localhost", ] = "localhost",
port: Annotated[ port: Annotated[
int, int,

View file

@ -76,9 +76,7 @@ IGNORELIST = [".marksman.toml"]
class ZonaConfig: class ZonaConfig:
base_url: str = "/" base_url: str = "/"
# dictionary where key is name, value is url # dictionary where key is name, value is url
sitemap: SitemapConfig = field( sitemap: SitemapConfig = field(default_factory=lambda: {"Home": "/"})
default_factory=lambda: {"Home": "/"}
)
# list of globs relative to content that should be ignored # list of globs relative to content that should be ignored
ignore: list[str] = field(default_factory=lambda: IGNORELIST) ignore: list[str] = field(default_factory=lambda: IGNORELIST)
markdown: MarkdownConfig = field(default_factory=MarkdownConfig) markdown: MarkdownConfig = field(default_factory=MarkdownConfig)

View file

@ -24,7 +24,6 @@ class Metadata:
template: str | None = None template: str | None = None
post: bool | None = None post: bool | None = None
draft: bool = False draft: bool = False
ignore: bool = False
math: bool = True math: bool = True

View file

@ -238,9 +238,7 @@ def serve(
event_handler, path=str(root / "content"), recursive=True event_handler, path=str(root / "content"), recursive=True
) )
observer.schedule( observer.schedule(
event_handler, event_handler, path=str(root / "templates"), recursive=True
path=str(root / "templates"),
recursive=True,
) )
observer.start() observer.start()

View file

@ -19,9 +19,7 @@ def get_resource(path: str) -> ZonaResource:
if file.is_file(): if file.is_file():
return ZonaResource(name=path, contents=file.read_text()) return ZonaResource(name=path, contents=file.read_text())
else: else:
raise FileNotFoundError( raise FileNotFoundError(f"{path} is not a valid Zona resource!")
f"{path} is not a valid Zona resource!"
)
def get_resources(subdir: str) -> list[ZonaResource]: def get_resources(subdir: str) -> list[ZonaResource]:
@ -77,13 +75,10 @@ def normalize_url(url: str) -> str:
return url return url
def should_ignore( def should_ignore(path: Path, patterns: list[str], base: Path) -> bool:
path: Path, patterns: list[str], base: Path
) -> bool:
rel_path = path.relative_to(base) rel_path = path.relative_to(base)
return any( return any(
fnmatch.fnmatch(str(rel_path), pattern) fnmatch.fnmatch(str(rel_path), pattern) for pattern in patterns
for pattern in patterns
) )