-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Python script to write dynamically courses page
- Loading branch information
Showing
8 changed files
with
134 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
date;title_de;title_fr;url | ||
15.11.2023;QGIS Kurs OST;Cours QGIS OST;https://ost.ch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,57 @@ | ||
<nav class="navbar navbar-expand-md navbar-dark bg-dark"> | ||
<div class="container-fluid"> | ||
<a class="navbar-brand" href="#"> | ||
<img src="/assets/img/logo.png" alt="Q" width="30" height="24"> | ||
</a> | ||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> | ||
<span class="navbar-toggler-icon"></span> | ||
</button> | ||
<div class="collapse navbar-collapse" id="navbarSupportedContent"> | ||
<ul class="navbar-nav me-auto mb-2 mb-lg-0"> | ||
<li class="nav-item"> | ||
<a class="nav-link active" aria-current="page" href="{% link fr/index.md %}">Home</a> | ||
</li> | ||
<li class="nav-item dropdown"> | ||
<a class='nav-link {% if page.url contains "verein" %}active{% endif %} dropdown-toggle' href="{% link fr/association/index.md %}" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> | ||
Association | ||
</a> | ||
<ul class="dropdown-menu" aria-labelledby="navbarDropdown"> | ||
<li><a class="dropdown-item" href="{% link fr/association/index.md %}">À propos de l'association</a></li> | ||
<li><a class="dropdown-item" href="{% link fr/association/assemblees-generales.md %}">Assemblées Générales</a></li> | ||
</ul> | ||
</li> | ||
<li class="nav-item"> | ||
<a class='nav-link {% if page.url contains "news" %} active {% endif %}' href="{% link fr/news/index.md %}">News</a> | ||
</li> | ||
<li class="nav-item dropdown"> | ||
<a class='nav-link {% if page.url contains "veranstaltungen" %}active{% endif %} dropdown-toggle' href="{% link fr/reunions/index.md %}" id="navbarDropdownVeranstaltungen" role="button" data-bs-toggle="dropdown" aria-expanded="false"> | ||
Réunions | ||
</a> | ||
<ul class="dropdown-menu" aria-labelledby="navbarDropdown"> | ||
{% assign sorted_pages = site.pages | sort:"year" | reverse %} | ||
{% for p in sorted_pages %} | ||
{% if p.path contains "reunions" and p.name != "index.md" %} | ||
<li><a class="dropdown-item" href="{{ p.url }}">{{ p.title }}</a></li> | ||
{% endif %} | ||
{% endfor %} | ||
</ul> | ||
</li> | ||
<li class="nav-item"> | ||
<a class='nav-link {% if page.url contains "projets-de-soutien" %}active{% endif %}' href="{% link fr/projets-de-soutien/index.md %}">Projets de soutien</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class='nav-link {% if page.url contains "sujets" %}active{% endif %}' href="{% link fr/sujets/index.md %}">Sujets</a> | ||
</li> | ||
</ul> | ||
<ul class="navbar-nav ms-auto mb-2 mb-lg-0"> | ||
<li class="nav-item ms-auto"> | ||
<a class="nav-link" href="/de/">deutsch</a> | ||
</li> | ||
</ul> | ||
</ul> | ||
<div class="container-fluid"> | ||
<a class="navbar-brand" href="#"> | ||
<img src="/assets/img/logo.png" alt="Q" width="30" height="24"> | ||
</a> | ||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> | ||
<span class="navbar-toggler-icon"></span> | ||
</button> | ||
<div class="collapse navbar-collapse" id="navbarSupportedContent"> | ||
<ul class="navbar-nav me-auto mb-2 mb-lg-0"> | ||
<li class="nav-item"> | ||
<a class="nav-link active" aria-current="page" href="{% link fr/index.md %}">Home</a> | ||
</li> | ||
<li class="nav-item dropdown"> | ||
<a class='nav-link {% if page.url contains "verein" %}active{% endif %} dropdown-toggle' href="{% link fr/association/index.md %}" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> | ||
Association | ||
</a> | ||
<ul class="dropdown-menu" aria-labelledby="navbarDropdown"> | ||
<li><a class="dropdown-item" href="{% link fr/association/index.md %}">À propos de l'association</a></li> | ||
<li><a class="dropdown-item" href="{% link fr/association/assemblees-generales.md %}">Assemblées Générales</a></li> | ||
</ul> | ||
</li> | ||
<li class="nav-item"> | ||
<a class='nav-link {% if page.url contains "news" %} active {% endif %}' href="{% link fr/news/index.md %}">News</a> | ||
</li> | ||
<li class="nav-item dropdown"> | ||
<a class='nav-link {% if page.url contains "veranstaltungen" %}active{% endif %} dropdown-toggle' href="{% link fr/reunions/index.md %}" id="navbarDropdownVeranstaltungen" role="button" data-bs-toggle="dropdown" aria-expanded="false"> | ||
Réunions | ||
</a> | ||
<ul class="dropdown-menu" aria-labelledby="navbarDropdown"> | ||
{% assign sorted_pages = site.pages | sort:"year" | reverse %} | ||
{% for p in sorted_pages %} | ||
{% if p.path contains "reunions" and p.name != "index.md" %} | ||
<li><a class="dropdown-item" href="{{ p.url }}">{{ p.title }}</a></li> | ||
{% endif %} | ||
{% endfor %} | ||
</ul> | ||
</li> | ||
<li class="nav-item"> | ||
<a class='nav-link {% if page.url contains "cours" %}active{% endif %}' href="{% link fr/cours/index.md %}">Cours</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class='nav-link {% if page.url contains "projets-de-soutien" %}active{% endif %}' href="{% link fr/projets-de-soutien/index.md %}">Projets de soutien</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class='nav-link {% if page.url contains "sujets" %}active{% endif %}' href="{% link fr/sujets/index.md %}">Sujets</a> | ||
</li> | ||
</ul> | ||
<ul class="navbar-nav ms-auto mb-2 mb-lg-0"> | ||
<li class="nav-item ms-auto"> | ||
<a class="nav-link" href="/de/">deutsch</a> | ||
</li> | ||
</ul> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
</nav> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ lang: de | |
|
||
# Aktuelle Kurse | ||
|
||
# Vergangene Kurse | ||
|
||
{% include courstable-de.html %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
|
||
layout: plain-fr | ||
lang: fr | ||
|
||
--- | ||
|
||
# Cours Actuels | ||
|
||
|
||
{% include courstable-fr.html %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<table class="table table-striped-columns"> | ||
<tbody> | ||
<tr> | ||
<th>Datum</th><th>Kurzbeschrieb</th><th>Link</th> | ||
</tr> | ||
{% for d in data %} | ||
<tr> | ||
<td>{{ d[0] }}</td><td>{{ d[1] }}</td><td><a href="{{ d[2] }}" class="external-link">{{ d[2] }}</a></td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<table class="table table-striped-columns"> | ||
<tbody> | ||
<tr> | ||
<th>Date</th><th>Brève description</th><th>Link</th> | ||
</tr> | ||
{% for d in data %} | ||
<tr> | ||
<td>{{ d[0] }}</td><td>{{ d[1] }}</td><td><a href="{{ d[2] }}" class="external-link">{{ d[2] }}</a></td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env python3 | ||
|
||
|
||
import csv | ||
import sys | ||
from jinja2 import Environment, FileSystemLoader | ||
|
||
def run(): | ||
|
||
environment = Environment(loader=FileSystemLoader("./")) | ||
|
||
for lang in ( {"lang": "de", "dir": "kurse"}, {"lang": "fr", "dir": "cours"} ): | ||
data = [] | ||
|
||
template = environment.get_template("template-%s.md" % lang['lang']) | ||
|
||
filename = "../_includes/courstable-%s.html" % (lang['lang']) | ||
|
||
with open("../_data/kurse-cours.csv", newline='') as csvfile: | ||
reader = csv.reader(csvfile, delimiter=";") | ||
|
||
# Skip header row | ||
next(reader, None) | ||
|
||
for row in reader: | ||
data.append((row[0], row[1], row[2])) | ||
|
||
content = template.render( | ||
data=data | ||
) | ||
|
||
with open(filename, mode="w", encoding="utf-8") as message: | ||
message.write(content) | ||
print(f"... wrote {filename}") | ||
|
||
if __name__ == "__main__": | ||
sys.exit(run()) |