fixed few annoyances

This commit is contained in:
BlenderDumbass 2024-11-27 21:57:44 +02:00
parent 786962980b
commit 151efdfc8a
4 changed files with 31 additions and 10 deletions

View file

@ -35,6 +35,7 @@ def Create(name):
"description":"", "description":"",
"author":"", "author":"",
"thumbnail":"", "thumbnail":"",
"license":"cc-by-sa",
"views":{ "views":{
"amount":0, "amount":0,
"viewers":[], "viewers":[],
@ -103,3 +104,5 @@ def Publish(name):
except Exception as e: except Exception as e:
print(clr["bold"]+clr["tdrd"]+"Error:"+clr["norm"]+" Could not publish!", e) print(clr["bold"]+clr["tdrd"]+"Error:"+clr["norm"]+" Could not publish!", e)
print(destination, "has been published!")

View file

@ -640,11 +640,15 @@ def AccountPage(server, account):
if mastodon: if mastodon:
# It could be mastodon url and not handle. # It could be mastodon url and not handle.
# https://social.trom.tf/@morsmortium
try: try:
if "/" in mastodon: if "/" in mastodon:
mastodon = mastodon.replace("https://", "").replace("http://", "") mastodon = mastodon.replace("https://", "").replace("http://", "")
mastodon = mastodon.split("/")[1]+"@"+mastodon.split("/")[0] mastodon = mastodon.split("/")[1]+"@"+mastodon.split("/")[0]
if not mastodon.startswith("@"): mastodon = "@"+mastodon
mastolink = "https://"+mastodon[1:].split("@")[1]+"/@"+mastodon[1:].split("@")[0] mastolink = "https://"+mastodon[1:].split("@")[1]+"/@"+mastodon[1:].split("@")[0]
html = html + '<center>' html = html + '<center>'
@ -1483,7 +1487,7 @@ def Login(server):
Redirect(server, "/") Redirect(server, "/settings")
def Register(server): def Register(server):

View file

@ -84,12 +84,18 @@ class handler(BaseHTTPRequestHandler):
elif self.path[1:].startswith(tuple(categories)): elif self.path[1:].startswith(tuple(categories)):
url = self.path[1:] url = self.path[1:]
if "?" in url: url = url[:url.find("?")] 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"): elif self.path[1:].startswith("account"):
url = self.path[9:] url = self.path[9:]
if "?" in url: url = url[:url.find("?")] 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"): elif self.path[1:].startswith("login"):
Render.LoginPage(self) Render.LoginPage(self)
@ -138,11 +144,14 @@ class handler(BaseHTTPRequestHandler):
elif self.path.startswith("/pictures/"): elif self.path.startswith("/pictures/"):
folder = Set.Folder() try:
f = open(folder+self.path, "rb") folder = Set.Folder()
f = f.read() f = open(folder+self.path, "rb")
Render.headers(self, 200) f = f.read()
self.wfile.write(f) Render.headers(self, 200)
self.wfile.write(f)
except:
Render.NotFound(self)
elif self.path == "/css": elif self.path == "/css":

View file

@ -143,7 +143,7 @@ def Open(md):
# untill it's untagged # untill it's untagged
code = "" code = ""
print("#####", n) #print("#####", n)
for l in md[n+1:]: for l in md[n+1:]:
if not l.startswith("```"): if not l.startswith("```"):
code = code + l + "\n" code = code + l + "\n"
@ -151,9 +151,14 @@ def Open(md):
else: else:
skip = n + code.count("\n") + 2 skip = n + code.count("\n") + 2
break break
print("!!!!!!!!!", skip) #print("!!!!!!!!!", skip)
tree.append(["text_cm", code+"\n"]) tree.append(["text_cm", code+"\n"])
te = "" te = ""
elif line.startswith("---"):
# Line break in markdown. In this case will be done like this:
te = '</div><div class="dark_box">'
elif line.startswith("#"): elif line.startswith("#"):
# The titles of the chapter. The Headers are usually written similar # The titles of the chapter. The Headers are usually written similar