From e8f06524bced1e80d033c869a536f4478d647f7b Mon Sep 17 00:00:00 2001 From: grey-cat-1908 Date: Fri, 3 May 2024 21:18:46 +0300 Subject: [PATCH] am am am am --- build.py | 48 ++++++++++++++++++----- content/blog/1d-collisions/meta.json | 12 ++++++ content/blog/china-tour/meta.json | 12 ++++++ content/blog/meta.json | 11 ++++++ content/blog/portable-minecraft/meta.json | 12 ++++++ content/blog/prognoz-vp/meta.json | 12 ++++++ content/blog/today-project/meta.json | 12 ++++++ meta.json | 12 ++++++ template.html | 18 +++++---- 9 files changed, 131 insertions(+), 18 deletions(-) create mode 100644 content/blog/1d-collisions/meta.json create mode 100644 content/blog/china-tour/meta.json create mode 100644 content/blog/meta.json create mode 100644 content/blog/portable-minecraft/meta.json create mode 100644 content/blog/prognoz-vp/meta.json create mode 100644 content/blog/today-project/meta.json create mode 100644 meta.json diff --git a/build.py b/build.py index c3b62fc..55927ce 100644 --- a/build.py +++ b/build.py @@ -1,11 +1,12 @@ import os import shutil +import json import mistune render = mistune.create_markdown( plugins=['math', 'strikethrough', 'footnotes', 'table', 'url', 'task_lists', 'abbr', 'mark', 'subscript', 'spoiler'] - ) +) try: shutil.rmtree("build") @@ -14,18 +15,40 @@ except: os.mkdir("build") - template_file = open('template.html', "r") template_text = template_file.read() template_file.close() +base_meta_file = open('meta.json', "r") +base_meta = json.loads(base_meta_file.read()) +base_meta_file.close() -def gen_file(directory): - file = open(directory, "r") +def parse_meta(data): + result = "" + + for key, value in data['tags'].items(): + result += f'\n' + + for key, value in data['og'].items(): + result += f'\n' + + return result + +def gen_file(directory, filename): + file = open(directory + filename, "r") md_text = file.read() file.close() - return template_text.replace("{{%CONTENT%}}", render(md_text)) + try: + file = open(directory + 'meta.json', "r") + meta = json.loads(file.read()) + file.close() + except: + meta = base_meta + + meta_data = parse_meta(meta) + + return template_text.replace("{{%CONTENT%}}", render(md_text)).replace("{{%TITLE%}}", meta['title']).replace("{{%META%}}", meta_data) def go_through(directory): for filename in os.listdir(directory): @@ -36,13 +59,18 @@ def go_through(directory): os.makedirs(f'build/{fier}{filename}') go_through(directory + "/" + filename) else: + if filename.split(".")[1] == "json": + continue for ofn in os.listdir("static"): - if len(ofn.split(".")) == 1: - shutil.copytree(f"{os.getcwd()}/static/{ofn}", f"{os.getcwd()}/build/{fier}{ofn}") - else: - shutil.copy(f"{os.getcwd()}/static/{ofn}", f"{os.getcwd()}/build/{fier}{ofn}") + try: + if len(ofn.split(".")) == 1: + shutil.copytree(f"{os.getcwd()}/static/{ofn}", f"{os.getcwd()}/build/{fier}{ofn}") + else: + shutil.copy(f"{os.getcwd()}/static/{ofn}", f"{os.getcwd()}/build/{fier}{ofn}") + except: + pass - content = gen_file(f"{os.getcwd()}/{directory}/{filename}") + content = gen_file(f"{os.getcwd()}/{directory}/", filename) loc = fier + filename.split(".")[0] + '.html' file = open(f"{os.getcwd()}/build/{loc}", "a") diff --git a/content/blog/1d-collisions/meta.json b/content/blog/1d-collisions/meta.json new file mode 100644 index 0000000..53c1db6 --- /dev/null +++ b/content/blog/1d-collisions/meta.json @@ -0,0 +1,12 @@ +{ + "title": "Arbuz Journal — Elastic Collisions Simulation", + "tags": { + "description": "A thorough breakdown of how author built a simulator of elastic collisions between two cubes, complete with a clear explanation and mathematical proof of how it works.", + "author": "Viktor K. (Marakarka)", + "keywords": "Marakarka, Arbuz, Programming, Journal, Science, Blog, Experiments, Elastic, Collisions, Physics, Processing" + }, + "og": { + "title": "Arbuz Journal — Elastic Collisions Simulation", + "description": "A thorough breakdown of how author built a simulator of elastic collisions between two cubes, complete with a clear explanation and mathematical proof of how it works." + } + } \ No newline at end of file diff --git a/content/blog/china-tour/meta.json b/content/blog/china-tour/meta.json new file mode 100644 index 0000000..fcdec5c --- /dev/null +++ b/content/blog/china-tour/meta.json @@ -0,0 +1,12 @@ +{ + "title": "Arbuz Journal — China Tour", + "tags": { + "description": "The author's blog about his trip to China, sharing what he saw and some interesting things about the country.", + "author": "Viktor K. (Marakarka)", + "keywords": "Marakarka, Arbuz, Journal, Blog, China, Trip" + }, + "og": { + "title": "Arbuz Journal — China Tour", + "description": "The author's blog about his trip to China, sharing what he saw and some interesting things about the country." + } + } \ No newline at end of file diff --git a/content/blog/meta.json b/content/blog/meta.json new file mode 100644 index 0000000..70414dc --- /dev/null +++ b/content/blog/meta.json @@ -0,0 +1,11 @@ +{ + "title": "Arbuz Journal", + "tags": { + "description": "Homepage of the Arbuz Journal", + "keywords": "Marakarka, Arbuz, Journal, Blog" + }, + "og": { + "title": "Arbuz Journal", + "description": "Homepage of the Arbuz Journal" + } + } \ No newline at end of file diff --git a/content/blog/portable-minecraft/meta.json b/content/blog/portable-minecraft/meta.json new file mode 100644 index 0000000..162e72d --- /dev/null +++ b/content/blog/portable-minecraft/meta.json @@ -0,0 +1,12 @@ +{ + "title": "Arbuz Journal — Portable Minecraft", + "tags": { + "description": "The developer's narrative detailing the creation journey of a portable Minecraft server project, designed to operate on a Raspberry Pi platform, accompanied by an explanation elucidating the intricacies involved in the development process.", + "author": "Viktor K. (Marakarka)", + "keywords": "Marakarka, Arbuz, Programming, Journal, Blog, Minecraft, Raspberry, Pi, Portable" + }, + "og": { + "title": "Arbuz Journal — Portable Minecraft", + "description": "The developer's narrative detailing the creation journey of a portable Minecraft server project, designed to operate on a Raspberry Pi platform, accompanied by an explanation elucidating the intricacies involved in the development process." + } + } \ No newline at end of file diff --git a/content/blog/prognoz-vp/meta.json b/content/blog/prognoz-vp/meta.json new file mode 100644 index 0000000..b28516d --- /dev/null +++ b/content/blog/prognoz-vp/meta.json @@ -0,0 +1,12 @@ +{ + "title": "Arbuz Journal [RU] — Прогноз Высшей Пробы", + "tags": { + "description": "Рассказ о том, как мы пытались создать единую методику прогнозирования граничных баллов Высшей Пробы, а также обзор того, что у нас получилось (и не получилось).", + "author": "Виктор К. и коллектив волонтеров", + "keywords": "Marakarka, Arbuz" + }, + "og": { + "title": "Arbuz Journal [RU] — Прогноз Высшей Пробы", + "description": "Рассказ о том, как мы пытались создать единую методику прогнозирования граничных баллов Высшей Пробы, а также обзор того, что у нас получилось (и не получилось)." + } + } \ No newline at end of file diff --git a/content/blog/today-project/meta.json b/content/blog/today-project/meta.json new file mode 100644 index 0000000..adc7ca3 --- /dev/null +++ b/content/blog/today-project/meta.json @@ -0,0 +1,12 @@ +{ + "title": "Arbuz Journal — TODAY Project", + "tags": { + "description": "A story and explanation about making a resource that shows the emoji and color of the day, even though it might seem useless at first glance.", + "author": "Viktor K. (Marakarka)", + "keywords": "Marakarka, Arbuz, Programming, Journal, Blog, Color, Emoji, Maths, Fun" + }, + "og": { + "title": "Arbuz Journal — TODAY Project", + "description": "A story and explanation about making a resource that shows the emoji and color of the day, even though it might seem useless at first glance." + } + } \ No newline at end of file diff --git a/meta.json b/meta.json new file mode 100644 index 0000000..fbc0835 --- /dev/null +++ b/meta.json @@ -0,0 +1,12 @@ +{ + "title": "Arbuz?", + "tags": { + "description": "The personal internet portal of Viktor K. (Marakarka)", + "author": "Viktor K. (Marakarka)", + "keywords": "Marakarka, Arbuz, Programming, Journal, Science, Blog, Experiments, Маракарка, Арбуз, Программирование, Журнал, Наука, Блог, Эксперименты" + }, + "og": { + "title": "Arbuz?", + "description": "The personal internet portal of Viktor K. (Marakarka)" + } + } \ No newline at end of file diff --git a/template.html b/template.html index c5c8ea0..4c8ff8a 100644 --- a/template.html +++ b/template.html @@ -1,21 +1,24 @@ - - + + + + {{%META%}} + - + - - - + + - Arbuz? + + {{%TITLE%}} @@ -58,5 +61,4 @@ src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"> -