From 3d5c437a74c705a140df6952afb9628d45d6f76d Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 10 Oct 2020 22:27:58 +0100 Subject: [PATCH] Use post Id rather than full path --- daemon.py | 14 ++++++++++---- webinterface.py | 5 +++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/daemon.py b/daemon.py index 71687f4c1..ab47fe056 100644 --- a/daemon.py +++ b/daemon.py @@ -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 diff --git a/webinterface.py b/webinterface.py index 3bce93052..9b030dddb 100644 --- a/webinterface.py +++ b/webinterface.py @@ -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, ' ' + \ '' + \ '