summaryrefslogtreecommitdiff
path: root/scripts
authorGiulio Cesare Solaroli <giulio.cesare@clipperz.com>2013-08-30 15:56:53 (UTC)
committer Giulio Cesare Solaroli <giulio.cesare@clipperz.com>2013-08-30 21:23:42 (UTC)
commit20bea94ab6b91c85b171dcf86baba0a64169d508 (patch) (unidiff)
tree6e38e91498dcdb861620eba1e237d1026fe79cc5 /scripts
parentbde3c7b98523112ade9c5bbf7390c4ecb494cd2e (diff)
downloadclipperz-20bea94ab6b91c85b171dcf86baba0a64169d508.zip
clipperz-20bea94ab6b91c85b171dcf86baba0a64169d508.tar.gz
clipperz-20bea94ab6b91c85b171dcf86baba0a64169d508.tar.bz2
First release of /delta version
Diffstat (limited to 'scripts') (more/less context) (ignore whitespace changes)
-rwxr-xr-xscripts/builder/backendBuilder.py7
-rw-r--r--[-rwxr-xr-x]scripts/builder/backends/phpBuilder.py0
-rw-r--r--scripts/builder/frontendBuilder.py73
-rw-r--r--scripts/builder/frontends/betaBuilder.py3
-rw-r--r--scripts/builder/frontends/deltaBuilder.py16
-rw-r--r--scripts/builder/frontends/gammaBuilder.py3
-rw-r--r--scripts/builder/frontends/gamma_mobileBuilder.py3
-rwxr-xr-xscripts/proxy/main.py19
8 files changed, 60 insertions, 64 deletions
diff --git a/scripts/builder/backendBuilder.py b/scripts/builder/backendBuilder.py
index b4ee990..ad6595c 100755
--- a/scripts/builder/backendBuilder.py
+++ b/scripts/builder/backendBuilder.py
@@ -65,15 +65,18 @@ class BackendBuilder(object):
65 def writeToFolder (self, folder, filename, content): 65 def writeToFolder (self, folder, filename, content):
66 file = open(os.path.join(folder, filename), 'w') 66 file = open(os.path.join(folder, filename), 'w')
67 file.write(content.encode('utf-8')) 67 file.write(content.encode('utf-8'))
68 file.close() 68 file.close()
69 69
70 70
71 def configureIndexContent (self, indexContent, requestPathPrefix = ".."): 71 #def configureIndexContent (self, indexContent, requestPathPrefix = ".."):
72 def configureIndexContent (self, indexContent):
72 result = indexContent 73 result = indexContent
73 result = result.replace( '@request.path@', requestPathPrefix + '/' + self.settings['request.path'] ) 74 # result = result.replace( '@request.path@', requestPathPrefix + '/' + self.settings['request.path'] )
75 result = result.replace( '@request.path@', self.settings['request.path'] )
76 result = result.replace( '@dump.path@', self.settings['dump.path'] )
74 result = result.replace( '@should.pay.toll@', self.settings['should.pay.toll'] ) 77 result = result.replace( '@should.pay.toll@', self.settings['should.pay.toll'] )
75 78
76 return result 79 return result
77 80
78 81
79 def formatMAC (self, value): 82 def formatMAC (self, value):
diff --git a/scripts/builder/backends/phpBuilder.py b/scripts/builder/backends/phpBuilder.py
index c928aa0..c928aa0 100755..100644
--- a/scripts/builder/backends/phpBuilder.py
+++ b/scripts/builder/backends/phpBuilder.py
diff --git a/scripts/builder/frontendBuilder.py b/scripts/builder/frontendBuilder.py
index e52c31e..b72179f 100644
--- a/scripts/builder/frontendBuilder.py
+++ b/scripts/builder/frontendBuilder.py
@@ -32,12 +32,14 @@ class FrontendBuilder(object):
32 32
33 #--------------------------------------------------------------------------- 33 #---------------------------------------------------------------------------
34 34
35 def name (self): 35 def name (self):
36 raise NotImplementedError() 36 raise NotImplementedError()
37 37
38 def projectResourceTypes (self):
39 raise NotImplementedError()
38 40
39 def copyStaticResources (self, targetFolder): 41 def copyStaticResources (self, targetFolder):
40 raise NotImplementedError() 42 raise NotImplementedError()
41 43
42 #--------------------------------------------------------------------------- 44 #---------------------------------------------------------------------------
43 45
@@ -90,15 +92,17 @@ class FrontendBuilder(object):
90 # except: 92 # except:
91 # pass 93 # pass
92 94
93 95
94 96
95 def copyResourcesToFolder (self, targetFolder): 97 def copyResourcesToFolder (self, targetFolder):
96 self.copyResources(self.projectDir, targetFolder, 'css') 98 # self.copyResources(self.projectDir, targetFolder, 'css')
97 self.copyResources(self.projectDir, targetFolder, 'js') 99 # self.copyResources(self.projectDir, targetFolder, 'js')
98 self.copyResources(self.projectDir, targetFolder, 'images') 100 # self.copyResources(self.projectDir, targetFolder, 'images')
101 for resoureceType in self.projectResourceTypes():
102 self.copyResources(self.projectDir, targetFolder, resoureceType)
99 self.copyStaticResources(targetFolder) 103 self.copyStaticResources(targetFolder)
100 104
101 105
102 def loadFilesContent (self, basePath, files): 106 def loadFilesContent (self, basePath, files):
103 result = "" 107 result = ""
104 108
@@ -240,61 +244,14 @@ class FrontendBuilder(object):
240 result = re.sub('"', '\\"', result) 244 result = re.sub('"', '\\"', result)
241 result = re.sub('\"', '%22', result) 245 result = re.sub('\"', '%22', result)
242 result = re.sub('\'', '%22', result) 246 result = re.sub('\'', '%22', result)
243 result = re.sub('\\\\', '%5c', result) 247 result = re.sub('\\\\', '%5c', result)
244 result = result.strip() 248 result = result.strip()
245 result = 'javascript:' + result 249 result = 'javascript:' + result
246
247 # replacers = [
248 # ('aForm', '_1' ),
249 # ('inputFields', '_2' ),
250 # ('passwordFieldsFound','_3' ),
251 # ('aDocument', '_6' ),
252 # ('aLevel', '_7' ),
253 # # ('result', '_8' ),
254 # ('documentForms', '_9' ),
255 # ('iFrames', '_c' ),
256 # ('anInputElement', '_d' ),
257 # ('options', '_f' ),
258 # ('option', '_12'),
259 # ('aLoginForm', '_13'),
260 # # ('action', '_17'),
261 # ('radioValues', '_18'),
262 # ('radioValueName', '_19'),
263 # ('inputElement', '_1a'),
264 # ('elementValues', '_1b'),
265 # ('radioValue', '_1c'),
266 # ('values', '_1d'),
267 # ('objtype', '_21'),
268 # ('useKey', '_27'),
269 # ('bookmarkletDiv', '_28'),
270 # ('someParameters', '_29'),
271 # ('anException', '_2a'),
272 # ('newDiv', '_2b'),
273 # ('base_url', '_2c'),
274 # ('help_url', '_2d'),
275 # ('logo_image_url', '_2e'),
276 # ('background_image_url','_2f'),
277 # ('close_image_url', '_30'),
278 # #('bookmarklet_textarea','_31'),
279 # ('innerHTML', '_32'),
280 # ]
281 # for replacer in replacers:
282 # result = re.sub('([^\.])' + replacer[0], '\\1' + replacer[1], result)
283
284 # replacers = [
285 # ('headNode', '_1' ),
286 # ('clipperzScriptNode','_2' ),
287 # ]
288 # for replacer in replacers:
289 # result = re.sub('([^\.])' + replacer[0], '\\1' + replacer[1], result)
290
291 # result = re.sub(';', ';\n', result)
292 250
293 return result 251 return result
294
295 252
296 253
297 def bookmarklet (self): 254 def bookmarklet (self):
298 cacheKey = 'bookmarklet' 255 cacheKey = 'bookmarklet'
299 if not self.processedFiles.has_key(cacheKey): 256 if not self.processedFiles.has_key(cacheKey):
300 result = 'bookmarklet="' + self.packBookmarklet(self.loadFilesContent('js', ['Bookmarklet.js']), "regular") + '";bookmarklet_ie="' + self.packBookmarklet(self.loadFilesContent('js', ['Bookmarklet_IE.js']), "IE") + '";' 257 result = 'bookmarklet="' + self.packBookmarklet(self.loadFilesContent('js', ['Bookmarklet.js']), "regular") + '";bookmarklet_ie="' + self.packBookmarklet(self.loadFilesContent('js', ['Bookmarklet_IE.js']), "IE") + '";'
@@ -385,23 +342,27 @@ class FrontendBuilder(object):
385 ) 342 )
386 jsLoadMode = 'EMBEDDED' 343 jsLoadMode = 'EMBEDDED'
387 344
388 elif assemblyMode == 'DEBUG': 345 elif assemblyMode == 'DEBUG':
389 copyright = self.assembleCopyrightHeader() 346 copyright = self.assembleCopyrightHeader()
390 css =self.cssTagsForFiles('./css', self.filterFiles(self.settings['css'])) 347 css =self.cssTagsForFiles('./css', self.filterFiles(self.settings['css']))
391 js =self.scriptTagForContent(self.bookmarklet()) + \ 348 js =self.scriptTagForContent(
392 '\n' + \ 349 self.bookmarklet()) + \
393 self.scriptTagsForFiles('./js', self.filterFiles(self.settings['js'])) 350 '\n' + \
351 self.scriptTagsForFiles('./js', self.filterFiles(self.settings['js'])
352 )
394 jsLoadMode = 'LINKED' 353 jsLoadMode = 'LINKED'
395 354
396 elif assemblyMode == 'DEVELOPMENT': 355 elif assemblyMode == 'DEVELOPMENT':
397 copyright = "" 356 copyright = ""
398 css =self.cssTagsForFiles('file://' + str(os.path.join(self.absolutePathForSources(), 'css')), self.filterFiles(self.settings['css'])) 357 css =self.cssTagsForFiles('file://' + str(os.path.join(self.absolutePathForSources(), 'css')), self.filterFiles(self.settings['css']))
399 js =self.scriptTagForContent(self.bookmarklet()) + \ 358 js =self.scriptTagForContent(
400 '\n' + \ 359 self.bookmarklet()) + \
401 self.scriptTagsForFiles('file://' + str(os.path.join(self.absolutePathForSources(), 'js')), self.filterFiles(self.settings['js'])) 360 '\n' + \
361 self.scriptTagsForFiles('file://' + str(os.path.join(self.absolutePathForSources(), 'js')), self.filterFiles(self.settings['js'])
362 )
402 jsLoadMode = 'LINKED' 363 jsLoadMode = 'LINKED'
403 versionType = 'development' 364 versionType = 'development'
404 365
405 else: 366 else:
406 raise NotImplementedError() 367 raise NotImplementedError()
407 368
diff --git a/scripts/builder/frontends/betaBuilder.py b/scripts/builder/frontends/betaBuilder.py
index c5a3e76..9b32404 100644
--- a/scripts/builder/frontends/betaBuilder.py
+++ b/scripts/builder/frontends/betaBuilder.py
@@ -3,12 +3,15 @@ import shutil
3 3
4class BetaBuilder(FrontendBuilder): 4class BetaBuilder(FrontendBuilder):
5 5
6 def name(self): 6 def name(self):
7 return "/beta builder" 7 return "/beta builder"
8 8
9 def projectResourceTypes (self):
10 return ['js', 'css', 'images']
11
9 def copyStaticResources (self, targetFolder): 12 def copyStaticResources (self, targetFolder):
10 for file in self.filterFiles(self.settings['staticResources']): 13 for file in self.filterFiles(self.settings['staticResources']):
11 src = self.absolutePathForSourceFile('staticResources', file) 14 src = self.absolutePathForSourceFile('staticResources', file)
12 dst = self.absolutePathForTargetFile(targetFolder, '', file) 15 dst = self.absolutePathForTargetFile(targetFolder, '', file)
13 shutil.copy2(src, dst) 16 shutil.copy2(src, dst)
14 17
diff --git a/scripts/builder/frontends/deltaBuilder.py b/scripts/builder/frontends/deltaBuilder.py
new file mode 100644
index 0000000..a341a83
--- a/dev/null
+++ b/scripts/builder/frontends/deltaBuilder.py
@@ -0,0 +1,16 @@
1from frontendBuilder import FrontendBuilder
2import shutil
3
4class DeltaBuilder(FrontendBuilder):
5
6 def name(self):
7 return "/delta builder"
8
9 def projectResourceTypes (self):
10 return ['js', 'css']
11
12 def copyStaticResources (self, targetFolder):
13 pass
14
15 def bookmarklet (self):
16 return "" \ No newline at end of file
diff --git a/scripts/builder/frontends/gammaBuilder.py b/scripts/builder/frontends/gammaBuilder.py
index a6ecb7b..c56fb1b 100644
--- a/scripts/builder/frontends/gammaBuilder.py
+++ b/scripts/builder/frontends/gammaBuilder.py
@@ -3,12 +3,15 @@ import shutil
3 3
4class GammaBuilder(FrontendBuilder): 4class GammaBuilder(FrontendBuilder):
5 5
6 def name(self): 6 def name(self):
7 return "/gamma builder" 7 return "/gamma builder"
8 8
9 def projectResourceTypes (self):
10 return ['js', 'css', 'images']
11
9 def copyStaticResources (self, targetFolder): 12 def copyStaticResources (self, targetFolder):
10 resourcesToCopy = [ 13 resourcesToCopy = [
11 # {'folder': 'html', 'source': 'exit_template.html','target': 'exit.html'}, 14 # {'folder': 'html', 'source': 'exit_template.html','target': 'exit.html'},
12 {'folder': 'html', 'source': 'exit_template.html','target': 'logout.html'}, 15 {'folder': 'html', 'source': 'exit_template.html','target': 'logout.html'},
13 {'folder': 'css', 'source': 'static.css', 'target': 'static.css'} 16 {'folder': 'css', 'source': 'static.css', 'target': 'static.css'}
14 ] 17 ]
diff --git a/scripts/builder/frontends/gamma_mobileBuilder.py b/scripts/builder/frontends/gamma_mobileBuilder.py
index f2e80c9..677a2b0 100644
--- a/scripts/builder/frontends/gamma_mobileBuilder.py
+++ b/scripts/builder/frontends/gamma_mobileBuilder.py
@@ -2,8 +2,11 @@ from frontendBuilder import FrontendBuilder
2 2
3class Gamma_MobileBuilder(FrontendBuilder): 3class Gamma_MobileBuilder(FrontendBuilder):
4 4
5 def name(self): 5 def name(self):
6 return "/gamma.mobile builder" 6 return "/gamma.mobile builder"
7 7
8 def projectResourceTypes (self):
9 return ['js', 'css', 'images']
10
8 def copyStaticResources (self, targetFolder): 11 def copyStaticResources (self, targetFolder):
9 pass 12 pass
diff --git a/scripts/proxy/main.py b/scripts/proxy/main.py
index 107ba16..8ce4989 100755
--- a/scripts/proxy/main.py
+++ b/scripts/proxy/main.py
@@ -24,26 +24,33 @@ 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 if request.uri.startswith('/json') or request.uri.startswith('/dump'): 30 uri = request.uri
31 uri = uri.split("?", 1)[0]
32 uri = uri.split("#", 1)[0]
33 if uri.startswith('/json') or uri.startswith('/dump'):
31 request.site = self 34 request.site = self
32 request.sitepath = copy.copy(request.prepath) 35 request.sitepath = copy.copy(request.prepath)
33 result = resource.getChildForRequest(self.resource, request) 36 result = resource.getChildForRequest(self.resource, request)
34 37
35 else: 38 else:
36 pathParts = request.uri.split('/') 39 pathParts = uri.split('/')
37 version = pathParts[1] 40 version = pathParts[1]
38 41
39 if pathParts[2].startswith('index.'): 42 if pathParts[2].startswith('index.'):
40 contentType = 'text/html' 43 contentType = 'text/html'
41 absoluteFilePath = os.path.join(projectTargetDir(), 'dev', version, pathParts[2]) 44 absoluteFilePath = os.path.join(projectTargetDir(), 'dev', version, pathParts[2])
42 result = static.File(absoluteFilePath, contentType) 45 result = static.File(absoluteFilePath, contentType)
43 46 elif pathParts[2].endswith('.webapp'):
47 contentType = 'application/x-web-app-manifest+json'
48 # absoluteFilePath = os.path.join(projectTargetDir(), 'dev', version, pathParts[2])
49 absoluteFilePath = os.path.join(projectBaseDir(), 'frontend', version, 'properties', pathParts[2])
50 result = static.File(absoluteFilePath, contentType)
44 else: 51 else:
45 #http://homer.local:8888/beta/css/clipperz/images/loginInfoBackground.png 52 #http://homer.local:8888/beta/css/clipperz/images/loginInfoBackground.png
46 #pathParts: ['', 'beta', 'css', 'clipperz', 'images', 'loginInfoBackground.png'] 53 #pathParts: ['', 'beta', 'css', 'clipperz', 'images', 'loginInfoBackground.png']
47 try: 54 try:
48 imagePathIndex = pathParts.index('images') 55 imagePathIndex = pathParts.index('images')
49 resourceType = 'images' 56 resourceType = 'images'
@@ -51,13 +58,13 @@ class ClipperzTestSite(server.Site):
51 del pathParts[2] 58 del pathParts[2]
52 except: 59 except:
53 resourceType = pathParts[2] 60 resourceType = pathParts[2]
54 61
55 basePath = projectBaseDir() + '/frontend' 62 basePath = projectBaseDir() + '/frontend'
56 if resourceType == 'images': 63 if resourceType == 'images':
57 fileExtension = os.path.splitext(request.uri)[1] 64 fileExtension = os.path.splitext(uri)[1]
58 if fileExtension == '.png': 65 if fileExtension == '.png':
59 contentType = 'image/png' 66 contentType = 'image/png'
60 elif fileExtension == '.jpg': 67 elif fileExtension == '.jpg':
61 contentType = 'image/jpeg' 68 contentType = 'image/jpeg'
62 elif fileExtension == '.gif': 69 elif fileExtension == '.gif':
63 contentType = 'image/gif' 70 contentType = 'image/gif'
@@ -72,23 +79,23 @@ class ClipperzTestSite(server.Site):
72 contentType = 'text/css' 79 contentType = 'text/css'
73 elif resourceType == 'js': 80 elif resourceType == 'js':
74 contentType = 'text/javascript' 81 contentType = 'text/javascript'
75 else: 82 else:
76 contentType = 'text/html' 83 contentType = 'text/html'
77 84
78 absoluteFilePath = basePath + request.uri 85 absoluteFilePath = basePath + uri
79 86
80 result = static.File(absoluteFilePath, contentType) 87 result = static.File(absoluteFilePath, contentType)
81 88
82 89
83 return result 90 return result
84 91
85 92
86 93
87def main (): 94def main ():
88 site = ClipperzTestSite(proxy.ReverseProxyResource('localhost', 8084, '/java-backend')) 95 site = ClipperzTestSite(proxy.ReverseProxyResource('localhost', 8080, '/java-backend'))
89 reactor.listenTCP(8888, site) 96 reactor.listenTCP(8888, site)
90 reactor.run() 97 reactor.run()
91 98
92 99
93if __name__ == "__main__": 100if __name__ == "__main__":
94 main() 101 main()