forked from indymedia/epicyon
Editing blog posts
parent
0ee0d432f6
commit
db19a3e29a
14
blog.py
14
blog.py
|
@ -609,7 +609,9 @@ def htmlEditBlog(mediaInstance: bool,translate: {}, \
|
||||||
|
|
||||||
editBlogForm+= \
|
editBlogForm+= \
|
||||||
'<form enctype="multipart/form-data" method="POST" accept-charset="UTF-8" action="'+ \
|
'<form enctype="multipart/form-data" method="POST" accept-charset="UTF-8" action="'+ \
|
||||||
pathBase+'?'+endpoint+'?page='+str(pageNumber)+'">'
|
pathBase+'?'+endpoint+'">'
|
||||||
|
editBlogForm+=' <input type="hidden" name="postUrl" value="'+postUrl+'">'
|
||||||
|
editBlogForm+=' <input type="hidden" name="pageNumber" value="'+str(pageNumber)+'">'
|
||||||
editBlogForm+=' <div class="vertical-center">'
|
editBlogForm+=' <div class="vertical-center">'
|
||||||
editBlogForm+=' <label for="nickname"><b>'+editBlogText+'</b></label>'
|
editBlogForm+=' <label for="nickname"><b>'+editBlogText+'</b></label>'
|
||||||
editBlogForm+=' <div class="container">'
|
editBlogForm+=' <div class="container">'
|
||||||
|
@ -622,7 +624,8 @@ def htmlEditBlog(mediaInstance: bool,translate: {}, \
|
||||||
|
|
||||||
editBlogForm+= \
|
editBlogForm+= \
|
||||||
' <a href="'+pathBase+ \
|
' <a href="'+pathBase+ \
|
||||||
'/searchemoji"><img loading="lazy" class="emojisearch" src="/emoji/1F601.png" title="'+ \
|
'/searchemoji"><img loading="lazy" '+ \
|
||||||
|
'class="emojisearch" src="/emoji/1F601.png" title="'+ \
|
||||||
translate['Search for emoji']+'" alt="'+ \
|
translate['Search for emoji']+'" alt="'+ \
|
||||||
translate['Search for emoji']+'"/></a>'
|
translate['Search for emoji']+'"/></a>'
|
||||||
editBlogForm+=' </div>'
|
editBlogForm+=' </div>'
|
||||||
|
@ -645,10 +648,13 @@ def htmlEditBlog(mediaInstance: bool,translate: {}, \
|
||||||
editBlogForm+= \
|
editBlogForm+= \
|
||||||
' <input type="text" name="subject" value="'+titleStr+'">'
|
' <input type="text" name="subject" value="'+titleStr+'">'
|
||||||
editBlogForm+=''
|
editBlogForm+=''
|
||||||
editBlogForm+=' <br><label class="labels">'+placeholderMessage+'</label>'
|
editBlogForm+= \
|
||||||
|
' <br><label class="labels">'+ \
|
||||||
|
placeholderMessage+'</label>'
|
||||||
messageBoxHeight=800
|
messageBoxHeight=800
|
||||||
|
|
||||||
contentStr=postJsonObject['object']['content'].replace('<p>','').replace('</p>','')
|
contentStr= \
|
||||||
|
postJsonObject['object']['content'].replace('<p>','').replace('</p>','')
|
||||||
|
|
||||||
editBlogForm+= \
|
editBlogForm+= \
|
||||||
' <textarea id="message" name="message" style="height:'+ \
|
' <textarea id="message" name="message" style="height:'+ \
|
||||||
|
|
72
daemon.py
72
daemon.py
|
@ -3896,8 +3896,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
return -1
|
return -1
|
||||||
elif postType=='newblog':
|
elif postType=='newblog':
|
||||||
messageJson= \
|
messageJson= \
|
||||||
createBlogPost(self.server.baseDir, \
|
createBlogPost(self.server.baseDir,nickname, \
|
||||||
nickname, \
|
|
||||||
self.server.domain,self.server.port, \
|
self.server.domain,self.server.port, \
|
||||||
self.server.httpPrefix, \
|
self.server.httpPrefix, \
|
||||||
fields['message'],False,False,False, \
|
fields['message'],False,False,False, \
|
||||||
|
@ -5362,6 +5361,75 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
self._benchmarkPOSTtimings(POSTstartTime,POSTtimings,13)
|
self._benchmarkPOSTtimings(POSTstartTime,POSTtimings,13)
|
||||||
|
|
||||||
|
# edit blog post
|
||||||
|
if authorized and self.path.endswith('/tlblogs?editblogpost'):
|
||||||
|
pageNumber=1
|
||||||
|
|
||||||
|
length = int(self.headers['Content-length'])
|
||||||
|
if length>self.server.maxPostLength:
|
||||||
|
print('POST size too large')
|
||||||
|
self.send_response(429)
|
||||||
|
self.end_headers()
|
||||||
|
return
|
||||||
|
|
||||||
|
optionsConfirmParams= \
|
||||||
|
self.rfile.read(length).decode('utf-8').replace('%40','@').replace('%3A',':').replace('%23','#').replace('%2F','/').replace('%3F','')
|
||||||
|
postUrl=None
|
||||||
|
if 'postUrl=' in optionsConfirmParams:
|
||||||
|
postUrl=optionsConfirmParams.split('postUrl=')[1]
|
||||||
|
if '&' in postUrl:
|
||||||
|
postUrl=postUrl.split('&')[0]
|
||||||
|
originPathStr= \
|
||||||
|
self.server.httpPrefix+'://'+self.server.domainFull+ \
|
||||||
|
self.path.split('?')[0]
|
||||||
|
if postUrl:
|
||||||
|
titleStr=''
|
||||||
|
if 'subject=' in optionsConfirmParams:
|
||||||
|
titleStr=optionsConfirmParams.split('subject=')[1]
|
||||||
|
if '&' in titleStr:
|
||||||
|
titleStr=titleStr.split('&')[0]
|
||||||
|
titleStr=titleStr.replace('%26','&')
|
||||||
|
contentStr=''
|
||||||
|
if 'message=' in optionsConfirmParams:
|
||||||
|
contentStr=optionsConfirmParams.split('message=')[1]
|
||||||
|
if '&' in contentStr:
|
||||||
|
contentStr=contentStr.split('&')[0]
|
||||||
|
contentStr=contentStr.replace('%26','&')
|
||||||
|
#editNickname=getNicknameFromActor(originPathStr)
|
||||||
|
# page number to return to
|
||||||
|
if 'pageNumber=' in optionsConfirmParams:
|
||||||
|
pageNumberStr=optionsConfirmParams.split('pageNumber=')[1]
|
||||||
|
if '&' in pageNumberStr:
|
||||||
|
pageNumberStr=pageNumberStr.split('&')[0]
|
||||||
|
if pageNumberStr.isdigit():
|
||||||
|
pageNumber=int(pageNumberStr)
|
||||||
|
nickname= \
|
||||||
|
getNicknameFromActor(originPathStr)
|
||||||
|
postFilename= \
|
||||||
|
locatePost(self.server.baseDir, \
|
||||||
|
nickname,self.server.domain, \
|
||||||
|
postUrl)
|
||||||
|
if postFilename and titleStr and contentStr:
|
||||||
|
postJsonObject=loadJson(postFilename)
|
||||||
|
if postJsonObject:
|
||||||
|
# remove any previous cached html
|
||||||
|
cacheFilename= \
|
||||||
|
self.server.baseDir+'/postcache/' + \
|
||||||
|
postUrl.replace('/','#')+'.html'
|
||||||
|
if os.path.isfile(cacheFilename):
|
||||||
|
try:
|
||||||
|
os.remove(cacheFilename)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
# save the new blog post
|
||||||
|
postJsonObject['object']['summary']=titleStr
|
||||||
|
postJsonObject['object']['content']=contentStr
|
||||||
|
saveJson(postJsonObject,postFilename)
|
||||||
|
self.server.POSTbusy=False
|
||||||
|
self._redirect_headers(originPathStr+ \
|
||||||
|
'?page='+str(pageNumber),cookie)
|
||||||
|
return
|
||||||
|
|
||||||
# an option was chosen from person options screen
|
# an option was chosen from person options screen
|
||||||
# view/follow/block/report
|
# view/follow/block/report
|
||||||
if authorized and self.path.endswith('/personoptions'):
|
if authorized and self.path.endswith('/personoptions'):
|
||||||
|
|
Loading…
Reference in New Issue