blurry-cli 0.16.0__tar.gz → 0.17.0__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.
Files changed (40) hide show
  1. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/PKG-INFO +1 -1
  2. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/__init__.py +3 -1
  3. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/cli.py +9 -0
  4. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/images.py +21 -15
  5. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/settings.py +2 -2
  6. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/pyproject.toml +1 -1
  7. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/LICENSE +0 -0
  8. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/README.md +0 -0
  9. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/__main__.py +0 -0
  10. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/async_typer.py +0 -0
  11. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/commands/__init__.py +0 -0
  12. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/commands/clean.py +0 -0
  13. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/commands/init.py +0 -0
  14. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/commands/version.py +0 -0
  15. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/constants.py +0 -0
  16. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/file_processors/__init__.py +0 -0
  17. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/gather_file_data_by_directory.py +0 -0
  18. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/markdown/__init__.py +0 -0
  19. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/markdown/front_matter.py +0 -0
  20. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/markdown/renderer_functions/__init__.py +0 -0
  21. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/markdown/renderer_functions/render_video.py +0 -0
  22. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/open_graph.py +0 -0
  23. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/plugins/__init__.py +0 -0
  24. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/plugins/html_plugins/__init__.py +0 -0
  25. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/plugins/html_plugins/minify_html_plugin.py +0 -0
  26. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/plugins/jinja_plugins/__init__.py +0 -0
  27. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/plugins/jinja_plugins/blurry_image_extension.py +0 -0
  28. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/plugins/jinja_plugins/filters.py +0 -0
  29. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/plugins/markdown_plugins/__init__.py +0 -0
  30. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/plugins/markdown_plugins/container_plugin.py +0 -0
  31. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/plugins/markdown_plugins/punctuation_plugin.py +0 -0
  32. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/plugins/markdown_plugins/python_code_plugin.py +0 -0
  33. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/py.typed +0 -0
  34. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/runserver_handlers.py +0 -0
  35. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/schema_validation/__init__.py +0 -0
  36. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/schema_validation/models.py +0 -0
  37. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/sitemap.py +0 -0
  38. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/templates.py +0 -0
  39. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/types.py +0 -0
  40. {blurry_cli-0.16.0 → blurry_cli-0.17.0}/blurry/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: blurry-cli
3
- Version: 0.16.0
3
+ Version: 0.17.0
4
4
  Summary: A Mistune-based static site generator for Python
5
5
  License: MIT
6
6
  Keywords: static-site-generator,seo,pagespeed
@@ -16,7 +16,7 @@ from rich.progress import TaskProgressColumn
16
16
  from rich.progress import TextColumn
17
17
 
18
18
  from blurry.async_typer import AsyncTyper
19
- from blurry.cli import print_blurry_name
19
+ from blurry.cli import check_avif_support, print_blurry_name
20
20
  from blurry.cli import print_plugin_table
21
21
  from blurry.commands.clean import clean_build_directory
22
22
  from blurry.commands.init import initialize_new_project
@@ -66,6 +66,7 @@ async def build(release=True, clean: bool = False):
66
66
  update_settings()
67
67
  print_blurry_name()
68
68
  print_plugin_table()
69
+ check_avif_support(console=warning_console)
69
70
 
70
71
  build_directory = get_build_directory()
71
72
 
@@ -164,6 +165,7 @@ def runserver():
164
165
  """Starts HTTP server with live reloading."""
165
166
  print_blurry_name()
166
167
  print_plugin_table()
168
+ check_avif_support(console=warning_console)
167
169
 
168
170
  SETTINGS = get_settings()
169
171
  os.environ.setdefault(f"{ENV_VAR_PREFIX}BUILD_MODE", "dev")
@@ -1,5 +1,6 @@
1
1
  from rich.console import Console
2
2
  from rich.table import Table
3
+ import wand.version
3
4
 
4
5
  from blurry.plugins import discovered_html_plugins
5
6
  from blurry.plugins import discovered_jinja_extensions
@@ -35,3 +36,11 @@ def print_plugin_table():
35
36
  )
36
37
 
37
38
  console.print(plugin_table)
39
+
40
+
41
+ def check_avif_support(console: Console):
42
+ if "AVIFABC" in wand.version.formats():
43
+ return
44
+ console.print(
45
+ "AVIF support not found. Falling back to WEBP. See https://trac.ffmpeg.org/wiki/Encode/AV1"
46
+ )
@@ -3,11 +3,14 @@ from concurrent.futures import Future
3
3
  from pathlib import Path
4
4
 
5
5
  from wand.image import Image
6
+ import wand.version
6
7
 
7
8
  from blurry.settings import get_build_directory
8
9
  from blurry.settings import get_content_directory
9
10
  from blurry.settings import get_settings
10
11
 
12
+ has_avif_support = "AVIF" in wand.version.formats()
13
+
11
14
 
12
15
  def get_target_image_widths():
13
16
  SETTINGS = get_settings()
@@ -30,17 +33,20 @@ def add_image_width_to_path(image_path: Path, width: int) -> Path:
30
33
  return Path(new_filename)
31
34
 
32
35
 
33
- def convert_image_to_avif(image_path: Path, target_path: Path | None = None):
36
+ def convert_image_to_avif_or_webp(image_path: Path, target_path: Path | None = None):
34
37
  SETTINGS = get_settings()
35
- AVIF_COMPRESSION_QUALITY = SETTINGS["AVIF_COMPRESSION_QUALITY"]
38
+ IMAGE_COMPRESSION_QUALITY = SETTINGS["IMAGE_COMPRESSION_QUALITY"]
36
39
  image_suffix = image_path.suffix
37
- avif_filepath = str(target_path or image_path).replace(image_suffix, ".avif")
38
- if Path(avif_filepath).exists():
40
+ new_image_format = "avif" if has_avif_support else "webp"
41
+ new_filepath = str(target_path or image_path).replace(
42
+ image_suffix, f".{new_image_format}"
43
+ )
44
+ if Path(new_filepath).exists():
39
45
  return
40
46
  with Image(filename=str(image_path)) as image:
41
- image.format = "avif"
42
- image.compression_quality = AVIF_COMPRESSION_QUALITY
43
- image.save(filename=avif_filepath)
47
+ image.format = new_image_format
48
+ image.compression_quality = IMAGE_COMPRESSION_QUALITY
49
+ image.save(filename=new_filepath)
44
50
 
45
51
 
46
52
  def clone_and_resize_image(
@@ -61,12 +67,12 @@ async def generate_images_for_srcset(image_path: Path):
61
67
  build_path = BUILD_DIR / image_path.resolve().relative_to(CONTENT_DIR)
62
68
  with concurrent.futures.ThreadPoolExecutor() as executor:
63
69
  # Convert original image
64
- full_sized_avif_future = executor.submit(
65
- convert_image_to_avif, image_path=image_path, target_path=build_path
70
+ full_sized_image_future = executor.submit(
71
+ convert_image_to_avif_or_webp, image_path=image_path, target_path=build_path
66
72
  )
67
- image_futures.append(full_sized_avif_future)
73
+ image_futures.append(full_sized_image_future)
68
74
 
69
- # Store resized image futures so AVIF versions can be created once they're done
75
+ # Store resized image futures so AVIF/WEBP versions can be created once they're done
70
76
  resize_future_to_filepath: dict[Future, Path] = {}
71
77
 
72
78
  width = Image(filename=str(image_path)).width
@@ -82,13 +88,13 @@ async def generate_images_for_srcset(image_path: Path):
82
88
  new_filepath_in_build
83
89
  )
84
90
 
85
- # Create AVIF versions of resized images as they're ready
91
+ # Create AVIF/WEBP versions of resized images as they're ready
86
92
  for future in concurrent.futures.as_completed(resize_future_to_filepath):
87
93
  resized_image_filepath = resize_future_to_filepath[future]
88
- resized_avif_future = executor.submit(
89
- convert_image_to_avif, resized_image_filepath
94
+ resized_image_future = executor.submit(
95
+ convert_image_to_avif_or_webp, resized_image_filepath
90
96
  )
91
- image_futures.append(resized_avif_future)
97
+ image_futures.append(resized_image_future)
92
98
 
93
99
  concurrent.futures.wait(image_futures + list(resize_future_to_filepath.keys()))
94
100
 
@@ -8,7 +8,7 @@ from blurry.constants import SETTINGS_FILENAME
8
8
 
9
9
 
10
10
  class Settings(TypedDict):
11
- AVIF_COMPRESSION_QUALITY: int
11
+ IMAGE_COMPRESSION_QUALITY: int
12
12
  BUILD_DIRECTORY_NAME: str
13
13
  CONTENT_DIRECTORY_NAME: str
14
14
  MARKDOWN_FILE_JINJA_TEMPLATE_EXTENSION: str
@@ -28,7 +28,7 @@ class Settings(TypedDict):
28
28
 
29
29
 
30
30
  SETTINGS: Settings = {
31
- "AVIF_COMPRESSION_QUALITY": 90,
31
+ "IMAGE_COMPRESSION_QUALITY": 90,
32
32
  "BUILD_DIRECTORY_NAME": "dist",
33
33
  "CONTENT_DIRECTORY_NAME": "content",
34
34
  "TEMPLATES_DIRECTORY_NAME": "templates",
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "blurry-cli"
3
- version = "0.16.0"
3
+ version = "0.17.0"
4
4
  description = "A Mistune-based static site generator for Python"
5
5
  authors = ["John Franey <franey@duck.com>"]
6
6
  license = "MIT"
File without changes
File without changes
File without changes
File without changes
File without changes