render-engine 2025.10.1a2__py3-none-any.whl → 2025.11.1__py3-none-any.whl
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.
- render_engine/__version__.py +34 -0
- render_engine/collection.py +38 -11
- render_engine/content_managers/__init__.py +7 -0
- render_engine/content_managers/base_content_manager.py +22 -0
- render_engine/content_managers/file_content_manager.py +57 -0
- render_engine/site.py +11 -1
- render_engine/site_map.py +1 -1
- {render_engine-2025.10.1a2.dist-info → render_engine-2025.11.1.dist-info}/METADATA +1 -1
- {render_engine-2025.10.1a2.dist-info → render_engine-2025.11.1.dist-info}/RECORD +11 -7
- {render_engine-2025.10.1a2.dist-info → render_engine-2025.11.1.dist-info}/WHEEL +0 -0
- {render_engine-2025.10.1a2.dist-info → render_engine-2025.11.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# file generated by setuptools-scm
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
|
|
4
|
+
__all__ = [
|
|
5
|
+
"__version__",
|
|
6
|
+
"__version_tuple__",
|
|
7
|
+
"version",
|
|
8
|
+
"version_tuple",
|
|
9
|
+
"__commit_id__",
|
|
10
|
+
"commit_id",
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
TYPE_CHECKING = False
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from typing import Tuple
|
|
16
|
+
from typing import Union
|
|
17
|
+
|
|
18
|
+
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
19
|
+
COMMIT_ID = Union[str, None]
|
|
20
|
+
else:
|
|
21
|
+
VERSION_TUPLE = object
|
|
22
|
+
COMMIT_ID = object
|
|
23
|
+
|
|
24
|
+
version: str
|
|
25
|
+
__version__: str
|
|
26
|
+
__version_tuple__: VERSION_TUPLE
|
|
27
|
+
version_tuple: VERSION_TUPLE
|
|
28
|
+
commit_id: COMMIT_ID
|
|
29
|
+
__commit_id__: COMMIT_ID
|
|
30
|
+
|
|
31
|
+
__version__ = version = '2025.11.1'
|
|
32
|
+
__version_tuple__ = version_tuple = (2025, 11, 1)
|
|
33
|
+
|
|
34
|
+
__commit_id__ = commit_id = None
|
render_engine/collection.py
CHANGED
|
@@ -6,10 +6,12 @@ from pathlib import Path
|
|
|
6
6
|
from typing import Any
|
|
7
7
|
|
|
8
8
|
import dateutil.parser as dateparse
|
|
9
|
-
from more_itertools import batched
|
|
9
|
+
from more_itertools import batched
|
|
10
10
|
from render_engine_parser import BasePageParser
|
|
11
11
|
from slugify import slugify
|
|
12
12
|
|
|
13
|
+
from render_engine.content_managers import ContentManager, FileContentManager
|
|
14
|
+
|
|
13
15
|
from ._base_object import BaseObject
|
|
14
16
|
from .archive import Archive
|
|
15
17
|
from .feeds import RSSFeed
|
|
@@ -56,6 +58,9 @@ class Collection(BaseObject):
|
|
|
56
58
|
title: str
|
|
57
59
|
template: str | None
|
|
58
60
|
archive_template str | None: The template to use for the archive pages.
|
|
61
|
+
ContentManager: type[ContentManager] | None = FileContentManager
|
|
62
|
+
content_manager: ContentManager
|
|
63
|
+
content_manager_extras: dict[str, Any]: kwargs to pass to the ContentManager when instantiating
|
|
59
64
|
|
|
60
65
|
Methods:
|
|
61
66
|
|
|
@@ -84,6 +89,8 @@ class Collection(BaseObject):
|
|
|
84
89
|
template_vars: dict[str, Any]
|
|
85
90
|
template: str | None
|
|
86
91
|
plugin_manager: PluginManager | None
|
|
92
|
+
ContentManager: type[ContentManager] | None = FileContentManager
|
|
93
|
+
content_manager_extras: dict[str, Any]
|
|
87
94
|
|
|
88
95
|
def __init__(
|
|
89
96
|
self,
|
|
@@ -102,9 +109,16 @@ class Collection(BaseObject):
|
|
|
102
109
|
self.title = self._title
|
|
103
110
|
self.template_vars = getattr(self, "template_vars", {})
|
|
104
111
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
112
|
+
cm_extras = {
|
|
113
|
+
"content_path": getattr(self, "content_path", None),
|
|
114
|
+
"include_suffixes": getattr(self, "include_suffixes", None),
|
|
115
|
+
"collection": self,
|
|
116
|
+
}
|
|
117
|
+
if hasattr(self, "content_manager_extras"):
|
|
118
|
+
cm_extras.update(self.content_manager_extras)
|
|
119
|
+
self.content_manager = self.ContentManager(**cm_extras)
|
|
120
|
+
if hasattr(self, "pages"):
|
|
121
|
+
self.content_manager.pages = self.pages
|
|
108
122
|
|
|
109
123
|
def get_page(
|
|
110
124
|
self,
|
|
@@ -116,8 +130,6 @@ class Collection(BaseObject):
|
|
|
116
130
|
Parser=self.Parser,
|
|
117
131
|
)
|
|
118
132
|
|
|
119
|
-
if getattr(self, "_pm", None):
|
|
120
|
-
_page.register_plugins(self.plugins, **self.plugin_settings)
|
|
121
133
|
_page.parser_extras = getattr(self, "parser_extras", {})
|
|
122
134
|
_page.routes = self.routes
|
|
123
135
|
_page.template = getattr(self, "template", None)
|
|
@@ -162,7 +174,7 @@ class Collection(BaseObject):
|
|
|
162
174
|
"""
|
|
163
175
|
try:
|
|
164
176
|
return sorted(
|
|
165
|
-
(page for page in self
|
|
177
|
+
(page for page in self),
|
|
166
178
|
key=self._sort_key(self.sort_by),
|
|
167
179
|
reverse=self.sort_reverse,
|
|
168
180
|
)
|
|
@@ -231,10 +243,7 @@ class Collection(BaseObject):
|
|
|
231
243
|
return f"{__name__}"
|
|
232
244
|
|
|
233
245
|
def __iter__(self):
|
|
234
|
-
|
|
235
|
-
self.pages = [self.get_page(page) for page in self.iter_content_path()]
|
|
236
|
-
for page in self.pages: # noqa: UP028
|
|
237
|
-
yield page
|
|
246
|
+
yield from self.content_manager
|
|
238
247
|
|
|
239
248
|
def _run_collection_plugins(self, site, hook_type: str):
|
|
240
249
|
"""
|
|
@@ -279,6 +288,24 @@ class Collection(BaseObject):
|
|
|
279
288
|
feed.site = self.site
|
|
280
289
|
feed.render(route="./", theme_manager=self.site.theme_manager)
|
|
281
290
|
|
|
291
|
+
def create_entry(
|
|
292
|
+
self, filepath: Path = None, editor: str = None, content: str = None, metadata: dict = None
|
|
293
|
+
) -> str:
|
|
294
|
+
"""
|
|
295
|
+
Create a new entry for the Collection
|
|
296
|
+
|
|
297
|
+
:param filepath: Path object for the new entry
|
|
298
|
+
:param editor: Editor to open to edit the entry.
|
|
299
|
+
:param content: Content for the new entry
|
|
300
|
+
:param metadata: Metadata for the new entry
|
|
301
|
+
"""
|
|
302
|
+
context = copy.deepcopy(self._metadata_attrs())
|
|
303
|
+
if metadata:
|
|
304
|
+
context.update(metadata)
|
|
305
|
+
return self.content_manager.create_entry(
|
|
306
|
+
filepath=filepath, editor=editor, metadata=context, content=content or "Hello, world!"
|
|
307
|
+
)
|
|
308
|
+
|
|
282
309
|
|
|
283
310
|
def render_archives(archive, **kwargs) -> list[Archive]:
|
|
284
311
|
return [archive.render(pages=archive.pages, **kwargs) for archive in archive]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from collections.abc import Generator, Iterable
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ContentManager(ABC):
|
|
7
|
+
"""Base ContentManager abstract class"""
|
|
8
|
+
|
|
9
|
+
@property
|
|
10
|
+
@abstractmethod
|
|
11
|
+
def pages(self) -> Iterable:
|
|
12
|
+
"""The Page objects managed by the content manager"""
|
|
13
|
+
...
|
|
14
|
+
|
|
15
|
+
def __iter__(self) -> Generator:
|
|
16
|
+
"""Iterator for the ContentManager"""
|
|
17
|
+
yield from self.pages
|
|
18
|
+
|
|
19
|
+
@abstractmethod
|
|
20
|
+
def create_entry(self, filepath: Path = None, editor: str = None, metadata: dict = None, content: str = None):
|
|
21
|
+
"""Create a new entry"""
|
|
22
|
+
...
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import subprocess
|
|
2
|
+
from collections.abc import Iterable
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from more_itertools import flatten
|
|
6
|
+
|
|
7
|
+
from render_engine.content_managers import ContentManager
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class FileContentManager(ContentManager):
|
|
11
|
+
"""Content manager for content stored on the file system as individual files"""
|
|
12
|
+
|
|
13
|
+
def __init__(
|
|
14
|
+
self,
|
|
15
|
+
content_path: Path | str,
|
|
16
|
+
collection,
|
|
17
|
+
include_suffixes: Iterable[str] = ("*.md", "*.html"),
|
|
18
|
+
**kwargs,
|
|
19
|
+
):
|
|
20
|
+
self.content_path = content_path
|
|
21
|
+
self.include_suffixes = include_suffixes
|
|
22
|
+
self.collection = collection
|
|
23
|
+
self._pages = None
|
|
24
|
+
|
|
25
|
+
def iter_content_path(self):
|
|
26
|
+
"""Iterate through in the collection's content path."""
|
|
27
|
+
return flatten([Path(self.content_path).glob(suffix) for suffix in self.include_suffixes])
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
def pages(self) -> Iterable:
|
|
31
|
+
if self._pages is None:
|
|
32
|
+
self._pages = [self.collection.get_page(page) for page in self.iter_content_path()]
|
|
33
|
+
yield from self._pages
|
|
34
|
+
|
|
35
|
+
@pages.setter
|
|
36
|
+
def pages(self, value: Iterable):
|
|
37
|
+
self._pages = value
|
|
38
|
+
|
|
39
|
+
def create_entry(
|
|
40
|
+
self, filepath: Path = None, editor: str = None, metadata: dict = None, content: str = None
|
|
41
|
+
) -> str:
|
|
42
|
+
"""
|
|
43
|
+
Create a new entry for the Collection
|
|
44
|
+
|
|
45
|
+
:param filepath: Path object for the new entry
|
|
46
|
+
:param editor: Editor to open to edit the entry.
|
|
47
|
+
:param content: The content for the entry
|
|
48
|
+
:param metadata: Metadata for the new entry
|
|
49
|
+
"""
|
|
50
|
+
if not filepath:
|
|
51
|
+
raise ValueError("filepath needs to be specified.")
|
|
52
|
+
|
|
53
|
+
parsed_content = self.collection.Parser.create_entry(content=content, **metadata)
|
|
54
|
+
filepath.write_text(parsed_content)
|
|
55
|
+
if editor:
|
|
56
|
+
subprocess.run([editor, filepath])
|
|
57
|
+
return f"New entry created at {filepath} ."
|
render_engine/site.py
CHANGED
|
@@ -3,6 +3,7 @@ import logging
|
|
|
3
3
|
from collections import defaultdict
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
|
|
6
|
+
import rich
|
|
6
7
|
from jinja2 import FileSystemLoader, PrefixLoader
|
|
7
8
|
from rich.progress import Progress
|
|
8
9
|
|
|
@@ -13,6 +14,12 @@ from .plugins import PluginManager, handle_plugin_registration
|
|
|
13
14
|
from .site_map import SiteMap
|
|
14
15
|
from .themes import Theme, ThemeManager
|
|
15
16
|
|
|
17
|
+
try:
|
|
18
|
+
# Get the RE version for display. If it's not set it means we're working locally.
|
|
19
|
+
from render_engine.__version__ import __version__ as re_version
|
|
20
|
+
except ImportError:
|
|
21
|
+
re_version = "development"
|
|
22
|
+
|
|
16
23
|
|
|
17
24
|
class Site:
|
|
18
25
|
"""
|
|
@@ -251,7 +258,10 @@ class Site:
|
|
|
251
258
|
You can choose to call it manually in your file or
|
|
252
259
|
use the CLI command [`render-engine build`][src.render_engine.cli.build]
|
|
253
260
|
"""
|
|
254
|
-
|
|
261
|
+
rich.print(
|
|
262
|
+
f"[green]Building {repr(self.site_vars.get('SITE_TITLE', 'your site'))} "
|
|
263
|
+
f"with Render Engine version {re_version}"
|
|
264
|
+
)
|
|
255
265
|
with Progress() as progress:
|
|
256
266
|
task_site_map = progress.add_task("Generating site map", total=1)
|
|
257
267
|
self._site_map = SiteMap(self.route_list, self.site_vars.get("SITE_URL", ""))
|
render_engine/site_map.py
CHANGED
|
@@ -22,7 +22,7 @@ class SiteMapEntry:
|
|
|
22
22
|
self._route = f"/{route.lstrip('/')}/{self.path_name}" if from_collection else f"/{self.path_name}"
|
|
23
23
|
self.entries = list()
|
|
24
24
|
case Collection():
|
|
25
|
-
self._route = f"/{
|
|
25
|
+
self._route = f"/{entry.routes[0].lstrip('/')}"
|
|
26
26
|
self.entries = [
|
|
27
27
|
SiteMapEntry(collection_entry, self._route, from_collection=True) for collection_entry in entry
|
|
28
28
|
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: render_engine
|
|
3
|
-
Version: 2025.
|
|
3
|
+
Version: 2025.11.1
|
|
4
4
|
Summary: A Flexible Static Site Generator for Python
|
|
5
5
|
Project-URL: homepage, https://github.com/render-engine/render-engine/
|
|
6
6
|
Project-URL: repository, https://github.com/render-engine/render-engine/
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
render_engine/.gitignore,sha256=74oa8YR8gNxKxB6lCtoqmgtB2xpZnWM539Qsl4wI_lg,12
|
|
2
2
|
render_engine/__init__.py,sha256=3fgua4ZA9o1pvQ5unhY1gRARLXFqAu019NEYqZTjP20,154
|
|
3
3
|
render_engine/__main__.py,sha256=uI7aBBZz0qSDwwwD11nS5oltWsuLw9hStfYo8O1aNws,144
|
|
4
|
+
render_engine/__version__.py,sha256=s8M9-UvQuY0Oq3E-DpMy-7tuQGi8g1QtU5RnILzjZ7c,712
|
|
4
5
|
render_engine/_base_object.py,sha256=DIyLdQ6gS4a0DP46zwGYkYIyewh8uRFznJmaUch7d8M,3546
|
|
5
6
|
render_engine/archive.py,sha256=S3-kCmDNVKkEfKDKxcEk-sXkBD0vS0RDnFfPunYkU8g,2072
|
|
6
7
|
render_engine/blog.py,sha256=f9GqFUFsta0KZnFhCiajobpfQyALqvgI5sbLm6zt1zw,1571
|
|
7
|
-
render_engine/collection.py,sha256=
|
|
8
|
+
render_engine/collection.py,sha256=eqeVxZ_ASrOra7kayhAkPSHocpM1mbxwhsH6ZtK-oMk,11294
|
|
8
9
|
render_engine/engine.py,sha256=GOtUiq4ny5GHaLSCeH5u1Zk1JnWJVh63vK7etJiwS20,2843
|
|
9
10
|
render_engine/feeds.py,sha256=i-VHsb6pRplMzaenBn6oeqh9yI_N4WVUAExPox6iJgw,921
|
|
10
11
|
render_engine/hookspecs.py,sha256=GhOpw0zTQjfwWOFYYbJ4P7Cvq-oy1MmTPHmd90dr0kg,2292
|
|
@@ -12,9 +13,12 @@ render_engine/links.py,sha256=pKmQMTz8-yGX8IecHcrlF3Dkejk7cptaO3qCkQiHB9I,2560
|
|
|
12
13
|
render_engine/page.py,sha256=l6sKWNJ4gBtC_ONEc0u479q3znL-8Q7U_phNqXqmh6w,8988
|
|
13
14
|
render_engine/plugins.py,sha256=NXM8QTbbRV-DwgpQRoIhILijJBN4SyYg2Rkk1LUAuZM,4703
|
|
14
15
|
render_engine/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
-
render_engine/site.py,sha256=
|
|
16
|
-
render_engine/site_map.py,sha256=
|
|
16
|
+
render_engine/site.py,sha256=aarHkveSVDOy7hRPzrx_ga3DmmirZQcLvcJdyw-b8lY,13329
|
|
17
|
+
render_engine/site_map.py,sha256=I1p_yMDMy1jpIivgNgZptnsxZa8NkcrpciVJE3DlFlQ,5422
|
|
17
18
|
render_engine/themes.py,sha256=TFG1rd34QCBvBWfeDbawgsn6kprmjsDTa1pdDSwDMic,4207
|
|
19
|
+
render_engine/content_managers/__init__.py,sha256=z1x99J0GNcfqYFrugD0EleiZR6b-sfM6zViDTH1iF0s,161
|
|
20
|
+
render_engine/content_managers/base_content_manager.py,sha256=umb2Tze7UE7ON74hOe_WiykOk9-xTPw40_l3W5Cy5_U,620
|
|
21
|
+
render_engine/content_managers/file_content_manager.py,sha256=pKyldWKGocI2WAY8H_6d9dWY26hUxm4N5_oavO_FxJ0,1884
|
|
18
22
|
render_engine/extras/__init__.py,sha256=L4jr4A7Jl-ODnSx1q2fP3_dBo37Dw6yepNRddu1nFNo,72
|
|
19
23
|
render_engine/parsers/markdown.py,sha256=0jpixCaoHaL0IRSvFIljJIRCvFkXoKTEYQNK38LwMDU,287
|
|
20
24
|
render_engine/render_engine_templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -32,7 +36,7 @@ render_engine/render_engine_templates/base_templates/_page.html,sha256=jjrY2BAwl
|
|
|
32
36
|
render_engine/render_engine_templates/components/footer.html,sha256=HkPGGhfN0HcYm7t8zgXWCQ3bsCbT8FxT4_n2-9e1zUE,74
|
|
33
37
|
render_engine/render_engine_templates/components/page_title.html,sha256=l8aE1TY94UPHXHqAyy6jv4IoN2Hv9cbrTPh7ILkMyxg,137
|
|
34
38
|
render_engine/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
35
|
-
render_engine-2025.
|
|
36
|
-
render_engine-2025.
|
|
37
|
-
render_engine-2025.
|
|
38
|
-
render_engine-2025.
|
|
39
|
+
render_engine-2025.11.1.dist-info/METADATA,sha256=RQFVPrcI7wh8jq6DaDPSS5Rlv-s8r1zqeSeRhlJU7Zk,11893
|
|
40
|
+
render_engine-2025.11.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
41
|
+
render_engine-2025.11.1.dist-info/top_level.txt,sha256=aNGALDMsFyrusho04AvUjSivsgEE9tQp_LP_jGr312Q,14
|
|
42
|
+
render_engine-2025.11.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|