Use post Id rather than full path

main
Bob Mottram 2020-10-10 22:27:58 +01:00
parent 634b66c59e
commit 3d5c437a74
2 changed files with 13 additions and 6 deletions

View File

@ -8108,16 +8108,21 @@ class PubServer(BaseHTTPRequestHandler):
def _editNewsPost(self, callingDomain: str, path: str,
translate: {}, baseDir: str,
httpPrefix: str, domain: str, port: int,
domainFull: str,
cookie: str) -> bool:
"""Show the edit screen for a news post
"""
if '/users/' in path and '/editnewspost=' in path:
postUrl = path.split('/editnewspost=')[1]
if '?' in postUrl:
postUrl = postUrl.split('?')[0]
postId = path.split('/editnewspost=')[1]
if '?' in postId:
postId = postId.split('?')[0]
postUrl = httpPrefix + '://' + domainFull + \
'/users/news/statuses' + postId
print('TEST postUrl: ' + postUrl)
msg = htmlEditNewsPost(translate, baseDir,
path, domain, port,
httpPrefix, postUrl).encode('utf-8')
httpPrefix,
postUrl).encode('utf-8')
if msg:
self._set_headers('text/html', len(msg),
cookie, callingDomain)
@ -9516,6 +9521,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.httpPrefix,
self.server.domain,
self.server.port,
self.server.domainFull,
cookie):
return

View File

@ -1371,8 +1371,9 @@ def htmlEditNewsPost(translate: {}, baseDir: str, path: str,
if not isEditor(baseDir, nickname):
return ''
postUrl = postUrl.replace('/', '#')
postFilename = locatePost(baseDir, nickname, domain, postUrl)
print('TEST htmlEditNewsPost 5: ' + str(postFilename))
print('TEST htmlEditNewsPost 5: ' + str(postFilename) + ' ' + postUrl)
if not postFilename:
return ''
postJsonObject = loadJson(postFilename)
@ -4623,7 +4624,7 @@ def individualPostAsHtml(allowDownloads: bool,
' ' + \
'<a class="imageAnchor" href="/users/' + \
nickname + '/editnewspost=' + \
blogPostId.replace('/', '#') + \
blogPostId.split('/statuses/')[1] + \
'?actor=' + actorNickname + \
'" title="' + translate['Edit blog post'] + '">' + \
'<img loading="lazy" title="' + \