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/builder/frontendBuilder.py | |
parent | ff33328861685c1a2d5f9b729a2b3595509c38ee (diff) | |
parent | 6f7ead0446aae6dd9f40b183e402b059a33d0517 (diff) | |
download | clipperz-0e396afdc4aa9ec8734ba48f90e9fefbad3b2b33.zip clipperz-0e396afdc4aa9ec8734ba48f90e9fefbad3b2b33.tar.gz clipperz-0e396afdc4aa9ec8734ba48f90e9fefbad3b2b33.tar.bz2 |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'scripts/builder/frontendBuilder.py') (more/less context) (ignore whitespace changes)
-rw-r--r-- | scripts/builder/frontendBuilder.py | 5 |
1 files changed, 3 insertions, 2 deletions
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 | |||
@@ -75,33 +75,34 @@ class FrontendBuilder(object): | |||
75 | 75 | ||
76 | for file in self.filterFiles(files): | 76 | for file in self.filterFiles(files): |
77 | try: | 77 | try: |
78 | fileHandler = codecs.open(self.absolutePathForSourceFile(basePath, file), 'r', 'utf-8') | 78 | fileHandler = codecs.open(self.absolutePathForSourceFile(basePath, file), 'r', 'utf-8') |
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): |
104 | # http://stackoverflow.com/questions/222581/python-script-for-minifying-css/223689#223689 | 105 | # http://stackoverflow.com/questions/222581/python-script-for-minifying-css/223689#223689 |
105 | 106 | ||
106 | # remove comments - this will break a lot of hacks :-P | 107 | # remove comments - this will break a lot of hacks :-P |
107 | css = re.sub( r'\s*/\*\s*\*/', "$$HACK1$$", css ) # preserve IE<6 comment hack | 108 | css = re.sub( r'\s*/\*\s*\*/', "$$HACK1$$", css ) # preserve IE<6 comment hack |
@@ -306,33 +307,33 @@ class FrontendBuilder(object): | |||
306 | self.processedFiles[processedFile] = result | 307 | self.processedFiles[processedFile] = result |
307 | 308 | ||
308 | return self.processedFiles[processedFile] | 309 | return self.processedFiles[processedFile] |
309 | 310 | ||
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: |
335 | result = self.processedFiles[cacheKey] | 336 | result = self.processedFiles[cacheKey] |
336 | 337 | ||
337 | #self.log("# cacheKey:\n" + result) | 338 | #self.log("# cacheKey:\n" + result) |
338 | return result | 339 | return result |