mirror of
https://github.com/markqvist/reticulum_website.git
synced 2025-06-07 06:32:55 -04: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
1 changed files with 36 additions and 19 deletions
29
build.py
29
build.py
|
@ -94,7 +94,8 @@ menu_translations = {
|
||||||
"CREDITS": "Credits",
|
"CREDITS": "Credits",
|
||||||
"SOURCE": "Quellcode",
|
"SOURCE": "Quellcode",
|
||||||
"DONATE": "Unterstützen",
|
"DONATE": "Unterstützen",
|
||||||
},"pl": {
|
},
|
||||||
|
"pl": {
|
||||||
"RETICULUM": "Reticulum",
|
"RETICULUM": "Reticulum",
|
||||||
"START": "Jak Zacząć",
|
"START": "Jak Zacząć",
|
||||||
"HARDWARE": "Hardware",
|
"HARDWARE": "Hardware",
|
||||||
|
@ -137,8 +138,9 @@ menu_translations = {
|
||||||
"CREDITS": "致谢",
|
"CREDITS": "致谢",
|
||||||
"SOURCE": "源代码",
|
"SOURCE": "源代码",
|
||||||
"DONATE": "支持开发",
|
"DONATE": "支持开发",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
def get_page_lang(page):
|
def get_page_lang(page):
|
||||||
page_lang = primary_lang
|
page_lang = primary_lang
|
||||||
|
@ -149,6 +151,7 @@ def get_page_lang(page):
|
||||||
page_lang = lang["ext"]
|
page_lang = lang["ext"]
|
||||||
return page_lang
|
return page_lang
|
||||||
|
|
||||||
|
|
||||||
def get_languages_md(page):
|
def get_languages_md(page):
|
||||||
page = page.replace(SOURCES_PATH, ".")
|
page = page.replace(SOURCES_PATH, ".")
|
||||||
current_page_lang = get_page_lang(page)
|
current_page_lang = get_page_lang(page)
|
||||||
|
@ -176,13 +179,24 @@ def get_languages_md(page):
|
||||||
def get_menu_md(lang):
|
def get_menu_md(lang):
|
||||||
local_menu_md = menu_md
|
local_menu_md = menu_md
|
||||||
for entry in menu_translations[lang]:
|
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
|
return local_menu_md
|
||||||
|
|
||||||
|
|
||||||
def scan_pages(base_path):
|
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] != "."]
|
files = [
|
||||||
directories = [file for file in os.listdir(base_path) if os.path.isdir(os.path.join(base_path, file)) and file[:1] != "."]
|
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 = []
|
page_sources = []
|
||||||
|
|
||||||
|
@ -195,6 +209,7 @@ def scan_pages(base_path):
|
||||||
|
|
||||||
return page_sources
|
return page_sources
|
||||||
|
|
||||||
|
|
||||||
source_files = scan_pages(SOURCES_PATH)
|
source_files = scan_pages(SOURCES_PATH)
|
||||||
|
|
||||||
for mdf in source_files:
|
for mdf in source_files:
|
||||||
|
@ -208,7 +223,9 @@ for mdf in source_files:
|
||||||
|
|
||||||
md = f.read().decode(INPUT_ENCODING)
|
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
|
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
|
html = document_start + html + document_end
|
||||||
|
|
||||||
of = BUILD_PATH + mdf.replace(SOURCES_PATH, "").replace(".md", ".html")
|
of = BUILD_PATH + mdf.replace(SOURCES_PATH, "").replace(".md", ".html")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue