Full path on shares images

master
Bob Mottram 2019-07-25 17:15:02 +01:00
parent eeba9b5214
commit 8572c235f1
3 changed files with 21 additions and 13 deletions

View File

@ -382,12 +382,13 @@ class PubServer(BaseHTTPRequestHandler):
# if not authorized then show the login screen
if self.headers.get('Accept'):
if 'text/html' in self.headers['Accept'] and self.path!='/login':
if not authorized:
self.send_response(303)
self.send_header('Location', '/login')
self.end_headers()
self.server.POSTbusy=False
return
if '/media/' not in self.path and 'sharefiles' not in self.path:
if not authorized:
self.send_response(303)
self.send_header('Location', '/login')
self.end_headers()
self.server.POSTbusy=False
return
# get css
# Note that this comes before the busy flag to avoid conflicts

View File

@ -1154,7 +1154,8 @@ if args.testdata:
setRole(baseDir,nickname,domain,'someproject','assistant')
setAvailability(baseDir,nickname,domain,'busy')
addShare(baseDir,nickname,domain, \
addShare(baseDir, \
httpPrefix,nickname,domain,port, \
"spanner", \
"It's a spanner", \
"img/shares1.png", \
@ -1163,7 +1164,8 @@ if args.testdata:
"City", \
"2 months",
debug)
addShare(baseDir,nickname,domain, \
addShare(baseDir, \
httpPrefix,nickname,domain,port, \
"witch hat", \
"Spooky", \
"img/shares2.png", \

View File

@ -45,7 +45,8 @@ def removeShare(baseDir: str,nickname: str,domain: str, \
with open(sharesFilename, 'w') as fp:
commentjson.dump(sharesJson, fp, indent=4, sort_keys=True)
def addShare(baseDir: str,nickname: str,domain: str, \
def addShare(baseDir: str, \
httpPrefix: str,nickname: str,domain: str,port: int, \
displayName: str, \
summary: str, \
imageFilename: str, \
@ -99,6 +100,9 @@ def addShare(baseDir: str,nickname: str,domain: str, \
# copy or move the image for the shared item to its destination
if imageFilename:
if os.path.isfile(imageFilename):
domainFull=domain
if port!=80 and port!=443:
domainFull=domain+':'+str(port)
if not os.path.isdir(baseDir+'/sharefiles'):
os.mkdir(baseDir+'/sharefiles')
if not os.path.isdir(baseDir+'/sharefiles/'+nickname):
@ -108,17 +112,17 @@ def addShare(baseDir: str,nickname: str,domain: str, \
removeMetaData(imageFilename,itemIDfile+'.png')
if moveImage:
os.remove(imageFilename)
imageUrl='/sharefiles/'+nickname+'/'+itemID+'.png'
imageUrl=httpPrefix+'://'+domainFull+'/sharefiles/'+nickname+'/'+itemID+'.png'
if imageFilename.endswith('.jpg'):
removeMetaData(imageFilename,itemIDfile+'.jpg')
if moveImage:
os.remove(imageFilename)
imageUrl='/sharefiles/'+nickname+'/'+itemID+'.jpg'
imageUrl=httpPrefix+'://'+domainFull+'/sharefiles/'+nickname+'/'+itemID+'.jpg'
if imageFilename.endswith('.gif'):
removeMetaData(imageFilename,itemIDfile+'.gif')
if moveImage:
os.remove(imageFilename)
imageUrl='/sharefiles/'+nickname+'/'+itemID+'.gif'
imageUrl=httpPrefix+'://'+domainFull+'/sharefiles/'+nickname+'/'+itemID+'.gif'
sharesJson[itemID] = {
"displayName": displayName,
@ -469,7 +473,8 @@ def outboxShareUpload(baseDir: str,httpPrefix: str, \
if debug:
print('DEBUG: duration missing from Offer')
return
addShare(baseDir,nickname,domain, \
addShare(baseDir, \
httpPrefix,nickname,domain,port, \
messageJson['object']['displayName'], \
messageJson['object']['summary'], \
messageJson['object']['imageFilename'], \