author | Clipperz <info@clipperz.com> | 2013-01-09 10:37:39 (UTC) |
---|---|---|
committer | Clipperz <info@clipperz.com> | 2013-01-09 10:37:39 (UTC) |
commit | 5996ee475c193f08a713eb53338e4769c2716aa7 (patch) (unidiff) | |
tree | 18947a78d3946635ace383bfc3bacdabda11aafd | |
parent | 813c3245eebfebf9d951e082b9a7473d0116b63a (diff) | |
download | clipperz-5996ee475c193f08a713eb53338e4769c2716aa7.zip clipperz-5996ee475c193f08a713eb53338e4769c2716aa7.tar.gz clipperz-5996ee475c193f08a713eb53338e4769c2716aa7.tar.bz2 |
Fixed build script
Changed the build script in order to replace placeholders even if present multiple times
-rw-r--r-- | scripts/builder/frontendBuilder.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/scripts/builder/frontendBuilder.py b/scripts/builder/frontendBuilder.py index fc603c4..e52c31e 100644 --- a/scripts/builder/frontendBuilder.py +++ b/scripts/builder/frontendBuilder.py | |||
@@ -215,199 +215,199 @@ class FrontendBuilder(object): | |||
215 | ('findLoginForm', 'flf'), | 215 | ('findLoginForm', 'flf'), |
216 | ('findLoginForm', 'flf'), | 216 | ('findLoginForm', 'flf'), |
217 | ('formParameters', 'fp' ), | 217 | ('formParameters', 'fp' ), |
218 | ('pageParameters', 'pp' ), | 218 | ('pageParameters', 'pp' ), |
219 | ('serializeJSON', 'sj' ), | 219 | ('serializeJSON', 'sj' ), |
220 | ('reprString', 'rs' ), | 220 | ('reprString', 'rs' ), |
221 | ('logFormParameters', 'lfp'), | 221 | ('logFormParameters', 'lfp'), |
222 | ('loadClipperzBookmarklet','lcb'), | 222 | ('loadClipperzBookmarklet','lcb'), |
223 | ('loginForm', 'lf' ), | 223 | ('loginForm', 'lf' ), |
224 | ('parameters', 'p' ), | 224 | ('parameters', 'p' ), |
225 | ('inputElementValues', 'iev'), | 225 | ('inputElementValues', 'iev'), |
226 | ] | 226 | ] |
227 | result = self.compressJS(bookmakeletCode, version + " bookmarklet") | 227 | result = self.compressJS(bookmakeletCode, version + " bookmarklet") |
228 | 228 | ||
229 | result = re.sub('\n', ' ', result) #Fit all in a single line | 229 | 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!! | 230 | # 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) | 231 | # result = re.sub('\s?([,\+=\(\)\{\};])\s?', '\\1', result) |
232 | 232 | ||
233 | for replacer in replacers: | 233 | for replacer in replacers: |
234 | result = re.sub(replacer[0], replacer[1], result) | 234 | result = re.sub(replacer[0], replacer[1], result) |
235 | 235 | ||
236 | # <!-- escaping required to handle the bookmarklet code within the javascript code --> | 236 | # <!-- escaping required to handle the bookmarklet code within the javascript code --> |
237 | result = re.sub('\://', '%3a%2f%2f',result) | 237 | result = re.sub('\://', '%3a%2f%2f',result) |
238 | result = re.sub('/', '%2f', result) | 238 | result = re.sub('/', '%2f', result) |
239 | # result = re.sub('"', '%22', result) | 239 | # result = re.sub('"', '%22', result) |
240 | result = re.sub('"', '\\"', result) | 240 | result = re.sub('"', '\\"', result) |
241 | result = re.sub('\"', '%22', result) | 241 | result = re.sub('\"', '%22', result) |
242 | result = re.sub('\'', '%22', result) | 242 | result = re.sub('\'', '%22', result) |
243 | result = re.sub('\\\\', '%5c', result) | 243 | result = re.sub('\\\\', '%5c', result) |
244 | result = result.strip() | 244 | result = result.strip() |
245 | result = 'javascript:' + result | 245 | result = 'javascript:' + result |
246 | 246 | ||
247 | # replacers = [ | 247 | # replacers = [ |
248 | # ('aForm', '_1' ), | 248 | # ('aForm', '_1' ), |
249 | # ('inputFields', '_2' ), | 249 | # ('inputFields', '_2' ), |
250 | # ('passwordFieldsFound','_3' ), | 250 | # ('passwordFieldsFound','_3' ), |
251 | # ('aDocument', '_6' ), | 251 | # ('aDocument', '_6' ), |
252 | # ('aLevel', '_7' ), | 252 | # ('aLevel', '_7' ), |
253 | # # ('result', '_8' ), | 253 | # # ('result', '_8' ), |
254 | # ('documentForms', '_9' ), | 254 | # ('documentForms', '_9' ), |
255 | # ('iFrames', '_c' ), | 255 | # ('iFrames', '_c' ), |
256 | # ('anInputElement', '_d' ), | 256 | # ('anInputElement', '_d' ), |
257 | # ('options', '_f' ), | 257 | # ('options', '_f' ), |
258 | # ('option', '_12'), | 258 | # ('option', '_12'), |
259 | # ('aLoginForm', '_13'), | 259 | # ('aLoginForm', '_13'), |
260 | # # ('action', '_17'), | 260 | # # ('action', '_17'), |
261 | # ('radioValues', '_18'), | 261 | # ('radioValues', '_18'), |
262 | # ('radioValueName', '_19'), | 262 | # ('radioValueName', '_19'), |
263 | # ('inputElement', '_1a'), | 263 | # ('inputElement', '_1a'), |
264 | # ('elementValues', '_1b'), | 264 | # ('elementValues', '_1b'), |
265 | # ('radioValue', '_1c'), | 265 | # ('radioValue', '_1c'), |
266 | # ('values', '_1d'), | 266 | # ('values', '_1d'), |
267 | # ('objtype', '_21'), | 267 | # ('objtype', '_21'), |
268 | # ('useKey', '_27'), | 268 | # ('useKey', '_27'), |
269 | # ('bookmarkletDiv', '_28'), | 269 | # ('bookmarkletDiv', '_28'), |
270 | # ('someParameters', '_29'), | 270 | # ('someParameters', '_29'), |
271 | # ('anException', '_2a'), | 271 | # ('anException', '_2a'), |
272 | # ('newDiv', '_2b'), | 272 | # ('newDiv', '_2b'), |
273 | # ('base_url', '_2c'), | 273 | # ('base_url', '_2c'), |
274 | # ('help_url', '_2d'), | 274 | # ('help_url', '_2d'), |
275 | # ('logo_image_url', '_2e'), | 275 | # ('logo_image_url', '_2e'), |
276 | # ('background_image_url','_2f'), | 276 | # ('background_image_url','_2f'), |
277 | # ('close_image_url', '_30'), | 277 | # ('close_image_url', '_30'), |
278 | # #('bookmarklet_textarea','_31'), | 278 | # #('bookmarklet_textarea','_31'), |
279 | # ('innerHTML', '_32'), | 279 | # ('innerHTML', '_32'), |
280 | # ] | 280 | # ] |
281 | # for replacer in replacers: | 281 | # for replacer in replacers: |
282 | # result = re.sub('([^\.])' + replacer[0], '\\1' + replacer[1], result) | 282 | # result = re.sub('([^\.])' + replacer[0], '\\1' + replacer[1], result) |
283 | 283 | ||
284 | # replacers = [ | 284 | # replacers = [ |
285 | # ('headNode', '_1' ), | 285 | # ('headNode', '_1' ), |
286 | # ('clipperzScriptNode','_2' ), | 286 | # ('clipperzScriptNode','_2' ), |
287 | # ] | 287 | # ] |
288 | # for replacer in replacers: | 288 | # for replacer in replacers: |
289 | # result = re.sub('([^\.])' + replacer[0], '\\1' + replacer[1], result) | 289 | # result = re.sub('([^\.])' + replacer[0], '\\1' + replacer[1], result) |
290 | 290 | ||
291 | # result = re.sub(';', ';\n', result) | 291 | # result = re.sub(';', ';\n', result) |
292 | 292 | ||
293 | return result | 293 | return result |
294 | 294 | ||
295 | 295 | ||
296 | 296 | ||
297 | def bookmarklet (self): | 297 | def bookmarklet (self): |
298 | cacheKey = 'bookmarklet' | 298 | cacheKey = 'bookmarklet' |
299 | if not self.processedFiles.has_key(cacheKey): | 299 | 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") + '";' | 300 | 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 | 301 | self.processedFiles[cacheKey] = result |
302 | else: | 302 | else: |
303 | result = self.processedFiles[cacheKey] | 303 | result = self.processedFiles[cacheKey] |
304 | 304 | ||
305 | return result | 305 | return result |
306 | 306 | ||
307 | 307 | ||
308 | def replaceTemplatePlaceholders (self, pageTitle, copyright, css, code, jsLoadMode, version, versionType): | 308 | def replaceTemplatePlaceholders (self, pageTitle, copyright, css, code, jsLoadMode, version, versionType): |
309 | result = self.template() | 309 | result = self.template() |
310 | 310 | ||
311 | result = result.replace('@page.title@', pageTitle, 1) | 311 | result = result.replace('@page.title@', pageTitle) |
312 | result = result.replace('@copyright@', copyright, 1) | 312 | result = result.replace('@copyright@', copyright) |
313 | result = result.replace('@css@', css, 1) | 313 | result = result.replace('@css@', css) |
314 | #result = result.replace('@bookmarklet@', bookmarklet,1) | 314 | #result = result.replace('@bookmarklet@', bookmarklet) |
315 | result = result.replace('@application.version@', version, 1) | 315 | result = result.replace('@application.version@', version) |
316 | result = result.replace('@application.version.type@', versionType,1) | 316 | result = result.replace('@application.version.type@',versionType) |
317 | result = result.replace('@js_' + jsLoadMode + '@', code, 1) | 317 | result = result.replace('@js_' + jsLoadMode + '@', code) |
318 | 318 | ||
319 | result = re.sub('@js_[^@]+@', '', result) | 319 | result = re.sub('@js_[^@]+@', '', result) |
320 | 320 | ||
321 | return result | 321 | return result |
322 | 322 | ||
323 | 323 | ||
324 | def assembleCopyrightHeader (self): | 324 | def assembleCopyrightHeader (self): |
325 | processedFile = 'copyright' | 325 | processedFile = 'copyright' |
326 | if not self.processedFiles.has_key(processedFile): | 326 | if not self.processedFiles.has_key(processedFile): |
327 | #self.log("assembling copyright header") | 327 | #self.log("assembling copyright header") |
328 | copyrightValues = self.settings['copyright.values'] | 328 | copyrightValues = self.settings['copyright.values'] |
329 | license = self.loadFilesContent('../../properties', ['license.txt']) | 329 | license = self.loadFilesContent('../../properties', ['license.txt']) |
330 | result = self.loadFilesContent('properties', ['creditsAndCopyrights.txt']) | 330 | result = self.loadFilesContent('properties', ['creditsAndCopyrights.txt']) |
331 | 331 | ||
332 | result = re.sub('@clipperz.license@', license, result) | 332 | result = re.sub('@clipperz.license@', license, result) |
333 | for key in copyrightValues: | 333 | for key in copyrightValues: |
334 | result = re.sub('@'+key+'@', copyrightValues[key], result) | 334 | result = re.sub('@'+key+'@', copyrightValues[key], result) |
335 | 335 | ||
336 | self.processedFiles[processedFile] = result | 336 | self.processedFiles[processedFile] = result |
337 | 337 | ||
338 | return self.processedFiles[processedFile] | 338 | return self.processedFiles[processedFile] |
339 | 339 | ||
340 | 340 | ||
341 | def cssTagsForFiles (self, basePath, files): | 341 | def cssTagsForFiles (self, basePath, files): |
342 | #<link rel="stylesheet" type="text/css" href="./css/reset-min.css" /> | 342 | #<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)) | 343 | return '\n'.join(map(lambda file: '<link rel="stylesheet" type="text/css" href="' + basePath + '/' + file + '" />', files)) |
344 | 344 | ||
345 | 345 | ||
346 | def cssTagForContent (self, content): | 346 | def cssTagForContent (self, content): |
347 | return '<style type="text/css">' + content + '</style>' | 347 | return '<style type="text/css">' + content + '</style>' |
348 | 348 | ||
349 | 349 | ||
350 | def scriptTagsForFiles (self, basePath, files): | 350 | def scriptTagsForFiles (self, basePath, files): |
351 | #<script type='text/javascript' src='./js/src/bookmarklet.js'></script> | 351 | #<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)) | 352 | return '\n'.join(map(lambda file: '<script type="text/javascript" src="' + basePath + '/' + file + '" charset="utf-8"></script>', files)) |
353 | 353 | ||
354 | 354 | ||
355 | def scriptTagForContent (self, content): | 355 | def scriptTagForContent (self, content): |
356 | return '<script>' + content + '</script>' | 356 | return '<script>' + content + '</script>' |
357 | 357 | ||
358 | 358 | ||
359 | def assembleVersion (self, pageTitle, copyright, css, js, jsLoadMode, version, versionType): | 359 | def assembleVersion (self, pageTitle, copyright, css, js, jsLoadMode, version, versionType): |
360 | cacheKey = version + "-" + versionType | 360 | cacheKey = version + "-" + versionType |
361 | if not self.processedFiles.has_key(cacheKey): | 361 | if not self.processedFiles.has_key(cacheKey): |
362 | result = self.replaceTemplatePlaceholders(pageTitle, copyright, css, js, jsLoadMode, version, versionType) | 362 | result = self.replaceTemplatePlaceholders(pageTitle, copyright, css, js, jsLoadMode, version, versionType) |
363 | self.processedFiles[cacheKey] = result | 363 | self.processedFiles[cacheKey] = result |
364 | else: | 364 | else: |
365 | result = self.processedFiles[cacheKey] | 365 | result = self.processedFiles[cacheKey] |
366 | 366 | ||
367 | #self.log("# cacheKey:\n" + result) | 367 | #self.log("# cacheKey:\n" + result) |
368 | return result | 368 | return result |
369 | 369 | ||
370 | 370 | ||
371 | def assemble (self, assemblyMode='INSTALL', versionType='LIVE'): | 371 | def assemble (self, assemblyMode='INSTALL', versionType='LIVE'): |
372 | 372 | ||
373 | if versionType == 'LIVE': | 373 | if versionType == 'LIVE': |
374 | pageTitle = "Clipperz - " + self.module | 374 | pageTitle = "Clipperz - " + self.module |
375 | else: | 375 | else: |
376 | pageTitle = "Clipperz - " + self.module + " [" + versionType + " - " + assemblyMode +"]" | 376 | pageTitle = "Clipperz - " + self.module + " [" + versionType + " - " + assemblyMode +"]" |
377 | 377 | ||
378 | if assemblyMode == 'INSTALL': | 378 | if assemblyMode == 'INSTALL': |
379 | copyright = self.assembleCopyrightHeader() | 379 | copyright = self.assembleCopyrightHeader() |
380 | css =self.cssTagForContent(self.compressCSS(self.loadFilesContent('css', self.settings['css']))) | 380 | css =self.cssTagForContent(self.compressCSS(self.loadFilesContent('css', self.settings['css']))) |
381 | js =self.scriptTagForContent( | 381 | js =self.scriptTagForContent( |
382 | self.bookmarklet() + | 382 | self.bookmarklet() + |
383 | '\n' + | 383 | '\n' + |
384 | self.compressJS(self.loadFilesContent('js', self.settings['js']), "application") | 384 | self.compressJS(self.loadFilesContent('js', self.settings['js']), "application") |
385 | ) | 385 | ) |
386 | jsLoadMode = 'EMBEDDED' | 386 | jsLoadMode = 'EMBEDDED' |
387 | 387 | ||
388 | elif assemblyMode == 'DEBUG': | 388 | elif assemblyMode == 'DEBUG': |
389 | copyright = self.assembleCopyrightHeader() | 389 | copyright = self.assembleCopyrightHeader() |
390 | css =self.cssTagsForFiles('./css', self.filterFiles(self.settings['css'])) | 390 | css =self.cssTagsForFiles('./css', self.filterFiles(self.settings['css'])) |
391 | js =self.scriptTagForContent(self.bookmarklet()) + \ | 391 | js =self.scriptTagForContent(self.bookmarklet()) + \ |
392 | '\n' + \ | 392 | '\n' + \ |
393 | self.scriptTagsForFiles('./js', self.filterFiles(self.settings['js'])) | 393 | self.scriptTagsForFiles('./js', self.filterFiles(self.settings['js'])) |
394 | jsLoadMode = 'LINKED' | 394 | jsLoadMode = 'LINKED' |
395 | 395 | ||
396 | elif assemblyMode == 'DEVELOPMENT': | 396 | elif assemblyMode == 'DEVELOPMENT': |
397 | copyright = "" | 397 | copyright = "" |
398 | css =self.cssTagsForFiles('file://' + str(os.path.join(self.absolutePathForSources(), 'css')), self.filterFiles(self.settings['css'])) | 398 | css =self.cssTagsForFiles('file://' + str(os.path.join(self.absolutePathForSources(), 'css')), self.filterFiles(self.settings['css'])) |
399 | js =self.scriptTagForContent(self.bookmarklet()) + \ | 399 | js =self.scriptTagForContent(self.bookmarklet()) + \ |
400 | '\n' + \ | 400 | '\n' + \ |
401 | self.scriptTagsForFiles('file://' + str(os.path.join(self.absolutePathForSources(), 'js')), self.filterFiles(self.settings['js'])) | 401 | self.scriptTagsForFiles('file://' + str(os.path.join(self.absolutePathForSources(), 'js')), self.filterFiles(self.settings['js'])) |
402 | jsLoadMode = 'LINKED' | 402 | jsLoadMode = 'LINKED' |
403 | versionType = 'development' | 403 | versionType = 'development' |
404 | 404 | ||
405 | else: | 405 | else: |
406 | raise NotImplementedError() | 406 | raise NotImplementedError() |
407 | 407 | ||
408 | return self.assembleVersion( | 408 | return self.assembleVersion( |
409 | pageTitle = pageTitle, | 409 | pageTitle = pageTitle, |
410 | copyright = copyright, | 410 | copyright = copyright, |
411 | css = css, | 411 | css = css, |
412 | js = js, | 412 | js = js, |
413 | jsLoadMode = jsLoadMode, | 413 | jsLoadMode = jsLoadMode, |