From 8572c235f14305d55fac2c93e440e00a44dd52a9 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 25 Jul 2019 17:15:02 +0100 Subject: [PATCH] Full path on shares images --- daemon.py | 13 +++++++------ epicyon.py | 6 ++++-- shares.py | 15 ++++++++++----- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/daemon.py b/daemon.py index 2ac5224c..54fe9875 100644 --- a/daemon.py +++ b/daemon.py @@ -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 diff --git a/epicyon.py b/epicyon.py index dc2f77f9..59def645 100644 --- a/epicyon.py +++ b/epicyon.py @@ -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", \ diff --git a/shares.py b/shares.py index 674487e2..e35f59c4 100644 --- a/shares.py +++ b/shares.py @@ -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'], \