diff --git a/gsitegen/generate.py b/gsitegen/generate.py index f4367dd..a711dfe 100644 --- a/gsitegen/generate.py +++ b/gsitegen/generate.py @@ -66,11 +66,12 @@ def generateLines(title, lines): def generatePage(title, doc): global pages global titles - global pagescount + if 'pages' not in globals(): pages = [] if 'titles' not in globals(): titles = [] + if 'navbar' in globals(): pages.append(str(E.ul(navbar)) + str(doc)) titles.append(title) @@ -86,7 +87,6 @@ def writePages(homepage): os.mkdir("./website-output") except FileExistsError: pass - print("Output directory already exists, let's clean it!") #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'): @@ -107,15 +107,13 @@ def writePages(homepage): except FileExistsError: pass - changed = False + changed = True filepath = Path("./website-output" + foldername + "/index.html") if filepath.exists(): with open("./website-output" + foldername + "/index.html", 'r') as newpage: - if newpage.read() != page: - changed = True - else: - changed = True + if newpage.read() == page: + changed = False if changed: with open("./website-output" + foldername + "/index.html", 'w') as newpage: