Reply to post

master
Bob Mottram 2019-07-31 14:51:10 +01:00
parent 4e67445904
commit fbb7636a3b
2 changed files with 19 additions and 7 deletions

View File

@ -640,6 +640,11 @@ class PubServer(BaseHTTPRequestHandler):
self.server.GETbusy=False
return
inReplyTo=None
if authorized and '?replyto=' in self.path:
inReplyTo=self.path.split('?replyto=')[1]
self.path=self.path.split('?replyto=')[0]+'/newpost'
if '/users/' in self.path and \
(self.path.endswith('/newpost') or \
self.path.endswith('/newunlisted') or \
@ -647,7 +652,7 @@ class PubServer(BaseHTTPRequestHandler):
self.path.endswith('/newdm') or \
self.path.endswith('/newshare')):
self._set_headers('text/html',cookie)
self.wfile.write(htmlNewPost(self.server.baseDir,self.path).encode())
self.wfile.write(htmlNewPost(self.server.baseDir,self.path,inReplyTo).encode())
self.server.GETbusy=False
return
@ -883,6 +888,7 @@ class PubServer(BaseHTTPRequestHandler):
if 'text/html' in self.headers['Accept']:
self._set_headers('text/html',cookie)
self.wfile.write(htmlIndividualPost( \
self.server.baseDir, \
self.server.session, \
self.server.cachedWebfingers,self.server.personCache, \
nickname,self.server.domain,self.server.port, \

View File

@ -81,9 +81,14 @@ def htmlLogin(baseDir: str) -> str:
loginForm+=htmlFooter()
return loginForm
def htmlNewPost(baseDir: str,path: str) -> str:
def htmlNewPost(baseDir: str,path: str,inReplyTo: str) -> str:
replyStr=''
if not path.endswith('/newshare'):
newPostText='<p class="new-post-text">Enter your post text below.</p>'
if not inReplyTo:
newPostText='<p class="new-post-text">Enter your post text below.</p>'
else:
newPostText='<p class="new-post-text">Enter your reply to <a href="'+inReplyTo+'">this post</a> below.</p>'
replyStr='<input type="hidden" name="replyTo" value="'+inReplyTo+'">'
else:
newPostText='<p class="new-post-text">Enter the details for your shared item below.</p>'
@ -146,7 +151,8 @@ def htmlNewPost(baseDir: str,path: str) -> str:
' </div>' \
' <input type="submit" name="submitPost" value="Submit">' \
' <a href="'+pathBase+'/outbox"><button class="cancelbtn">Cancel</button></a>' \
' </div>' \
' </div>'+ \
replyStr+ \
' <input type="text" placeholder="'+placeholderSubject+'" name="subject">' \
'' \
' <textarea id="message" name="message" placeholder="'+placeholderMessage+'" style="height:200px"></textarea>' \
@ -546,11 +552,11 @@ def individualPostAsHtml(baseDir: str, \
footerStr='<span class="'+timeClass+'">'+publishedStr+'</span>\n'
if showIcons:
footerStr='<div class="'+containerClassIcons+'">'
footerStr+='<a href="/users/'+nickname+'?replyto='+postJsonObject['object']['id']+'">'
footerStr+='<a href="/users/'+nickname+'?replyto='+postJsonObject['object']['id']+'" title="Reply to this post">'
footerStr+='<img src="/icons/reply.png"/></a>'
footerStr+='<a href="/users/'+nickname+'?repeat='+postJsonObject['object']['id']+'">'
footerStr+='<a href="/users/'+nickname+'?repeat='+postJsonObject['object']['id']+'" title="Repeat this post">'
footerStr+='<img src="/icons/repeat_inactive.png"/></a>'
footerStr+='<a href="/users/'+nickname+'?like='+postJsonObject['object']['id']+'">'
footerStr+='<a href="/users/'+nickname+'?like='+postJsonObject['object']['id']+'" title="Like this post">'
footerStr+='<img src="/icons/like_inactive.png"/></a>'
footerStr+='<span class="'+timeClass+'">'+publishedStr+'</span>'
footerStr+='</div>'