2023-09-27 14:47:55 +00:00
|
|
|
#! /usr/bin/env python3
|
2023-08-07 11:29:42 +00:00
|
|
|
import os
|
|
|
|
|
|
|
|
PAGES = [
|
|
|
|
{'name': 'index', 'titleSR': 'Početna', 'titleEN': 'Home', 'style': 'home'},
|
|
|
|
{'name': 'account', 'titleSR': 'Nalog', 'titleEN': 'Account', 'style': 'account'},
|
2024-04-15 18:56:29 +00:00
|
|
|
{'name': 'about', 'titleSR': 'O nama', 'titleEN': 'About us', 'style': 'about'},
|
2024-04-03 01:11:59 +00:00
|
|
|
{'name': 'statute', 'titleSR': 'Statut', 'titleEN': 'Statute', 'style': 'statute'},
|
2023-08-07 11:29:42 +00:00
|
|
|
{'name': 'events', 'titleSR': 'Događaji', 'titleEN': 'Events', 'style': 'events'},
|
2023-08-30 11:09:10 +00:00
|
|
|
{'name': 'events_archive', 'titleSR': 'Arhiva događaja', 'titleEN': 'Events archive', 'style': 'events'},
|
2023-08-07 11:29:42 +00:00
|
|
|
{'name': 'services', 'titleSR': 'Servisi', 'titleEN': 'Services', 'style': 'services'},
|
|
|
|
{'name': 'webring', 'titleSR': 'Webring', 'titleEN': 'Webring', 'style': ''},
|
2024-11-10 03:10:18 +00:00
|
|
|
{'name': 'donations', 'titleSR': 'Donacije', 'titleEN': 'Donations', 'style': 'donations'},
|
2024-09-06 00:17:15 +00:00
|
|
|
{'name': 'deconference', 'titleSR': 'Dekonferencija', 'titleEN': 'Deconference', 'style': 'deconference'},
|
2023-08-07 11:29:42 +00:00
|
|
|
]
|
|
|
|
|
2023-08-29 13:25:20 +00:00
|
|
|
def buildPage(filename: str, pageTitle: str, pageHtml: str, pageStyle: str, template: str) -> str:
|
2023-08-07 11:29:42 +00:00
|
|
|
template = template.replace('<!--TITLE-->', pageTitle)
|
|
|
|
style = '' if not pageStyle else f'<link rel=\"stylesheet\" href=\"/styles/{pageStyle}.css\">'
|
|
|
|
template = template.replace('<!--ADDITIONAL_STYLE-->', style)
|
2023-08-29 13:25:20 +00:00
|
|
|
template = template.replace('PAGE_NAME', filename)
|
2023-08-07 11:29:42 +00:00
|
|
|
template = template.replace('<!--MAIN-->', pageHtml)
|
|
|
|
return template
|
|
|
|
|
|
|
|
def main():
|
|
|
|
os.makedirs('site/en/', exist_ok=True)
|
|
|
|
with open('template/page-en.html') as fTempEN, open('template/page-sr.html') as fTempSR:
|
|
|
|
templateSR = fTempSR.read()
|
|
|
|
templateEN = fTempEN.read()
|
|
|
|
for page in PAGES:
|
|
|
|
with open(f'pages/sr/{page["name"]}.html') as f:
|
|
|
|
pageHtml = f.read()
|
2023-08-29 13:25:20 +00:00
|
|
|
html = buildPage(page['name'], page['titleSR'], pageHtml, page['style'], templateSR)
|
2023-08-07 11:29:42 +00:00
|
|
|
f = open(f'site/{page["name"]}.html', 'w')
|
|
|
|
f.write(html)
|
|
|
|
f.close()
|
2023-08-29 13:25:20 +00:00
|
|
|
with open(f'pages/en/{page["name"]}.html') as f:
|
|
|
|
pageHtml = f.read()
|
|
|
|
html = buildPage(page['name'], page['titleEN'], pageHtml, page['style'], templateEN)
|
|
|
|
f = open(f'site/en/{page["name"]}.html', 'w')
|
|
|
|
f.write(html)
|
|
|
|
f.close()
|
2023-08-07 11:29:42 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2023-09-27 14:47:55 +00:00
|
|
|
main()
|