author | Josh <jokajak@gmail.com> | 2012-03-17 19:29:33 (UTC) |
---|---|---|
committer | Josh <jokajak@gmail.com> | 2012-03-17 19:29:33 (UTC) |
commit | 0e396afdc4aa9ec8734ba48f90e9fefbad3b2b33 (patch) (unidiff) | |
tree | 2ace8ec32d24c1d34b4578fe9297c4e4b4b97720 /scripts | |
parent | ff33328861685c1a2d5f9b729a2b3595509c38ee (diff) | |
parent | 6f7ead0446aae6dd9f40b183e402b059a33d0517 (diff) | |
download | clipperz-0e396afdc4aa9ec8734ba48f90e9fefbad3b2b33.zip clipperz-0e396afdc4aa9ec8734ba48f90e9fefbad3b2b33.tar.gz clipperz-0e396afdc4aa9ec8734ba48f90e9fefbad3b2b33.tar.bz2 |
Merge remote-tracking branch 'upstream/master'
-rw-r--r-- | scripts/builder/backendBuilder.py | 21 | ||||
-rw-r--r-- | scripts/builder/frontendBuilder.py | 5 | ||||
-rw-r--r-- | scripts/builder/repository.py | 18 |
3 files changed, 31 insertions, 13 deletions
diff --git a/scripts/builder/backendBuilder.py b/scripts/builder/backendBuilder.py index 3e61955..5b91678 100644 --- a/scripts/builder/backendBuilder.py +++ b/scripts/builder/backendBuilder.py | |||
@@ -82,37 +82,50 @@ class BackendBuilder(object): | |||
82 | 82 | ||
83 | def shouldCompileCode (self): | 83 | def shouldCompileCode (self): |
84 | return ('debug' in self.versions) or ('install' in self.versions) | 84 | return ('debug' in self.versions) or ('install' in self.versions) |
85 | 85 | ||
86 | 86 | ||
87 | def run (self): | 87 | def run (self): |
88 | print self.name() + " - RUN" | 88 | print self.name() + " - RUN" |
89 | 89 | ||
90 | if self.shouldCompileCode(): | 90 | if self.shouldCompileCode(): |
91 | self.compileCode() | 91 | self.compileCode() |
92 | 92 | ||
93 | for frontend in self.frontends: | 93 | for frontend in self.frontends: |
94 | if (frontend.module == frontend.submodule): | ||
95 | submoduleExtension = '' | ||
96 | else: | ||
97 | submoduleExtension = '.' + frontend.submodule | ||
98 | |||
94 | main.createFolder(os.path.join(self.frontEndTempFolder(), frontend.module)) | 99 | main.createFolder(os.path.join(self.frontEndTempFolder(), frontend.module)) |
95 | 100 | ||
96 | if 'debug' in self.versions: | 101 | if 'debug' in self.versions: |
97 | frontend.copyResourcesToFolder(self.frontEndTempFolder()) | 102 | frontend.copyResourcesToFolder(self.frontEndTempFolder()) |
98 | 103 | ||
99 | index = self.configureIndexContent(frontend.assemble(assemblyMode='DEBUG', versionType='DEBUG')) | 104 | index = self.configureIndexContent(frontend.assemble(assemblyMode='DEBUG', versionType='DEBUG')) |
100 | self.writeToFolder(self.frontEndTempFolder(), os.path.join(frontend.module, 'index_debug.html'), index) | 105 | self.writeToFolder(self.frontEndTempFolder(), os.path.join(frontend.module, 'index_debug' + submoduleExtension + '.html'), index) |
101 | 106 | ||
102 | if 'install' in self.versions: | 107 | if 'install' in self.versions: |
103 | index = self.configureIndexContent(frontend.assemble()) | 108 | index = self.configureIndexContent(frontend.assemble()) |
104 | self.writeToFolder(self.frontEndTempFolder(), os.path.join(frontend.module, 'index.html'), index) | 109 | self.writeToFolder(self.frontEndTempFolder(), os.path.join(frontend.module, 'index' + submoduleExtension + '.html'), index) |
105 | 110 | ||
106 | self.logChecksums(index, "[" + self.name() + " - " + frontend.module + "] index.html checksum") | 111 | self.logChecksums(index, "[" + self.name() + " - " + frontend.module + "] index" + submoduleExtension + ".html checksum") |
107 | 112 | ||
108 | self.createPackage() | 113 | self.createPackage() |
109 | 114 | ||
110 | if 'development' in self.versions: | 115 | if 'development' in self.versions: |
111 | for frontend in self.frontends: | 116 | for frontend in self.frontends: |
117 | if (frontend.module == frontend.submodule): | ||
118 | submoduleExtension = '' | ||
119 | else: | ||
120 | submoduleExtension = '.' + frontend.submodule | ||
121 | |||
122 | print "FRONTEND module: " + frontend.module | ||
123 | print "FRONTEND submodule: " + frontend.submodule | ||
124 | |||
112 | main.createFolder(os.path.join(self.developmentTargetFolder(), frontend.module)) | 125 | main.createFolder(os.path.join(self.developmentTargetFolder(), frontend.module)) |
113 | 126 | ||
114 | index = self.configureIndexContent(frontend.assemble(assemblyMode='DEVELOPMENT', versionType='DEBUG'), self.settings['development.settings']['url']) | 127 | index = self.configureIndexContent(frontend.assemble(assemblyMode='DEVELOPMENT', versionType='DEBUG'), self.settings['development.settings']['url']) |
115 | self.writeToFolder(self.developmentTargetFolder(), os.path.join(frontend.module, 'index.html'), index) | 128 | self.writeToFolder(self.developmentTargetFolder(), os.path.join(frontend.module, 'index' + submoduleExtension + '.html'), index) |
116 | 129 | ||
117 | 130 | ||
118 | #=================================================================== | 131 | #=================================================================== |
diff --git a/scripts/builder/frontendBuilder.py b/scripts/builder/frontendBuilder.py index dae837b..1f0f92f 100644 --- a/scripts/builder/frontendBuilder.py +++ b/scripts/builder/frontendBuilder.py | |||
@@ -79,25 +79,26 @@ class FrontendBuilder(object): | |||
79 | except: | 79 | except: |
80 | print "FILE: " + file | 80 | print "FILE: " + file |
81 | 81 | ||
82 | result += fileHandler.read() + '\n' | 82 | result += fileHandler.read() + '\n' |
83 | fileHandler.close() | 83 | fileHandler.close() |
84 | 84 | ||
85 | return result | 85 | return result |
86 | 86 | ||
87 | 87 | ||
88 | def template (self): | 88 | def template (self): |
89 | processedFile = 'html_template' | 89 | processedFile = 'html_template' |
90 | if not self.processedFiles.has_key(processedFile): | 90 | if not self.processedFiles.has_key(processedFile): |
91 | self.processedFiles[processedFile] = self.loadFilesContent('html', ['index_template.html']) | 91 | #self.processedFiles[processedFile] = self.loadFilesContent('html', ['index_template.html']) |
92 | self.processedFiles[processedFile] = self.loadFilesContent('html', [self.settings['html.template']]) | ||
92 | 93 | ||
93 | return self.processedFiles[processedFile] | 94 | return self.processedFiles[processedFile] |
94 | 95 | ||
95 | 96 | ||
96 | def cssminCompressor (self, css): | 97 | def cssminCompressor (self, css): |
97 | # package found here: | 98 | # package found here: |
98 | # - http://stackoverflow.com/questions/222581/python-script-for-minifying-css/2396777#2396777 | 99 | # - http://stackoverflow.com/questions/222581/python-script-for-minifying-css/2396777#2396777 |
99 | # actual downloaded version: http://pypi.python.org/pypi/cssmin/0.1.4 | 100 | # actual downloaded version: http://pypi.python.org/pypi/cssmin/0.1.4 |
100 | return cssmin.cssmin(css) | 101 | return cssmin.cssmin(css) |
101 | 102 | ||
102 | 103 | ||
103 | def regexCssCompressor (self, css): | 104 | def regexCssCompressor (self, css): |
@@ -310,25 +311,25 @@ class FrontendBuilder(object): | |||
310 | 311 | ||
311 | def cssTagsForFiles (self, basePath, files): | 312 | def cssTagsForFiles (self, basePath, files): |
312 | #<link rel="stylesheet" type="text/css" href="./css/reset-min.css" /> | 313 | #<link rel="stylesheet" type="text/css" href="./css/reset-min.css" /> |
313 | return '\n'.join(map(lambda file: '<link rel="stylesheet" type="text/css" href="' + basePath + '/' + file + '" />', files)) | 314 | return '\n'.join(map(lambda file: '<link rel="stylesheet" type="text/css" href="' + basePath + '/' + file + '" />', files)) |
314 | 315 | ||
315 | 316 | ||
316 | def cssTagForContent (self, content): | 317 | def cssTagForContent (self, content): |
317 | return '<style type="text/css">' + content + '</style>' | 318 | return '<style type="text/css">' + content + '</style>' |
318 | 319 | ||
319 | 320 | ||
320 | def scriptTagsForFiles (self, basePath, files): | 321 | def scriptTagsForFiles (self, basePath, files): |
321 | #<script type='text/javascript' src='./js/src/bookmarklet.js'></script> | 322 | #<script type='text/javascript' src='./js/src/bookmarklet.js'></script> |
322 | return '\n'.join(map(lambda file: '<script type="text/javascript" src="' + basePath + '/' + file + '"></script>', files)) | 323 | return '\n'.join(map(lambda file: '<script type="text/javascript" src="' + basePath + '/' + file + '" charset="utf-8"></script>', files)) |
323 | 324 | ||
324 | 325 | ||
325 | def scriptTagForContent (self, content): | 326 | def scriptTagForContent (self, content): |
326 | return '<script>' + content + '</script>' | 327 | return '<script>' + content + '</script>' |
327 | 328 | ||
328 | 329 | ||
329 | def assembleVersion (self, pageTitle, copyright, css, js, jsLoadMode, version, versionType): | 330 | def assembleVersion (self, pageTitle, copyright, css, js, jsLoadMode, version, versionType): |
330 | cacheKey = version + "-" + versionType | 331 | cacheKey = version + "-" + versionType |
331 | if not self.processedFiles.has_key(cacheKey): | 332 | if not self.processedFiles.has_key(cacheKey): |
332 | result = self.replaceTemplatePlaceholders(pageTitle, copyright, css, js, jsLoadMode, version, versionType) | 333 | result = self.replaceTemplatePlaceholders(pageTitle, copyright, css, js, jsLoadMode, version, versionType) |
333 | self.processedFiles[cacheKey] = result | 334 | self.processedFiles[cacheKey] = result |
334 | else: | 335 | else: |
diff --git a/scripts/builder/repository.py b/scripts/builder/repository.py index 0efa10b..0045de7 100644 --- a/scripts/builder/repository.py +++ b/scripts/builder/repository.py | |||
@@ -1,29 +1,32 @@ | |||
1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python |
2 | # -*- coding: UTF-8 -*- | 2 | # -*- coding: UTF-8 -*- |
3 | 3 | ||
4 | 4 | ||
5 | def repositoryWithPath (path): | 5 | def repositoryWithPath (path): |
6 | try: | 6 | try: |
7 | from git import Repo | ||
8 | |||
9 | repo = Repo(path) | ||
10 | result = GitRepository(repo, path) | ||
11 | except ImportError: | ||
12 | print "Failed to import git, please install http://gitorious.org/git-python" | ||
13 | except: | ||
14 | from mercurial import ui, hg | 7 | from mercurial import ui, hg |
15 | 8 | ||
16 | repo = hg.repository(ui.ui(), path) | 9 | repo = hg.repository(ui.ui(), path) |
17 | result = HgRepository(repo, path) | 10 | result = HgRepository(repo, path) |
11 | except: | ||
12 | try: | ||
13 | from git import Repo | ||
14 | |||
15 | repo = Repo(path) | ||
16 | result = GitRepository(repo, path) | ||
17 | except ImportError, exception: | ||
18 | print "Failed to import git, please install http://gitorious.org/git-python" | ||
19 | raise exception | ||
20 | |||
18 | 21 | ||
19 | return result | 22 | return result |
20 | 23 | ||
21 | 24 | ||
22 | #=================================================================== | 25 | #=================================================================== |
23 | 26 | ||
24 | 27 | ||
25 | class Repository(object): | 28 | class Repository(object): |
26 | 29 | ||
27 | def __init__ (self, repository, path): | 30 | def __init__ (self, repository, path): |
28 | self.repository = repository | 31 | self.repository = repository |
29 | self.path = path | 32 | self.path = path |
@@ -41,24 +44,25 @@ class Repository(object): | |||
41 | result = self.revision() | 44 | result = self.revision() |
42 | if self.areTherePendingChanges(): | 45 | if self.areTherePendingChanges(): |
43 | result = '>>> ' + result + ' <<<' | 46 | result = '>>> ' + result + ' <<<' |
44 | 47 | ||
45 | # print "VERSION: " + result | 48 | # print "VERSION: " + result |
46 | return result | 49 | return result |
47 | 50 | ||
48 | 51 | ||
49 | #=================================================================== | 52 | #=================================================================== |
50 | 53 | ||
51 | 54 | ||
52 | class GitRepository(Repository): | 55 | class GitRepository(Repository): |
56 | #http://gitorious.org/git-python | ||
53 | 57 | ||
54 | def revision (self): | 58 | def revision (self): |
55 | return self.repository.head.commit.hexsha | 59 | return self.repository.head.commit.hexsha |
56 | 60 | ||
57 | 61 | ||
58 | def areTherePendingChanges (self): | 62 | def areTherePendingChanges (self): |
59 | return self.repository.is_dirty() | 63 | return self.repository.is_dirty() |
60 | 64 | ||
61 | 65 | ||
62 | #=================================================================== | 66 | #=================================================================== |
63 | 67 | ||
64 | 68 | ||