]> OzVa Git service - blog/commitdiff
Fixed paths on page lookup
authorMax Value <greenwoodw50@gmail.com>
Mon, 16 Dec 2024 13:31:39 +0000 (13:31 +0000)
committerMax Value <greenwoodw50@gmail.com>
Mon, 16 Dec 2024 13:31:39 +0000 (13:31 +0000)
blog.py

diff --git a/blog.py b/blog.py
index 16ad6e5bc5f885438abb1b77e817ce6c4c3c88f1..d28b5b3930fe25a8da135d65b5af8a4dcdb7612a 100755 (executable)
--- a/blog.py
+++ b/blog.py
@@ -69,8 +69,8 @@ def get_search():
        name_string = "</em>' '<em>".join(names)
        content = f"<h1>Search '<em>{name_string}</em>'</h1><ul>"
 
-       for file_name in listdir("./pages"):
-               with open(f"./pages/{file_name}", "r") as f:
+       for file_name in listdir(f"{blog_path}/pages"):
+               with open(f"{blog_path}/pages/{file_name}", "r") as f:
                        s = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
                        for name in names:
                                i = s.find(str.encode(name))
@@ -115,11 +115,11 @@ def get_categories():
        if name == "all":
                return redirect("/categories")
 
-       for file_name in listdir("./pages"):
+       for file_name in listdir(f"{blog_path}/pages"):
                keywords = ["Undefined"]
                title = "Untitled post"
                abstract = "..."
-               with open(f"./pages/{file_name}", "r") as f:
+               with open(f"{blog_path}/pages/{file_name}", "r") as f:
                        while keywords == ["Undefined"]:
                                line = f.readline().split(":")
                                if len(line) == 2:
@@ -163,7 +163,7 @@ def get_categories():
 def generate_page(title):
        title = title.replace("/", "")
        try:
-               with open(f"pages/{title}.md", "r") as f:
+               with open(f"{blog_path}/pages/{title}.md", "r") as f:
                        html = md.convert(f.read())
                        metadata = {k: v[0] for k, v in md.Meta.items()}
                        md.reset()