forked from indymedia/epicyon
Add blog content
parent
e0190b2106
commit
5fe0e5d381
25
blog.py
25
blog.py
|
@ -26,6 +26,8 @@ from webinterface import htmlFooter
|
|||
from webinterface import addEmbeddedElements
|
||||
from utils import getNicknameFromActor
|
||||
from utils import getDomainFromActor
|
||||
from utils import locatePost
|
||||
from utils import loadJson
|
||||
from posts import createBlogsTimeline
|
||||
|
||||
|
||||
|
@ -534,9 +536,18 @@ def htmlEditBlog(mediaInstance: bool,translate: {}, \
|
|||
baseDir: str,httpPrefix: str, \
|
||||
path: str, \
|
||||
pageNumber: int, \
|
||||
nickname: str,domain: str) -> str:
|
||||
nickname: str,domain: str, \
|
||||
postUrl: str) -> str:
|
||||
"""Edit a blog post after it was created
|
||||
"""
|
||||
postFilename=locatePost(baseDir,nickname,domain,postUrl)
|
||||
if not postFilename:
|
||||
return None
|
||||
|
||||
postJsonObject=loadJson(postFilename)
|
||||
if not postJsonObject:
|
||||
return None
|
||||
|
||||
iconsDir=getIconsDir(baseDir)
|
||||
|
||||
editBlogText='<p class="new-post-text">'+translate['Write your post text below.']+'</p>'
|
||||
|
@ -597,7 +608,7 @@ def htmlEditBlog(mediaInstance: bool,translate: {}, \
|
|||
|
||||
editBlogForm+= \
|
||||
'<form enctype="multipart/form-data" method="POST" accept-charset="UTF-8" action="'+ \
|
||||
path+'?'+endpoint+'?page='+str(pageNumber)+'">'
|
||||
pathBase+'?'+endpoint+'?page='+str(pageNumber)+'">'
|
||||
editBlogForm+=' <div class="vertical-center">'
|
||||
editBlogForm+=' <label for="nickname"><b>'+editBlogText+'</b></label>'
|
||||
editBlogForm+=' <div class="container">'
|
||||
|
@ -627,14 +638,20 @@ def htmlEditBlog(mediaInstance: bool,translate: {}, \
|
|||
editBlogForm+=editBlogImageSection
|
||||
editBlogForm+= \
|
||||
' <label class="labels">'+placeholderSubject+'</label><br>'
|
||||
editBlogForm+=' <input type="text" name="subject">'
|
||||
titleStr=''
|
||||
if postJsonObject['object'].get('summary'):
|
||||
titleStr=postJsonObject['object']['summary']
|
||||
editBlogForm+= \
|
||||
' <input type="text" name="subject" value="'+titleStr+'">'
|
||||
editBlogForm+=''
|
||||
editBlogForm+=' <br><label class="labels">'+placeholderMessage+'</label>'
|
||||
messageBoxHeight=800
|
||||
|
||||
contentStr=postJsonObject['object']['content']
|
||||
|
||||
editBlogForm+= \
|
||||
' <textarea id="message" name="message" style="height:'+ \
|
||||
str(messageBoxHeight)+'px"></textarea>'
|
||||
str(messageBoxHeight)+'px">'+contentStr+'</textarea>'
|
||||
editBlogForm+=dateAndLocation
|
||||
if not mediaInstance:
|
||||
editBlogForm+=editBlogImageSection
|
||||
|
|
15
daemon.py
15
daemon.py
|
@ -2380,20 +2380,25 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
actor=self.path.split('?actor=')[1]
|
||||
if '?' in actor:
|
||||
actor=actor.split('?')[0]
|
||||
actor=self.server.domainFull+'/users/'+actor
|
||||
pathWithoutOptions=self.path.split('?')[0]
|
||||
if actor in pathWithoutOptions:
|
||||
nickname=getNicknameFromActor(self.path)
|
||||
postUrl=pathWithoutOptions+'/statuses/'+messageId
|
||||
msg=htmlEditBlog(self.server.mediaInstance, \
|
||||
self.server.translate, \
|
||||
self.server.baseDir, \
|
||||
self.server.httpPrefix, \
|
||||
self.path, \
|
||||
replyPageNumber, \
|
||||
nickname,self.server.domain).encode()
|
||||
self._set_headers('text/html',len(msg),cookie)
|
||||
self._write(msg)
|
||||
self.server.GETbusy=False
|
||||
return
|
||||
nickname,self.server.domain, \
|
||||
postUrl)
|
||||
if msg:
|
||||
msg-msg.encode()
|
||||
self._set_headers('text/html',len(msg),cookie)
|
||||
self._write(msg)
|
||||
self.server.GETbusy=False
|
||||
return
|
||||
|
||||
# edit profile in web interface
|
||||
if '/users/' in self.path and self.path.endswith('/editprofile'):
|
||||
|
|
|
@ -2992,15 +2992,16 @@ def individualPostAsHtml(recentPostsCache: {},maxRecentPosts: int, \
|
|||
editStr=''
|
||||
if fullDomain+'/users/'+nickname in postJsonObject['actor']:
|
||||
if isBlogPost(postJsonObject):
|
||||
editStr+= \
|
||||
'<a href="/users/'+nickname+'?editblogpost='+ \
|
||||
postJsonObject['object']['id']+ \
|
||||
'?actor='+postJsonObject['actor']+ \
|
||||
'" title="'+translate['Edit blog post']+'">'+ \
|
||||
'<img loading="lazy" title="'+ \
|
||||
translate['Edit blog post']+' |" alt="'+ \
|
||||
translate['Edit blog post']+ \
|
||||
' |" src="/'+iconsDir+'/edit.png"/></a>'
|
||||
if '/statuses/' in postJsonObject['object']['id']:
|
||||
editStr+= \
|
||||
'<a href="/users/'+nickname+'?editblogpost='+ \
|
||||
postJsonObject['object']['id'].split('/statuses/')[1]+ \
|
||||
'?actor='+actorNickname+ \
|
||||
'" title="'+translate['Edit blog post']+'">'+ \
|
||||
'<img loading="lazy" title="'+ \
|
||||
translate['Edit blog post']+' |" alt="'+ \
|
||||
translate['Edit blog post']+ \
|
||||
' |" src="/'+iconsDir+'/edit.png"/></a>'
|
||||
|
||||
announceStr=''
|
||||
if not isModerationPost and showRepeatIcon:
|
||||
|
|
Loading…
Reference in New Issue