forked from Decentrala/website
		
	Implement page builder for English
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1,5 +1,6 @@
 | 
			
		||||
venv/
 | 
			
		||||
site/*.html
 | 
			
		||||
site/en/*.html
 | 
			
		||||
site/atom_blog.xml
 | 
			
		||||
site/atom_events.xml
 | 
			
		||||
poster.html
 | 
			
		||||
 
 | 
			
		||||
@@ -9,10 +9,11 @@ PAGES = [
 | 
			
		||||
    {'name': 'webring', 'titleSR': 'Webring', 'titleEN': 'Webring', 'style': ''},
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
def buildPage(pageTitle: str, pageHtml: str, pageStyle: str, template: str) -> str:
 | 
			
		||||
def buildPage(filename: str, pageTitle: str, pageHtml: str, pageStyle: str, template: str) -> str:
 | 
			
		||||
    template = template.replace('<!--TITLE-->', pageTitle)
 | 
			
		||||
    style =  '' if not pageStyle else f'<link rel=\"stylesheet\" href=\"/styles/{pageStyle}.css\">'
 | 
			
		||||
    template = template.replace('<!--ADDITIONAL_STYLE-->', style)
 | 
			
		||||
    template = template.replace('PAGE_NAME', filename)
 | 
			
		||||
    template = template.replace('<!--MAIN-->', pageHtml)
 | 
			
		||||
    return template
 | 
			
		||||
 | 
			
		||||
@@ -24,10 +25,16 @@ def main():
 | 
			
		||||
        for page in PAGES:
 | 
			
		||||
            with open(f'pages/sr/{page["name"]}.html') as f:
 | 
			
		||||
                pageHtml = f.read()
 | 
			
		||||
                html = buildPage(page['titleSR'], pageHtml, page['style'], templateSR)
 | 
			
		||||
                html = buildPage(page['name'], page['titleSR'], pageHtml, page['style'], templateSR)
 | 
			
		||||
                f = open(f'site/{page["name"]}.html', 'w')
 | 
			
		||||
                f.write(html)
 | 
			
		||||
                f.close()
 | 
			
		||||
            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()
 | 
			
		||||
 | 
			
		||||
if __name__ == '__main__':
 | 
			
		||||
    main()
 | 
			
		||||
							
								
								
									
										3
									
								
								prep.py
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								prep.py
									
									
									
									
									
								
							@@ -77,10 +77,7 @@ events = load_events()
 | 
			
		||||
events = sort_events(events)
 | 
			
		||||
write_events(events)
 | 
			
		||||
 | 
			
		||||
print(events)
 | 
			
		||||
 | 
			
		||||
newevents = build_html(events, DAYS_SR, MONTHS_SR)
 | 
			
		||||
print(newevents)
 | 
			
		||||
 | 
			
		||||
with open("pages/sr/events.html","wt") as file:
 | 
			
		||||
    file.writelines(["<h1>Događaji</h1>\n", "<table>\n", "<tr><th>Datum</th><th>Vreme</th><th>Mesto</th><th>Tema</th></tr>\n"])
 | 
			
		||||
 
 | 
			
		||||
@@ -111,7 +111,7 @@ a:focus {
 | 
			
		||||
  background: linear-gradient(90deg, var(--hightlight) 0%, var(--hightlight) 50%, var(--bg) 51%, var(--bg) 100%);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.account {
 | 
			
		||||
.lang {
 | 
			
		||||
  font-size: 2rem;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -210,8 +210,4 @@ screen and (max-width: 1500px) {
 | 
			
		||||
  #theme-switcher {
 | 
			
		||||
    margin-right: 1rem;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  .account {
 | 
			
		||||
    font-size: 1rem;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -9,12 +9,13 @@
 | 
			
		||||
  <link rel="shortcut icon" href="/img/favicon.ico" type="image/x-icon">
 | 
			
		||||
  <script src="/scripts/main.js" defer></script>
 | 
			
		||||
  <title><!--TITLE--> Decentrala</title>
 | 
			
		||||
  <link rel="alternate" hreflang="sr" href="/PAGE_NAME" />
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
  <header>
 | 
			
		||||
    <a id="logo" href="/"><img src="/img/logo-light.svg" alt="Logo"> Decentrala</a>
 | 
			
		||||
    <a id="logo" href="/en/"><img src="/img/logo-light.svg" alt="Logo"> Decentrala</a>
 | 
			
		||||
    <button id="theme-switcher"></button>
 | 
			
		||||
    <a class="account" href="/en/account">Account</a>
 | 
			
		||||
    <a class="lang" hreflang="sr" href="/PAGE_NAME">SR</a>
 | 
			
		||||
  </header>
 | 
			
		||||
  <main>
 | 
			
		||||
    <!--MAIN-->
 | 
			
		||||
@@ -22,9 +23,10 @@
 | 
			
		||||
  <footer>
 | 
			
		||||
    <button id="sections-button" opened="false"><img src="/img/strelica-closed-light.svg" alt="OpenMenu"></button>
 | 
			
		||||
    <nav>
 | 
			
		||||
      <a href="/en/events">Događaji</a>
 | 
			
		||||
      <a href="/en/services">Servisi</a>
 | 
			
		||||
      <a href="/en/contact">Kontakt</a>
 | 
			
		||||
      <a href="/en/events">Events</a>
 | 
			
		||||
      <a href="/en/services">Services</a>
 | 
			
		||||
      <a href="/en/contact">Contact</a>
 | 
			
		||||
      <a href="/en/account">Account</a>
 | 
			
		||||
    </nav>
 | 
			
		||||
    <span class="links">
 | 
			
		||||
      <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/"><img src="/img/cc-light.svg" alt="CreativeCommons"></a>
 | 
			
		||||
 
 | 
			
		||||
@@ -9,12 +9,13 @@
 | 
			
		||||
  <link rel="shortcut icon" href="/img/favicon.ico" type="image/x-icon">
 | 
			
		||||
  <script src="/scripts/main.js" defer></script>
 | 
			
		||||
  <title><!--TITLE--> Decentrala</title>
 | 
			
		||||
  <link rel="alternate" hreflang="en" href="/en/PAGE_NAME" />
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
  <header>
 | 
			
		||||
    <a id="logo" href="/"><img src="/img/logo-light.svg" alt="Logo"> Decentrala</a>
 | 
			
		||||
    <button id="theme-switcher"></button>
 | 
			
		||||
    <a class="account" href="/account">Nalog</a>
 | 
			
		||||
    <a class="lang" hreflang="en" href="/en/PAGE_NAME">EN</a>
 | 
			
		||||
  </header>
 | 
			
		||||
  <main>
 | 
			
		||||
    <!--MAIN-->
 | 
			
		||||
@@ -25,6 +26,7 @@
 | 
			
		||||
      <a href="/events">Događaji</a>
 | 
			
		||||
      <a href="/services">Servisi</a>
 | 
			
		||||
      <a href="/contact">Kontakt</a>
 | 
			
		||||
      <a class="account" href="/account">Nalog</a>
 | 
			
		||||
    </nav>
 | 
			
		||||
    <span class="links">
 | 
			
		||||
      <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/"><img src="/img/cc-light.svg" alt="CreativeCommons"></a>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user