mirror of https://gitlab.com/bashrc2/epicyon
Screen for confirming removal of shared item
parent
91ee36f638
commit
2f336bc33f
15
daemon.py
15
daemon.py
|
@ -76,6 +76,7 @@ from roles import setRole
|
||||||
from roles import clearModeratorStatus
|
from roles import clearModeratorStatus
|
||||||
from skills import outboxSkills
|
from skills import outboxSkills
|
||||||
from availability import outboxAvailability
|
from availability import outboxAvailability
|
||||||
|
from webinterface import htmlRemoveSharedItem
|
||||||
from webinterface import htmlInboxDMs
|
from webinterface import htmlInboxDMs
|
||||||
from webinterface import htmlUnblockConfirm
|
from webinterface import htmlUnblockConfirm
|
||||||
from webinterface import htmlPersonOptions
|
from webinterface import htmlPersonOptions
|
||||||
|
@ -979,6 +980,20 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self._redirect_headers(actor+'/inbox',cookie)
|
self._redirect_headers(actor+'/inbox',cookie)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# remove a shared item
|
||||||
|
if htmlGET and '?rmshare=' in self.path:
|
||||||
|
shareName=self.path.split('?rmshare=')[1]
|
||||||
|
actor=self.server.httpPrefix+'://'+self.server.domainFull+self.path.split('?rmshare=')[0]
|
||||||
|
msg=htmlRemoveSharedItem(self.server.baseDir,actor,shareName).encode()
|
||||||
|
if not msg:
|
||||||
|
self._redirect_headers(actor+'/inbox',cookie)
|
||||||
|
self.server.GETbusy=False
|
||||||
|
return
|
||||||
|
self._set_headers('text/html',len(msg),cookie)
|
||||||
|
self.wfile.write(msg)
|
||||||
|
self.server.GETbusy=False
|
||||||
|
return
|
||||||
|
|
||||||
# delete a post from the web interface icon
|
# delete a post from the web interface icon
|
||||||
if htmlGET and '?delete=' in self.path:
|
if htmlGET and '?delete=' in self.path:
|
||||||
deleteUrl=self.path.split('?delete=')[1]
|
deleteUrl=self.path.split('?delete=')[1]
|
||||||
|
|
|
@ -149,8 +149,10 @@ def htmlSearchSharedItems(baseDir: str,searchStr: str, \
|
||||||
sharedItemsForm+='<b>Category:</b> '+sharedItem['category']+' '
|
sharedItemsForm+='<b>Category:</b> '+sharedItem['category']+' '
|
||||||
sharedItemsForm+='<b>Location:</b> '+sharedItem['location']+'</p>'
|
sharedItemsForm+='<b>Location:</b> '+sharedItem['location']+'</p>'
|
||||||
contactActor=httpPrefix+'://'+domainFull+'/users/'+contactNickname
|
contactActor=httpPrefix+'://'+domainFull+'/users/'+contactNickname
|
||||||
sharedItemsForm+='<p><a href="'+actor+'?replydm=sharedesc:'+sharedItem['displayName']+'?mention='+contactActor+'">Contact</a>'
|
sharedItemsForm+='<p><a href="'+actor+'?replydm=sharedesc:'+sharedItem['displayName']+'?mention='+contactActor+'"><button class="button">Contact</button></a>'
|
||||||
sharedItemsForm+='</div>'
|
if actor.endswith('/users/'+contactNickname):
|
||||||
|
sharedItemsForm+=' <a href="'+actor+'?rmshare='+name+'"><button class="button">Remove</button></a>'
|
||||||
|
sharedItemsForm+='</p></div>'
|
||||||
if not resultsExist and currPage>1:
|
if not resultsExist and currPage>1:
|
||||||
# previous page link, needs to be a POST
|
# previous page link, needs to be a POST
|
||||||
sharedItemsForm+= \
|
sharedItemsForm+= \
|
||||||
|
@ -1583,6 +1585,52 @@ def htmlPostReplies(baseDir: str,session,wfRequest: {},personCache: {}, \
|
||||||
|
|
||||||
return htmlHeader()+repliesStr+htmlFooter()
|
return htmlHeader()+repliesStr+htmlFooter()
|
||||||
|
|
||||||
|
def htmlRemoveSharedItem(baseDir: str,actor: str,shareName: str) -> str:
|
||||||
|
"""Shows a screen asking to confirm the removal of a shared item
|
||||||
|
"""
|
||||||
|
nickname=getNicknameFromActor(actor)
|
||||||
|
domain,port=getDomainFromActor(actor)
|
||||||
|
sharesFile=baseDir+'/accounts/'+nickname+'@'+domain+'/shares.json'
|
||||||
|
if not os.path.isfile(sharesFile):
|
||||||
|
return None
|
||||||
|
sharesJson=None
|
||||||
|
with open(sharesFile, 'r') as fp:
|
||||||
|
sharesJson=commentjson.load(fp)
|
||||||
|
if not sharesJson:
|
||||||
|
return None
|
||||||
|
if not sharesJson.get(shareName):
|
||||||
|
return None
|
||||||
|
sharedItemDisplayName=sharesJson[shareName]['displayName']
|
||||||
|
sharedItemImageUrl=None
|
||||||
|
if sharesJson[shareName].get('imageUrl'):
|
||||||
|
sharedItemImageUrl=sharesJson[shareName]['imageUrl']
|
||||||
|
|
||||||
|
if os.path.isfile(baseDir+'/img/shares-background.png'):
|
||||||
|
if not os.path.isfile(baseDir+'/accounts/shares-background.png'):
|
||||||
|
copyfile(baseDir+'/img/shares-background.png',baseDir+'/accounts/shares-background.png')
|
||||||
|
|
||||||
|
with open(baseDir+'/epicyon-follow.css', 'r') as cssFile:
|
||||||
|
profileStyle = cssFile.read()
|
||||||
|
sharesStr=htmlHeader(profileStyle)
|
||||||
|
sharesStr+='<div class="follow">'
|
||||||
|
sharesStr+=' <div class="followAvatar">'
|
||||||
|
sharesStr+=' <center>'
|
||||||
|
if sharedItemImageUrl:
|
||||||
|
sharesStr+=' <img src="'+sharedItemImageUrl+'"/>'
|
||||||
|
sharesStr+=' <p class="followText">Remove '+sharedItemDisplayName+' ?</p>'
|
||||||
|
sharesStr+= \
|
||||||
|
' <form method="POST" action="'+actor+'/rmshare">' \
|
||||||
|
' <input type="hidden" name="actor" value="'+actor+'">' \
|
||||||
|
' <input type="hidden" name="shareName" value="'+shareName+'">' \
|
||||||
|
' <button type="submit" class="button" name="submitYes">Yes</button>' \
|
||||||
|
' <a href="'+actor+'/inbox'+'"><button class="button">No</button></a>' \
|
||||||
|
' </form>'
|
||||||
|
sharesStr+=' </center>'
|
||||||
|
sharesStr+=' </div>'
|
||||||
|
sharesStr+='</div>'
|
||||||
|
sharesStr+=htmlFooter()
|
||||||
|
return sharesStr
|
||||||
|
|
||||||
def htmlFollowConfirm(baseDir: str,originPathStr: str,followActor: str,followProfileUrl: str) -> str:
|
def htmlFollowConfirm(baseDir: str,originPathStr: str,followActor: str,followProfileUrl: str) -> str:
|
||||||
"""Asks to confirm a follow
|
"""Asks to confirm a follow
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue