blurry-cli 0.4.0__tar.gz → 0.4.2__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.
- {blurry_cli-0.4.0 → blurry_cli-0.4.2}/PKG-INFO +2 -3
- blurry_cli-0.4.2/blurry/__main__.py +3 -0
- {blurry_cli-0.4.0 → blurry_cli-0.4.2}/blurry/images.py +7 -11
- {blurry_cli-0.4.0 → blurry_cli-0.4.2}/blurry/markdown/__init__.py +8 -5
- {blurry_cli-0.4.0 → blurry_cli-0.4.2}/blurry/plugins/html_plugins/minify_html_plugin.py +1 -3
- {blurry_cli-0.4.0 → blurry_cli-0.4.2}/blurry/sitemap.py +4 -3
- {blurry_cli-0.4.0 → blurry_cli-0.4.2}/blurry/utils.py +31 -8
- {blurry_cli-0.4.0 → blurry_cli-0.4.2}/pyproject.toml +11 -5
- blurry_cli-0.4.0/blurry/__main__.py +0 -5
- {blurry_cli-0.4.0 → blurry_cli-0.4.2}/LICENSE +0 -0
- {blurry_cli-0.4.0 → blurry_cli-0.4.2}/README.md +0 -0
- {blurry_cli-0.4.0 → blurry_cli-0.4.2}/blurry/__init__.py +0 -0
- {blurry_cli-0.4.0 → blurry_cli-0.4.2}/blurry/async_typer.py +0 -0
- {blurry_cli-0.4.0 → blurry_cli-0.4.2}/blurry/constants.py +0 -0
- {blurry_cli-0.4.0 → blurry_cli-0.4.2}/blurry/markdown/front_matter.py +0 -0
- {blurry_cli-0.4.0 → blurry_cli-0.4.2}/blurry/markdown/renderer_functions/__init__.py +0 -0
- {blurry_cli-0.4.0 → blurry_cli-0.4.2}/blurry/markdown/renderer_functions/render_video.py +0 -0
- {blurry_cli-0.4.0 → blurry_cli-0.4.2}/blurry/open_graph.py +0 -0
- {blurry_cli-0.4.0 → blurry_cli-0.4.2}/blurry/plugins/__init__.py +0 -0
- {blurry_cli-0.4.0 → blurry_cli-0.4.2}/blurry/plugins/html_plugins/__init__.py +0 -0
- {blurry_cli-0.4.0 → blurry_cli-0.4.2}/blurry/plugins/markdown_plugins/__init__.py +0 -0
- {blurry_cli-0.4.0 → blurry_cli-0.4.2}/blurry/plugins/markdown_plugins/container_plugin.py +0 -0
- {blurry_cli-0.4.0 → blurry_cli-0.4.2}/blurry/plugins/markdown_plugins/punctuation_plugin.py +0 -0
- {blurry_cli-0.4.0 → blurry_cli-0.4.2}/blurry/plugins/markdown_plugins/python_code_plugin.py +0 -0
- {blurry_cli-0.4.0 → blurry_cli-0.4.2}/blurry/py.typed +0 -0
- {blurry_cli-0.4.0 → blurry_cli-0.4.2}/blurry/settings.py +0 -0
- {blurry_cli-0.4.0 → blurry_cli-0.4.2}/blurry/types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: blurry-cli
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.2
|
|
4
4
|
Summary: A Mistune-based static site generator for Python
|
|
5
5
|
Home-page: https://github.com/blurry-dev/blurry
|
|
6
6
|
License: MIT
|
|
@@ -14,8 +14,7 @@ Classifier: Operating System :: OS Independent
|
|
|
14
14
|
Classifier: Programming Language :: Python :: 3
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.10
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
18
|
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content :: Content Management System
|
|
20
19
|
Classifier: Topic :: Internet :: WWW/HTTP :: Site Management
|
|
21
20
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
-
import concurrent.futures
|
|
3
2
|
from pathlib import Path
|
|
4
|
-
from typing import Optional
|
|
5
3
|
|
|
6
4
|
from wand.image import Image
|
|
7
5
|
|
|
@@ -31,7 +29,7 @@ def add_image_width_to_path(image_path: Path, width: int) -> Path:
|
|
|
31
29
|
return Path(new_filename)
|
|
32
30
|
|
|
33
31
|
|
|
34
|
-
async def convert_image_to_avif(image_path: Path, target_path:
|
|
32
|
+
async def convert_image_to_avif(image_path: Path, target_path: Path | None = None):
|
|
35
33
|
image_suffix = image_path.suffix
|
|
36
34
|
if image_suffix in [".webp", ".gif"]:
|
|
37
35
|
return
|
|
@@ -59,18 +57,16 @@ async def generate_images_for_srcset(image_path: Path):
|
|
|
59
57
|
new_filepath = add_image_width_to_path(image_path, target_width)
|
|
60
58
|
relative_filepath = new_filepath.resolve().relative_to(CONTENT_DIR)
|
|
61
59
|
build_filepath = BUILD_DIR / relative_filepath
|
|
62
|
-
if build_filepath.exists():
|
|
63
|
-
continue
|
|
64
60
|
with img.clone() as resized:
|
|
61
|
+
avif_files_to_create.append(build_filepath)
|
|
62
|
+
if build_filepath.exists():
|
|
63
|
+
continue
|
|
65
64
|
resized.transform(resize=str(target_width))
|
|
66
65
|
resized.save(filename=build_filepath)
|
|
67
|
-
avif_files_to_create.append(build_filepath)
|
|
68
66
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
avif_files_to_create,
|
|
73
|
-
)
|
|
67
|
+
await asyncio.gather(
|
|
68
|
+
*[convert_image_to_avif(avif_file) for avif_file in avif_files_to_create]
|
|
69
|
+
)
|
|
74
70
|
|
|
75
71
|
|
|
76
72
|
def get_widths_for_image_width(image_width: int) -> list[int]:
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
2
|
from typing import Any
|
|
3
|
-
from typing import Type
|
|
4
3
|
from typing import TypeGuard
|
|
5
4
|
|
|
6
5
|
import mistune
|
|
@@ -28,7 +27,7 @@ from blurry.settings import SETTINGS
|
|
|
28
27
|
from blurry.types import is_str
|
|
29
28
|
from blurry.utils import build_path_to_url
|
|
30
29
|
from blurry.utils import content_path_to_url
|
|
31
|
-
from blurry.utils import
|
|
30
|
+
from blurry.utils import convert_relative_path_in_markdown_file_to_pathname
|
|
32
31
|
from blurry.utils import path_to_url_pathname
|
|
33
32
|
from blurry.utils import remove_lazy_loading_from_first_image
|
|
34
33
|
from blurry.utils import resolve_relative_path_in_markdown
|
|
@@ -102,7 +101,9 @@ class BlurryRenderer(mistune.HTMLRenderer):
|
|
|
102
101
|
def link(self, text, url, title: str | None = None) -> str:
|
|
103
102
|
link_is_relative = url.startswith(".")
|
|
104
103
|
if link_is_relative:
|
|
105
|
-
url =
|
|
104
|
+
url = convert_relative_path_in_markdown_file_to_pathname(
|
|
105
|
+
content_directory=CONTENT_DIR, filepath=self.filepath, relative_path=url
|
|
106
|
+
)
|
|
106
107
|
|
|
107
108
|
if text is None:
|
|
108
109
|
text = url
|
|
@@ -111,7 +112,9 @@ class BlurryRenderer(mistune.HTMLRenderer):
|
|
|
111
112
|
}
|
|
112
113
|
if title:
|
|
113
114
|
attrs["title"] = escape(title)
|
|
114
|
-
if
|
|
115
|
+
if link_is_relative:
|
|
116
|
+
attrs["rel"] = "noreferrer"
|
|
117
|
+
else:
|
|
115
118
|
attrs["target"] = "_blank"
|
|
116
119
|
attrs["rel"] = "noopener"
|
|
117
120
|
|
|
@@ -124,7 +127,7 @@ class BlurryRenderer(mistune.HTMLRenderer):
|
|
|
124
127
|
|
|
125
128
|
def is_blurry_renderer(
|
|
126
129
|
renderer: mistune.HTMLRenderer,
|
|
127
|
-
) -> TypeGuard[
|
|
130
|
+
) -> TypeGuard[type[BlurryRenderer]]:
|
|
128
131
|
return isinstance(renderer, BlurryRenderer)
|
|
129
132
|
|
|
130
133
|
|
|
@@ -23,9 +23,7 @@ def minify_style_tags(html: str) -> str:
|
|
|
23
23
|
for style_tag in style_tags:
|
|
24
24
|
css = style_tag.text()
|
|
25
25
|
minified_css = minify_css(css)
|
|
26
|
-
minified_style_tag = HTMLParser(
|
|
27
|
-
f"<style>{minified_css}</style>"
|
|
28
|
-
).head.child # type: ignore
|
|
26
|
+
minified_style_tag = HTMLParser(f"<style>{minified_css}</style>").head.child # type: ignore
|
|
29
27
|
style_tag.replace_with(minified_style_tag) # type: ignore
|
|
30
28
|
|
|
31
29
|
return parser.html or html
|
|
@@ -14,7 +14,7 @@ SITEMAP_TEMPLATE = """<?xml version="1.0" encoding="UTF-8"?>
|
|
|
14
14
|
{urls}
|
|
15
15
|
</urlset>
|
|
16
16
|
""".strip()
|
|
17
|
-
URL_TEMPLATE = " <url><loc>{url}</loc
|
|
17
|
+
URL_TEMPLATE = " <url><loc>{url}</loc>{lastmod_tag}</url>"
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
def generate_sitemap_for_file_data_list(file_data_list: list[MarkdownFileData]) -> str:
|
|
@@ -23,11 +23,12 @@ def generate_sitemap_for_file_data_list(file_data_list: list[MarkdownFileData])
|
|
|
23
23
|
lastmod = file_data.front_matter.get(
|
|
24
24
|
"dateModified"
|
|
25
25
|
) or file_data.front_matter.get("datePublished")
|
|
26
|
+
lastmod_tag = f"<lastmod>{lastmod}</lastmod>" if lastmod else ""
|
|
26
27
|
url = file_data.front_matter.get("url")
|
|
27
|
-
sitemap_url_data.append({"
|
|
28
|
+
sitemap_url_data.append({"lastmod_tag": lastmod_tag, "url": url})
|
|
28
29
|
|
|
29
30
|
sitemap_url_content = "\n".join(
|
|
30
|
-
URL_TEMPLATE.format(url=data["url"],
|
|
31
|
+
URL_TEMPLATE.format(url=data["url"], lastmod_tag=data["lastmod_tag"])
|
|
31
32
|
for data in sitemap_url_data
|
|
32
33
|
)
|
|
33
34
|
return SITEMAP_TEMPLATE.format(urls=sitemap_url_content)
|
|
@@ -8,6 +8,7 @@ from blurry.settings import SETTINGS
|
|
|
8
8
|
from blurry.types import DirectoryFileData
|
|
9
9
|
|
|
10
10
|
CONTENT_DIR = get_content_directory()
|
|
11
|
+
BUILD_DIR = get_build_directory()
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
def get_domain_with_scheme():
|
|
@@ -29,14 +30,30 @@ def convert_content_path_to_directory_in_build(path: Path) -> Path:
|
|
|
29
30
|
return BUILD_DIR.joinpath(path)
|
|
30
31
|
|
|
31
32
|
|
|
32
|
-
def
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
def convert_relative_path_in_markdown_file_to_pathname(
|
|
34
|
+
content_directory: Path, filepath: Path, relative_path: str
|
|
35
|
+
) -> str:
|
|
36
|
+
directory = filepath.parent
|
|
37
|
+
pathname_start = directory.relative_to(content_directory)
|
|
38
|
+
|
|
39
|
+
while relative_path.startswith(prefix := "../"):
|
|
40
|
+
pathname_start = pathname_start.parent
|
|
41
|
+
relative_path = relative_path[len(prefix) :]
|
|
42
|
+
if relative_path.startswith(prefix := "./"):
|
|
43
|
+
relative_path = relative_path[len(prefix) :]
|
|
35
44
|
if relative_path.endswith("index.md"):
|
|
36
45
|
relative_path = relative_path.replace("index.md", "")
|
|
37
46
|
elif relative_path.endswith(".md"):
|
|
38
47
|
relative_path = relative_path.replace(".md", "") + "/"
|
|
39
|
-
|
|
48
|
+
|
|
49
|
+
pathname_prefix = str(pathname_start).removeprefix(".")
|
|
50
|
+
|
|
51
|
+
pathname = f"{pathname_prefix}/{relative_path}"
|
|
52
|
+
|
|
53
|
+
if not pathname.startswith("/"):
|
|
54
|
+
pathname = f"/{pathname}"
|
|
55
|
+
|
|
56
|
+
return pathname
|
|
40
57
|
|
|
41
58
|
|
|
42
59
|
def resolve_relative_path_in_markdown(relative_path: str, markdown_file: Path) -> Path:
|
|
@@ -57,17 +74,23 @@ def write_index_file_creating_path(directory_path: Path, content: str):
|
|
|
57
74
|
filepath.write_text(content)
|
|
58
75
|
|
|
59
76
|
|
|
60
|
-
def
|
|
77
|
+
def content_path_to_url_pathname(path: Path) -> str:
|
|
61
78
|
BUILD_DIR = get_build_directory()
|
|
62
79
|
if path.suffix == ".md":
|
|
63
80
|
build_directory = convert_content_path_to_directory_in_build(path)
|
|
64
81
|
relative_directory = build_directory.relative_to(BUILD_DIR)
|
|
65
82
|
# Handle root page
|
|
66
83
|
if str(relative_directory) == ".":
|
|
67
|
-
return
|
|
68
|
-
return f"
|
|
84
|
+
return "/"
|
|
85
|
+
return f"/{relative_directory}/"
|
|
86
|
+
|
|
87
|
+
return path_to_url_pathname(path)
|
|
69
88
|
|
|
70
|
-
|
|
89
|
+
|
|
90
|
+
def content_path_to_url(path: Path) -> str:
|
|
91
|
+
domain_with_scheme = get_domain_with_scheme()
|
|
92
|
+
pathname = content_path_to_url_pathname(path)
|
|
93
|
+
return f"{domain_with_scheme}{pathname}"
|
|
71
94
|
|
|
72
95
|
|
|
73
96
|
def build_path_to_url(path: Path) -> str:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "blurry-cli"
|
|
3
|
-
version = "0.4.
|
|
3
|
+
version = "0.4.2"
|
|
4
4
|
description = "A Mistune-based static site generator for Python"
|
|
5
5
|
authors = ["John Franey <franey@duck.com>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -35,15 +35,17 @@ selectolax = "^0.3.6"
|
|
|
35
35
|
toml = "^0.10.2"
|
|
36
36
|
typer = "^0.6.1"
|
|
37
37
|
|
|
38
|
-
[tool.poetry.
|
|
38
|
+
[tool.poetry.scripts]
|
|
39
|
+
blurry = 'blurry:main'
|
|
40
|
+
|
|
41
|
+
[tool.poetry.group.dev.dependencies]
|
|
39
42
|
black = "^22.10.0"
|
|
43
|
+
nox = "^2023.4.22"
|
|
40
44
|
pyright = "^1.1.311"
|
|
41
45
|
pytest = "^6.2.2"
|
|
42
46
|
pytest-cov = "^2.11.1"
|
|
43
47
|
pytest-watch = "^4.2.0"
|
|
44
|
-
|
|
45
|
-
[tool.poetry.scripts]
|
|
46
|
-
blurry = 'blurry:main'
|
|
48
|
+
ruff = "^0.1.5"
|
|
47
49
|
|
|
48
50
|
[build-system]
|
|
49
51
|
requires = ["poetry-core>=1.0.0"]
|
|
@@ -53,6 +55,10 @@ build-backend = "poetry.core.masonry.api"
|
|
|
53
55
|
include = ["blurry/**"]
|
|
54
56
|
exclude = ["**/node_modules", "**/__pycache__", "**/.*", "blurry/tests"]
|
|
55
57
|
|
|
58
|
+
[tool.ruff]
|
|
59
|
+
target-version = "py310"
|
|
60
|
+
line-length = 88
|
|
61
|
+
|
|
56
62
|
[tool.poetry.plugins."blurry.html_plugins"]
|
|
57
63
|
minify_html = 'blurry.plugins.html_plugins.minify_html_plugin:minify_html'
|
|
58
64
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|