Skip to content

Commit 2e36b60

Browse files
feat: Make static_site_generator.py a standalone script (#81)
Signed-off-by: Roger Barker <roger.barker@swirldslabs.com> Co-authored-by: Andrew Brandt <andrew.brandt@hashgraph.com>
1 parent 1a3c4d3 commit 2e36b60

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

src/static_site_generator.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from jinja2 import Environment, FileSystemLoader
2+
from rich import print
3+
import json
24
import logging
35
import os
46

@@ -13,7 +15,7 @@ def __init__(self):
1315
'tasks': []
1416
}
1517

16-
def generate_site(self, data:list=None, projects:list[str]=None, output_file='./_site/index.html'):
18+
def generate_site(self, data:list=None, projects:list[str]=None, output_file='./_site/index.html') -> None:
1719
logging.info("Generating Static Site")
1820
env = Environment(loader=FileSystemLoader('templates'))
1921
template = env.get_template('kaban_board.html')
@@ -40,3 +42,20 @@ def generate_site(self, data:list=None, projects:list[str]=None, output_file='./
4042
f.write(output)
4143

4244
logging.info("Static Site Generated @ ./_site/index.html")
45+
46+
def main():
47+
ss_gen = StaticSiteGenerator()
48+
data_file:str = input("Enter the path to the json file with data: ")
49+
if not os.path.exists(data_file):
50+
print(f"[bold red]File {data_file} does not exist.[/bold red]")
51+
return
52+
53+
data:list = []
54+
with open(data_file, 'r') as f:
55+
data = json.load(f)
56+
57+
ss_gen.generate_site(data=data)
58+
59+
if __name__ == "__main__":
60+
main()
61+

0 commit comments

Comments
 (0)