diff options
author | Oxbian <got.dacs@slmail.me> | 2023-06-25 00:26:05 +0200 |
---|---|---|
committer | Oxbian <got.dacs@slmail.me> | 2023-06-25 00:26:05 +0200 |
commit | c1832daf3b2e12772b01d92cc59f9b38b458a9b1 (patch) | |
tree | 22d6e26e4cf15cf3836e7bae547003caaa26a04a /tools | |
parent | e1810b85fe0a66893b8e101dd52a5fbc83d407ec (diff) | |
download | ArKa-Blog-c1832daf3b2e12772b01d92cc59f9b38b458a9b1.tar.gz ArKa-Blog-c1832daf3b2e12772b01d92cc59f9b38b458a9b1.zip |
Updating ArkaBlog & removing old things
Diffstat (limited to 'tools')
-rw-r--r-- | tools/atom_post_template.xml | 23 | ||||
-rw-r--r-- | tools/atom_template.xml | 12 | ||||
-rw-r--r-- | tools/index_template.html | 43 | ||||
-rw-r--r-- | tools/page-generator.py | 162 | ||||
-rw-r--r-- | tools/page_template.html | 41 |
5 files changed, 0 insertions, 281 deletions
diff --git a/tools/atom_post_template.xml b/tools/atom_post_template.xml deleted file mode 100644 index 52703f7..0000000 --- a/tools/atom_post_template.xml +++ /dev/null @@ -1,23 +0,0 @@ -<entry xml:lang="fr"> - <author><name>Oxbian</name><uri>https://blog.arka.rocks</uri></author> - <title type="html">$TITLE</title> - <link rel="alternate" type="text/html" href="$URL"/> - <id>$URL</id> - <published>$DATE</published> - <updated>$DATE</updated> - <content type="html"> - <h1>$TITLE</h1> - $CONTENT - </content> -</entry> - - <h2>Articles sur les bonnes pratiques</h2> - <ul> - <li><a href="articles/">Vie privée</a></li> - <li><a href="articles/">Vie privée</a></li> - </ul> - - <h2>Autres articles</h2> - <ul> - <li><a href="articles/">KKOOOYYAAA</a></li> - </ul>
\ No newline at end of file diff --git a/tools/atom_template.xml b/tools/atom_template.xml deleted file mode 100644 index 9fca838..0000000 --- a/tools/atom_template.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<feed xmlns="http://www.w3.org/2005/Atom" - xmlns:thr="http://purl.org/syndication/thread/1.0" - xml:lang="fr"> - <title type="text">blog.arka.rocks</title> - <subtitle type="text">Blog d'Oxbian</subtitle> - <updated>$DATE</updated> - <link rel="alternate" type="text/html" href="https://blog.arka.rocks"/> - <id>https://blog.arka.rocks</id> - <link rel="self" type="application/atom+xml" href="https://blog.arka.rocks/atom.xml"/> -$CONTENT -</feed> diff --git a/tools/index_template.html b/tools/index_template.html deleted file mode 100644 index fab5a2d..0000000 --- a/tools/index_template.html +++ /dev/null @@ -1,43 +0,0 @@ -<!DOCTYPE html> -<html lang="fr"> -<head> - <meta charset="UTF-8"> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <meta name="description" content="Blog d'Oxbian"> - <meta property="og:title" content="Blog d'Oxbian"> - <meta property="og:url" content="https://blog.arka.rocks"> - <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"> -</head> -<body> - <header> - <div class="navbar"> - <a href="index.html">Accueil</a> - <a href="pages/how-to-read.html">Comment lire ce blog ?</a> - <a href="pages/about.html">À Propos</a> - </div> - </header> - <main> - <article> - <h1>Bienvenue sur mon blog</h1> - <p>Sur ce blog vous retrouverez des articles liées à l'informatique, la programmation, le réseau, la sécurité, le libre, etc. - De plus j'y partage aussi des articles sur les bonnes pratiques dans divers domaines, comme la vie privée, le sport..</p> - - $CONTENT - </article> - </main> - <hr> - <footer> - <p>Contactez-moi pour toute question ou discussion, je répond assez vite en général.</p> - <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> diff --git a/tools/page-generator.py b/tools/page-generator.py deleted file mode 100644 index 63526cb..0000000 --- a/tools/page-generator.py +++ /dev/null @@ -1,162 +0,0 @@ -import os -import html - -articles_path = 'articles/' -generate_path = 'pages/' -atom_content = "" -index_content = "<h2>Articles</h2><ul>" - -"""Parse le fichier markdown et retourne le contenu à mettre dans notre page html""" -def parsemd(filename): - content = {'content': '', 'title': '', 'date': '', 'description': '', 'filename': generate_path + filename.split('.')[0] + '.html'} - inquote, inpre, inul = False, False, False - for line in open('../' + articles_path + filename, "r"): - line = line.strip() - - # Récupère la date - if line.startswith('date:'): - content['date'] = line.split(':')[1].strip() - - # Récupère la description - if line.startswith('description:'): - content['description'] = line.split(':')[1].strip() - - # Ferme la citation si on ne cite plus - if inquote and not line.startswith(">"): - content['content'] += "</blockquote>\n" - inquote = False - - # Ferme la liste si on ne liste plus - if inul and not line.startswith("-"): - content['content'] += "</li></ul>\n" - inul = False - - # Vérifie si on est dans un bloc de code - if line.startswith("```"): - if inpre: - content['content'] += "</code></pre>\n" - - content['content'] += "<pre><code>" + line.lstrip("```") - inpre = True - - # Vérifie si on est dans une citation - elif line.startswith(">"): - if inquote: - 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>" + parseline(line.lstrip("- ")) - else: - content['content'] += "<ul><li>" + parseline(line.lstrip("- ")) - inul = True - - # Vérifie si on est dans un titre - elif line.startswith("###"): - content['content'] += "<h3>" + parseline(line.lstrip("# ")) + "</h3>\n" - elif line.startswith("##"): - content['content'] += "<h2>" + parseline(line.lstrip("# ")) + "</h2>\n" - elif line.startswith("#"): - content['title'] += parseline(line.lstrip("# ")) - - # Sinon, on est dans un paragraphe - elif line != " " and line != "": - 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 - -"""Parse une ligne de texte afin d'enlever les caractères spéciaux html, les liens, et symboles gras / italiques du markdown""" -def parseline(line): - # Change les &, <, > pour le support en HTML - html.escape(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('', '<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 - -"""Fonction pour transformer un fichier markdown en page html""" -def md2html(filename): - content = parsemd(filename) # Contenu parsé de notre fichier markdown - template = open('page_template.html', 'r').read() - - # Création du fichier html & ajout du contenu - output = open('../' + generate_path + filename.split('.')[0] + '.html', 'w') - output.write(template.replace("$CONTENT", content['content']).replace("$TITLE", content['title']). - replace("$DATE", content['date']).replace("$DESC", content['description'])) - output.close() - - # Génération du post Atom et de l'index - generatePageXML(content) - global index_content - index_content += '<li><a href="' + content['filename'] + '">' + content['title'] + '</a></li>\n' - -""" Génère le post Atom""" -def generatePageXML(data): - global atom_content - template = open('atom_post_template.xml', 'r').read() - atom_content += template.replace("$TITLE", data['title']).replace("$DATE", data['date']).replace("$CONTENT", - data['content']).replace("$URL", "https://blog.arka.rocks/" + data['filename']) - -""" Génère le fichier Atom""" -def generateAtom(): - template = open('atom_template.xml', 'r').read() - output = open('../atom.xml', 'w') - output.write(template.replace("$CONTENT", atom_content)) - output.close() - -""" Génère l'index""" -def updateIndex(): - template = open('index_template.html', 'r').read() - output = open('../index.html', 'w') - output.write(template.replace("$CONTENT", index_content + '</ul>')) - output.close() - -if __name__=="__main__": - if not os.path.exists('../' + generate_path): - os.mkdir('../' + generate_path) - else: # Régénation du blog - for file in os.listdir('../' + generate_path): - os.remove('../' + generate_path + file) - os.remove('../atom.xml') - os.remove('../index.html') - - for file in os.listdir('../' + articles_path): - print("Génération en cours du fichier: " + file) - md2html(file) - print("Génération du fichier RSS / Atom") - generateAtom() - print("Génération de l'index") - updateIndex() diff --git a/tools/page_template.html b/tools/page_template.html deleted file mode 100644 index 871d433..0000000 --- a/tools/page_template.html +++ /dev/null @@ -1,41 +0,0 @@ -<!DOCTYPE html> -<html lang="fr"> -<head> - <meta charset="UTF-8"> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <meta name="description" content="$DESC"> - <meta property="og:title" content="$TITLE"> - <meta property="og:type" content="article" > - <meta property="og:article:author" content="Oxbian"> - <meta property="og:article:published_time" content="$DATE" > - <meta property="og:image" content="$IMAGE_PREVIEW" > - <title>$TITLE</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"> -</head> -<body> - <header> - <div class="navbar"> - <a href="../index.html">Accueil</a> - <a href="../pages/how-to-read.html">Comment lire ce blog ?</a> - <a href="../pages/about.html">À Propos</a> - </div> - </header> - <main> - <article> - <h1>$TITLE</h1> - $CONTENT - </article> - </main> - <hr> - <footer> - <p>Contactez-moi pour toute question ou discussion, je répond assez vite en général.</p> - <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> |