main
Bob Mottram 2021-07-03 21:15:34 +01:00
parent 500e72f064
commit 9194d95b17
2 changed files with 19 additions and 32 deletions

View File

@ -111,18 +111,12 @@ def manualApproveFollowRequest(session, baseDir: str,
reqNick = approveHandle.split('@')[0] reqNick = approveHandle.split('@')[0]
reqDomain = approveHandle.split('@')[1].strip() reqDomain = approveHandle.split('@')[1].strip()
reqPrefix = httpPrefix + '://' + reqDomain reqPrefix = httpPrefix + '://' + reqDomain
if reqPrefix + '/profile/' + reqNick in approveFollowsStr: paths = ('/profile/', '/channel/', '/accounts/', '/u/')
for userPath in paths:
if reqPrefix + userPath + reqNick in approveFollowsStr:
exists = True exists = True
approveHandleFull = reqPrefix + '/profile/' + reqNick approveHandleFull = reqPrefix + userPath + reqNick
elif reqPrefix + '/channel/' + reqNick in approveFollowsStr: break
exists = True
approveHandleFull = reqPrefix + '/channel/' + reqNick
elif reqPrefix + '/accounts/' + reqNick in approveFollowsStr:
exists = True
approveHandleFull = reqPrefix + '/accounts/' + reqNick
elif reqPrefix + '/u/' + reqNick in approveFollowsStr:
exists = True
approveHandleFull = reqPrefix + '/u/' + reqNick
if not exists: if not exists:
print('Manual follow accept: ' + approveHandleFull + print('Manual follow accept: ' + approveHandleFull +
' not in requests file "' + ' not in requests file "' +

View File

@ -140,29 +140,22 @@ def markdownToHtml(markdown: str) -> str:
linesList = markdown.split('\n') linesList = markdown.split('\n')
htmlStr = '' htmlStr = ''
ctr = 0 ctr = 0
titles = {
"h5": '#####',
"h4": '####',
"h3": '###',
"h2": '##',
"h1": '#'
}
for line in linesList: for line in linesList:
if ctr > 0: if ctr > 0:
htmlStr += '<br>' htmlStr += '<br>'
if line.startswith('#####'): for h, hashes in titles.items():
line = line.replace('#####', '').strip() if line.startswith(hashes):
line = '<h5>' + line + '</h5>' line = line.replace(hashes, '').strip()
ctr = -1 line = '<' + h + '>' + line + '</' + h + '>'
elif line.startswith('####'):
line = line.replace('####', '').strip()
line = '<h4>' + line + '</h4>'
ctr = -1
elif line.startswith('###'):
line = line.replace('###', '').strip()
line = '<h3>' + line + '</h3>'
ctr = -1
elif line.startswith('##'):
line = line.replace('##', '').strip()
line = '<h2>' + line + '</h2>'
ctr = -1
elif line.startswith('#'):
line = line.replace('#', '').strip()
line = '<h1>' + line + '</h1>'
ctr = -1 ctr = -1
break
htmlStr += line htmlStr += line
ctr += 1 ctr += 1
return htmlStr return htmlStr