crieur 1.0.4__tar.gz → 1.1.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.0.4
3
+ Version: 1.1.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.0.4"
3
+ VERSION = "1.1.0"
4
4
  ROOT_DIR = Path(__file__).parent
@@ -22,10 +22,12 @@ def version():
22
22
 
23
23
  @cli
24
24
  def generate(
25
- title="Crieur",
26
- base_url="/",
25
+ title: str = "Crieur",
26
+ base_url: str = "/",
27
+ extra_vars: str = "",
27
28
  target_path: Path = Path() / "public",
28
29
  source_path: Path = Path() / "sources",
30
+ templates_path: Path = Path(__file__).parent / "templates",
29
31
  ):
30
32
  """Generate a new revue website.
31
33
 
@@ -41,7 +43,9 @@ def generate(
41
43
  numeros.append(numero)
42
44
 
43
45
  keywords = collect_keywords(numeros)
44
- generate_html(title, base_url, numeros, keywords, target_path)
46
+ generate_html(
47
+ title, base_url, numeros, keywords, extra_vars, target_path, templates_path
48
+ )
45
49
 
46
50
  static_path_local = Path(__file__).parent / "statics"
47
51
  shutil.copytree(static_path_local, target_path / "statics", dirs_exist_ok=True)
@@ -1,40 +1,43 @@
1
+ import json
1
2
  import locale
2
3
  import shutil
3
- from pathlib import Path
4
4
 
5
5
  import mistune
6
6
  from jinja2 import Environment as Env
7
7
  from jinja2 import FileSystemLoader
8
8
  from slugify import slugify
9
9
 
10
+ from . import VERSION
10
11
  from .utils import neighborhood
11
12
 
12
13
  locale.setlocale(locale.LC_ALL, "")
13
- environment = Env(loader=FileSystemLoader(str(Path(__file__).parent / "templates")))
14
+ md = mistune.create_markdown(plugins=["footnotes", "superscript"])
14
15
 
15
16
 
16
17
  def slugify_(value):
17
18
  return slugify(value)
18
19
 
19
20
 
20
- environment.filters["slugify"] = slugify_
21
-
22
- md = mistune.create_markdown(plugins=["footnotes", "superscript"])
23
-
24
-
25
21
  def markdown(value):
26
22
  return md(value) if value else ""
27
23
 
28
24
 
29
- environment.filters["markdown"] = markdown
25
+ def generate_html(
26
+ title, base_url, numeros, keywords, extra_vars, target_path, templates_path
27
+ ):
28
+ environment = Env(loader=FileSystemLoader(str(templates_path)))
29
+ environment.filters["slugify"] = slugify_
30
+ environment.filters["markdown"] = markdown
30
31
 
32
+ extra_vars = json.loads(extra_vars) if extra_vars else {}
31
33
 
32
- def generate_html(title, base_url, numeros, keywords, target_path):
33
34
  common_params = {
34
35
  "title": title,
35
36
  "base_url": base_url,
36
37
  "numeros": numeros,
37
38
  "keywords": keywords,
39
+ "crieur_version": VERSION,
40
+ **extra_vars,
38
41
  }
39
42
 
40
43
  template_homepage = environment.get_template("homepage.html")
@@ -20,19 +20,21 @@ class Numero(YAMLWizard):
20
20
 
21
21
  loaded_articles = []
22
22
  for article in self.articles:
23
+ article_slug = slugify(article["article"]["title"])
23
24
  article_folder = (
24
- yaml_path.parent
25
- / f"{article['article']['title']}-{article['article']['_id']}"
25
+ yaml_path.parent / f"{article_slug}-{article['article']['_id']}"
26
26
  )
27
- article_yaml_path = article_folder / f"{article['article']['title']}.yaml"
27
+ article_yaml_path = article_folder / f"{article_slug}.yaml"
28
28
  try:
29
29
  loaded_article = Article.from_yaml_file(article_yaml_path)
30
30
  except ComposerError:
31
31
  loaded_article = Article.from_yaml(
32
32
  article_yaml_path.read_text().split("---")[1]
33
33
  )
34
+ if not loaded_article.id:
35
+ loaded_article.id = article_slug
34
36
  loaded_article.content_md = (
35
- article_folder / f"{article['article']['title']}.md"
37
+ article_folder / f"{article_slug}.md"
36
38
  ).read_text()
37
39
  loaded_article.images_path = (
38
40
  article_folder / "images"
@@ -46,13 +48,13 @@ class Numero(YAMLWizard):
46
48
 
47
49
  @dataclass
48
50
  class Article(YAMLWizard):
49
- id: str
50
51
  title: str
51
52
  title_f: str
52
- date: Optional[DatePattern["%Y/%m/%d"]] # noqa: F722
53
+ id: str = ""
53
54
  subtitle: str = ""
54
55
  subtitle_f: str = ""
55
56
  content_md: str = ""
57
+ date: Optional[DatePattern["%Y/%m/%d"]] = None # noqa: F722
56
58
  authors: list = None
57
59
  abstract: list = None
58
60
  keywords: list = None
@@ -1,7 +1,7 @@
1
1
  {% extends "base.html" %}
2
2
 
3
3
  {% block content %}
4
- <h2><a href="{{ base_url }}numeros/{{ numero.name }}">{{ numero.name }}</a></h2>
4
+ <h2><a href="{{ base_url }}numero/{{ numero.name }}/">{{ numero.name }}</a></h2>
5
5
 
6
6
  <article>
7
7
  <header>
@@ -4,6 +4,7 @@
4
4
  <!-- Has to be within the first 1024 bytes, hence before the <title>
5
5
  See: https://www.w3.org/TR/2012/CR-html5-20121217/document-metadata.html#charset -->
6
6
  <meta charset="utf-8" />
7
+ <meta name="generator" content="Crieur {{ crieur_version }}">
7
8
  <!-- Why no `X-UA-Compatible` meta: https://stackoverflow.com/a/6771584 -->
8
9
  <!-- The viewport meta is quite crowded and we are responsible for that.
9
10
  See: https://codepen.io/tigt/post/meta-viewport-for-2015 -->
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes