crieur 1.1.0__tar.gz → 1.3.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.
Potentially problematic release.
This version of crieur might be problematic. Click here for more details.
- {crieur-1.1.0 → crieur-1.3.0}/PKG-INFO +8 -2
- {crieur-1.1.0 → crieur-1.3.0}/README.md +7 -1
- {crieur-1.1.0 → crieur-1.3.0}/crieur/__init__.py +1 -1
- {crieur-1.1.0 → crieur-1.3.0}/crieur/cli.py +17 -4
- {crieur-1.1.0 → crieur-1.3.0}/crieur/generator.py +10 -2
- {crieur-1.1.0 → crieur-1.3.0}/crieur/models.py +55 -0
- {crieur-1.1.0 → crieur-1.3.0}/crieur/templates/article.html +2 -1
- crieur-1.3.0/crieur/templates/author.html +17 -0
- {crieur-1.1.0 → crieur-1.3.0}/crieur/templates/base.html +3 -0
- {crieur-1.1.0 → crieur-1.3.0}/crieur/templates/homepage.html +31 -15
- {crieur-1.1.0 → crieur-1.3.0}/crieur/templates/keyword.html +1 -1
- {crieur-1.1.0 → crieur-1.3.0}/crieur/templates/numero.html +1 -1
- {crieur-1.1.0 → crieur-1.3.0}/.gitignore +0 -0
- {crieur-1.1.0 → crieur-1.3.0}/LICENSE +0 -0
- {crieur-1.1.0 → crieur-1.3.0}/crieur/__main__.py +0 -0
- {crieur-1.1.0 → crieur-1.3.0}/crieur/statics/pico.css +0 -0
- {crieur-1.1.0 → crieur-1.3.0}/crieur/utils.py +0 -0
- {crieur-1.1.0 → crieur-1.3.0}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: crieur
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.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
|
|
@@ -750,17 +750,23 @@ help = output.decode().split("\n", 1)[1] # Remove Pandoc version.
|
|
|
750
750
|
cog.out(f"```\n{help}\n```")
|
|
751
751
|
]]] -->
|
|
752
752
|
```
|
|
753
|
-
[--
|
|
753
|
+
[--extra-vars EXTRA_VARS] [--target-path TARGET_PATH]
|
|
754
|
+
[--source-path SOURCE_PATH]
|
|
755
|
+
[--templates-path TEMPLATES_PATH] [--without-statics]
|
|
754
756
|
|
|
755
757
|
options:
|
|
756
758
|
-h, --help show this help message and exit
|
|
757
759
|
--title, -t TITLE Title of the website (default: Crieur).
|
|
758
760
|
--base-url BASE_URL Base URL of the website, ending with / (default: /).
|
|
761
|
+
--extra-vars EXTRA_VARS
|
|
762
|
+
stringified JSON extra vars passed to the templates.
|
|
759
763
|
--target-path TARGET_PATH
|
|
760
764
|
Path where site is built (default: /public/).
|
|
761
765
|
--source-path SOURCE_PATH
|
|
762
766
|
Path where stylo source were downloaded (default:
|
|
763
767
|
/sources/).
|
|
768
|
+
--templates-path TEMPLATES_PATH
|
|
769
|
+
--without-statics Do not copy statics if True (default: False).
|
|
764
770
|
|
|
765
771
|
```
|
|
766
772
|
<!-- [[[end]]] -->
|
|
@@ -46,17 +46,23 @@ help = output.decode().split("\n", 1)[1] # Remove Pandoc version.
|
|
|
46
46
|
cog.out(f"```\n{help}\n```")
|
|
47
47
|
]]] -->
|
|
48
48
|
```
|
|
49
|
-
[--
|
|
49
|
+
[--extra-vars EXTRA_VARS] [--target-path TARGET_PATH]
|
|
50
|
+
[--source-path SOURCE_PATH]
|
|
51
|
+
[--templates-path TEMPLATES_PATH] [--without-statics]
|
|
50
52
|
|
|
51
53
|
options:
|
|
52
54
|
-h, --help show this help message and exit
|
|
53
55
|
--title, -t TITLE Title of the website (default: Crieur).
|
|
54
56
|
--base-url BASE_URL Base URL of the website, ending with / (default: /).
|
|
57
|
+
--extra-vars EXTRA_VARS
|
|
58
|
+
stringified JSON extra vars passed to the templates.
|
|
55
59
|
--target-path TARGET_PATH
|
|
56
60
|
Path where site is built (default: /public/).
|
|
57
61
|
--source-path SOURCE_PATH
|
|
58
62
|
Path where stylo source were downloaded (default:
|
|
59
63
|
/sources/).
|
|
64
|
+
--templates-path TEMPLATES_PATH
|
|
65
|
+
--without-statics Do not copy statics if True (default: False).
|
|
60
66
|
|
|
61
67
|
```
|
|
62
68
|
<!-- [[[end]]] -->
|
|
@@ -10,7 +10,7 @@ from minicli import cli, run
|
|
|
10
10
|
|
|
11
11
|
from . import VERSION
|
|
12
12
|
from .generator import generate_html
|
|
13
|
-
from .models import collect_keywords, configure_numero
|
|
13
|
+
from .models import collect_authors, collect_keywords, configure_numero
|
|
14
14
|
from .utils import each_file_from, each_folder_from
|
|
15
15
|
|
|
16
16
|
|
|
@@ -28,13 +28,17 @@ def generate(
|
|
|
28
28
|
target_path: Path = Path() / "public",
|
|
29
29
|
source_path: Path = Path() / "sources",
|
|
30
30
|
templates_path: Path = Path(__file__).parent / "templates",
|
|
31
|
+
without_statics: bool = False,
|
|
31
32
|
):
|
|
32
33
|
"""Generate a new revue website.
|
|
33
34
|
|
|
34
35
|
:title: Title of the website (default: Crieur).
|
|
35
36
|
:base_url: Base URL of the website, ending with / (default: /).
|
|
37
|
+
:extra_vars: stringified JSON extra vars passed to the templates.
|
|
36
38
|
:target_path: Path where site is built (default: /public/).
|
|
37
39
|
:source_path: Path where stylo source were downloaded (default: /sources/).
|
|
40
|
+
:template_path: Path where templates are located (default: @crieur/templates/).
|
|
41
|
+
:without_statics: Do not copy statics if True (default: False).
|
|
38
42
|
"""
|
|
39
43
|
numeros = []
|
|
40
44
|
for numero in each_folder_from(source_path):
|
|
@@ -43,12 +47,21 @@ def generate(
|
|
|
43
47
|
numeros.append(numero)
|
|
44
48
|
|
|
45
49
|
keywords = collect_keywords(numeros)
|
|
50
|
+
authors = collect_authors(numeros)
|
|
46
51
|
generate_html(
|
|
47
|
-
title,
|
|
52
|
+
title,
|
|
53
|
+
base_url,
|
|
54
|
+
numeros,
|
|
55
|
+
keywords,
|
|
56
|
+
authors,
|
|
57
|
+
extra_vars,
|
|
58
|
+
target_path,
|
|
59
|
+
templates_path,
|
|
48
60
|
)
|
|
49
61
|
|
|
50
|
-
|
|
51
|
-
|
|
62
|
+
if not without_statics:
|
|
63
|
+
static_path_local = Path(__file__).parent / "statics"
|
|
64
|
+
shutil.copytree(static_path_local, target_path / "statics", dirs_exist_ok=True)
|
|
52
65
|
|
|
53
66
|
|
|
54
67
|
@cli
|
|
@@ -23,7 +23,7 @@ def markdown(value):
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
def generate_html(
|
|
26
|
-
title, base_url, numeros, keywords, extra_vars, target_path, templates_path
|
|
26
|
+
title, base_url, numeros, keywords, authors, extra_vars, target_path, templates_path
|
|
27
27
|
):
|
|
28
28
|
environment = Env(loader=FileSystemLoader(str(templates_path)))
|
|
29
29
|
environment.filters["slugify"] = slugify_
|
|
@@ -36,6 +36,7 @@ def generate_html(
|
|
|
36
36
|
"base_url": base_url,
|
|
37
37
|
"numeros": numeros,
|
|
38
38
|
"keywords": keywords,
|
|
39
|
+
"authors": authors,
|
|
39
40
|
"crieur_version": VERSION,
|
|
40
41
|
**extra_vars,
|
|
41
42
|
}
|
|
@@ -48,7 +49,7 @@ def generate_html(
|
|
|
48
49
|
for numero in numeros:
|
|
49
50
|
template_numero = environment.get_template("numero.html")
|
|
50
51
|
content = template_numero.render(numero=numero, **common_params)
|
|
51
|
-
numero_folder = target_path / "numero" / numero.
|
|
52
|
+
numero_folder = target_path / "numero" / numero.slug
|
|
52
53
|
numero_folder.mkdir(parents=True, exist_ok=True)
|
|
53
54
|
(numero_folder / "index.html").write_text(content)
|
|
54
55
|
|
|
@@ -75,3 +76,10 @@ def generate_html(
|
|
|
75
76
|
keyword_folder = target_path / "mot-clef" / keyword.slug
|
|
76
77
|
keyword_folder.mkdir(parents=True, exist_ok=True)
|
|
77
78
|
(keyword_folder / "index.html").write_text(content)
|
|
79
|
+
|
|
80
|
+
for slug, author in authors.items():
|
|
81
|
+
template_author = environment.get_template("author.html")
|
|
82
|
+
content = template_author.render(author=author, **common_params)
|
|
83
|
+
author_folder = target_path / "auteur" / author.slug
|
|
84
|
+
author_folder.mkdir(parents=True, exist_ok=True)
|
|
85
|
+
(author_folder / "index.html").write_text(content)
|
|
@@ -14,6 +14,9 @@ class Numero(YAMLWizard):
|
|
|
14
14
|
metadata: str
|
|
15
15
|
articles: list
|
|
16
16
|
|
|
17
|
+
def __post_init__(self):
|
|
18
|
+
self.slug = slugify(self.name)
|
|
19
|
+
|
|
17
20
|
def configure_articles(self, yaml_path):
|
|
18
21
|
# Preserves abstract_fr key (vs. abstract-fr) when converting to_yaml()
|
|
19
22
|
DumpMeta(key_transform="SNAKE").bind_to(Article)
|
|
@@ -59,6 +62,9 @@ class Article(YAMLWizard):
|
|
|
59
62
|
abstract: list = None
|
|
60
63
|
keywords: list = None
|
|
61
64
|
|
|
65
|
+
def __post_init__(self):
|
|
66
|
+
self.slug = slugify(self.title)
|
|
67
|
+
|
|
62
68
|
|
|
63
69
|
def configure_numero(yaml_path):
|
|
64
70
|
# Preserves abstract_fr key (vs. abstract-fr) when converting to_yaml()
|
|
@@ -92,6 +98,29 @@ class Keyword:
|
|
|
92
98
|
return len_self < len_other
|
|
93
99
|
|
|
94
100
|
|
|
101
|
+
@dataclass
|
|
102
|
+
class Author:
|
|
103
|
+
slug: str
|
|
104
|
+
forname: str
|
|
105
|
+
surname: str
|
|
106
|
+
articles: list
|
|
107
|
+
|
|
108
|
+
def __str__(self):
|
|
109
|
+
return f"{self.forname} {self.surname}"
|
|
110
|
+
|
|
111
|
+
def __eq__(self, other):
|
|
112
|
+
return self.slug == other.slug
|
|
113
|
+
|
|
114
|
+
def __lt__(self, other: "Author"):
|
|
115
|
+
if not isinstance(other, Author):
|
|
116
|
+
return NotImplemented
|
|
117
|
+
len_self = len(self.articles)
|
|
118
|
+
len_other = len(other.articles)
|
|
119
|
+
if len_self == len_other:
|
|
120
|
+
return self.slug > other.slug
|
|
121
|
+
return len_self < len_other
|
|
122
|
+
|
|
123
|
+
|
|
95
124
|
def collect_keywords(numeros):
|
|
96
125
|
keywords = {}
|
|
97
126
|
for numero in numeros:
|
|
@@ -112,3 +141,29 @@ def collect_keywords(numeros):
|
|
|
112
141
|
article_keywords.append(kw)
|
|
113
142
|
article.keywords = article_keywords
|
|
114
143
|
return dict(sorted(keywords.items(), key=lambda item: item[1], reverse=True))
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def collect_authors(numeros):
|
|
147
|
+
authors = {}
|
|
148
|
+
for numero in numeros:
|
|
149
|
+
for article in numero.articles:
|
|
150
|
+
article_authors = []
|
|
151
|
+
for athr in article.authors:
|
|
152
|
+
author_forname = athr["forname"]
|
|
153
|
+
author_surname = athr["surname"]
|
|
154
|
+
author_name = f"{author_forname} {author_surname}"
|
|
155
|
+
author_slug = slugify(author_name)
|
|
156
|
+
if author_slug in authors:
|
|
157
|
+
authors[author_slug].articles.append(article)
|
|
158
|
+
kw = authors[author_slug]
|
|
159
|
+
else:
|
|
160
|
+
kw = Author(
|
|
161
|
+
slug=author_slug,
|
|
162
|
+
forname=author_forname,
|
|
163
|
+
surname=author_surname,
|
|
164
|
+
articles=[article],
|
|
165
|
+
)
|
|
166
|
+
authors[author_slug] = kw
|
|
167
|
+
article_authors.append(kw)
|
|
168
|
+
article.authors = article_authors
|
|
169
|
+
return dict(sorted(authors.items(), key=lambda item: item[1], reverse=True))
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{% extends "base.html" %}
|
|
2
2
|
|
|
3
3
|
{% block content %}
|
|
4
|
-
<h2><a href="{{ base_url }}numero/{{ numero.
|
|
4
|
+
<h2><a href="{{ base_url }}numero/{{ numero.slug }}/">{{ numero.name }}</a></h2>
|
|
5
5
|
|
|
6
6
|
<article>
|
|
7
7
|
<header>
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
<details>
|
|
15
15
|
<summary role="button"><em>{{ author.forname }} {{ author.surname }}</em></summary>
|
|
16
16
|
{{ author.biography|markdown }}
|
|
17
|
+
<a href="{{ base_url }}auteur/{{ author.slug }}/" role="button" class="secondary">Autres articles de l’auteur·ice →</a>
|
|
17
18
|
</details>
|
|
18
19
|
{% endfor %}
|
|
19
20
|
</div>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{% extends "base.html" %}
|
|
2
|
+
|
|
3
|
+
{% block content %}
|
|
4
|
+
<article>
|
|
5
|
+
<header>
|
|
6
|
+
<h2>{{ author }} ({{ author.articles|length }})</h2>
|
|
7
|
+
</header>
|
|
8
|
+
|
|
9
|
+
<div>
|
|
10
|
+
<ul>
|
|
11
|
+
{% for article in author.articles %}
|
|
12
|
+
<li><a href="{{ base_url }}numero/{{ article.numero.slug }}/article/{{ article.id }}/">{{ article.title_f }}</a></li>
|
|
13
|
+
{% endfor %}
|
|
14
|
+
</ul>
|
|
15
|
+
</div>
|
|
16
|
+
</article>
|
|
17
|
+
{% endblock content %}
|
|
@@ -57,31 +57,47 @@
|
|
|
57
57
|
{% endblock extra_head %}
|
|
58
58
|
|
|
59
59
|
{% block content %}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
60
|
+
<article>
|
|
61
|
+
<dl>
|
|
62
|
+
<dt>Mots-clefs :</dt>
|
|
63
|
+
<dd>
|
|
64
|
+
{% for slug, keyword in keywords.items() %}
|
|
65
|
+
{% if loop.index < 20 %}
|
|
66
|
+
<a href="{{ base_url }}mot-clef/{{ keyword.slug }}/">#{{ keyword.name }}</a>({{ keyword.articles|length }}){%- if not loop.last -%}, {% endif %}
|
|
67
|
+
{% endif %}
|
|
68
|
+
{% endfor %}{% if keywords|length >= 20 %}…
|
|
69
|
+
<details>
|
|
70
|
+
<summary role="button">Voir plus de mot-clés :</summary>
|
|
71
|
+
{% for slug, keyword in keywords.items() %}
|
|
72
|
+
{% if loop.index >= 20 %}
|
|
73
|
+
<a href="{{ base_url }}mot-clef/{{ keyword.slug }}/">#{{ keyword.name }}</a>({{ keyword.articles|length }}){%- if not loop.last -%}, {% endif %}
|
|
74
|
+
{% endif %}
|
|
75
|
+
{% endfor %}
|
|
76
|
+
</details>
|
|
77
|
+
{% endif %}
|
|
78
|
+
</dd>
|
|
79
|
+
<dt>Auteur·ices :</dt>
|
|
80
|
+
<dd>
|
|
81
|
+
{% for slug, author in authors.items() %}
|
|
82
|
+
{% if loop.index < 20 %}
|
|
83
|
+
<a href="{{ base_url }}auteur/{{ author.slug }}/">#{{ author }}</a>({{ author.articles|length }}){%- if not loop.last -%}, {% endif %}
|
|
84
|
+
{% endif %}
|
|
85
|
+
{% endfor %}
|
|
86
|
+
</dd>
|
|
87
|
+
</dl>
|
|
88
|
+
</article>
|
|
73
89
|
<div class="grid">
|
|
74
90
|
{% for numero in numeros %}
|
|
75
91
|
<article>
|
|
76
92
|
<header>
|
|
77
93
|
<hgroup>
|
|
78
|
-
<h2><a href="{{ base_url }}numero/{{ numero.
|
|
94
|
+
<h2><a href="{{ base_url }}numero/{{ numero.slug }}/">{{ numero.name }}</a></h2>
|
|
79
95
|
<p>Le {{ numero.articles.0.date.strftime('%d %B %Y') }}</p>
|
|
80
96
|
</hgroup>
|
|
81
97
|
</header>
|
|
82
98
|
<ul>
|
|
83
99
|
{% for article in numero.articles %}
|
|
84
|
-
<li><a href="{{ base_url }}numero/{{ numero.
|
|
100
|
+
<li><a href="{{ base_url }}numero/{{ numero.slug }}/article/{{ article.id }}/">{{ article.title_f }}</a></li>
|
|
85
101
|
{% endfor %}
|
|
86
102
|
</ul>
|
|
87
103
|
</article>
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<div>
|
|
10
10
|
<ul>
|
|
11
11
|
{% for article in keyword.articles %}
|
|
12
|
-
<li><a href="{{ base_url }}numero/{{ article.numero.
|
|
12
|
+
<li><a href="{{ base_url }}numero/{{ article.numero.slug }}/article/{{ article.id }}/">{{ article.title_f }}</a></li>
|
|
13
13
|
{% endfor %}
|
|
14
14
|
</ul>
|
|
15
15
|
</div>
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
{% for article in numero.articles %}
|
|
60
60
|
<article>
|
|
61
61
|
<header>
|
|
62
|
-
<h3><a href="{{ base_url }}numero/{{ numero.
|
|
62
|
+
<h3><a href="{{ base_url }}numero/{{ numero.slug }}/article/{{ article.id }}/">{{ article.title_f }}</a></h3>
|
|
63
63
|
</header>
|
|
64
64
|
{{ article.subtitle_f|markdown }}
|
|
65
65
|
{% if article.authors %}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|