summaryrefslogtreecommitdiff
path: root/scripts/proxy/main.py
authorGiulio Cesare Solaroli <giulio.cesare@clipperz.com>2013-10-02 07:59:30 (UTC)
committer Giulio Cesare Solaroli <giulio.cesare@clipperz.com>2013-10-02 07:59:30 (UTC)
commit1180b7b195157aaeb4f0d5380e0c886bbd06c2e2 (patch) (side-by-side diff)
tree709e33a09d9325d382aabaf0a0828e20ebdb96db /scripts/proxy/main.py
parent20bea94ab6b91c85b171dcf86baba0a64169d508 (diff)
downloadclipperz-1180b7b195157aaeb4f0d5380e0c886bbd06c2e2.zip
clipperz-1180b7b195157aaeb4f0d5380e0c886bbd06c2e2.tar.gz
clipperz-1180b7b195157aaeb4f0d5380e0c886bbd06c2e2.tar.bz2
Updated /delta
Switched from less to scss. Still no build script to update the final CSS, though. Added preliminary support for storing account data on browser's local storage for offline viewing. No public backend currently support this feature.
Diffstat (limited to 'scripts/proxy/main.py') (more/less context) (ignore whitespace changes)
-rwxr-xr-xscripts/proxy/main.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/scripts/proxy/main.py b/scripts/proxy/main.py
index 8ce4989..58a4d7f 100755
--- a/scripts/proxy/main.py
+++ b/scripts/proxy/main.py
@@ -27,76 +27,81 @@ class ClipperzTestSite(server.Site):
def getResourceFor(self, request):
uri = request.uri
uri = uri.split("?", 1)[0]
uri = uri.split("#", 1)[0]
if uri.startswith('/json') or uri.startswith('/dump'):
request.site = self
request.sitepath = copy.copy(request.prepath)
result = resource.getChildForRequest(self.resource, request)
else:
pathParts = uri.split('/')
version = pathParts[1]
if pathParts[2].startswith('index.'):
contentType = 'text/html'
absoluteFilePath = os.path.join(projectTargetDir(), 'dev', version, pathParts[2])
result = static.File(absoluteFilePath, contentType)
elif pathParts[2].endswith('.webapp'):
contentType = 'application/x-web-app-manifest+json'
# absoluteFilePath = os.path.join(projectTargetDir(), 'dev', version, pathParts[2])
absoluteFilePath = os.path.join(projectBaseDir(), 'frontend', version, 'properties', pathParts[2])
result = static.File(absoluteFilePath, contentType)
+ elif pathParts[2].endswith('.appcache'):
+ contentType = 'text/cache-manifest'
+ absoluteFilePath = os.path.join(projectBaseDir(), 'frontend', version, 'properties', pathParts[2])
+ result = static.File(absoluteFilePath, contentType)
else:
# http://homer.local:8888/beta/css/clipperz/images/loginInfoBackground.png
# pathParts: ['', 'beta', 'css', 'clipperz', 'images', 'loginInfoBackground.png']
try:
imagePathIndex = pathParts.index('images')
resourceType = 'images'
for _ in range(2, imagePathIndex):
del pathParts[2]
except:
resourceType = pathParts[2]
basePath = projectBaseDir() + '/frontend'
if resourceType == 'images':
fileExtension = os.path.splitext(uri)[1]
if fileExtension == '.png':
contentType = 'image/png'
elif fileExtension == '.jpg':
contentType = 'image/jpeg'
elif fileExtension == '.gif':
contentType = 'image/gif'
else:
print "ERROR - unknown image extension: " + fileExtension
absoluteFilePath = basePath + '/'.join(pathParts)
else:
resourceType = pathParts[2]
if resourceType == 'css':
contentType = 'text/css'
elif resourceType == 'js':
contentType = 'text/javascript'
else:
contentType = 'text/html'
absoluteFilePath = basePath + uri
result = static.File(absoluteFilePath, contentType)
return result
def main ():
site = ClipperzTestSite(proxy.ReverseProxyResource('localhost', 8080, '/java-backend'))
+# site = ClipperzTestSite(proxy.ReverseProxyResource('www.clipperz.com', 443, '/'))
reactor.listenTCP(8888, site)
reactor.run()
if __name__ == "__main__":
main()