-rwxr-xr-x | scripts/builder/backendBuilder.py | 7 | ||||
-rw-r--r--[-rwxr-xr-x] | scripts/builder/backends/phpBuilder.py | 0 | ||||
-rw-r--r-- | scripts/builder/frontendBuilder.py | 73 | ||||
-rw-r--r-- | scripts/builder/frontends/betaBuilder.py | 3 | ||||
-rw-r--r-- | scripts/builder/frontends/deltaBuilder.py | 16 | ||||
-rw-r--r-- | scripts/builder/frontends/gammaBuilder.py | 3 | ||||
-rw-r--r-- | scripts/builder/frontends/gamma_mobileBuilder.py | 3 | ||||
-rwxr-xr-x | scripts/proxy/main.py | 19 |
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 | |||
@@ -1,145 +1,148 @@ | |||
1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python |
2 | # -*- coding: UTF-8 -*- | 2 | # -*- coding: UTF-8 -*- |
3 | 3 | ||
4 | import sys, os, json | 4 | import sys, os, json |
5 | import shutil | 5 | import shutil |
6 | import hashlib | 6 | import hashlib |
7 | 7 | ||
8 | from functools import reduce | 8 | from functools import reduce |
9 | from operator import add | 9 | from operator import add |
10 | from itertools import izip | 10 | from itertools import izip |
11 | 11 | ||
12 | import main | 12 | import main |
13 | 13 | ||
14 | #=================================================================== | 14 | #=================================================================== |
15 | 15 | ||
16 | class BackendBuilder(object): | 16 | class BackendBuilder(object): |
17 | 17 | ||
18 | def __init__ (self, projectTargetDir, frontends, versions, settings): | 18 | def __init__ (self, projectTargetDir, frontends, versions, settings): |
19 | self.projectTargetDir = projectTargetDir | 19 | self.projectTargetDir = projectTargetDir |
20 | self.frontends = frontends | 20 | self.frontends = frontends |
21 | self.versions = versions | 21 | self.versions = versions |
22 | self.settings = settings | 22 | self.settings = settings |
23 | 23 | ||
24 | # -------------------------------------------------------------------------- | 24 | # -------------------------------------------------------------------------- |
25 | 25 | ||
26 | def name (self): | 26 | def name (self): |
27 | raise NotImplementedError() | 27 | raise NotImplementedError() |
28 | 28 | ||
29 | 29 | ||
30 | def relativePath (self): | 30 | def relativePath (self): |
31 | raise NotImplementedError() | 31 | raise NotImplementedError() |
32 | 32 | ||
33 | 33 | ||
34 | def compileCode (self): | 34 | def compileCode (self): |
35 | raise NotImplementedError() | 35 | raise NotImplementedError() |
36 | 36 | ||
37 | 37 | ||
38 | def createPackage (self): | 38 | def createPackage (self): |
39 | raise NotImplementedError() | 39 | raise NotImplementedError() |
40 | 40 | ||
41 | # -------------------------------------------------------------------------- | 41 | # -------------------------------------------------------------------------- |
42 | 42 | ||
43 | def sourceFolder (self): | 43 | def sourceFolder (self): |
44 | return os.path.join(main.projectBaseDir() , 'backend', self.relativePath(), 'src') | 44 | return os.path.join(main.projectBaseDir() , 'backend', self.relativePath(), 'src') |
45 | 45 | ||
46 | 46 | ||
47 | def tempFolder (self): | 47 | def tempFolder (self): |
48 | return os.path.join(self.projectTargetDir, '.tmp', self.relativePath()) | 48 | return os.path.join(self.projectTargetDir, '.tmp', self.relativePath()) |
49 | 49 | ||
50 | 50 | ||
51 | def frontEndTempFolder (self): | 51 | def frontEndTempFolder (self): |
52 | return self.tempFolder() | 52 | return self.tempFolder() |
53 | 53 | ||
54 | 54 | ||
55 | def developmentTargetFolder (self): | 55 | def developmentTargetFolder (self): |
56 | return os.path.join(self.projectTargetDir, 'development') | 56 | return os.path.join(self.projectTargetDir, 'development') |
57 | 57 | ||
58 | 58 | ||
59 | def targetFolder (self): | 59 | def targetFolder (self): |
60 | return os.path.join(self.projectTargetDir, self.relativePath()) | 60 | return os.path.join(self.projectTargetDir, self.relativePath()) |
61 | 61 | ||
62 | 62 | ||
63 | # -------------------------------------------------------------------------- | 63 | # -------------------------------------------------------------------------- |
64 | 64 | ||
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): |
80 | x = iter(value) | 83 | x = iter(value) |
81 | return ' '.join([reduce(add, tup) for tup in izip(x, x, x, x)]) | 84 | return ' '.join([reduce(add, tup) for tup in izip(x, x, x, x)]) |
82 | 85 | ||
83 | 86 | ||
84 | def logChecksums (self, content, message): | 87 | def logChecksums (self, content, message): |
85 | md5Digest = self.formatMAC(hashlib.md5(content.encode('utf-8')).hexdigest()) | 88 | md5Digest = self.formatMAC(hashlib.md5(content.encode('utf-8')).hexdigest()) |
86 | shaDigest = self.formatMAC(hashlib.sha1(content.encode('utf-8')).hexdigest()) | 89 | shaDigest = self.formatMAC(hashlib.sha1(content.encode('utf-8')).hexdigest()) |
87 | sha256Digest= self.formatMAC(hashlib.sha256(content.encode('utf-8')).hexdigest()) | 90 | sha256Digest= self.formatMAC(hashlib.sha256(content.encode('utf-8')).hexdigest()) |
88 | print "-----" | 91 | print "-----" |
89 | print message + ": " + md5Digest + " (md5)" | 92 | print message + ": " + md5Digest + " (md5)" |
90 | print message + ": " + shaDigest + " (sha1)" | 93 | print message + ": " + shaDigest + " (sha1)" |
91 | print message + ": " + sha256Digest + " (sha256)" | 94 | print message + ": " + sha256Digest + " (sha256)" |
92 | print "=====" | 95 | print "=====" |
93 | 96 | ||
94 | 97 | ||
95 | def shouldCompileCode (self): | 98 | def shouldCompileCode (self): |
96 | return ('debug' in self.versions) or ('install' in self.versions) | 99 | return ('debug' in self.versions) or ('install' in self.versions) |
97 | 100 | ||
98 | 101 | ||
99 | def run (self): | 102 | def run (self): |
100 | print self.name() + " - RUN" | 103 | print self.name() + " - RUN" |
101 | 104 | ||
102 | if self.shouldCompileCode(): | 105 | if self.shouldCompileCode(): |
103 | self.compileCode() | 106 | self.compileCode() |
104 | 107 | ||
105 | for frontend in self.frontends: | 108 | for frontend in self.frontends: |
106 | if (frontend.module == frontend.submodule): | 109 | if (frontend.module == frontend.submodule): |
107 | submoduleExtension = '' | 110 | submoduleExtension = '' |
108 | else: | 111 | else: |
109 | submoduleExtension = '.' + frontend.submodule | 112 | submoduleExtension = '.' + frontend.submodule |
110 | 113 | ||
111 | main.createFolder(os.path.join(self.frontEndTempFolder(), frontend.module)) | 114 | main.createFolder(os.path.join(self.frontEndTempFolder(), frontend.module)) |
112 | 115 | ||
113 | if 'debug' in self.versions: | 116 | if 'debug' in self.versions: |
114 | frontend.copyResourcesToFolder(self.frontEndTempFolder()) | 117 | frontend.copyResourcesToFolder(self.frontEndTempFolder()) |
115 | 118 | ||
116 | index = self.configureIndexContent(frontend.assemble(assemblyMode='DEBUG', versionType='DEBUG')) | 119 | index = self.configureIndexContent(frontend.assemble(assemblyMode='DEBUG', versionType='DEBUG')) |
117 | self.writeToFolder(self.frontEndTempFolder(), os.path.join(frontend.module, 'index_debug' + submoduleExtension + '.html'), index) | 120 | self.writeToFolder(self.frontEndTempFolder(), os.path.join(frontend.module, 'index_debug' + submoduleExtension + '.html'), index) |
118 | 121 | ||
119 | if 'install' in self.versions: | 122 | if 'install' in self.versions: |
120 | index = self.configureIndexContent(frontend.assemble()) | 123 | index = self.configureIndexContent(frontend.assemble()) |
121 | self.writeToFolder(self.frontEndTempFolder(), os.path.join(frontend.module, 'index' + submoduleExtension + '.html'), index) | 124 | self.writeToFolder(self.frontEndTempFolder(), os.path.join(frontend.module, 'index' + submoduleExtension + '.html'), index) |
122 | 125 | ||
123 | self.logChecksums(index, "[" + self.name() + " - " + frontend.module + "] index" + submoduleExtension + ".html checksum") | 126 | self.logChecksums(index, "[" + self.name() + " - " + frontend.module + "] index" + submoduleExtension + ".html checksum") |
124 | 127 | ||
125 | self.createPackage() | 128 | self.createPackage() |
126 | 129 | ||
127 | # if 'development' in self.versions: | 130 | # if 'development' in self.versions: |
128 | # for frontend in self.frontends: | 131 | # for frontend in self.frontends: |
129 | # if (frontend.module == frontend.submodule): | 132 | # if (frontend.module == frontend.submodule): |
130 | # submoduleExtension = '' | 133 | # submoduleExtension = '' |
131 | # else: | 134 | # else: |
132 | # submoduleExtension = '.' + frontend.submodule | 135 | # submoduleExtension = '.' + frontend.submodule |
133 | # | 136 | # |
134 | # print "FRONTEND module: " + frontend.module | 137 | # print "FRONTEND module: " + frontend.module |
135 | # print "FRONTEND submodule: " + frontend.submodule | 138 | # print "FRONTEND submodule: " + frontend.submodule |
136 | # | 139 | # |
137 | ## main.createFolder(os.path.join(self.developmentTargetFolder(), frontend.module)) | 140 | ## main.createFolder(os.path.join(self.developmentTargetFolder(), frontend.module)) |
138 | # main.createFolder(self.developmentTargetFolder()) | 141 | # main.createFolder(self.developmentTargetFolder()) |
139 | # | 142 | # |
140 | # index = self.configureIndexContent(frontend.assemble(assemblyMode='DEVELOPMENT', versionType='DEBUG'), self.settings['development.settings']['url']) | 143 | # index = self.configureIndexContent(frontend.assemble(assemblyMode='DEVELOPMENT', versionType='DEBUG'), self.settings['development.settings']['url']) |
141 | ## self.writeToFolder(self.developmentTargetFolder(), os.path.join(frontend.module, 'index_development' + submoduleExtension + '.html'), index) | 144 | ## self.writeToFolder(self.developmentTargetFolder(), os.path.join(frontend.module, 'index_development' + submoduleExtension + '.html'), index) |
142 | # self.writeToFolder(self.developmentTargetFolder(), os.path.join(frontend.module + submoduleExtension + '.html'), index) | 145 | # self.writeToFolder(self.developmentTargetFolder(), os.path.join(frontend.module + submoduleExtension + '.html'), index) |
143 | 146 | ||
144 | 147 | ||
145 | #=================================================================== | 148 | #=================================================================== |
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 | |||
@@ -1,420 +1,381 @@ | |||
1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python |
2 | # -*- coding: UTF-8 -*- | 2 | # -*- coding: UTF-8 -*- |
3 | 3 | ||
4 | import sys, os, re | 4 | import sys, os, re |
5 | import cssmin | 5 | import cssmin |
6 | import jsmin | 6 | import jsmin |
7 | import codecs | 7 | import codecs |
8 | import shutil | 8 | import shutil |
9 | import StringIO | 9 | import StringIO |
10 | import urllib | 10 | import urllib |
11 | 11 | ||
12 | import main | 12 | import main |
13 | 13 | ||
14 | #=============================================================================== | 14 | #=============================================================================== |
15 | 15 | ||
16 | class FrontendBuilder(object): | 16 | class FrontendBuilder(object): |
17 | 17 | ||
18 | def __init__ (self, frontend, settings, repositoryVersion): | 18 | def __init__ (self, frontend, settings, repositoryVersion): |
19 | if '.' in frontend: | 19 | if '.' in frontend: |
20 | moduleComponents = frontend.split('.') | 20 | moduleComponents = frontend.split('.') |
21 | self.module = moduleComponents[0] | 21 | self.module = moduleComponents[0] |
22 | self.submodule = moduleComponents[1] | 22 | self.submodule = moduleComponents[1] |
23 | else: | 23 | else: |
24 | self.module = frontend | 24 | self.module = frontend |
25 | self.submodule = frontend | 25 | self.submodule = frontend |
26 | 26 | ||
27 | self.settings = settings | 27 | self.settings = settings |
28 | self.projectDir = main.projectBaseDir() | 28 | self.projectDir = main.projectBaseDir() |
29 | # self.repository = repository.repositoryWithPath(self.projectDir) | 29 | # self.repository = repository.repositoryWithPath(self.projectDir) |
30 | self.repositoryVersion = repositoryVersion | 30 | self.repositoryVersion = repositoryVersion |
31 | self.processedFiles = {} | 31 | self.processedFiles = {} |
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 | ||
44 | def log (self, message): | 46 | def log (self, message): |
45 | module = self.module | 47 | module = self.module |
46 | if (self.module != self.submodule): | 48 | if (self.module != self.submodule): |
47 | module = module + "." + self.submodule | 49 | module = module + "." + self.submodule |
48 | print "frontend [" + module + "]: " + message | 50 | print "frontend [" + module + "]: " + message |
49 | 51 | ||
50 | 52 | ||
51 | def absolutePathForSources (self): | 53 | def absolutePathForSources (self): |
52 | return os.path.join(self.projectDir, 'frontend', self.module) | 54 | return os.path.join(self.projectDir, 'frontend', self.module) |
53 | 55 | ||
54 | 56 | ||
55 | def absolutePathForSourceFile (self, basePath, file): | 57 | def absolutePathForSourceFile (self, basePath, file): |
56 | return os.path.join(self.absolutePathForSources(), basePath, file) | 58 | return os.path.join(self.absolutePathForSources(), basePath, file) |
57 | 59 | ||
58 | 60 | ||
59 | def absolutePathForTargetFile (self, folder, basePath, file): | 61 | def absolutePathForTargetFile (self, folder, basePath, file): |
60 | return os.path.join(folder, self.module, basePath, file) | 62 | return os.path.join(folder, self.module, basePath, file) |
61 | 63 | ||
62 | 64 | ||
63 | def filterFiles (self, files): | 65 | def filterFiles (self, files): |
64 | result = [] | 66 | result = [] |
65 | 67 | ||
66 | for file in files: | 68 | for file in files: |
67 | if file.startswith('--'): | 69 | if file.startswith('--'): |
68 | pass | 70 | pass |
69 | else: | 71 | else: |
70 | result.append(file) | 72 | result.append(file) |
71 | 73 | ||
72 | return result | 74 | return result |
73 | 75 | ||
74 | 76 | ||
75 | def copyResources (self, sourceFolder, destinationFolder, fileType): | 77 | def copyResources (self, sourceFolder, destinationFolder, fileType): |
76 | if fileType in self.settings: | 78 | if fileType in self.settings: |
77 | for file in self.filterFiles(self.settings[fileType]): | 79 | for file in self.filterFiles(self.settings[fileType]): |
78 | src = self.absolutePathForSourceFile(fileType, file) | 80 | src = self.absolutePathForSourceFile(fileType, file) |
79 | dst = self.absolutePathForTargetFile(destinationFolder, fileType, file) | 81 | dst = self.absolutePathForTargetFile(destinationFolder, fileType, file) |
80 | main.createFolder(os.path.dirname(dst)) | 82 | main.createFolder(os.path.dirname(dst)) |
81 | shutil.copy2(src, dst) | 83 | shutil.copy2(src, dst) |
82 | else: | 84 | else: |
83 | srcFolder = os.path.join(self.absolutePathForSources(), fileType) | 85 | srcFolder = os.path.join(self.absolutePathForSources(), fileType) |
84 | dstFolder = os.path.join(destinationFolder, self.module, fileType) | 86 | dstFolder = os.path.join(destinationFolder, self.module, fileType) |
85 | if not(os.path.exists(dstFolder)): | 87 | if not(os.path.exists(dstFolder)): |
86 | shutil.copytree(srcFolder, dstFolder) | 88 | shutil.copytree(srcFolder, dstFolder) |
87 | 89 | ||
88 | # try: | 90 | # try: |
89 | # shutil.copytree(srcFolder, dstFolder) | 91 | # shutil.copytree(srcFolder, dstFolder) |
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 | ||
105 | for file in self.filterFiles(files): | 109 | for file in self.filterFiles(files): |
106 | try: | 110 | try: |
107 | fileHandler = codecs.open(self.absolutePathForSourceFile(basePath, file), 'r', 'utf-8') | 111 | fileHandler = codecs.open(self.absolutePathForSourceFile(basePath, file), 'r', 'utf-8') |
108 | except: | 112 | except: |
109 | print "FILE: " + file | 113 | print "FILE: " + file |
110 | 114 | ||
111 | result += fileHandler.read() + '\n' | 115 | result += fileHandler.read() + '\n' |
112 | fileHandler.close() | 116 | fileHandler.close() |
113 | 117 | ||
114 | return result | 118 | return result |
115 | 119 | ||
116 | 120 | ||
117 | def template (self): | 121 | def template (self): |
118 | processedFile = 'html_template' | 122 | processedFile = 'html_template' |
119 | if not self.processedFiles.has_key(processedFile): | 123 | if not self.processedFiles.has_key(processedFile): |
120 | #self.processedFiles[processedFile] = self.loadFilesContent('html', ['index_template.html']) | 124 | #self.processedFiles[processedFile] = self.loadFilesContent('html', ['index_template.html']) |
121 | self.processedFiles[processedFile] = self.loadFilesContent('html', [self.settings['html.template']]) | 125 | self.processedFiles[processedFile] = self.loadFilesContent('html', [self.settings['html.template']]) |
122 | 126 | ||
123 | return self.processedFiles[processedFile] | 127 | return self.processedFiles[processedFile] |
124 | 128 | ||
125 | 129 | ||
126 | def cssminCompressor (self, css): | 130 | def cssminCompressor (self, css): |
127 | # package found here: | 131 | # package found here: |
128 | # - http://stackoverflow.com/questions/222581/python-script-for-minifying-css/2396777#2396777 | 132 | # - http://stackoverflow.com/questions/222581/python-script-for-minifying-css/2396777#2396777 |
129 | # actual downloaded version: http://pypi.python.org/pypi/cssmin/0.1.4 | 133 | # actual downloaded version: http://pypi.python.org/pypi/cssmin/0.1.4 |
130 | return cssmin.cssmin(css) | 134 | return cssmin.cssmin(css) |
131 | 135 | ||
132 | 136 | ||
133 | def regexCssCompressor (self, css): | 137 | def regexCssCompressor (self, css): |
134 | # http://stackoverflow.com/questions/222581/python-script-for-minifying-css/223689#223689 | 138 | # http://stackoverflow.com/questions/222581/python-script-for-minifying-css/223689#223689 |
135 | 139 | ||
136 | # remove comments - this will break a lot of hacks :-P | 140 | # remove comments - this will break a lot of hacks :-P |
137 | css = re.sub( r'\s*/\*\s*\*/', "$$HACK1$$", css ) # preserve IE<6 comment hack | 141 | css = re.sub( r'\s*/\*\s*\*/', "$$HACK1$$", css ) # preserve IE<6 comment hack |
138 | css = re.sub( r'/\*[\s\S]*?\*/', "", css ) | 142 | css = re.sub( r'/\*[\s\S]*?\*/', "", css ) |
139 | css = css.replace( "$$HACK1$$", '/**/' ) # preserve IE<6 comment hack | 143 | css = css.replace( "$$HACK1$$", '/**/' ) # preserve IE<6 comment hack |
140 | 144 | ||
141 | # url() doesn't need quotes | 145 | # url() doesn't need quotes |
142 | css = re.sub( r'url\((["\'])([^)]*)\1\)', r'url(\2)', css ) | 146 | css = re.sub( r'url\((["\'])([^)]*)\1\)', r'url(\2)', css ) |
143 | 147 | ||
144 | # spaces may be safely collapsed as generated content will collapse them anyway | 148 | # spaces may be safely collapsed as generated content will collapse them anyway |
145 | css = re.sub( r'\s+', ' ', css ) | 149 | css = re.sub( r'\s+', ' ', css ) |
146 | 150 | ||
147 | # shorten collapsable colors: #aabbcc to #abc | 151 | # shorten collapsable colors: #aabbcc to #abc |
148 | css = re.sub( r'#([0-9a-f])\1([0-9a-f])\2([0-9a-f])\3(\s|;)', r'#\1\2\3\4', css ) | 152 | css = re.sub( r'#([0-9a-f])\1([0-9a-f])\2([0-9a-f])\3(\s|;)', r'#\1\2\3\4', css ) |
149 | 153 | ||
150 | # fragment values can loose zeros | 154 | # fragment values can loose zeros |
151 | css = re.sub( r':\s*0(\.\d+([cm]m|e[mx]|in|p[ctx]))\s*;', r':\1;', css ) | 155 | css = re.sub( r':\s*0(\.\d+([cm]m|e[mx]|in|p[ctx]))\s*;', r':\1;', css ) |
152 | 156 | ||
153 | for rule in re.findall( r'([^{]+){([^}]*)}', css ): | 157 | for rule in re.findall( r'([^{]+){([^}]*)}', css ): |
154 | 158 | ||
155 | # we don't need spaces around operators | 159 | # we don't need spaces around operators |
156 | selectors = [re.sub( r'(?<=[\[\(>+=])\s+|\s+(?=[=~^$*|>+\]\)])', r'', selector.strip() ) for selector in rule[0].split( ',' )] | 160 | selectors = [re.sub( r'(?<=[\[\(>+=])\s+|\s+(?=[=~^$*|>+\]\)])', r'', selector.strip() ) for selector in rule[0].split( ',' )] |
157 | 161 | ||
158 | # order is important, but we still want to discard repetitions | 162 | # order is important, but we still want to discard repetitions |
159 | properties = {} | 163 | properties = {} |
160 | porder = [] | 164 | porder = [] |
161 | for prop in re.findall( '(.*?):(.*?)(;|$)', rule[1] ): | 165 | for prop in re.findall( '(.*?):(.*?)(;|$)', rule[1] ): |
162 | key = prop[0].strip().lower() | 166 | key = prop[0].strip().lower() |
163 | if key not in porder: porder.append( key ) | 167 | if key not in porder: porder.append( key ) |
164 | properties[ key ] = prop[1].strip() | 168 | properties[ key ] = prop[1].strip() |
165 | 169 | ||
166 | # output rule if it contains any declarations | 170 | # output rule if it contains any declarations |
167 | if properties: | 171 | if properties: |
168 | print "%s{%s}" % ( ','.join( selectors ), ''.join(['%s:%s;' % (key, properties[key]) for key in porder])[:-1] ) | 172 | print "%s{%s}" % ( ','.join( selectors ), ''.join(['%s:%s;' % (key, properties[key]) for key in porder])[:-1] ) |
169 | 173 | ||
170 | return css | 174 | return css |
171 | 175 | ||
172 | 176 | ||
173 | def compressCSS (self, css): | 177 | def compressCSS (self, css): |
174 | self.log("compressing CSS") | 178 | self.log("compressing CSS") |
175 | #return self.regexCssCompressor(css) | 179 | #return self.regexCssCompressor(css) |
176 | return self.cssminCompressor(css) | 180 | return self.cssminCompressor(css) |
177 | 181 | ||
178 | 182 | ||
179 | #========================================================================== | 183 | #========================================================================== |
180 | 184 | ||
181 | def compressJS_jsmin (self, js, description): | 185 | def compressJS_jsmin (self, js, description): |
182 | self.log("compressing " + description + " code") | 186 | self.log("compressing " + description + " code") |
183 | original = StringIO.StringIO(js) | 187 | original = StringIO.StringIO(js) |
184 | output = StringIO.StringIO() | 188 | output = StringIO.StringIO() |
185 | 189 | ||
186 | jsMinifier = jsmin.JavascriptMinify() | 190 | jsMinifier = jsmin.JavascriptMinify() |
187 | jsMinifier.minify(original, output) | 191 | jsMinifier.minify(original, output) |
188 | 192 | ||
189 | result = output.getvalue() | 193 | result = output.getvalue() |
190 | 194 | ||
191 | original.close() | 195 | original.close() |
192 | output.close() | 196 | output.close() |
193 | 197 | ||
194 | return result | 198 | return result |
195 | 199 | ||
196 | def compressJS_closureCompiler (self, js, description): | 200 | def compressJS_closureCompiler (self, js, description): |
197 | #Googles Closure compiler | 201 | #Googles Closure compiler |
198 | #java -jar compiler.jar --js=in1.js --js=in2.js ... --js_output_file=out.js | 202 | #java -jar compiler.jar --js=in1.js --js=in2.js ... --js_output_file=out.js |
199 | 203 | ||
200 | result = js | 204 | result = js |
201 | 205 | ||
202 | return result | 206 | return result |
203 | 207 | ||
204 | 208 | ||
205 | def compressJS (self, js, description): | 209 | def compressJS (self, js, description): |
206 | return self.compressJS_jsmin(js, description) | 210 | return self.compressJS_jsmin(js, description) |
207 | #return self.compressJS_closureCompiler(js, description) | 211 | #return self.compressJS_closureCompiler(js, description) |
208 | 212 | ||
209 | 213 | ||
210 | #========================================================================== | 214 | #========================================================================== |
211 | 215 | ||
212 | def packBookmarklet (self, bookmakeletCode, version): | 216 | def packBookmarklet (self, bookmakeletCode, version): |
213 | replacers = [ | 217 | replacers = [ |
214 | ('isLoginForm', 'ilf'), | 218 | ('isLoginForm', 'ilf'), |
215 | ('findLoginForm', 'flf'), | 219 | ('findLoginForm', 'flf'), |
216 | ('findLoginForm', 'flf'), | 220 | ('findLoginForm', 'flf'), |
217 | ('formParameters', 'fp' ), | 221 | ('formParameters', 'fp' ), |
218 | ('pageParameters', 'pp' ), | 222 | ('pageParameters', 'pp' ), |
219 | ('serializeJSON', 'sj' ), | 223 | ('serializeJSON', 'sj' ), |
220 | ('reprString', 'rs' ), | 224 | ('reprString', 'rs' ), |
221 | ('logFormParameters', 'lfp'), | 225 | ('logFormParameters', 'lfp'), |
222 | ('loadClipperzBookmarklet','lcb'), | 226 | ('loadClipperzBookmarklet','lcb'), |
223 | ('loginForm', 'lf' ), | 227 | ('loginForm', 'lf' ), |
224 | ('parameters', 'p' ), | 228 | ('parameters', 'p' ), |
225 | ('inputElementValues', 'iev'), | 229 | ('inputElementValues', 'iev'), |
226 | ] | 230 | ] |
227 | result = self.compressJS(bookmakeletCode, version + " bookmarklet") | 231 | result = self.compressJS(bookmakeletCode, version + " bookmarklet") |
228 | 232 | ||
229 | result = re.sub('\n', ' ', result) #Fit all in a single line | 233 | result = re.sub('\n', ' ', result) #Fit all in a single line |
230 | # result = re.sub('\s+', ' ', result) #Collapse "redundant" spaces. WARNING: this could have some evil side effects on constant strings used inside to code!! | 234 | # result = re.sub('\s+', ' ', result) #Collapse "redundant" spaces. WARNING: this could have some evil side effects on constant strings used inside to code!! |
231 | # result = re.sub('\s?([,\+=\(\)\{\};])\s?', '\\1', result) | 235 | # result = re.sub('\s?([,\+=\(\)\{\};])\s?', '\\1', result) |
232 | 236 | ||
233 | for replacer in replacers: | 237 | for replacer in replacers: |
234 | result = re.sub(replacer[0], replacer[1], result) | 238 | result = re.sub(replacer[0], replacer[1], result) |
235 | 239 | ||
236 | # <!-- escaping required to handle the bookmarklet code within the javascript code --> | 240 | # <!-- escaping required to handle the bookmarklet code within the javascript code --> |
237 | result = re.sub('\://', '%3a%2f%2f',result) | 241 | result = re.sub('\://', '%3a%2f%2f',result) |
238 | result = re.sub('/', '%2f', result) | 242 | result = re.sub('/', '%2f', result) |
239 | # result = re.sub('"', '%22', result) | 243 | # result = re.sub('"', '%22', result) |
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") + '";' |
301 | self.processedFiles[cacheKey] = result | 258 | self.processedFiles[cacheKey] = result |
302 | else: | 259 | else: |
303 | result = self.processedFiles[cacheKey] | 260 | result = self.processedFiles[cacheKey] |
304 | 261 | ||
305 | return result | 262 | return result |
306 | 263 | ||
307 | 264 | ||
308 | def replaceTemplatePlaceholders (self, pageTitle, copyright, css, code, jsLoadMode, version, versionType): | 265 | def replaceTemplatePlaceholders (self, pageTitle, copyright, css, code, jsLoadMode, version, versionType): |
309 | result = self.template() | 266 | result = self.template() |
310 | 267 | ||
311 | result = result.replace('@page.title@', pageTitle) | 268 | result = result.replace('@page.title@', pageTitle) |
312 | result = result.replace('@copyright@', copyright) | 269 | result = result.replace('@copyright@', copyright) |
313 | result = result.replace('@css@', css) | 270 | result = result.replace('@css@', css) |
314 | #result = result.replace('@bookmarklet@', bookmarklet) | 271 | #result = result.replace('@bookmarklet@', bookmarklet) |
315 | result = result.replace('@application.version@', version) | 272 | result = result.replace('@application.version@', version) |
316 | result = result.replace('@application.version.type@',versionType) | 273 | result = result.replace('@application.version.type@',versionType) |
317 | result = result.replace('@js_' + jsLoadMode + '@', code) | 274 | result = result.replace('@js_' + jsLoadMode + '@', code) |
318 | 275 | ||
319 | result = re.sub('@js_[^@]+@', '', result) | 276 | result = re.sub('@js_[^@]+@', '', result) |
320 | 277 | ||
321 | return result | 278 | return result |
322 | 279 | ||
323 | 280 | ||
324 | def assembleCopyrightHeader (self): | 281 | def assembleCopyrightHeader (self): |
325 | processedFile = 'copyright' | 282 | processedFile = 'copyright' |
326 | if not self.processedFiles.has_key(processedFile): | 283 | if not self.processedFiles.has_key(processedFile): |
327 | #self.log("assembling copyright header") | 284 | #self.log("assembling copyright header") |
328 | copyrightValues = self.settings['copyright.values'] | 285 | copyrightValues = self.settings['copyright.values'] |
329 | license = self.loadFilesContent('../../properties', ['license.txt']) | 286 | license = self.loadFilesContent('../../properties', ['license.txt']) |
330 | result = self.loadFilesContent('properties', ['creditsAndCopyrights.txt']) | 287 | result = self.loadFilesContent('properties', ['creditsAndCopyrights.txt']) |
331 | 288 | ||
332 | result = re.sub('@clipperz.license@', license, result) | 289 | result = re.sub('@clipperz.license@', license, result) |
333 | for key in copyrightValues: | 290 | for key in copyrightValues: |
334 | result = re.sub('@'+key+'@', copyrightValues[key], result) | 291 | result = re.sub('@'+key+'@', copyrightValues[key], result) |
335 | 292 | ||
336 | self.processedFiles[processedFile] = result | 293 | self.processedFiles[processedFile] = result |
337 | 294 | ||
338 | return self.processedFiles[processedFile] | 295 | return self.processedFiles[processedFile] |
339 | 296 | ||
340 | 297 | ||
341 | def cssTagsForFiles (self, basePath, files): | 298 | def cssTagsForFiles (self, basePath, files): |
342 | #<link rel="stylesheet" type="text/css" href="./css/reset-min.css" /> | 299 | #<link rel="stylesheet" type="text/css" href="./css/reset-min.css" /> |
343 | return '\n'.join(map(lambda file: '<link rel="stylesheet" type="text/css" href="' + basePath + '/' + file + '" />', files)) | 300 | return '\n'.join(map(lambda file: '<link rel="stylesheet" type="text/css" href="' + basePath + '/' + file + '" />', files)) |
344 | 301 | ||
345 | 302 | ||
346 | def cssTagForContent (self, content): | 303 | def cssTagForContent (self, content): |
347 | return '<style type="text/css">' + content + '</style>' | 304 | return '<style type="text/css">' + content + '</style>' |
348 | 305 | ||
349 | 306 | ||
350 | def scriptTagsForFiles (self, basePath, files): | 307 | def scriptTagsForFiles (self, basePath, files): |
351 | #<script type='text/javascript' src='./js/src/bookmarklet.js'></script> | 308 | #<script type='text/javascript' src='./js/src/bookmarklet.js'></script> |
352 | return '\n'.join(map(lambda file: '<script type="text/javascript" src="' + basePath + '/' + file + '" charset="utf-8"></script>', files)) | 309 | return '\n'.join(map(lambda file: '<script type="text/javascript" src="' + basePath + '/' + file + '" charset="utf-8"></script>', files)) |
353 | 310 | ||
354 | 311 | ||
355 | def scriptTagForContent (self, content): | 312 | def scriptTagForContent (self, content): |
356 | return '<script>' + content + '</script>' | 313 | return '<script>' + content + '</script>' |
357 | 314 | ||
358 | 315 | ||
359 | def assembleVersion (self, pageTitle, copyright, css, js, jsLoadMode, version, versionType): | 316 | def assembleVersion (self, pageTitle, copyright, css, js, jsLoadMode, version, versionType): |
360 | cacheKey = version + "-" + versionType | 317 | cacheKey = version + "-" + versionType |
361 | if not self.processedFiles.has_key(cacheKey): | 318 | if not self.processedFiles.has_key(cacheKey): |
362 | result = self.replaceTemplatePlaceholders(pageTitle, copyright, css, js, jsLoadMode, version, versionType) | 319 | result = self.replaceTemplatePlaceholders(pageTitle, copyright, css, js, jsLoadMode, version, versionType) |
363 | self.processedFiles[cacheKey] = result | 320 | self.processedFiles[cacheKey] = result |
364 | else: | 321 | else: |
365 | result = self.processedFiles[cacheKey] | 322 | result = self.processedFiles[cacheKey] |
366 | 323 | ||
367 | #self.log("# cacheKey:\n" + result) | 324 | #self.log("# cacheKey:\n" + result) |
368 | return result | 325 | return result |
369 | 326 | ||
370 | 327 | ||
371 | def assemble (self, assemblyMode='INSTALL', versionType='LIVE'): | 328 | def assemble (self, assemblyMode='INSTALL', versionType='LIVE'): |
372 | 329 | ||
373 | if versionType == 'LIVE': | 330 | if versionType == 'LIVE': |
374 | pageTitle = "Clipperz - " + self.module | 331 | pageTitle = "Clipperz - " + self.module |
375 | else: | 332 | else: |
376 | pageTitle = "Clipperz - " + self.module + " [" + versionType + " - " + assemblyMode +"]" | 333 | pageTitle = "Clipperz - " + self.module + " [" + versionType + " - " + assemblyMode +"]" |
377 | 334 | ||
378 | if assemblyMode == 'INSTALL': | 335 | if assemblyMode == 'INSTALL': |
379 | copyright = self.assembleCopyrightHeader() | 336 | copyright = self.assembleCopyrightHeader() |
380 | css =self.cssTagForContent(self.compressCSS(self.loadFilesContent('css', self.settings['css']))) | 337 | css =self.cssTagForContent(self.compressCSS(self.loadFilesContent('css', self.settings['css']))) |
381 | js =self.scriptTagForContent( | 338 | js =self.scriptTagForContent( |
382 | self.bookmarklet() + | 339 | self.bookmarklet() + |
383 | '\n' + | 340 | '\n' + |
384 | self.compressJS(self.loadFilesContent('js', self.settings['js']), "application") | 341 | self.compressJS(self.loadFilesContent('js', self.settings['js']), "application") |
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 | ||
408 | return self.assembleVersion( | 369 | return self.assembleVersion( |
409 | pageTitle = pageTitle, | 370 | pageTitle = pageTitle, |
410 | copyright = copyright, | 371 | copyright = copyright, |
411 | css = css, | 372 | css = css, |
412 | js = js, | 373 | js = js, |
413 | jsLoadMode = jsLoadMode, | 374 | jsLoadMode = jsLoadMode, |
414 | version = self.repositoryVersion, | 375 | version = self.repositoryVersion, |
415 | versionType = versionType | 376 | versionType = versionType |
416 | ) | 377 | ) |
417 | 378 | ||
418 | 379 | ||
419 | 380 | ||
420 | 381 | ||
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 | |||
@@ -1,14 +1,17 @@ | |||
1 | from frontendBuilder import FrontendBuilder | 1 | from frontendBuilder import FrontendBuilder |
2 | import shutil | 2 | import shutil |
3 | 3 | ||
4 | class BetaBuilder(FrontendBuilder): | 4 | class 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 @@ | |||
1 | from frontendBuilder import FrontendBuilder | ||
2 | import shutil | ||
3 | |||
4 | class 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 | |||
@@ -1,27 +1,30 @@ | |||
1 | from frontendBuilder import FrontendBuilder | 1 | from frontendBuilder import FrontendBuilder |
2 | import shutil | 2 | import shutil |
3 | 3 | ||
4 | class GammaBuilder(FrontendBuilder): | 4 | class 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 | ] |
15 | 18 | ||
16 | for resource in resourcesToCopy: | 19 | for resource in resourcesToCopy: |
17 | src = self.absolutePathForSourceFile(resource['folder'], resource['source']) | 20 | src = self.absolutePathForSourceFile(resource['folder'], resource['source']) |
18 | dst = self.absolutePathForTargetFile(targetFolder, '', resource['target']) | 21 | dst = self.absolutePathForTargetFile(targetFolder, '', resource['target']) |
19 | shutil.copy2(src, dst) | 22 | shutil.copy2(src, dst) |
20 | 23 | ||
21 | # src = self.absolutePathForSourceFile('html', 'exit_template.html') | 24 | # src = self.absolutePathForSourceFile('html', 'exit_template.html') |
22 | # dst = self.absolutePathForTargetFile(targetFolder, '', 'exit.html') | 25 | # dst = self.absolutePathForTargetFile(targetFolder, '', 'exit.html') |
23 | # shutil.copy2(src, dst) | 26 | # shutil.copy2(src, dst) |
24 | 27 | ||
25 | # src = self.absolutePathForSourceFile('css', 'static.css') | 28 | # src = self.absolutePathForSourceFile('css', 'static.css') |
26 | # dst = self.absolutePathForTargetFile(targetFolder, '', 'static.css') | 29 | # dst = self.absolutePathForTargetFile(targetFolder, '', 'static.css') |
27 | # shutil.copy2(src, dst) | 30 | # shutil.copy2(src, dst) |
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 | |||
@@ -1,9 +1,12 @@ | |||
1 | from frontendBuilder import FrontendBuilder | 1 | from frontendBuilder import FrontendBuilder |
2 | 2 | ||
3 | class Gamma_MobileBuilder(FrontendBuilder): | 3 | class 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 | |||
@@ -1,95 +1,102 @@ | |||
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 | 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' |
50 | for _ in range(2, imagePathIndex): | 57 | for _ in range(2, imagePathIndex): |
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' |
64 | else: | 71 | else: |
65 | print "ERROR - unknown image extension: " + fileExtension | 72 | print "ERROR - unknown image extension: " + fileExtension |
66 | 73 | ||
67 | absoluteFilePath = basePath + '/'.join(pathParts) | 74 | absoluteFilePath = basePath + '/'.join(pathParts) |
68 | else: | 75 | else: |
69 | resourceType = pathParts[2] | 76 | resourceType = pathParts[2] |
70 | 77 | ||
71 | if resourceType == 'css': | 78 | if resourceType == 'css': |
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 | ||
87 | def main (): | 94 | def 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 | ||
93 | if __name__ == "__main__": | 100 | if __name__ == "__main__": |
94 | main() | 101 | main() |
95 | 102 | ||