crieur 1.1.0__tar.gz → 1.2.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.1.0
3
+ Version: 1.2.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
- [--target-path TARGET_PATH] [--source-path SOURCE_PATH]
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
- [--target-path TARGET_PATH] [--source-path SOURCE_PATH]
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]]] -->
@@ -1,4 +1,4 @@
1
1
  from pathlib import Path
2
2
 
3
- VERSION = "1.1.0"
3
+ VERSION = "1.2.0"
4
4
  ROOT_DIR = Path(__file__).parent
@@ -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):
@@ -47,8 +51,9 @@ def generate(
47
51
  title, base_url, numeros, keywords, extra_vars, target_path, templates_path
48
52
  )
49
53
 
50
- static_path_local = Path(__file__).parent / "statics"
51
- shutil.copytree(static_path_local, target_path / "statics", dirs_exist_ok=True)
54
+ if not without_statics:
55
+ static_path_local = Path(__file__).parent / "statics"
56
+ shutil.copytree(static_path_local, target_path / "statics", dirs_exist_ok=True)
52
57
 
53
58
 
54
59
  @cli
@@ -48,7 +48,7 @@ def generate_html(
48
48
  for numero in numeros:
49
49
  template_numero = environment.get_template("numero.html")
50
50
  content = template_numero.render(numero=numero, **common_params)
51
- numero_folder = target_path / "numero" / numero.name
51
+ numero_folder = target_path / "numero" / numero.slug
52
52
  numero_folder.mkdir(parents=True, exist_ok=True)
53
53
  (numero_folder / "index.html").write_text(content)
54
54
 
@@ -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()
@@ -1,7 +1,7 @@
1
1
  {% extends "base.html" %}
2
2
 
3
3
  {% block content %}
4
- <h2><a href="{{ base_url }}numero/{{ numero.name }}/">{{ numero.name }}</a></h2>
4
+ <h2><a href="{{ base_url }}numero/{{ numero.slug }}/">{{ numero.name }}</a></h2>
5
5
 
6
6
  <article>
7
7
  <header>
@@ -75,13 +75,13 @@
75
75
  <article>
76
76
  <header>
77
77
  <hgroup>
78
- <h2><a href="{{ base_url }}numero/{{ numero.name }}/">{{ numero.name }}</a></h2>
78
+ <h2><a href="{{ base_url }}numero/{{ numero.slug }}/">{{ numero.name }}</a></h2>
79
79
  <p>Le {{ numero.articles.0.date.strftime('%d %B %Y') }}</p>
80
80
  </hgroup>
81
81
  </header>
82
82
  <ul>
83
83
  {% for article in numero.articles %}
84
- <li><a href="{{ base_url }}numero/{{ numero.name }}/article/{{ article.id }}/">{{ article.title_f }}</a></li>
84
+ <li><a href="{{ base_url }}numero/{{ numero.slug }}/article/{{ article.id }}/">{{ article.title_f }}</a></li>
85
85
  {% endfor %}
86
86
  </ul>
87
87
  </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.name }}/article/{{ article.id }}/">{{ article.title_f }}</a></li>
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.name }}/article/{{ article.id }}/">{{ article.title_f }}</a></h3>
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