Compare commits

...

3 Commits

Author SHA1 Message Date
Cutieguwu
c91a3f85b2 Create main.html 2025-07-21 16:19:06 -04:00
Cutieguwu
579857a477 Update acknowledgements.html 2025-07-21 16:18:50 -04:00
Cutieguwu
abe4a76c25 Delete balloon.py 2025-07-21 15:04:30 -04:00
3 changed files with 39 additions and 109 deletions

View File

@@ -6,8 +6,16 @@
<include src="includes/meta.html" /> <include src="includes/meta.html" />
</head> </head>
<body class="viewport"> <body class="viewport">
<include src="includes/nav.html" /> <nav class="pane_nav">
<div class="main_pane"> <include src="includes/nav_logo.html" />
<include src="includes/nav_menu.html" />
<div class="location">
<p class="location_header">You are here:</p>
<p class="location_page">Acknowledgements</p>
</div>
<include src="includes/nav_quick_links.html" />
</nav>
<div class="pane_main">
<p>There are currently no acknowledgements</p> <p>There are currently no acknowledgements</p>
<p>In terms of security, hopefully that means I'm doing a good-ish job.</p> <p>In terms of security, hopefully that means I'm doing a good-ish job.</p>
<p> <p>
@@ -15,6 +23,10 @@
getting the basics handled. getting the basics handled.
</p> </p>
</div> </div>
<div class="pane_spacer">
<div class="spacer_container"><p>#AD</p></div>
<div class="spacer_container"><p>#AD</p></div>
</div>
<include src="includes/scripts.html" /> <include src="includes/scripts.html" />
</body> </body>
</html> </html>

View File

@@ -1,107 +0,0 @@
from __future__ import annotations
from dataclasses import dataclass
from types import NoneType
from typing import Optional
from result import Result, Ok, Err
from icecream import ic
import os
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from _typeshed import StrPath
WORK_DIR: StrPath = os.getcwd()
@dataclass
class Tag:
value: str
trail: Optional[str]
def __post_init__(self) -> None:
self.trail = self.trail if (self.trail is not None) and (self.trail.strip() != '') else None
# Returns the type of tag.
def type(self) -> str:
type = str()
for c in self.value:
if c.isspace():
break
type += c
return type
def get_param(self, param: str) -> Optional[str]:
pos = self.value.find(param) + param.__len__() + len('="')
if pos == -1:
return None
param_value = str()
for idx in range(pos, (self.value.__len__() - param.__len__())):
param_value += self.value[idx]
return param_value
def write(self) -> str:
return f'<{self.value}>{self.trail if self.trail != None else ''}'
@dataclass
class HTML:
value: str
# Returns all tags in order in the html file.
def tags(self) -> list[Tag]:
tag = str()
trail: Optional[str] = str()
tags = list()
record = False
for c in self.value:
if c == '<' and tag != '':
tags.append(Tag(tag, trail))
tag = str()
trail = str()
if c == '<' or c == '>':
record = not record # why can't I have ! operator...
elif record == True:
tag += c
else:
trail += c
tags.append(Tag(tag, trail))
return tags
def inflate(self) -> Result[str, str]:
file = str()
for tag in self.tags():
if tag.type() == 'include':
chunk = tag.get_param('src')
if isinstance(chunk, NoneType):
return Err('FileNotFoundError')
html = HTML(open(str(WORK_DIR) + '/src/' + chunk, 'rt').read())
file += html.inflate().expect('FileNotFoundError')
else:
file += tag.write()
return Ok(file)
# Convert the HTML obj into a str to write to file.
def write(self) -> str:
return self.inflate().unwrap()
def main() -> None:
with open(str(WORK_DIR) + '/src/index.html', 'rt') as f:
html_src = HTML(f.read())
with open(str(WORK_DIR) + '/target/index.html', 'w') as f:
f.write(html_src.write())
if __name__ == '__main__':
main()

25
src/templates/main.html Normal file
View File

@@ -0,0 +1,25 @@
<!doctype html>
<html lang="en-ca">
<head>
<title>Main Template | Cutieguwu</title>
<include src="includes/meta.html" />
</head>
<body class="viewport">
<nav class="pane_nav">
<include src="includes/nav_logo.html" />
<include src="includes/nav_menu.html" />
<div class="location">
<p class="location_header">You are here:</p>
<p class="location_page">Main Template</p>
</div>
<include src="includes/nav_quick_links.html" />
</nav>
<div class="pane_main"></div>
<div class="pane_spacer">
<div class="spacer_container"><p>#AD</p></div>
<div class="spacer_container"><p>#AD</p></div>
</div>
<include src="includes/scripts.html" />
</body>
</html>