def sourcesLoaded(self, locale, moduleName, modulePath): module = self.currentBuild.files[locale][moduleName] if not "__styles__" in module: return styles = module["__styles__"] for match in re.finditer(r"url\((base64/[^)]+)\)", styles): path = match.group(1) b64Image = buildutil.base64EncodeImage(modulePath + "/img/" + path) styles = styles.replace("url(%s)" % path, "url(%s)" % b64Image) module["__styles__"] = styles
def writeBootHtml(self, locale): bootstrapCode = { "head": "", "body": "Application.init([config])", "tail": "" } self.invokeFeatures("generateBootstrapCode", locale, bootstrapCode) headJs = ( "try{document.domain='%(domain)s'}catch(e){}" "function giveUp(e){var a=confirm('Het spijt me te moeten zeggen dat %(title)s niet kon opstarten. Zullen we het opnieuw proberen?');" r"if(a){window.location.reload()}else{document.body?document.body.innerHTML='<h1>'+e+'</h1><p><button onclick=\"window.location.reload()\">Verfrissen</button></p>':alert(e)}}" "try{" "%(head)s" "function go(){" "%(body)s" "}" "%(tail)s" "}catch(e){giveUp(e)}") % { "domain": self.projectManifest["domain"], "title": self.projectManifest["title"], "head": bootstrapCode["head"], "body": bootstrapCode["body"], "tail": bootstrapCode["tail"] } onloadJs = ("try{go()}catch(e){giveUp(e)}") # icing on the cake, include your favorite icon in the HTML favicon = buildutil.base64EncodeImage(self.projectDir + "/boot/favicon.ico") with open(self.projectDir + "/boot/boot.tpl.html") as f: bootHtml = f.read() % { "favicon": favicon, "headJs": headJs, "onloadJs": onloadJs } filename = buildutil.getDestinationFileName("boot", None, bootHtml, locale, "html") with codecs.open(self.buildDir + "/" + filename, "w", "utf-8") as f: f.write(bootHtml) return buildutil.getContentHash(bootHtml)
def writeBootHtml(self, locale): bootstrapCode = { "head": "", "body": "Application.init([config])", "tail": "" } self.invokeFeatures("generateBootstrapCode", locale, bootstrapCode) headJs = ( "try{document.domain='%(domain)s'}catch(e){}" "function giveUp(e){var a=confirm('Het spijt me te moeten zeggen dat %(title)s niet kon opstarten. Zullen we het opnieuw proberen?');" r"if(a){window.location.reload()}else{document.body?document.body.innerHTML='<h1>'+e+'</h1><p><button onclick=\"window.location.reload()\">Verfrissen</button></p>':alert(e)}}" "try{" "%(head)s" "function go(){" "%(body)s" "}" "%(tail)s" "}catch(e){giveUp(e)}" ) % { "domain": self.projectManifest["domain"], "title": self.projectManifest["title"], "head": bootstrapCode["head"], "body": bootstrapCode["body"], "tail": bootstrapCode["tail"] } onloadJs = ("try{go()}catch(e){giveUp(e)}") # icing on the cake, include your favorite icon in the HTML favicon = buildutil.base64EncodeImage(self.projectDir + "/boot/favicon.ico") with open(self.projectDir + "/boot/boot.tpl.html") as f: bootHtml = f.read() % { "favicon": favicon, "headJs": headJs, "onloadJs": onloadJs } filename = buildutil.getDestinationFileName("boot", None, bootHtml, locale, "html") with codecs.open(self.buildDir + "/" + filename, "w", "utf-8") as f: f.write(bootHtml) return buildutil.getContentHash(bootHtml)