summaryrefslogtreecommitdiff
path: root/src/pyssg/pyssg.py
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <david@luevano.xyz>2021-05-16 18:46:01 -0600
committerDavid Luevano Alvarado <david@luevano.xyz>2021-05-16 18:46:01 -0600
commit0dae5d53c49dd7b946990ca9e232fb924bf4f918 (patch)
tree93d4e990a9351a139339e2baf91d82b45849ddb4 /src/pyssg/pyssg.py
parenteaee38a4b6ebedc106548876cdbe1fe433c514bb (diff)
refactor code and finish basic features
Diffstat (limited to 'src/pyssg/pyssg.py')
-rw-r--r--src/pyssg/pyssg.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/pyssg/pyssg.py b/src/pyssg/pyssg.py
index b076abb..3f8cb8d 100644
--- a/src/pyssg/pyssg.py
+++ b/src/pyssg/pyssg.py
@@ -3,7 +3,7 @@ from argparse import ArgumentParser, Namespace
from .database import Database
from .template import Template
-from .builder import build_static_site
+from .builder import HTMLBuilder
def get_options() -> Namespace:
@@ -20,6 +20,10 @@ def get_options() -> Namespace:
type=str,
help='''dst directory; generated (and transfered html)
files; defaults to 'dst' ''')
+ parser.add_argument('-u', '--url',
+ required=True,
+ type=str,
+ help='''base url without trailing slash''')
parser.add_argument('-i', '--init',
action='store_true',
help='''initializes the dir structure, templates,
@@ -36,6 +40,7 @@ def main() -> None:
opts: dict[str] = vars(get_options())
src: str = opts['src']
dst: str = opts['dst']
+ base_url: str = opts['url']
if opts['init']:
try:
@@ -44,14 +49,22 @@ def main() -> None:
except FileExistsError:
pass
+ # write default templates
template: Template = Template(src)
template.write()
return
if opts['build']:
+ # start the db
db: Database = Database(os.path.join(src, '.files'))
+ db.read()
+
+ # read templates
+ template: Template = Template(src)
+ template.read()
- build_static_site(src, dst, db)
+ builder: HTMLBuilder = HTMLBuilder(src, dst, base_url, template, db)
+ builder.build()
db.write()
return