diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d298be1 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +public/ \ No newline at end of file diff --git a/build.py b/build.py new file mode 100755 index 0000000..7fffff5 --- /dev/null +++ b/build.py @@ -0,0 +1,112 @@ +#!/usr/bin/env python3 +import os +from io import TextIOWrapper +import sys + +NAVBAR_FMT = ''' + +''' +SELECT_FMT = ' <' +current_source = '' + + +def token_to_str(token: str) -> str: + global current_source + + if token == 'NAVBAR': + home_str = '' + projects_str = '' + about_str = '' + + if current_source == 'index.html': + home_str = SELECT_FMT + elif current_source == 'projects.html': + projects_str = SELECT_FMT + elif current_source == 'about.html': + about_str = SELECT_FMT + + return NAVBAR_FMT.format(home_str, projects_str, about_str) + elif token.endswith('.html'): + return open('includes/' + token).read() + else: + return '{{' + token + '}}' + + +def replace_line(line: str) -> (str, int): + ret = '' + count = 0 + + replacing = False + token = '' + i = 0 + while i < (len(line) - 2): + if replacing: + if line[i:i+2] == r'}}': + replacing = False + ret += token_to_str(token) + i += 2 + token = '' + count += 1 + else: + token += line[i] + i += 1 + else: + if line[i:i+2] == r'{{': + replacing = True + i += 2 + else: + ret += line[i] + i += 1 + + if replacing: + ret += '{{' + token + ret += line[i:] + + return (ret, count) + +def stream_template(in_fd: TextIOWrapper, out_fd: TextIOWrapper) -> int: + replacements = 0 + + while True: + line = in_fd.readline() + if line == '': + break + + new_line, count = replace_line(line) + out_fd.write(new_line) + replacements += count + + return replacements + + +def main(): + global current_source + + includes = os.listdir('includes') + sources = os.listdir('src') + + print(includes) + print(sources) + + if not os.path.isdir('public'): + os.mkdir('public') + + for source in sources: + current_source = source + + in_fd = open('src/' + source, 'r') + out_fd = open('public/' + source, 'w') + stream_template(in_fd, out_fd) + +if __name__ == '__main__': + main() diff --git a/includes/footer.html b/includes/footer.html new file mode 100644 index 0000000..efcd2ab --- /dev/null +++ b/includes/footer.html @@ -0,0 +1,5 @@ +

Hand written by Aaron Cook + + + +

\ No newline at end of file diff --git a/includes/header.html b/includes/header.html new file mode 100644 index 0000000..f1ee96e --- /dev/null +++ b/includes/header.html @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/includes/titlebar.html b/includes/titlebar.html new file mode 100644 index 0000000..51b6436 --- /dev/null +++ b/includes/titlebar.html @@ -0,0 +1 @@ +

Aaron G.C. Personal Website

\ No newline at end of file diff --git a/public/about.html b/public/about.html deleted file mode 100644 index 1dc4ea0..0000000 --- a/public/about.html +++ /dev/null @@ -1,33 +0,0 @@ - - -
- - -
- - -
-

Aaron G.C. Personal Website

-
- -
- - -
-

Site currently under construction.

-
-
- - - - - \ No newline at end of file diff --git a/public/index.html b/public/index.html deleted file mode 100644 index 5dae69d..0000000 --- a/public/index.html +++ /dev/null @@ -1,31 +0,0 @@ - - -
- - -
- - -
-

Aaron G.C. Personal Website

-
- -
- - -
-

Site currently under construction.

-
-
- - - - diff --git a/src/about.html b/src/about.html new file mode 100644 index 0000000..bda6349 --- /dev/null +++ b/src/about.html @@ -0,0 +1,27 @@ + + +
+ {{header.html}} +
+ + +
+ {{titlebar.html}} +
+ +
+ + +
+

Site currently under construction.

+
+
+ + + + + \ No newline at end of file diff --git a/src/index.html b/src/index.html new file mode 100644 index 0000000..a62e6fb --- /dev/null +++ b/src/index.html @@ -0,0 +1,26 @@ + + +
+ {{header.html}} +
+ + +
+ {{titlebar.html}} +
+ +
+ + +
+

Site currently under construction.

+
+
+ + + + diff --git a/public/main.css b/src/main.css similarity index 100% rename from public/main.css rename to src/main.css diff --git a/public/projects.html b/src/projects.html similarity index 62% rename from public/projects.html rename to src/projects.html index 590ca1e..324ae53 100644 --- a/public/projects.html +++ b/src/projects.html @@ -1,22 +1,17 @@
- - + {{header.html}}
-

Aaron G.C. Personal Website

+ {{titlebar.html}}
@@ -46,8 +41,7 @@