crieur 1.5.0__py3-none-any.whl → 1.6.0__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.
Potentially problematic release.
This version of crieur might be problematic. Click here for more details.
- crieur/__init__.py +1 -1
- crieur/cli.py +1 -1
- crieur/generator.py +1 -1
- crieur/models.py +66 -3
- crieur/templates/article.html +1 -1
- {crieur-1.5.0.dist-info → crieur-1.6.0.dist-info}/METADATA +2 -1
- {crieur-1.5.0.dist-info → crieur-1.6.0.dist-info}/RECORD +10 -10
- {crieur-1.5.0.dist-info → crieur-1.6.0.dist-info}/WHEEL +0 -0
- {crieur-1.5.0.dist-info → crieur-1.6.0.dist-info}/entry_points.txt +0 -0
- {crieur-1.5.0.dist-info → crieur-1.6.0.dist-info}/licenses/LICENSE +0 -0
crieur/__init__.py
CHANGED
crieur/cli.py
CHANGED
|
@@ -45,7 +45,7 @@ def generate(
|
|
|
45
45
|
numeros = []
|
|
46
46
|
for numero in each_folder_from(source_path):
|
|
47
47
|
for corpus_yaml in each_file_from(numero, pattern="*.yaml"):
|
|
48
|
-
numero = configure_numero(corpus_yaml)
|
|
48
|
+
numero = configure_numero(corpus_yaml, base_url)
|
|
49
49
|
numeros.append(numero)
|
|
50
50
|
|
|
51
51
|
keywords = collect_keywords(numeros)
|
crieur/generator.py
CHANGED
|
@@ -113,7 +113,7 @@ def generate_feed(title, base_url, numeros, extra_vars, target_path, number, lan
|
|
|
113
113
|
)
|
|
114
114
|
for author in article.authors:
|
|
115
115
|
feed_entry.author(name=str(author))
|
|
116
|
-
feed_entry.summary(summary=
|
|
116
|
+
feed_entry.summary(summary=article.content_html, type="html")
|
|
117
117
|
if article.keywords:
|
|
118
118
|
for keyword in article.keywords:
|
|
119
119
|
feed_entry.category(term=keyword.name)
|
crieur/models.py
CHANGED
|
@@ -1,13 +1,67 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
2
|
from datetime import datetime
|
|
3
|
+
from textwrap import dedent
|
|
3
4
|
from typing import Optional
|
|
4
5
|
|
|
6
|
+
import mistune
|
|
5
7
|
from dataclass_wizard import DatePattern, DumpMeta, YAMLWizard
|
|
6
8
|
from dataclass_wizard import errors as dw_errors
|
|
9
|
+
from PIL import Image, UnidentifiedImageError
|
|
7
10
|
from slugify import slugify
|
|
8
11
|
from yaml.composer import ComposerError
|
|
9
12
|
|
|
10
13
|
|
|
14
|
+
class ImgsWithSizesRenderer(mistune.HTMLRenderer):
|
|
15
|
+
"""Renders images as <figure>s and add sizes."""
|
|
16
|
+
|
|
17
|
+
def __init__(
|
|
18
|
+
self,
|
|
19
|
+
escape=True,
|
|
20
|
+
allow_harmful_protocols=None,
|
|
21
|
+
base_url=None,
|
|
22
|
+
article=None,
|
|
23
|
+
):
|
|
24
|
+
super().__init__()
|
|
25
|
+
self._base_url = base_url
|
|
26
|
+
self._article = article
|
|
27
|
+
|
|
28
|
+
def paragraph(self, text):
|
|
29
|
+
# In case of a figure, we do not want the (non-standard) paragraph.
|
|
30
|
+
if text.strip().startswith("<figure>"):
|
|
31
|
+
return text
|
|
32
|
+
return super().paragraph(text)
|
|
33
|
+
|
|
34
|
+
def image(self, alt, url):
|
|
35
|
+
if self._article.images_path is None:
|
|
36
|
+
print(f"Image with URL `{url}` is discarded.")
|
|
37
|
+
return ""
|
|
38
|
+
full_path = self._article.images_path.resolve().parent / url
|
|
39
|
+
try:
|
|
40
|
+
image = Image.open(full_path)
|
|
41
|
+
except (IsADirectoryError, FileNotFoundError, UnidentifiedImageError):
|
|
42
|
+
print(f"`{full_path}` is not a valid image.")
|
|
43
|
+
return ""
|
|
44
|
+
width, height = image.size
|
|
45
|
+
caption = f"<figcaption>{alt}</figcaption>" if alt else ""
|
|
46
|
+
full_url = f"{self._base_url}{self._article.url}{url}"
|
|
47
|
+
return dedent(
|
|
48
|
+
f"""\
|
|
49
|
+
<figure>
|
|
50
|
+
<a href="{full_url}"
|
|
51
|
+
title="Cliquer pour une version haute résolution">
|
|
52
|
+
<img
|
|
53
|
+
src="{full_url}"
|
|
54
|
+
width="{width}" height="{height}"
|
|
55
|
+
loading="lazy"
|
|
56
|
+
decoding="async"
|
|
57
|
+
alt="{alt}">
|
|
58
|
+
</a>
|
|
59
|
+
{caption}
|
|
60
|
+
</figure>
|
|
61
|
+
"""
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
|
|
11
65
|
@dataclass
|
|
12
66
|
class Numero(YAMLWizard):
|
|
13
67
|
_id: str
|
|
@@ -19,7 +73,7 @@ class Numero(YAMLWizard):
|
|
|
19
73
|
def __post_init__(self):
|
|
20
74
|
self.slug = slugify(self.name)
|
|
21
75
|
|
|
22
|
-
def configure_articles(self, yaml_path):
|
|
76
|
+
def configure_articles(self, yaml_path, base_url):
|
|
23
77
|
# Preserves abstract_fr key (vs. abstract-fr) when converting to_yaml()
|
|
24
78
|
DumpMeta(key_transform="SNAKE").bind_to(Article)
|
|
25
79
|
|
|
@@ -61,6 +115,15 @@ class Numero(YAMLWizard):
|
|
|
61
115
|
else None
|
|
62
116
|
)
|
|
63
117
|
loaded_article.numero = self
|
|
118
|
+
md = mistune.create_markdown(
|
|
119
|
+
renderer=ImgsWithSizesRenderer(
|
|
120
|
+
escape=False,
|
|
121
|
+
base_url=base_url,
|
|
122
|
+
article=loaded_article,
|
|
123
|
+
),
|
|
124
|
+
plugins=["footnotes", "superscript"],
|
|
125
|
+
)
|
|
126
|
+
loaded_article.content_html = md(loaded_article.content_md)
|
|
64
127
|
loaded_articles.append(loaded_article)
|
|
65
128
|
self.articles = sorted(loaded_articles, reverse=True)
|
|
66
129
|
|
|
@@ -94,7 +157,7 @@ class Article(YAMLWizard):
|
|
|
94
157
|
return f"numero/{self.numero.slug}/article/{self.id}/"
|
|
95
158
|
|
|
96
159
|
|
|
97
|
-
def configure_numero(yaml_path):
|
|
160
|
+
def configure_numero(yaml_path, base_url):
|
|
98
161
|
# Preserves abstract_fr key (vs. abstract-fr) when converting to_yaml()
|
|
99
162
|
DumpMeta(key_transform="SNAKE").bind_to(Numero)
|
|
100
163
|
|
|
@@ -103,7 +166,7 @@ def configure_numero(yaml_path):
|
|
|
103
166
|
except ComposerError:
|
|
104
167
|
numero = Numero.from_yaml(yaml_path.read_text().split("---")[1])
|
|
105
168
|
|
|
106
|
-
numero.configure_articles(yaml_path)
|
|
169
|
+
numero.configure_articles(yaml_path, base_url)
|
|
107
170
|
return numero
|
|
108
171
|
|
|
109
172
|
|
crieur/templates/article.html
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: crieur
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.6.0
|
|
4
4
|
Summary: A Static Revue Generator.
|
|
5
5
|
Project-URL: Homepage, https://gitlab.huma-num.fr/ecrinum/crieur
|
|
6
6
|
Project-URL: Issues, https://gitlab.huma-num.fr/ecrinum/crieur/-/issues
|
|
@@ -689,6 +689,7 @@ Requires-Dist: httpx
|
|
|
689
689
|
Requires-Dist: jinja2
|
|
690
690
|
Requires-Dist: minicli
|
|
691
691
|
Requires-Dist: mistune
|
|
692
|
+
Requires-Dist: pillow
|
|
692
693
|
Requires-Dist: python-slugify
|
|
693
694
|
Requires-Dist: pytz>=2025.2
|
|
694
695
|
Requires-Dist: pyyaml>=6.0.2
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
crieur/__init__.py,sha256=
|
|
1
|
+
crieur/__init__.py,sha256=OTKpyo3mBk05AW9jx7vHsWhKpHveyDwTU6fnJyxLxWo,77
|
|
2
2
|
crieur/__main__.py,sha256=bYt9eEaoRQWdejEHFD8REx9jxVEdZptECFsV7F49Ink,30
|
|
3
|
-
crieur/cli.py,sha256=
|
|
4
|
-
crieur/generator.py,sha256=
|
|
5
|
-
crieur/models.py,sha256=
|
|
3
|
+
crieur/cli.py,sha256=MyqGylQE691ILFnR_58925erUbluC30FrOLuok0PAB8,5737
|
|
4
|
+
crieur/generator.py,sha256=wbMeE0jCEy7kw8jhjscoeTjj8nyRPv6jqA76ZQeCdg8,4386
|
|
5
|
+
crieur/models.py,sha256=KrW6gy7z0RzDBdUAd2VgwzcNkMOpdRPnu9JxvkNGZ8c,8727
|
|
6
6
|
crieur/utils.py,sha256=kIdxpd5LgVv13Lx2aEXzjQttBDtcppRlwNsH0vwX8f0,1566
|
|
7
7
|
crieur/statics/pico.css,sha256=VdrimW9PLcEIzqJ__s062OrwBj_Jb6jZIwbtdqOtM-w,93407
|
|
8
|
-
crieur/templates/article.html,sha256=
|
|
8
|
+
crieur/templates/article.html,sha256=AgqMIM0HG9IDFZ8tArsCLgbLmx86oY-HC6Jj2lgzUMg,1281
|
|
9
9
|
crieur/templates/author.html,sha256=1VHZi6Wld1gWYPfeW3cEJ2ULOKrp9xoCVRhDjPUDdHg,420
|
|
10
10
|
crieur/templates/base.html,sha256=4ZOLAnmle0_m8Y3lWT6wcH8f-_7SymxEDeIUzDQNnks,1626
|
|
11
11
|
crieur/templates/homepage.html,sha256=7YG7kA4AFuyrSuqWeFAVj09ogwsybE7w0-NKMLWms5s,2994
|
|
12
12
|
crieur/templates/keyword.html,sha256=Hv3Ep3R6oN5pBw14gfQT-aeqEiuFiatmVZLWn5hR1e4,428
|
|
13
13
|
crieur/templates/numero.html,sha256=F7hCaAHJ1WRWxD_zfhJzyLaiwXblJWJF7DUTy41Mnu8,1849
|
|
14
|
-
crieur-1.
|
|
15
|
-
crieur-1.
|
|
16
|
-
crieur-1.
|
|
17
|
-
crieur-1.
|
|
18
|
-
crieur-1.
|
|
14
|
+
crieur-1.6.0.dist-info/METADATA,sha256=OCG3y13RZyHppOrUhjvC5v_WO7e1bJj6Vd1TedJYRNk,45046
|
|
15
|
+
crieur-1.6.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
16
|
+
crieur-1.6.0.dist-info/entry_points.txt,sha256=edmbmPxs9QXyvSMpPJBDPGw3vZOJEKqXJhysYNx3QSM,43
|
|
17
|
+
crieur-1.6.0.dist-info/licenses/LICENSE,sha256=F5acw9_laHeyi4wPmQyf_ttyz81VqCIwScwO8C1FhXU,34519
|
|
18
|
+
crieur-1.6.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|