crieur 1.2.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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: crieur
3
- Version: 1.2.0
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
@@ -1,4 +1,4 @@
1
1
  from pathlib import Path
2
2
 
3
- VERSION = "1.2.0"
3
+ VERSION = "1.3.0"
4
4
  ROOT_DIR = Path(__file__).parent
@@ -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
 
@@ -47,8 +47,16 @@ def generate(
47
47
  numeros.append(numero)
48
48
 
49
49
  keywords = collect_keywords(numeros)
50
+ authors = collect_authors(numeros)
50
51
  generate_html(
51
- title, base_url, numeros, keywords, extra_vars, target_path, templates_path
52
+ title,
53
+ base_url,
54
+ numeros,
55
+ keywords,
56
+ authors,
57
+ extra_vars,
58
+ target_path,
59
+ templates_path,
52
60
  )
53
61
 
54
62
  if not without_statics:
@@ -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
  }
@@ -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)
@@ -98,6 +98,29 @@ class Keyword:
98
98
  return len_self < len_other
99
99
 
100
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
+
101
124
  def collect_keywords(numeros):
102
125
  keywords = {}
103
126
  for numero in numeros:
@@ -118,3 +141,29 @@ def collect_keywords(numeros):
118
141
  article_keywords.append(kw)
119
142
  article.keywords = article_keywords
120
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))
@@ -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 %}
@@ -21,6 +21,9 @@
21
21
  h1 {
22
22
  text-align: center;
23
23
  }
24
+ dt {
25
+ font-weight: bold;
26
+ }
24
27
  </style>
25
28
  {% block extra_head %}
26
29
  {% endblock extra_head %}
@@ -57,19 +57,35 @@
57
57
  {% endblock extra_head %}
58
58
 
59
59
  {% block content %}
60
- {% for slug, keyword in keywords.items() %}
61
- {% if loop.index < 20 %}
62
- <a href="{{ base_url }}mot-clef/{{ keyword.slug }}/">#{{ keyword.name }}</a>({{ keyword.articles|length }}){%- if not loop.last -%}, {% endif %}
63
- {% endif %}
64
- {% endfor %}
65
- <details>
66
- <summary role="button">Voir plus de mot-clés :</summary>
67
- {% for slug, keyword in keywords.items() %}
68
- {% if loop.index >= 20 %}
69
- <a href="{{ base_url }}mot-clef/{{ keyword.slug }}/">#{{ keyword.name }}</a>({{ keyword.articles|length }}){%- if not loop.last -%}, {% endif %}
70
- {% endif %}
71
- {% endfor %}
72
- </details>
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>
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes