author | Giulio 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) |
commit | 1180b7b195157aaeb4f0d5380e0c886bbd06c2e2 (patch) (unidiff) | |
tree | 709e33a09d9325d382aabaf0a0828e20ebdb96db /scripts | |
parent | 20bea94ab6b91c85b171dcf86baba0a64169d508 (diff) | |
download | clipperz-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.
-rw-r--r-- | scripts/builder/frontends/deltaBuilder.py | 9 | ||||
-rwxr-xr-x | scripts/proxy/main.py | 5 |
2 files changed, 13 insertions, 1 deletions
diff --git a/scripts/builder/frontends/deltaBuilder.py b/scripts/builder/frontends/deltaBuilder.py index a341a83..17ac941 100644 --- a/scripts/builder/frontends/deltaBuilder.py +++ b/scripts/builder/frontends/deltaBuilder.py | |||
@@ -1,16 +1,23 @@ | |||
1 | from frontendBuilder import FrontendBuilder | 1 | from frontendBuilder import FrontendBuilder |
2 | import shutil | 2 | import shutil |
3 | 3 | ||
4 | class DeltaBuilder(FrontendBuilder): | 4 | class DeltaBuilder(FrontendBuilder): |
5 | 5 | ||
6 | def name(self): | 6 | def name(self): |
7 | return "/delta builder" | 7 | return "/delta builder" |
8 | 8 | ||
9 | def projectResourceTypes (self): | 9 | def projectResourceTypes (self): |
10 | return ['js', 'css'] | 10 | return ['js', 'css'] |
11 | 11 | ||
12 | def copyStaticResources (self, targetFolder): | 12 | def copyStaticResources (self, targetFolder): |
13 | pass | 13 | resourcesToCopy = [ |
14 | {'folder': 'properties', 'source': 'manifest.appcache','target': 'manifest.appcache'} | ||
15 | ] | ||
16 | |||
17 | for resource in resourcesToCopy: | ||
18 | src = self.absolutePathForSourceFile(resource['folder'], resource['source']) | ||
19 | dst = self.absolutePathForTargetFile(targetFolder, '', resource['target']) | ||
20 | shutil.copy2(src, dst) | ||
14 | 21 | ||
15 | def bookmarklet (self): | 22 | def bookmarklet (self): |
16 | return "" \ No newline at end of file | 23 | return "" \ No newline at end of file |
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 | |||
@@ -1,102 +1,107 @@ | |||
1 | from twisted.internet import reactor | 1 | from twisted.internet import reactor |
2 | from twisted.web import proxy, server, http, resource, static | 2 | from twisted.web import proxy, server, http, resource, static |
3 | from posixpath import basename, dirname | 3 | from posixpath import basename, dirname |
4 | 4 | ||
5 | import copy | 5 | import copy |
6 | import sys | 6 | import sys |
7 | import os | 7 | import os |
8 | import pprint | 8 | import pprint |
9 | 9 | ||
10 | #-------------------------------------------------------------------- | 10 | #-------------------------------------------------------------------- |
11 | 11 | ||
12 | def scriptDir (): | 12 | def scriptDir (): |
13 | return os.path.dirname(sys.argv[0]) | 13 | return os.path.dirname(sys.argv[0]) |
14 | 14 | ||
15 | def projectBaseDir (): | 15 | def projectBaseDir (): |
16 | return os.path.abspath(scriptDir() + '/../..') | 16 | return os.path.abspath(scriptDir() + '/../..') |
17 | 17 | ||
18 | def projectTargetDir(): | 18 | def projectTargetDir(): |
19 | return projectBaseDir() + '/target/' | 19 | return projectBaseDir() + '/target/' |
20 | 20 | ||
21 | #-------------------------------------------------------------------- | 21 | #-------------------------------------------------------------------- |
22 | 22 | ||
23 | class ClipperzTestSite(server.Site): | 23 | class ClipperzTestSite(server.Site): |
24 | 24 | ||
25 | def __init__(self, resource, logPath=None, timeout=60 * 60 * 12): | 25 | def __init__(self, resource, logPath=None, timeout=60 * 60 * 12): |
26 | server.Site.__init__(self, resource, logPath, timeout) | 26 | server.Site.__init__(self, resource, logPath, timeout) |
27 | 27 | ||
28 | 28 | ||
29 | def getResourceFor(self, request): | 29 | def getResourceFor(self, request): |
30 | uri = request.uri | 30 | uri = request.uri |
31 | uri = uri.split("?", 1)[0] | 31 | uri = uri.split("?", 1)[0] |
32 | uri = uri.split("#", 1)[0] | 32 | uri = uri.split("#", 1)[0] |
33 | if uri.startswith('/json') or uri.startswith('/dump'): | 33 | if uri.startswith('/json') or uri.startswith('/dump'): |
34 | request.site = self | 34 | request.site = self |
35 | request.sitepath = copy.copy(request.prepath) | 35 | request.sitepath = copy.copy(request.prepath) |
36 | result = resource.getChildForRequest(self.resource, request) | 36 | result = resource.getChildForRequest(self.resource, request) |
37 | 37 | ||
38 | else: | 38 | else: |
39 | pathParts = uri.split('/') | 39 | pathParts = uri.split('/') |
40 | version = pathParts[1] | 40 | version = pathParts[1] |
41 | 41 | ||
42 | if pathParts[2].startswith('index.'): | 42 | if pathParts[2].startswith('index.'): |
43 | contentType = 'text/html' | 43 | contentType = 'text/html' |
44 | absoluteFilePath = os.path.join(projectTargetDir(), 'dev', version, pathParts[2]) | 44 | absoluteFilePath = os.path.join(projectTargetDir(), 'dev', version, pathParts[2]) |
45 | result = static.File(absoluteFilePath, contentType) | 45 | result = static.File(absoluteFilePath, contentType) |
46 | elif pathParts[2].endswith('.webapp'): | 46 | elif pathParts[2].endswith('.webapp'): |
47 | contentType = 'application/x-web-app-manifest+json' | 47 | contentType = 'application/x-web-app-manifest+json' |
48 | # absoluteFilePath = os.path.join(projectTargetDir(), 'dev', version, pathParts[2]) | 48 | # absoluteFilePath = os.path.join(projectTargetDir(), 'dev', version, pathParts[2]) |
49 | absoluteFilePath = os.path.join(projectBaseDir(), 'frontend', version, 'properties', pathParts[2]) | 49 | absoluteFilePath = os.path.join(projectBaseDir(), 'frontend', version, 'properties', pathParts[2]) |
50 | result = static.File(absoluteFilePath, contentType) | 50 | result = static.File(absoluteFilePath, contentType) |
51 | elif pathParts[2].endswith('.appcache'): | ||
52 | contentType = 'text/cache-manifest' | ||
53 | absoluteFilePath = os.path.join(projectBaseDir(), 'frontend', version, 'properties', pathParts[2]) | ||
54 | result = static.File(absoluteFilePath, contentType) | ||
51 | else: | 55 | else: |
52 | #http://homer.local:8888/beta/css/clipperz/images/loginInfoBackground.png | 56 | #http://homer.local:8888/beta/css/clipperz/images/loginInfoBackground.png |
53 | #pathParts: ['', 'beta', 'css', 'clipperz', 'images', 'loginInfoBackground.png'] | 57 | #pathParts: ['', 'beta', 'css', 'clipperz', 'images', 'loginInfoBackground.png'] |
54 | try: | 58 | try: |
55 | imagePathIndex = pathParts.index('images') | 59 | imagePathIndex = pathParts.index('images') |
56 | resourceType = 'images' | 60 | resourceType = 'images' |
57 | for _ in range(2, imagePathIndex): | 61 | for _ in range(2, imagePathIndex): |
58 | del pathParts[2] | 62 | del pathParts[2] |
59 | except: | 63 | except: |
60 | resourceType = pathParts[2] | 64 | resourceType = pathParts[2] |
61 | 65 | ||
62 | basePath = projectBaseDir() + '/frontend' | 66 | basePath = projectBaseDir() + '/frontend' |
63 | if resourceType == 'images': | 67 | if resourceType == 'images': |
64 | fileExtension = os.path.splitext(uri)[1] | 68 | fileExtension = os.path.splitext(uri)[1] |
65 | if fileExtension == '.png': | 69 | if fileExtension == '.png': |
66 | contentType = 'image/png' | 70 | contentType = 'image/png' |
67 | elif fileExtension == '.jpg': | 71 | elif fileExtension == '.jpg': |
68 | contentType = 'image/jpeg' | 72 | contentType = 'image/jpeg' |
69 | elif fileExtension == '.gif': | 73 | elif fileExtension == '.gif': |
70 | contentType = 'image/gif' | 74 | contentType = 'image/gif' |
71 | else: | 75 | else: |
72 | print "ERROR - unknown image extension: " + fileExtension | 76 | print "ERROR - unknown image extension: " + fileExtension |
73 | 77 | ||
74 | absoluteFilePath = basePath + '/'.join(pathParts) | 78 | absoluteFilePath = basePath + '/'.join(pathParts) |
75 | else: | 79 | else: |
76 | resourceType = pathParts[2] | 80 | resourceType = pathParts[2] |
77 | 81 | ||
78 | if resourceType == 'css': | 82 | if resourceType == 'css': |
79 | contentType = 'text/css' | 83 | contentType = 'text/css' |
80 | elif resourceType == 'js': | 84 | elif resourceType == 'js': |
81 | contentType = 'text/javascript' | 85 | contentType = 'text/javascript' |
82 | else: | 86 | else: |
83 | contentType = 'text/html' | 87 | contentType = 'text/html' |
84 | 88 | ||
85 | absoluteFilePath = basePath + uri | 89 | absoluteFilePath = basePath + uri |
86 | 90 | ||
87 | result = static.File(absoluteFilePath, contentType) | 91 | result = static.File(absoluteFilePath, contentType) |
88 | 92 | ||
89 | 93 | ||
90 | return result | 94 | return result |
91 | 95 | ||
92 | 96 | ||
93 | 97 | ||
94 | def main (): | 98 | def main (): |
95 | site = ClipperzTestSite(proxy.ReverseProxyResource('localhost', 8080, '/java-backend')) | 99 | site = ClipperzTestSite(proxy.ReverseProxyResource('localhost', 8080, '/java-backend')) |
100 | #site = ClipperzTestSite(proxy.ReverseProxyResource('www.clipperz.com', 443, '/')) | ||
96 | reactor.listenTCP(8888, site) | 101 | reactor.listenTCP(8888, site) |
97 | reactor.run() | 102 | reactor.run() |
98 | 103 | ||
99 | 104 | ||
100 | if __name__ == "__main__": | 105 | if __name__ == "__main__": |
101 | main() | 106 | main() |
102 | 107 | ||