aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOxbian <got.dacs@slmail.me>2023-04-02 22:42:10 +0200
committerOxbian <got.dacs@slmail.me>2023-04-02 22:42:10 +0200
commitede72d38ccb920ddf92104cf899bf1e461978a4e (patch)
tree6c3710963b22af04df191eb53b83d0c2841fa8d8
downloadArKa-Blog-ede72d38ccb920ddf92104cf899bf1e461978a4e.tar.gz
ArKa-Blog-ede72d38ccb920ddf92104cf899bf1e461978a4e.zip
Init commit\nAjout du générateur de page html à partir des fichiers markdown, d'un style basique inspiré du blog de ploum.net.
-rw-r--r--assets/css/style.css41
-rw-r--r--index.html54
-rw-r--r--readme.md11
-rw-r--r--tools/page-generator.py110
-rw-r--r--tools/page_template.html40
5 files changed, 256 insertions, 0 deletions
diff --git a/assets/css/style.css b/assets/css/style.css
new file mode 100644
index 0000000..4940e28
--- /dev/null
+++ b/assets/css/style.css
@@ -0,0 +1,41 @@
+body
+{
+ margin: 2vh auto;
+ max-width: 800px;
+ color:#00072D;
+ background-color: #C2EAFF;
+}
+
+h1, footer
+{
+ text-align: center;
+}
+
+a
+{
+ color: #87B37A;
+ text-decoration: none;
+}
+
+a:hover
+{
+ text-decoration:underline;
+}
+
+.center {
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+ width: 60%;
+}
+.header{
+ margin: 1em 0;
+ display: block;
+ width:100%;
+}
+
+.navbar{
+ display: flex;
+ justify-content: space-between;
+ font-weight: bold;
+} \ No newline at end of file
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..21f72b1
--- /dev/null
+++ b/index.html
@@ -0,0 +1,54 @@
+<!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">
+ <meta property="og:article:published_time" content="2023-04-01" >
+ <title>Blog d'Oxbian</title>
+ <link rel="alternate" href="../rss.xml" type="application/rss+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/howtoread.html">Comment lire ce blog ?</a>
+ <a href="pages/about.html">À Propos</a>
+ </div>
+ </header>
+ <main>
+ <article>
+ <h1>Bienvenue sur mon blog</h1>
+ 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..
+
+ <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>
+ </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>
+ <a href="../rss.xml"></a>
+ </footer>
+</body>
+</html> \ No newline at end of file
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..56c2116
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,11 @@
+# ArKaBlog
+------
+
+Ce repo contient le blog & le générateur du blog se trouvant à l'adresse blog.arka.rocks.
+
+Le générateur en python permet de passé de fichier markdown à des fichier html en tout simplicité à partir d'un modèle de page existant.
+
+# TODO
+
+- Flux RSS
+- Ajout automatique des pages générées dans la page principale \ No newline at end of file
diff --git a/tools/page-generator.py b/tools/page-generator.py
new file mode 100644
index 0000000..e5747db
--- /dev/null
+++ b/tools/page-generator.py
@@ -0,0 +1,110 @@
+import os
+
+articles_path = 'articles/'
+generate_path = 'archives/'
+
+"""Parse le fichier markdown et retourne le contenu à mettre dans notre page html"""
+def parsemd(filename):
+ content = {'content': '', 'title': '', 'date': '', 'description': ''}
+ 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'] += "</blockquote>\n"
+
+ content['content'] += "<blockquote>" + 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("- ")
+ else:
+ content['content'] += "<ul><li>" + line.lstrip("- ")
+ inul = True
+
+ # Vérifie si on est dans un titre
+ elif line.startswith("###"):
+ content['content'] += "<h3>" + line.lstrip("# ") + "</h3>\n"
+ elif line.startswith("##"):
+ content['content'] += "<h2>" + line.lstrip("# ") + "</h2>\n"
+ elif line.startswith("#"):
+ content['title'] += 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"
+ return content
+
+
+def md2html(filename):
+ content = parsemd(filename) # Contenu parsé de notre fichier markdown
+ template = open('page_template.html', 'r').read()
+ 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']))
+
+
+"""
+def generateRSS(data):
+
+def updateIndex(data):
+"""
+if __name__=="__main__":
+ if not os.path.exists('../' + generate_path):
+ os.mkdir('../' + generate_path)
+ else:
+ for file in os.listdir('../' + generate_path):
+ os.remove('../' + generate_path + file)
+ for file in os.listdir('../' + articles_path):
+ print("Génération en cours du fichier: " + file)
+ md2html(file) \ No newline at end of file
diff --git a/tools/page_template.html b/tools/page_template.html
new file mode 100644
index 0000000..3dda284
--- /dev/null
+++ b/tools/page_template.html
@@ -0,0 +1,40 @@
+<!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="../rss.xml" type="application/rss+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/howtoread.html">Comment lire ce blog ?</a>
+ <a href="../pages/about.html">À Propos</a>
+ </div>
+ </header>
+ <main>
+ <article>
+ <h1>$TITLE</h1>
+ $CONTENT
+ </article>
+ </main>
+ <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>
+ </footer>
+</body>
+</html> \ No newline at end of file
ArKa projects. All rights to me, and your next child right arm.