summaryrefslogtreecommitdiff
path: root/scripts/builder/frontendBuilder.py
Side-by-side diff
Diffstat (limited to 'scripts/builder/frontendBuilder.py') (more/less context) (ignore whitespace changes)
-rw-r--r--scripts/builder/frontendBuilder.py5
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
@@ -67,49 +67,50 @@ class FrontendBuilder(object):
def copyResourcesToFolder (self, targetFolder):
self.copyResources(self.projectDir, targetFolder, 'css')
self.copyResources(self.projectDir, targetFolder, 'js')
def loadFilesContent (self, basePath, files):
result = ""
for file in self.filterFiles(files):
try:
fileHandler = codecs.open(self.absolutePathForSourceFile(basePath, file), 'r', 'utf-8')
except:
print "FILE: " + file
result += fileHandler.read() + '\n'
fileHandler.close()
return result
def template (self):
processedFile = 'html_template'
if not self.processedFiles.has_key(processedFile):
- self.processedFiles[processedFile] = self.loadFilesContent('html', ['index_template.html'])
+ # self.processedFiles[processedFile] = self.loadFilesContent('html', ['index_template.html'])
+ self.processedFiles[processedFile] = self.loadFilesContent('html', [self.settings['html.template']])
return self.processedFiles[processedFile]
def cssminCompressor (self, css):
# package found here:
# - http://stackoverflow.com/questions/222581/python-script-for-minifying-css/2396777#2396777
# actual downloaded version: http://pypi.python.org/pypi/cssmin/0.1.4
return cssmin.cssmin(css)
def regexCssCompressor (self, css):
# http://stackoverflow.com/questions/222581/python-script-for-minifying-css/223689#223689
# remove comments - this will break a lot of hacks :-P
css = re.sub( r'\s*/\*\s*\*/', "$$HACK1$$", css ) # preserve IE<6 comment hack
css = re.sub( r'/\*[\s\S]*?\*/', "", css )
css = css.replace( "$$HACK1$$", '/**/' ) # preserve IE<6 comment hack
# url() doesn't need quotes
css = re.sub( r'url\((["\'])([^)]*)\1\)', r'url(\2)', css )
# spaces may be safely collapsed as generated content will collapse them anyway
css = re.sub( r'\s+', ' ', css )
@@ -298,49 +299,49 @@ class FrontendBuilder(object):
copyrightValues = self.settings['copyright.values']
license = self.loadFilesContent('../../properties', ['license.txt'])
result = self.loadFilesContent('properties', ['creditsAndCopyrights.txt'])
result = re.sub('@clipperz.license@', license, result)
for key in copyrightValues:
result = re.sub('@'+key+'@', copyrightValues[key], result)
self.processedFiles[processedFile] = result
return self.processedFiles[processedFile]
def cssTagsForFiles (self, basePath, files):
#<link rel="stylesheet" type="text/css" href="./css/reset-min.css" />
return '\n'.join(map(lambda file: '<link rel="stylesheet" type="text/css" href="' + basePath + '/' + file + '" />', files))
def cssTagForContent (self, content):
return '<style type="text/css">' + content + '</style>'
def scriptTagsForFiles (self, basePath, files):
#<script type='text/javascript' src='./js/src/bookmarklet.js'></script>
- return '\n'.join(map(lambda file: '<script type="text/javascript" src="' + basePath + '/' + file + '"></script>', files))
+ return '\n'.join(map(lambda file: '<script type="text/javascript" src="' + basePath + '/' + file + '" charset="utf-8"></script>', files))
def scriptTagForContent (self, content):
return '<script>' + content + '</script>'
def assembleVersion (self, pageTitle, copyright, css, js, jsLoadMode, version, versionType):
cacheKey = version + "-" + versionType
if not self.processedFiles.has_key(cacheKey):
result = self.replaceTemplatePlaceholders(pageTitle, copyright, css, js, jsLoadMode, version, versionType)
self.processedFiles[cacheKey] = result
else:
result = self.processedFiles[cacheKey]
#self.log("# cacheKey:\n" + result)
return result
def assemble (self, assemblyMode='INSTALL', versionType='LIVE'):
if versionType == 'LIVE':
pageTitle = "Clipperz - " + self.module
else:
pageTitle = "Clipperz - " + self.module + " [" + versionType + " - " + assemblyMode +"]"