Example #1
0
    def sourcesConcatenated(self, locale, moduleName, modulePath):
        if moduleName == "inline":
            return

        module = self.currentBuild.files[locale][moduleName]

        bootNs = self.currentBuild.files[locale]["boot"]["__manifest__"][
            "namespace"]

        js = module["__concat__"]

        doStringify = (
            (not "stringify" in self.options or self.options["stringify"])
            and not (moduleName == "boot"
                     and not "inline" in self.projectBuilder.features))

        if doStringify:
            if moduleName == "boot":
                js = "try{%s.Modules.addModule(\"%s\",'%s')}catch(e){giveUp(e)}" % (
                    bootNs, moduleName, buildutil.jsStringEscape(js))
            else:
                js = "%s.Modules.addModule(\"%s\",'%s')" % (
                    bootNs, moduleName, buildutil.jsStringEscape(js))
        else:
            js += "%s.Modules.enableModule(\"%s\")" % (bootNs, moduleName)

        module["__concat__"] = js
Example #2
0
    def sourcesLoaded(self, locale, moduleName, modulePath):
        self.rebuildNeeded = False

        module = self.currentBuild.files[locale][moduleName]

        templates = buildutil.dirEntries(modulePath + "/tmpl")
        for path in templates:
            if not path.endswith(".tmpl.html"):
                continue

            path = self.projectBuilder.resolveFile(path, modulePath + "/tmpl")
            contents = self.projectBuilder.modifiedFiles.read(locale, path)
            if contents:
                module[path] = contents
                self.rebuildNeeded = True

        if not self.rebuildNeeded:
            return

        print "    Loading jQuery templates..."

        module["__templates__"] = u""

        wsReplacer = re.compile(r"[ \t\n\r\f\v]+", flags=re.MULTILINE)
        spaceReplacer = re.compile(r"> <", flags=re.MULTILINE)

        templates = buildutil.dirEntries(modulePath + "/tmpl")
        for path in templates:
            if not path.endswith(".tmpl.html"):
                continue

            path = self.projectBuilder.resolveFile(path, modulePath + "/tmpl")

            template = None
            templateId = None
            for line in module[path].splitlines():
                if line.startswith("<!-- template"):
                    try:
                        templateId = re.findall(r"id=\"(.*)\"", line)[0]
                    except IndexError:
                        raise BuildError(
                            "Template is missing an ID in file %s" %
                            os.path.basename(path))
                    template = u""
                elif line.startswith("<!-- /template"):
                    template = template.replace(
                        " href=\"#\"", " href=\"javascript:void(0)\"")

                    template = wsReplacer.sub(r" ", template).strip()
                    template = spaceReplacer.sub(r"><", template)

                    module[
                        "__templates__"] += u"$.template(\"%s.%s\", '%s');\n" % (
                            moduleName, templateId,
                            buildutil.jsStringEscape(template))
                    template = None
                else:
                    if template is not None:
                        template += line
Example #3
0
    def sourcesConcatenated(self, locale, moduleName, modulePath):
        if moduleName == "inline":
            return

        module = self.currentBuild.files[locale][moduleName]

        bootNs = self.currentBuild.files[locale]["boot"]["__manifest__"]["namespace"]

        js = buildutil.jsStringEscape(module["__concat__"])

        if moduleName == "boot":
            js = "try{%s.Modules.addModule(\"%s\",'%s')}catch(e){giveUp(e)}" % (bootNs, moduleName, js)
        else:
            js = "%s.Modules.addModule(\"%s\",'%s')" % (bootNs, moduleName, js)

        module["__concat__"] = js
Example #4
0
    def sourcesConcatenated(self, locale, moduleName, modulePath):
        if moduleName == "inline":
            return

        module = self.currentBuild.files[locale][moduleName]

        bootNs = self.currentBuild.files[locale]["boot"]["__manifest__"][
            "namespace"]

        js = buildutil.jsStringEscape(module["__concat__"])

        if moduleName == "boot":
            js = "try{%s.Modules.addModule(\"%s\",'%s')}catch(e){giveUp(e)}" % (
                bootNs, moduleName, js)
        else:
            js = "%s.Modules.addModule(\"%s\",'%s')" % (bootNs, moduleName, js)

        module["__concat__"] = js
Example #5
0
    def sourcesConcatenated(self, locale, moduleName, modulePath):
        if moduleName == "inline":
            return

        module = self.currentBuild.files[locale][moduleName]

        bootNs = self.currentBuild.files[locale]["boot"]["__manifest__"]["namespace"]

        js = module["__concat__"]

        doStringify = ((not "stringify" in self.options or self.options["stringify"]) and
                       not (moduleName == "boot" and not "inline" in self.projectBuilder.features)) 

        if doStringify:
            if moduleName == "boot":
                js = "try{%s.Modules.addModule(\"%s\",'%s')}catch(e){giveUp(e)}" % (bootNs, moduleName, buildutil.jsStringEscape(js))
            else:
                js = "%s.Modules.addModule(\"%s\",'%s')" % (bootNs, moduleName, buildutil.jsStringEscape(js))
        else:
            js += "%s.Modules.enableModule(\"%s\")" % (bootNs, moduleName)

        module["__concat__"] = js
Example #6
0
    def sourcesLoaded(self, locale, moduleName, modulePath):
        self.rebuildNeeded = False

        module = self.currentBuild.files[locale][moduleName]

        templates = buildutil.dirEntries(modulePath + "/tmpl")
        for path in templates:
            if not path.endswith(".tmpl.html"):
                continue

            path = self.projectBuilder.resolveFile(path, modulePath + "/tmpl")
            contents = self.projectBuilder.modifiedFiles.read(locale, path)
            if contents:
                module[path] = contents
                self.rebuildNeeded = True

        if not self.rebuildNeeded:
            return

        print "    Loading jQuery templates..."

        module["__templates__"] = u""

        wsReplacer = re.compile(r"[ \t\n\r\f\v]+", flags = re.MULTILINE)
        spaceReplacer = re.compile(r"> <", flags = re.MULTILINE)

        templates = buildutil.dirEntries(modulePath + "/tmpl")
        for path in templates:
            if not path.endswith(".tmpl.html"):
                continue

            path = self.projectBuilder.resolveFile(path, modulePath + "/tmpl")

            template = None
            templateId = None
            for line in module[path].splitlines():
                if line.startswith("<!-- template"):
                    try:
                        templateId = re.findall(r"id=\"(.*)\"", line)[0]
                    except IndexError:
                        raise BuildError("Template is missing an ID in file %s" % os.path.basename(path))
                    template = u""
                elif line.startswith("<!-- /template"):
                    template = template.replace(" href=\"#\"", " href=\"javascript:void(0)\"")

                    template = wsReplacer.sub(r" ", template).strip()
                    template = spaceReplacer.sub(r"><", template)

                    module["__templates__"] += u"$.template(\"%s.%s\", '%s');\n" % (moduleName, templateId, buildutil.jsStringEscape(template))
                    template = None
                else:
                    if template is not None:
                        template += line