mirror of
https://github.com/markqvist/reticulum_website.git
synced 2025-02-18 13:44:16 -05:00
refactor: Just a little formatting here and there
Signed-off-by: nothingbutlucas <69118979+nothingbutlucas@users.noreply.github.com>
This commit is contained in:
parent
062104c85b
commit
e7c8c35a25
29
build.py
29
build.py
@ -94,7 +94,8 @@ menu_translations = {
|
||||
"CREDITS": "Credits",
|
||||
"SOURCE": "Quellcode",
|
||||
"DONATE": "Unterstützen",
|
||||
},"pl": {
|
||||
},
|
||||
"pl": {
|
||||
"RETICULUM": "Reticulum",
|
||||
"START": "Jak Zacząć",
|
||||
"HARDWARE": "Hardware",
|
||||
@ -137,8 +138,9 @@ menu_translations = {
|
||||
"CREDITS": "致谢",
|
||||
"SOURCE": "源代码",
|
||||
"DONATE": "支持开发",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def get_page_lang(page):
|
||||
page_lang = primary_lang
|
||||
@ -149,6 +151,7 @@ def get_page_lang(page):
|
||||
page_lang = lang["ext"]
|
||||
return page_lang
|
||||
|
||||
|
||||
def get_languages_md(page):
|
||||
page = page.replace(SOURCES_PATH, ".")
|
||||
current_page_lang = get_page_lang(page)
|
||||
@ -176,13 +179,24 @@ def get_languages_md(page):
|
||||
def get_menu_md(lang):
|
||||
local_menu_md = menu_md
|
||||
for entry in menu_translations[lang]:
|
||||
local_menu_md = local_menu_md.replace("{"+entry+"}", menu_translations[lang][entry])
|
||||
local_menu_md = local_menu_md.replace(
|
||||
"{" + entry + "}", menu_translations[lang][entry]
|
||||
)
|
||||
|
||||
return local_menu_md
|
||||
|
||||
|
||||
def scan_pages(base_path):
|
||||
files = [file for file in os.listdir(base_path) if os.path.isfile(os.path.join(base_path, file)) and file[:1] != "."]
|
||||
directories = [file for file in os.listdir(base_path) if os.path.isdir(os.path.join(base_path, file)) and file[:1] != "."]
|
||||
files = [
|
||||
file
|
||||
for file in os.listdir(base_path)
|
||||
if os.path.isfile(os.path.join(base_path, file)) and file[:1] != "."
|
||||
]
|
||||
directories = [
|
||||
file
|
||||
for file in os.listdir(base_path)
|
||||
if os.path.isdir(os.path.join(base_path, file)) and file[:1] != "."
|
||||
]
|
||||
|
||||
page_sources = []
|
||||
|
||||
@ -195,6 +209,7 @@ def scan_pages(base_path):
|
||||
|
||||
return page_sources
|
||||
|
||||
|
||||
source_files = scan_pages(SOURCES_PATH)
|
||||
|
||||
for mdf in source_files:
|
||||
@ -208,7 +223,9 @@ for mdf in source_files:
|
||||
|
||||
md = f.read().decode(INPUT_ENCODING)
|
||||
page_md = "<center>" + get_languages_md(mdf) + "" + get_menu_md(page_lang).replace("{LANG_EXT}", page_lang_ext) + "</center>\n\n" + md
|
||||
html = markdown.markdown(page_md, extensions=["markdown.extensions.fenced_code"])
|
||||
html = markdown.markdown(
|
||||
page_md, extensions=["markdown.extensions.fenced_code"]
|
||||
)
|
||||
html = document_start + html + document_end
|
||||
|
||||
of = BUILD_PATH + mdf.replace(SOURCES_PATH, "").replace(".md", ".html")
|
||||
|
Loading…
x
Reference in New Issue
Block a user