diff --git a/gsitegen/generate.py b/gsitegen/generate.py index 54777ae..06b33d8 100644 --- a/gsitegen/generate.py +++ b/gsitegen/generate.py @@ -143,7 +143,7 @@ def generatePage(title, doc): if 'titles' not in globals(): titles = [] - navbarfile = Path(__file__).parent.joinpath('navbar') + navbarfile = Path("./").parent.joinpath('navbar') if navbarfile.exists(): with navbarfile.open('r') as navbarfile: @@ -166,6 +166,9 @@ def generatePage(title, doc): def writePages(): global pages global titles + if 'pages' not in globals(): + print("Error: no page files found") + exit() #TODO only delete files that aren't present in newest site generation #deleting contents of folder without deleting the folder, to increase compatibility with various systems #for root, dirs, files in os.walk('./website-output'): @@ -181,7 +184,7 @@ def writePages(): if titles[id] != homepage: foldername = titles[id].replace(" ", "-").lower() - outputpath = Path(__file__).parent.joinpath("website-output") + outputpath = Path("./").parent.joinpath("website-output") dirpath = outputpath.joinpath(foldername) @@ -200,7 +203,7 @@ def writePages(): print("Written changed page: " + titles[id]) #resources - respath = Path(__file__).parent.joinpath("resources") + respath = Path("./").parent.joinpath("resources") if respath.exists(): #shutil.copytree copies timestamp too @@ -229,7 +232,7 @@ def main(): global homepage homepage = "Home" - footerfile = Path(__file__).parent.joinpath('footer') + footerfile = Path("./").parent.joinpath('footer') if footerfile.exists(): with footerfile.open('r') as footerfile: @@ -239,7 +242,7 @@ def main(): pagescount = 0 - for file in Path(__file__).parent.iterdir(): + for file in Path("./").parent.iterdir(): if file.is_file(): if file.suffix == ".page": pagescount += 1 diff --git a/tests/test_generate.py b/tests/test_generate.py index b7fd86f..08687f1 100644 --- a/tests/test_generate.py +++ b/tests/test_generate.py @@ -1,7 +1,7 @@ from gsitegen.generate import * from html5tagger import E -def test_something(): +def test_markdown(): doc = E() - parseMarkdown(doc, "## Heading 2") + doc = parseMarkdown(doc, "## Heading 2") assert str(doc) == "