am am am am

This commit is contained in:
grey-cat-1908 2024-05-03 21:18:46 +03:00
parent d3de1506e1
commit e8f06524bc
9 changed files with 131 additions and 18 deletions

View file

@ -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'<meta name="{key}" content="{value}">\n'
for key, value in data['og'].items():
result += f'<meta property="og:{key}" content="{value}">\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")

View file

@ -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."
}
}

View file

@ -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."
}
}

11
content/blog/meta.json Normal file
View file

@ -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"
}
}

View file

@ -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."
}
}

View file

@ -0,0 +1,12 @@
{
"title": "Arbuz Journal [RU] — Прогноз Высшей Пробы",
"tags": {
"description": "Рассказ о том, как мы пытались создать единую методику прогнозирования граничных баллов Высшей Пробы, а также обзор того, что у нас получилось (и не получилось).",
"author": "Виктор К. и коллектив волонтеров",
"keywords": "Marakarka, Arbuz"
},
"og": {
"title": "Arbuz Journal [RU] — Прогноз Высшей Пробы",
"description": "Рассказ о том, как мы пытались создать единую методику прогнозирования граничных баллов Высшей Пробы, а также обзор того, что у нас получилось (и не получилось)."
}
}

View file

@ -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."
}
}

12
meta.json Normal file
View file

@ -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)"
}
}

View file

@ -1,21 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta property="og:site_name" content="Arbuz?"/>
{{%META%}}
<link rel="stylesheet" href="/custom.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v6.4.2/css/all.css">
<link rel="icon" href="https://avatars.githubusercontent.com/u/61203964">
<script src="/javascript/navbar.js" async=""></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<!-- and it's easy to individually load additional languages -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/go.min.js"></script>
<script src="/javascript/navbar.js" async=""></script>
<script>hljs.highlightAll();</script>
<title>Arbuz?</title>
<title>{{%TITLE%}}</title>
</head>
<body>
@ -58,5 +61,4 @@
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js">
</script>
</body>
</html>