From 151efdfc8ae525cb0ca8bda6cfe0359d743c443c Mon Sep 17 00:00:00 2001 From: BlenderDumbass Date: Wed, 27 Nov 2024 21:57:44 +0200 Subject: [PATCH] fixed few annoyances --- modules/Create.py | 3 +++ modules/Render.py | 6 +++++- modules/Run.py | 23 ++++++++++++++++------- modules/markdown.py | 9 +++++++-- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/modules/Create.py b/modules/Create.py index c9103f7..3eb3946 100644 --- a/modules/Create.py +++ b/modules/Create.py @@ -35,6 +35,7 @@ def Create(name): "description":"", "author":"", "thumbnail":"", + "license":"cc-by-sa", "views":{ "amount":0, "viewers":[], @@ -103,3 +104,5 @@ def Publish(name): except Exception as e: print(clr["bold"]+clr["tdrd"]+"Error:"+clr["norm"]+" Could not publish!", e) + + print(destination, "has been published!") diff --git a/modules/Render.py b/modules/Render.py index 7e8178a..d3538b1 100644 --- a/modules/Render.py +++ b/modules/Render.py @@ -640,11 +640,15 @@ def AccountPage(server, account): if mastodon: # It could be mastodon url and not handle. + + # https://social.trom.tf/@morsmortium + try: if "/" in mastodon: mastodon = mastodon.replace("https://", "").replace("http://", "") mastodon = mastodon.split("/")[1]+"@"+mastodon.split("/")[0] + if not mastodon.startswith("@"): mastodon = "@"+mastodon mastolink = "https://"+mastodon[1:].split("@")[1]+"/@"+mastodon[1:].split("@")[0] html = html + '
' @@ -1483,7 +1487,7 @@ def Login(server): - Redirect(server, "/") + Redirect(server, "/settings") def Register(server): diff --git a/modules/Run.py b/modules/Run.py index 77b9785..b6d7a64 100644 --- a/modules/Run.py +++ b/modules/Run.py @@ -84,12 +84,18 @@ class handler(BaseHTTPRequestHandler): elif self.path[1:].startswith(tuple(categories)): url = self.path[1:] if "?" in url: url = url[:url.find("?")] - Render.ArticlePage(self, url) + try: + Render.ArticlePage(self, url) + except: + Render.NotFound(self) elif self.path[1:].startswith("account"): url = self.path[9:] if "?" in url: url = url[:url.find("?")] - Render.AccountPage(self, url) + try: + Render.AccountPage(self, url) + except: + Render.NotFound(self) elif self.path[1:].startswith("login"): Render.LoginPage(self) @@ -138,11 +144,14 @@ class handler(BaseHTTPRequestHandler): elif self.path.startswith("/pictures/"): - folder = Set.Folder() - f = open(folder+self.path, "rb") - f = f.read() - Render.headers(self, 200) - self.wfile.write(f) + try: + folder = Set.Folder() + f = open(folder+self.path, "rb") + f = f.read() + Render.headers(self, 200) + self.wfile.write(f) + except: + Render.NotFound(self) elif self.path == "/css": diff --git a/modules/markdown.py b/modules/markdown.py index 5c62992..35c78c8 100644 --- a/modules/markdown.py +++ b/modules/markdown.py @@ -143,7 +143,7 @@ def Open(md): # untill it's untagged code = "" - print("#####", n) + #print("#####", n) for l in md[n+1:]: if not l.startswith("```"): code = code + l + "\n" @@ -151,9 +151,14 @@ def Open(md): else: skip = n + code.count("\n") + 2 break - print("!!!!!!!!!", skip) + #print("!!!!!!!!!", skip) tree.append(["text_cm", code+"\n"]) te = "" + + elif line.startswith("---"): + + # Line break in markdown. In this case will be done like this: + te = '
' elif line.startswith("#"): # The titles of the chapter. The Headers are usually written similar