aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorOxbian <got.dacs@slmail.me>2023-05-03 21:43:29 +0200
committerOxbian <got.dacs@slmail.me>2023-05-03 21:43:29 +0200
commit284cf939ce32ed9a85c9d1b8a0d515ccc204bc0e (patch)
treef76c7ac64262c19047c8a24f1d98e91dae56583c /tools
parent4190413a18a4b0008c1e34647ba5c5fa371396db (diff)
downloadArKa-Blog-284cf939ce32ed9a85c9d1b8a0d515ccc204bc0e.tar.gz
ArKa-Blog-284cf939ce32ed9a85c9d1b8a0d515ccc204bc0e.zip
Ajout des premières pages, et modification du générateur afin d'avoir les citations
Diffstat (limited to 'tools')
-rw-r--r--tools/index_template.html6
-rw-r--r--tools/page-generator.py78
-rw-r--r--tools/page_template.html11
3 files changed, 55 insertions, 40 deletions
diff --git a/tools/index_template.html b/tools/index_template.html
index 9efa788..fab5a2d 100644
--- a/tools/index_template.html
+++ b/tools/index_template.html
@@ -9,9 +9,9 @@
<meta property="og:type" content="article">
<meta property="og:article:author" content="Oxbian">
<title>Blog d'Oxbian</title>
- <link rel="alternate" href="../atom.xml" type="application/atom+xml" title="RSS">
- <link rel="stylesheet" href="../assets/css/style.css">
- <link rel="shortcut icon" href="../assets/favicon/favicon.ico" type="image/x-icon">
+ <link rel="alternate" href="atom.xml" type="application/atom+xml" title="RSS">
+ <link rel="stylesheet" href="assets/css/style.css">
+ <link rel="shortcut icon" href="assets/favicon/favicon.ico" type="image/x-icon">
</head>
<body>
<header>
diff --git a/tools/page-generator.py b/tools/page-generator.py
index bde61a0..1257a73 100644
--- a/tools/page-generator.py
+++ b/tools/page-generator.py
@@ -1,7 +1,7 @@
import os
articles_path = 'articles/'
-generate_path = 'archives/'
+generate_path = 'pages/'
atom_content = ""
index_content = "<h2>Articles</h2><ul>"
@@ -41,53 +41,67 @@ def parsemd(filename):
# Vérifie si on est dans une citation
elif line.startswith(">"):
if inquote:
- content['content'] += "</blockquote>\n"
-
- content['content'] += "<blockquote>" + line.lstrip("> ")
- inquote = True
+ content['content'] += parseline(line.lstrip("> "))
+ else:
+ content['content'] += "<blockquote>" + parseline(line.lstrip("> "))
+ inquote = True
# Vérifie si on est dans un listing
elif line.startswith("-"):
if inul:
content['content'] += "</li>\n"
- content['content'] += "<li>" + line.lstrip("- ")
+ content['content'] += "<li>" + parseline(line.lstrip("- "))
else:
- content['content'] += "<ul><li>" + line.lstrip("- ")
+ content['content'] += "<ul><li>" + parseline(line.lstrip("- "))
inul = True
# Vérifie si on est dans un titre
elif line.startswith("###"):
- content['content'] += "<h3>" + line.lstrip("# ") + "</h3>\n"
+ content['content'] += "<h3>" + parseline(line.lstrip("# ")) + "</h3>\n"
elif line.startswith("##"):
- content['content'] += "<h2>" + line.lstrip("# ") + "</h2>\n"
+ content['content'] += "<h2>" + parseline(line.lstrip("# ")) + "</h2>\n"
elif line.startswith("#"):
- content['title'] += line.lstrip("# ")
+ content['title'] += parseline(line.lstrip("# "))
# Sinon, on est dans un paragraphe
elif line != " " and line != "":
- # Vérifie si on a des italiques ou gras
- while '*' in line:
- line = line.replace('*', '<i>', 1)
- line = line.replace('*', '</i>', 1)
- while '**' in line:
- line = line.replace('**', '<b>', 1)
- line = line.replace('**', '</b>', 1)
-
- # Vérifie si on a des images
- while '![' in line and ']' in line:
- title = line.split(']')[0].split('[')[1]
- link = line.split(']')[1].split('(')[1].split(')')[0]
- line = line.replace('![' + title + '](' + link + ')', '<img src="' + link + '" alt="' + title + '"/>')
-
- # Vérifie si on a des liens
- while '[' in line and ']' in line:
- title = line.split(']')[0].split('[')[1]
- link = line.split(']')[1].split('(')[1].split(')')[0]
- line = line.replace('[' + title + '](' + link + ')', '<a href="' + link + '">' + title + '</a>')
- content['content'] += "<p>" + line + "</p>\n"
+ content['content'] += "<p>" + parseline(line) + "</p>\n"
+ # Vérification que chaque balise est bien fermée
+ if inquote:
+ content['content'] += "</blockquote>\n"
+ inquote = False
+
+ if inul:
+ content['content'] += "</li></ul>\n"
+ inul = False
+
+ if inpre:
+ content['content'] += "</code></pre>\n"
+ inpre = False
return content
-
+def parseline(line):
+ # Vérifie si on a des italiques ou gras
+ while '*' in line:
+ line = line.replace('*', '<i>', 1)
+ line = line.replace('*', '</i>', 1)
+ while '**' in line:
+ line = line.replace('**', '<b>', 1)
+ line = line.replace('**', '</b>', 1)
+
+ # Vérifie si on a des images
+ while '![' in line and ']' in line:
+ title = line.split(']')[0].split('[')[1]
+ link = line.split(']')[1].split('(')[1].split(')')[0]
+ line = line.replace('![' + title + '](' + link + ')', '<img src="' + link + '" alt="' + title + '"/>')
+
+ # Vérifie si on a des liens
+ while '[' in line and ']' in line:
+ title = line.split(']')[0].split('[')[1]
+ link = line.split(']')[1].split('(')[1].split(')')[0]
+ line = line.replace('[' + title + '](' + link + ')', '<a href="' + link + '">' + title + '</a>')
+ return line
+
def md2html(filename):
content = parsemd(filename) # Contenu parsé de notre fichier markdown
template = open('page_template.html', 'r').read()
@@ -139,4 +153,4 @@ if __name__=="__main__":
print("Génération du fichier RSS / Atom")
generateAtom()
print("Génération de l'index")
- updateIndex() \ No newline at end of file
+ updateIndex()
diff --git a/tools/page_template.html b/tools/page_template.html
index aada517..871d433 100644
--- a/tools/page_template.html
+++ b/tools/page_template.html
@@ -28,13 +28,14 @@
$CONTENT
</article>
</main>
+ <hr>
<footer>
<p>Contactez-moi pour toute question ou discussion, je répond assez vite en général.</p>
- <ul class="contact">
- <li><a class="matrix" href="https://matrix.to/#/@oxbian:matrix.org">Matrix</a></li>
- <li><a class="mastodon" href="https://social.linux.pizza/@Oxbian">Mastodon</a></li>
- <li><a class="mail" href="mailto:oxbian.noch@simplelogin.com">Mail</a></li>
- </ul>
+ <div>
+ <a class="matrix" href="https://matrix.to/#/@oxbian:matrix.org">Matrix</a>
+ <a class="mastodon" href="https://social.linux.pizza/@Oxbian">Mastodon</a>
+ <a class="mail" href="mailto:oxbian.noch@simplelogin.com">Mail</a>
+ </div>
</footer>
</body>
</html>
ArKa projects. All rights to me, and your next child right arm.