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":"",
"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!")

View file

@ -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 + '<center>'
@ -1483,7 +1487,7 @@ def Login(server):
Redirect(server, "/")
Redirect(server, "/settings")
def Register(server):

View file

@ -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":

View file

@ -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,10 +151,15 @@ 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 = '</div><div class="dark_box">'
elif line.startswith("#"):
# The titles of the chapter. The Headers are usually written similar
# to how here in python you write comments. It's a # , space, and the