Ejemplo n.º 1
0
    def render(self):
        """
        Returns an XHTML string rendering this page.
        """
        html = common.docType()
        html += u"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
        html += u"<head>\n"
        html += u"<title>" + _("eXe") + "</title>\n"
        html += u"<meta http-equiv=\"Content-Type\" content=\"text/html; "
        html += u" charset=utf-8\" />\n"
        html += u"<!-- Created using eXe: http://exelearning.org -->\n"
        html += u"<style type=\"text/css\">\n"
        html += u"@import url(base.css);\n"
        html += u"@import url(content.css);\n"
        html += u"</style>\n"
        html += u'<script type="text/javascript" src="common.js"></script>\n'
        html += u"</head>\n"
        if self.scormType == 'commoncartridge':
            html += u"<body>"
        else:
            html += u"<script type=\"text/javascript\" "
            html += u"src=\"APIWrapper.js\"></script>\n"
            html += u"<script type=\"text/javascript\" "
            html += u"src=\"SCOFunctions.js\"></script>\n"
            html += u'<body onload="loadPage()" '
            html += u'onunload="unloadPage()">'
        html += u"<div id=\"outer\">\n"
        html += u"<div id=\"main\">\n"
        html += u"<div id=\"nodeDecoration\">\n"
        html += u"<p id=\"nodeTitle\">\n"
        html += escape(self.node.titleLong)
        html += u'</p></div>\n'

        for idevice in self.node.idevices:
            html += u'<div class="%s" id="id%s">\n' % (idevice.klass,
                                                       idevice.id)
            block = g_blockFactory.createBlock(None, idevice)
            if not block:
                log.critical("Unable to render iDevice.")
                raise Error("Unable to render iDevice.")
            if hasattr(idevice, "isQuiz"):
                html += block.renderJavascriptForScorm()
            html += self.processInternalLinks(
                block.renderView(self.node.package.style))
            html += u'</div>\n'  # iDevice div

        html += u"</div>\n"
        html += u"</div>\n"
        if self.node.package.scolinks:
            html += u'<div class="previousnext">'
            html += u'<a class="previouslink" '
            html += u'href="javascript: goBack();">%s</a> | <a class="nextlink" ' % _(
                'Previous')
            html += u'href="javascript: goForward();">%s</a>' % _('Next')
            html += u'</div>'
        html += self.renderLicense()
        html += self.renderFooter()
        html += u"</body></html>\n"
        html = html.encode('utf8')
        return html
Ejemplo n.º 2
0
 def renderNode(self, node):
     """
     Returns an XHTML string for this node and recurse for the children
     """
     html = ""
     html += '<div class="node">\n'
     html += '  <div id=\"nodeDecoration\">'
     html += '<p id=\"nodeTitle\">'
     html += escape(node.titleLong)
     html += '</p></div>\n'
     style = self.node.package.style
     for idevice in node.idevices:
         html += u'  <div class="%s" id="id%s">\n' % (idevice.klass,
                 idevice.id)
         block = g_blockFactory.createBlock(None, idevice)
         if not block:
             log.critical("Unable to render iDevice.")
             raise Error("Unable to render iDevice.")
         if hasattr(idevice, "isQuiz"):
             html += block.renderJavascriptForWeb()
         html += self.processInternalLinks(block.renderView(style))
         html += u'  </div>\n'     # iDevice div
     html += '</div>\n'          # node div
     for child in node.children:
         html += self.renderNode(child)
     return html
Ejemplo n.º 3
0
 def render(self, prevPage, nextPage, pages):
     """
     Returns an XHTML string rendering this page.
     """
     html = u'<?xml version="1.0" encoding="UTF-8"?>\n'
     html += u"<title>"
     html += escape(self.node.titleLong)
     html += u"</title>\n"
     body = ""
     for idevice in self.node.idevices:
         block = g_blockFactory.createBlock(None, idevice)
         if not block:
             log.critical("Unable to render iDevice.")
             raise Error("Unable to render iDevice.")
         if hasattr(idevice, "isCloze"):
             body += block.renderText()
         if idevice.title != "Forum Discussion":
             body += block.renderView("default")
     converter = HtmlToText(body)
     text = converter.convertToText()
     text = text.replace("&", "&amp;")
     text = text.replace(">", "&gt;")
     text = text.replace("<", "&lt;")
     text = text.replace("\r\n", " ")
     text = re.sub(r"^\n+", "", text)
     text = re.sub(r"\n{3,}", "\n\n", text)
     foot = self.getNavigationLink(prevPage, nextPage)
     bodylen = 4050 - len(html) - len(foot)
     if len(text) > bodylen:
         text = text[: text.rfind(" ", 1, bodylen)] + "...\n"
     html = html + text + foot
     html = html.encode("utf8")
     return html
Ejemplo n.º 4
0
    def _parseSpecialResources(self):
        """
        Parse every page and search for special resources like:
            - Linked images
            - Iframes' sources
        """
        # We have to get the rendered view of all idevices across all pages
        for page in self.pages:
            for idevice in page.node.idevices:
                block = g_blockFactory.createBlock(None, idevice)
                div = block.renderView(self.package.style)

                # Find iframes
                src_list = re.findall(r'<iframe[^>]*\ssrc="(.*?)"', div)
                if src_list:
                    self.specialResources['external'].append(page.name)

                # Find links
                src_list = re.findall(r'<a[^>]*\shref="(.*?)"', div)
                if src_list:
                    for src in src_list:
                        # Only include it if is a internal link
                        if Path(self.outputDir / src).exists():
                            self.specialResources['linked_resources'].append(
                                src)
Ejemplo n.º 5
0
 def render(self, prevPage, nextPage, pages):
     """
     Returns an XHTML string rendering this page.
     """
     html  = u"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
     html += u"<title>" 
     html += escape(self.node.titleLong)
     html += u"</title>\n" 
     body = ""
     for idevice in self.node.idevices:
         block = g_blockFactory.createBlock(None, idevice)
         if not block:
             log.critical("Unable to render iDevice.")
             raise Error("Unable to render iDevice.")
         if hasattr(idevice, "isCloze"):
             body += block.renderText()
         if idevice.title != "Forum Discussion":
             body += block.renderView('default')
     converter = HtmlToText(body)
     text = converter.convertToText()
     text = text.replace('&', '&amp;')
     text = text.replace('>', '&gt;')
     text = text.replace('<', '&lt;')
     text = text.replace('\r\n', ' ')
     text = re.sub(r'^\n+', '', text)
     text = re.sub(r'\n{3,}', '\n\n', text)
     foot = self.getNavigationLink(prevPage, nextPage)
     bodylen = 4050 - len(html) - len(foot)
     if len(text) > bodylen:
         text = text[:text.rfind(' ', 1, bodylen)] + '...\n'
     html = html + text + foot
     html = html.encode('utf8')
     return html
Ejemplo n.º 6
0
    def renderNode(self, node):
        """
        Returns an XHTML string for this node and recurse for the children
        """
        html = ""
        html += '<div class="node">\n'
        html += '  <div id=\"nodeDecoration\">'
        html += '<p id=\"nodeTitle\">'
        html += escape(node.titleLong)
        html += '</p></div>\n'

        style = self.node.package.style

        for idevice in node.idevices:
            html += u'  <div class="%s" id="id%s">\n' % (idevice.klass,
                                                         idevice.id)
            block = g_blockFactory.createBlock(None, idevice)
            if not block:
                log.critical("Unable to render iDevice.")
                raise Error("Unable to render iDevice.")
            if hasattr(idevice, "isQuiz"):
                html += block.renderJavascriptForWeb()
            html += self.processInternalLinks(block.renderView(style))
            html += u'  </div>\n'  # iDevice div

        html += '</div>\n'  # node div

        for child in node.children:
            html += self.renderNode(child)

        return html
Ejemplo n.º 7
0
    def render(self):
        """
        Returns an XHTML string rendering this page.
        """
        html  = common.docType()
        html += u"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
        html += u"<head>\n"
        html += u"<title>"+_("eXe")+"</title>\n"
        html += u"<meta http-equiv=\"Content-Type\" content=\"text/html; "
        html += u" charset=utf-8\" />\n";
        html += u"<!-- Created using eXe: http://exelearning.org -->\n"
        html += u"<style type=\"text/css\">\n"
        html += u"@import url(base.css);\n"
        html += u"@import url(content.css);\n"
        html += u"</style>\n"
        html += u'<script type="text/javascript" src="common.js"></script>\n'
        html += u"</head>\n"
        if self.scormType == 'commoncartridge':
            html += u"<body>"
        else:
            html += u"<script type=\"text/javascript\" "
            html += u"src=\"APIWrapper.js\"></script>\n" 
            html += u"<script type=\"text/javascript\" "
            html += u"src=\"SCOFunctions.js\"></script>\n"             
            html += u'<body onload="loadPage()" '
            html += u'onunload="unloadPage()">'
        html += u"<div id=\"outer\">\n"
        html += u"<div id=\"main\">\n"
        html += u"<div id=\"nodeDecoration\">\n"
        html += u"<p id=\"nodeTitle\">\n"
        html += escape(self.node.titleLong)
        html += u'</p></div>\n'

        for idevice in self.node.idevices:
            html += u'<div class="%s" id="id%s">\n' % (idevice.klass,
                    idevice.id)
            block = g_blockFactory.createBlock(None, idevice)
            if not block:
                log.critical("Unable to render iDevice.")
                raise Error("Unable to render iDevice.")
            if hasattr(idevice, "isQuiz"):
                html += block.renderJavascriptForScorm()
            html += self.processInternalLinks(
                    block.renderView(self.node.package.style))
            html += u'</div>\n'     # iDevice div

        html += u"</div>\n"
        html += u"</div>\n"
        if self.node.package.scolinks:
            html += u'<div class="previousnext">'
            html += u'<a class="previouslink" '
            html += u'href="javascript: goBack();">%s</a> | <a class="nextlink" ' % _('Previous')
            html += u'href="javascript: goForward();">%s</a>' % _('Next')
            html += u'</div>'
        html += self.renderLicense()
        html += self.renderFooter()
        html += u"</body></html>\n"
        html = html.encode('utf8')
        return html
Ejemplo n.º 8
0
def ideviceHasMediaelement(idevice):
    block = g_blockFactory.createBlock(None, idevice)
    if not block:
        log.critical("Unable to render iDevice.")
        raise Error("Unable to render iDevice.")
    content = block.renderView("default")
    if re.search("<(video|audio) .*class=['\"]mediaelement", content):
        return True
    return False
def ideviceHasTooltips(idevice):
    block = g_blockFactory.createBlock(None, idevice)
    if not block:
        log.critical("Unable to render iDevice.")
        raise Error("Unable to render iDevice.")
    content = block.renderView('default')
    if re.search('<a .*class=[\'"]exe-tooltip ', content):
        return True
    return False
Ejemplo n.º 10
0
def ideviceHasTooltips(idevice):
    block = g_blockFactory.createBlock(None, idevice)
    if not block:
        log.critical("Unable to render iDevice.")
        raise Error("Unable to render iDevice.")
    content = block.renderView('default')
    if re.search('<a .*class=[\'"]exe-tooltip ', content):
        return True
    return False
Ejemplo n.º 11
0
    def render(self):
        """
        Returns an XHTML string rendering this page.
        """
        html  = common.docType()
        #html += u"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
        lenguaje = G.application.config.locale
        html += u"<html lang=\"" + lenguaje + "\" xml:lang=\"" + lenguaje + "\" xmlns=\"http://www.w3.org/1999/xhtml\">\n"
        html += u"<head>\n"
        html += u"<meta http-equiv=\"Content-type\" content=\"text/html; "
        html += u" charset=utf-8\" />\n";
        html += u"<title>"+_("eXe")+"</title>\n"
        html += u"<style type=\"text/css\">\n"
        html += u"@import url(base.css);\n"
        html += u"@import url(content.css);\n"
        html += u"</style>\n"
        html += u'<script type="text/javascript" src="common.js"></script>\n'
        html += u"</head>\n"
        html += u"<body>\n"
        html += u"<div id=\"outer\">\n"
        html += u"<div id=\"main\">\n"
        html += u"<div id=\"nodeDecoration\">\n"
        html += u'<h1 id=\"nodeTitle\">\n'
        html += escape(self.node.titleLong)
        html += u'</h1>\n'
        html += u"</div>\n"

        for idevice in self.node.idevices:
            html += u'<div class="%s" id="id%s">\n' % (idevice.klass,
                    idevice.id)
            block = g_blockFactory.createBlock(None, idevice)
            if not block:
                log.critical("Unable to render iDevice.")
                raise Error("Unable to render iDevice.")
            if hasattr(idevice, "isQuiz"):
                html += block.renderJavascriptForWeb()
            if idevice.title != "Forum Discussion":
                html += self.processInternalLinks(
                        block.renderView(self.node.package.style))
            html += u'</div>\n'     # iDevice div

        html += u"</div>\n"
        html += self.renderLicense()
        html += self.renderFooter()
        html += u"</div>\n"
        html += u"</body></html>\n"
        html = html.encode('utf8')
        # JR: Eliminamos los atributos de las ecuaciones
        aux = re.compile("exe_math_latex=\"[^\"]*\"")
	html = aux.sub("", html)
	aux = re.compile("exe_math_size=\"[^\"]*\"")
	html = aux.sub("", html)
	#JR: Cambio el & en los enlaces del glosario
	html = html.replace("&concept", "&amp;concept")
        #JR: Cambiamos las anclas por enlaces a archivos
        html = html.replace('href="#', 'href="')
        return html
Ejemplo n.º 12
0
def ideviceHasMediaelement(idevice):
    block = g_blockFactory.createBlock(None, idevice)
    if not block:
        log.critical("Unable to render iDevice.")
        raise Error("Unable to render iDevice.")
    content = block.renderView('default')
    if re.search('<(video|audio) .*class=[\'"]mediaelement', content):
        return True
    return False
Ejemplo n.º 13
0
 def __addBlocks(self, node):
     """
     Add All the blocks for the currently selected node
     """
     for idevice in node.idevices:
         block = g_blockFactory.createBlock(self, idevice)
         if not block:
             log.critical(u"Unable to render iDevice.")
             raise Error(u"Unable to render iDevice.")
         self.blocks.append(block)
Ejemplo n.º 14
0
 def __addBlocks(self, node):
     """
     Add All the blocks for the currently selected node
     """
     for idevice in node.idevices:
         block = g_blockFactory.createBlock(self, idevice)
         if not block:
             log.critical(u"Unable to render iDevice.")
             raise Error(u"Unable to render iDevice.")
         self.blocks.append(block)
Ejemplo n.º 15
0
def ideviceHasGallery(idevice):
    if idevice.klass == 'GalleryIdevice':
        return True
    block = g_blockFactory.createBlock(None, idevice)
    if not block:
        log.critical("Unable to render iDevice.")
        raise Error("Unable to render iDevice.")
    content = block.renderView('default')
    if re.search(' rel=[\'"]lightbox', content):
        return True
    return False
Ejemplo n.º 16
0
def ideviceHasGallery(idevice):
    if idevice.klass == "GalleryIdevice":
        return True
    block = g_blockFactory.createBlock(None, idevice)
    if not block:
        log.critical("Unable to render iDevice.")
        raise Error("Unable to render iDevice.")
    content = block.renderView("default")
    if re.search(" rel=['\"]lightbox", content):
        return True
    return False
Ejemplo n.º 17
0
 def save(self, outputDir, prevPage, nextPage, pages, nonDevices):
     
     XMLPage.currentOutputDir = outputDir
     
     xml = u'<?xml version="1.0" encoding="UTF-8"?>\n'
     xml += u"<exepage title='%s' " % escape(self.node.titleLong)
     
     numRealDevices = 0
     
     """
     Remove all this stuff so that we don't show blank pages
     This is calculated by reading exetoc.xml
     
     if nextPage is not None:
         xml += u"nextpage='%s' " % nextPage.name
     if prevPage is not None:
         xml += u"prevpage='%s' " % prevPage.name
     """
     xml += u">"
     
     style = self.node.package.style
     
     for idevice in self.node.idevices:
         block = g_blockFactory.createBlock(None, idevice)
         
         if not block:
             log.critical("Unable to render iDevice.")
             raise Error("Unable to render iDevice.")
             
         if hasattr(block, "renderXML"):
             deviceId = ""
             if hasattr(block.renderXML, "__call__"):
                 #This block has support for renderXML
                 xml += block.renderXML(style)
                 numRealDevices = numRealDevices + 1
             else:
                 thisIdevice = block.idevice
                 ideviceClassName = thisIdevice.__class__.__name__
                 deviceId = thisIdevice.id
                 nonDevices.append(thisIdevice.__class__.__name__)
                 xml += "<idevice type='html' id='%s'>\n" % thisIdevice.id
                 xml += '<![CDATA[<div class="block" style="display:block">' \
                     + "<p>Idevice %s renderXML unsupported</p></div>]]>" % ideviceClassName
                 xml += "</idevice>"
                 
             
     xml += u"</exepage>"
         
     outfile = open(outputDir / self.name+".xml", "w")
     outfile.write(xml.encode("UTF-8"))
     outfile.close()
     
     return numRealDevices
Ejemplo n.º 18
0
    def render(self):
        """
        Returns an XHTML string rendering this page.
        """
        html  = common.docType()
        html += u"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
        html += u"<head>\n"
        html += u"<meta http-equiv=\"Content-type\" content=\"text/html; "
        html += u" charset=utf-8\" />\n";
        html += u"<title>"+_("eXe")+"</title>\n"
        html += u"<style type=\"text/css\">\n"
        html += u"@import url(base.css);\n"
        html += u"@import url(content.css);\n"
        html += u"</style>\n"
        html += u'<script type="text/javascript" src="common.js"></script>\n'
#modification by lernmodule.net		
        html += u'<script type="text/javascript" src="lernmodule_net.js"></script>\n'
#end modification		
        html += u"</head>\n"
        html += u"<body>\n"
        html += u"<div id=\"outer\">\n"
        html += u"<div id=\"main\">\n"
        html += u"<div id=\"nodeDecoration\">\n"
        html += u'<p id=\"nodeTitle\">\n'
        html += escape(self.node.titleLong)
        html += u'</p>\n'
        html += u"</div>\n"

        for idevice in self.node.idevices:
            html += u'<div class="%s" id="id%s">\n' % (idevice.klass,
                    idevice.id)
            block = g_blockFactory.createBlock(None, idevice)
            if not block:
                log.critical("Unable to render iDevice.")
                raise Error("Unable to render iDevice.")
            if hasattr(idevice, "isQuiz"):
                html += block.renderJavascriptForWeb()
            if idevice.title != "Forum Discussion":
                html += self.processInternalLinks(
                        block.renderView(self.node.package.style))
            html += u'</div>\n'     # iDevice div

        html += u"</div>\n"
        html += self.renderLicense()
        html += self.renderFooter()
#modification by lernmodule.net		
        html += u"<script type=\"text/javascript\" language=\"javascript\">doStart();</script></body></html>\n"
#end modification
        html += u"</div>\n"
        html += u"</body></html>\n"
        html = html.encode('utf8')
        return html
Ejemplo n.º 19
0
 def renderNode(self, node):
     """
     Returns an XHTML string for this node and recurse for the children
     """
     self.html += "\r\n\r\n**" + escape(node.titleLong) + "**"
     for idevice in node.idevices:
         block = g_blockFactory.createBlock(None, idevice)
         if not block:
             log.critical("Unable to render iDevice.")
             raise Error("Unable to render iDevice.")
         self.html += block.renderView('default')
     for child in node.children:
         self.renderNode(child)
Ejemplo n.º 20
0
    def save(self, outputDir, prevPage, nextPage, pages, nonDevices):

        XMLPage.currentOutputDir = outputDir

        xml = u'<?xml version="1.0" encoding="UTF-8"?>\n'
        xml += u"<exepage title='%s' " % escape(self.node.titleLong)

        numRealDevices = 0
        """
        Remove all this stuff so that we don't show blank pages
        This is calculated by reading exetoc.xml
        
        if nextPage is not None:
            xml += u"nextpage='%s' " % nextPage.name
        if prevPage is not None:
            xml += u"prevpage='%s' " % prevPage.name
        """
        xml += u">"

        style = self.node.package.style

        for idevice in self.node.idevices:
            block = g_blockFactory.createBlock(None, idevice)

            if not block:
                log.critical("Unable to render iDevice.")
                raise Error("Unable to render iDevice.")

            if hasattr(block, "renderXML"):
                deviceId = ""
                if hasattr(block.renderXML, "__call__"):
                    #This block has support for renderXML
                    xml += block.renderXML(style)
                    numRealDevices = numRealDevices + 1
                else:
                    thisIdevice = block.idevice
                    ideviceClassName = thisIdevice.__class__.__name__
                    deviceId = thisIdevice.id
                    nonDevices.append(thisIdevice.__class__.__name__)
                    xml += "<idevice type='html' id='%s'>\n" % thisIdevice.id
                    xml += '<![CDATA[<div class="block" style="display:block">' \
                        + "<p>Idevice %s renderXML unsupported</p></div>]]>" % ideviceClassName
                    xml += "</idevice>"

        xml += u"</exepage>"

        outfile = open(outputDir / self.name + ".xml", "w")
        outfile.write(xml.encode("UTF-8"))
        outfile.close()

        return numRealDevices
Ejemplo n.º 21
0
 def render(self):
     html = u""
     for idevice in self.node.idevices:
         if hasattr(idevice, "exportType") and \
             idevice.exportType == freetextidevice.HANDOUT:
             log.debug("Exportable found: %s" % idevice.id)
             
             html += u"<div class=\"%s\" id=\"id%s\">\n" % \
                 (escape(idevice.klass), escape(idevice.id))
             block = g_blockFactory.createBlock(None, idevice)
             style = self.node.package.style
             html += block.renderView(style)
             html += u"</div>\n"
             
     return html
Ejemplo n.º 22
0
    def render(self):
        html = u""
        for idevice in self.node.idevices:
            if hasattr(idevice, "exportType") and \
                idevice.exportType == freetextidevice.HANDOUT:
                log.debug("Exportable found: %s" % idevice.id)

                html += u"<div class=\"%s\" id=\"id%s\">\n" % \
                    (escape(idevice.klass), escape(idevice.id))
                block = g_blockFactory.createBlock(None, idevice)
                style = self.node.package.style
                html += block.renderView(style)
                html += u"</div>\n"

        return html
Ejemplo n.º 23
0
    def renderNode(self, node, nivel):
        """
        Returns an XHTML string for this node and recurse for the children
        """
        dT = common.getExportDocType()
        lb = "\n"  #Line breaks
        headerTag = "div"
        articleTag = "div"
        if dT == "HTML5":
            headerTag = "header"
            articleTag = "article"

        html = ""
        html += '<' + articleTag + ' class="node level-' + str(
            nivel) + '-node">' + lb
        html += '<' + headerTag + ' class=\"nodeDecoration\">'
        html += u'<h1 id=\"' + node.GetAnchorName() + '\" class=\"nodeTitle\">'
        html += escape(node.titleLong)
        html += '</h1></' + headerTag + '>' + lb

        style = self.node.package.style

        node.exportType = 'singlepage'

        for idevice in node.idevices:
            if idevice.klass != 'NotaIdevice':
                e = " em_iDevice"
                if unicode(idevice.emphasis) == '0':
                    e = ""
                html += u'<' + articleTag + ' class="iDevice_wrapper %s%s" id="id%s">%s' % (
                    idevice.klass, e, (idevice.id + "-" + node.id), lb)
                block = g_blockFactory.createBlock(None, idevice)
                if not block:
                    log.critical("Unable to render iDevice.")
                    raise Error("Unable to render iDevice.")
                if hasattr(idevice, "isQuiz"):
                    html += block.renderJavascriptForWeb()
                html += self.processInternalLinks(self.node.package,
                                                  block.renderView(style))
                html = html.replace('href="#auto_top"', 'href="#"')
                html += u'</' + articleTag + '>' + lb  # iDevice div

        html += '</' + articleTag + '>' + lb  # node div

        for child in node.children:
            html += self.renderNode(child, nivel + 1)

        return html
Ejemplo n.º 24
0
    def renderNode(self, node, nivel):
        """
        Returns an XHTML string for this node and recurse for the children
        """
        dT = common.getExportDocType()
        lb = "\n" #Line breaks
        sectionTag = "div"
        headerTag = "div"
        articleTag = "div"
        if dT == "HTML5":
            sectionTag = "section"
            headerTag = "header"
            articleTag = "article"
            nivel = 1
        
        html = ""
        html += '<'+articleTag+' class="node">'+lb
        html += '<'+headerTag+' class=\"nodeDecoration\">'
        html += u'<h' + str(nivel) + ' id=\"' + node.GetAnchorName() + '\" class=\"nodeTitle\">'
        html += escape(node.titleLong)
        html += '</h' + str(nivel) + '></'+headerTag+'>'+lb
        
        style = self.node.package.style

        for idevice in node.idevices:
            if idevice.klass != 'NotaIdevice':
                e=" em_iDevice"
                if unicode(idevice.emphasis)=='0':
                    e=""            
                html += u'<'+sectionTag+' class="iDevice_wrapper %s%s" id="id%s">%s' % (idevice.klass, e, (idevice.id+"-"+node.id), lb)
                block = g_blockFactory.createBlock(None, idevice)
                if not block:
                    log.critical("Unable to render iDevice.")
                    raise Error("Unable to render iDevice.")
                if hasattr(idevice, "isQuiz"):
                    html += block.renderJavascriptForWeb()
                html += self.processInternalLinks(self.node.package,block.renderView(style))
                html = html.replace('href="#auto_top"', 'href="#"')
                html += u'</'+sectionTag+'>'+lb # iDevice div

        html += '</'+articleTag+'>'+lb # node div

        for child in node.children:
            html += self.renderNode(child, nivel+1)

        return html
Ejemplo n.º 25
0
    def render(self, prevPage, nextPage, pages):
        """
        Returns an XHTML string rendering this page.
        """

        html = u"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
        html += u"<title>"
        html += escape(self.node.titleLong)
        html += u"</title>\n"

        body = ""
        for idevice in self.node.idevices:
            block = g_blockFactory.createBlock(None, idevice)
            if not block:
                log.critical("Unable to render iDevice.")
                raise Error("Unable to render iDevice.")
            if hasattr(idevice, "isCloze"):
                body += block.renderText()
            if idevice.title != "Forum Discussion":
                body += block.renderView('default')

        converter = HtmlToText(body)
        text = converter.convertToText()
        text = text.replace('&', '&amp;')
        text = text.replace('>', '&gt;')
        text = text.replace('<', '&lt;')
        text = text.replace('\r\n', ' ')
        # eliminate blank lines at the beginning of the body
        text = re.sub(r'^\n+', '', text)
        # collapse multiple blank lines
        text = re.sub(r'\n{3,}', '\n\n', text)

        foot = self.getNavigationLink(prevPage, nextPage)

        # trim near the max length
        bodylen = 4050 - len(html) - len(foot)
        if len(text) > bodylen:
            text = text[:text.rfind(' ', 1, bodylen)] + '...\n'

        html = html + text + foot
        # writes the footer for each page
        #html += self.renderLicense()
        #html += self.renderFooter()
        html = html.encode('utf8')
        return html
Ejemplo n.º 26
0
 def renderNode(self, node):
     """
     Returns an XHTML string for this node and recurse for the children
     """
     self.html += '<div id=\"nodeDecoration\">'
     self.html += '<p id=\"nodeTitle\">'
     self.html += escape(node.titleLong)
     self.html += '</p></div>\n'
     for idevice in node.idevices:
         block = g_blockFactory.createBlock(None, idevice)
         if not block:
             log.critical("Unable to render iDevice.")
             raise Error("Unable to render iDevice.")
         if hasattr(idevice, "isQuiz"):
             self.html += block.renderJavascriptForWeb()
         self.html += block.renderView(self.style)
     for child in node.children:
         self.renderNode(child)
Ejemplo n.º 27
0
 def render(self, prevPage, nextPage, pages):
     """
     Returns an XHTML string rendering this page.
     """
     html  = u"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
     html += u"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" "
     html += u" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
     html += u"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
     html += u"<head>\n"
     html += u"<style type=\"text/css\">\n"
     html += u"@import url(base.css);\n"
     html += u"@import url(content.css);\n"
     html += u"@import url(nav.css);</style>\n"
     html += u"<title> " 
     html += escape(self.node.titleLong)
     html += u" </title>\n" 
     html += u"<meta http-equiv=\"Content-Type\" content=\"text/html; "
     html += u" charset=utf-8\" />\n";
     html += u'<script type="text/javascript" src="common.js"></script>\n'
     html += u"</head>\n"
     html += u"<body>\n"
     html += u"<div id=\"navcontainer\">\n"
     html += self.leftNavigationBar(pages)
     html += u"</div>\n"
     html += u"<div id=\"main\">\n"
     style = self.node.package.style
     html += '<div id=\"nodeDecoration\">'
     html += '<p id=\"nodeTitle\">'
     html += escape(self.node.titleLong)
     html += '</p></div>\n'
     for idevice in self.node.idevices:
         block = g_blockFactory.createBlock(None, idevice)
         if not block:
             log.critical("Unable to render iDevice.")
             raise Error("Unable to render iDevice.")
         if hasattr(idevice, "isQuiz"):
             html += block.renderJavascriptForWeb()
         if idevice.title != "Forum Discussion":
             html += block.renderView(style)
     html += self.getNavigationLink(prevPage, nextPage)
     html += u"</div>\n"
     html += u"</body></html>\n"
     html = html.encode('utf8')
     return html
Ejemplo n.º 28
0
    def renderNode(self, node):
        """
        Returns an XHTML string for this node and recurse for the children
        """

        self.html += os.linesep * 2 + "**" + escape(node.titleLong) + "**"

        for idevice in node.idevices:
            block = g_blockFactory.createBlock(None, idevice)
            if not block:
                log.critical("Unable to render iDevice.")
                raise Error("Unable to render iDevice.")
            if hasattr(idevice, 'isCloze'):
                self.html += block.renderText()
            else:
                self.html += block.renderView('default')

        for child in node.children:
            self.renderNode(child)
Ejemplo n.º 29
0
 def render(self):
     """
     Returns an XHTML string rendering this page.
     """
     html  = common.docType()
     html += u"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
     html += u"<head>\n"
     html += u"<title>"+_("eXe")+"</title>\n"
     html += u"<meta http-equiv=\"Content-Type\" content=\"text/html; "
     html += u" charset=utf-8\" />\n";
     html += u"<style type=\"text/css\">\n"
     html += u"@import url(base.css);\n"
     html += u"@import url(content.css);\n"
     html += u"</style>\n"
     html += u"<script type=\"text/javascript\" "
     html += u"src=\"APIWrapper.js\"></script>\n" 
     html += u"<script type=\"text/javascript\" "
     html += u"src=\"SCOFunctions.js\"></script>\n"             
     html += u'<script type="text/javascript" src="common.js"></script>\n'
     html += u"</head>\n"
     html += u'<body onload="loadPage()" onbeforeunload="unloadPage()" '
     html += u'onunload="unloadPage()">'
     html += u"<div id=\"outer\">\n"
     html += u"<div id=\"main\">\n"
     html += u"<div id=\"nodeDecoration\">\n"
     html += u"<p id=\"nodeTitle\">\n"
     html += escape(self.node.titleLong)
     html += u'</p></div>\n'
     for idevice in self.node.idevices:
         block = g_blockFactory.createBlock(None, idevice)
         if not block:
             log.critical("Unable to render iDevice.")
             raise Error("Unable to render iDevice.")
         if hasattr(idevice, "isQuiz"):
             html += block.renderJavascriptForScorm()
         html += block.renderView(self.node.package.style)
     html += u"</div>\n"
     html += u"</div>\n"
     html += u"</body></html>\n"
     html = html.encode('utf8')
     return html
Ejemplo n.º 30
0
    def renderNode(self, node):
        """
        Returns an XHTML string for this node and recurse for the children
        """

        self.html += os.linesep*2 + "**" + escape(node.titleLong) + "**"


        for idevice in node.idevices:
            if idevice.klass != 'NotaIdevice':
                block = g_blockFactory.createBlock(None, idevice)
                if not block:
                    log.critical("Unable to render iDevice.")
                    raise Error("Unable to render iDevice.")
                if hasattr(idevice, 'isCloze'):
                    self.html += block.renderText()
                else:
                    self.html += block.renderView('default')

        for child in node.children:
            self.renderNode(child)
Ejemplo n.º 31
0
    def render(self, pages):
        html = '''<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <meta charset="utf-8" />
   </head>
   <body style="text-align: center;">
      <img id="img-cover" src="%s" alt="%s" />
   </body>
</html>'''
        src = 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D'
        for idevice in self.node.idevices:
            block = g_blockFactory.createBlock(None, idevice)
            div = block.renderView(self.node.package.style)
            srcs = re.findall(r'<img[^>]*\ssrc="(.*?)"', div)
            if srcs:
                src = srcs[0]
                self.cover = src
                break
        return html % (src, escape(self.node.package.title, True))
Ejemplo n.º 32
0
    def render(self):
        html = '''<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <meta charset="utf-8" />
   </head>
   <body style="text-align: center;">
      <img id="img-cover" src="%s" alt="%s" />
   </body>
</html>'''
        src = ''
        for idevice in self.node.idevices:
            block = g_blockFactory.createBlock(None, idevice)
            div = block.renderView(self.node.package.style)
            srcs = re.findall(r'<img[^>]*\ssrc="(.*?)"', div)
            if srcs:
                src = srcs[0]
                self.cover = src
                break
        return html % (src, self.node.package.title)
Ejemplo n.º 33
0
    def render(self):
        html = """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <meta charset="utf-8" />
   </head>
   <body style="text-align: center;">
      <img id="img-cover" src="%s" alt="%s" />
   </body>
</html>"""
        src = "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D"
        for idevice in self.node.idevices:
            block = g_blockFactory.createBlock(None, idevice)
            div = block.renderView(self.node.package.style)
            srcs = re.findall(r'<img[^>]*\ssrc="(.*?)"', div)
            if srcs:
                src = srcs[0]
                self.cover = src
                break
        return html % (src, escape(self.node.package.title, True))
Ejemplo n.º 34
0
    def _parseSpecialResources(self):
        """
        Parse every page and search for special resources like:
            - Linked images
            - Iframes' sources
        """
        # We have to get the rendered view of all idevices across all pages
        for page in self.pages:
            for idevice in page.node.idevices:
                block = g_blockFactory.createBlock(None, idevice)
                div = block.renderView(self.package.style)

                # Find iframes
                src_list = re.findall(r'<iframe[^>]*\ssrc="(.*?)"', div);
                if src_list:
                    self.specialResources['external'].append(page.name)

                # Find links
                src_list = re.findall(r'<a[^>]*\shref="(.*?)"', div);
                if src_list:
                    for src in src_list:
                        # Only include it if is a internal link
                        if Path(self.outputDir/src).exists():
                            self.specialResources['linked_resources'].append(src)
Ejemplo n.º 35
0
    def render(self):
        """
        Returns an XHTML string rendering this page.
        """
        old_dT = common.getExportDocType()
        common.setExportDocType("HTML5")
        dT = common.getExportDocType()
        lb = "\n"  # Line breaks
        sectionTag = "div"
        articleTag = "div"
        headerTag = "div"
        if dT == "HTML5":
            sectionTag = "section"
            articleTag = "article"
            headerTag = "header"
        html = common.docType()
        lenguaje = G.application.config.locale
        if self.node.package.lang != "":
            lenguaje = self.node.package.lang
        html += u'<html lang="' + lenguaje + '" xml:lang="' + lenguaje + '" xmlns="http://www.w3.org/1999/xhtml">' + lb
        html += u"<head>" + lb
        html += u"<title>"
        if self.node.id == "0":
            if self.node.package.title != "":
                html += escape(self.node.package.title)
            else:
                html += escape(self.node.titleLong)
        else:
            if self.node.package.title != "":
                html += escape(self.node.titleLong) + " | " + escape(self.node.package.title)
            else:
                html += escape(self.node.titleLong)
        html += u" </title>" + lb
        html += u'<meta charset="utf-8" />' + lb
        if dT != "HTML5" and self.node.package.lang != "":
            html += '<meta http-equiv="content-language" content="' + lenguaje + '" />' + lb
        if self.node.package.author != "":
            html += '<meta name="author" content="' + escape(self.node.package.author, True) + '" />' + lb
        html += common.getLicenseMetadata(self.node.package.license)
        html += '<meta name="generator" content="eXeLearning ' + release + ' - exelearning.net" />' + lb
        if self.node.id == "0":
            if self.node.package.description != "":
                html += '<meta name="description" content="' + escape(self.node.package.description, True) + '" />' + lb
        html += u'<link rel="stylesheet" type="text/css" href="base.css" />' + lb
        if common.hasWikipediaIdevice(self.node):
            html += u'<link rel="stylesheet" type="text/css" href="exe_wikipedia.css" />' + lb
        if common.hasGalleryIdevice(self.node):
            html += u'<link rel="stylesheet" type="text/css" href="exe_lightbox.css" />' + lb
        if common.hasFX(self.node):
            html += u'<link rel="stylesheet" type="text/css" href="exe_effects.css" />' + lb
        if common.hasSH(self.node):
            html += u'<link rel="stylesheet" type="text/css" href="exe_highlighter.css" />' + lb
        if common.hasGames(self.node):
            html += u'<link rel="stylesheet" type="text/css" href="exe_games.css" />' + lb
        html += u'<link rel="stylesheet" type="text/css" href="content.css" />' + lb
        if dT == "HTML5" or common.nodeHasMediaelement(self.node):
            html += u'<!--[if lt IE 9]><script type="text/javascript" src="exe_html5.js"></script><![endif]-->' + lb
        style = G.application.config.styleStore.getStyle(self.node.package.style)

        # jQuery
        if style.hasValidConfig:
            if style.get_jquery() == True:
                html += u'<script type="text/javascript" src="exe_jquery.js"></script>' + lb
            else:
                html += u'<script type="text/javascript" src="' + style.get_jquery() + '"></script>' + lb
        else:
            html += u'<script type="text/javascript" src="exe_jquery.js"></script>' + lb

        if common.hasGalleryIdevice(self.node):
            html += u'<script type="text/javascript" src="exe_lightbox.js"></script>' + lb
        if common.hasFX(self.node):
            html += u'<script type="text/javascript" src="exe_effects.js"></script>' + lb
        if common.hasSH(self.node):
            html += u'<script type="text/javascript" src="exe_highlighter.js"></script>' + lb
        html += common.getJavaScriptStrings() + lb
        if common.hasGames(self.node):
            # The games require additional strings
            html += common.getGamesJavaScriptStrings() + lb
            html += u'<script type="text/javascript" src="exe_games.js"></script>' + lb
        html += u'<script type="text/javascript" src="common.js"></script>' + lb
        if common.hasMagnifier(self.node):
            html += u'<script type="text/javascript" src="mojomagnify.js"></script>' + lb
        # Some styles might have their own JavaScript files (see their config.xml file)
        if style.hasValidConfig:
            html += style.get_extra_head()
        html += u"</head>" + lb
        html += u'<body class="exe-epub3"><script type="text/javascript">document.body.className+=" js"</script>' + lb
        html += u'<div id="outer">' + lb
        html += u"<" + sectionTag + ' id="main">' + lb
        html += u"<" + headerTag + ' id="nodeDecoration">'
        html += u'<div id="headerContent">'
        html += u'<h1 id="nodeTitle">'
        html += escape(self.node.titleLong)
        html += u"</h1>"
        html += u"</div>"
        html += u"</" + headerTag + ">" + lb

        self.node.exportType = "epub"

        for idevice in self.node.idevices:
            if idevice.klass != "NotaIdevice":
                e = " em_iDevice"
                if unicode(idevice.emphasis) == "0":
                    e = ""
                html += (
                    u"<"
                    + articleTag
                    + ' class="iDevice_wrapper %s%s" id="id%s">%s' % (idevice.klass, e, idevice.id, lb)
                )
                block = g_blockFactory.createBlock(None, idevice)
                if not block:
                    log.critical("Unable to render iDevice.")
                    raise Error("Unable to render iDevice.")
                if hasattr(idevice, "isQuiz"):
                    html += htmlentitydecode(block.renderJavascriptForWeb())
                if idevice.title != "Forum Discussion":
                    html += htmlentitydecode(self.processInternalLinks(block.renderView(self.node.package.style)))
                html += u"</" + articleTag + ">" + lb  # iDevice div

        html += u"</" + sectionTag + ">" + lb  # /#main
        html += self.renderLicense()
        html += unicode(BeautifulSoup(self.renderFooter(), convertEntities=BeautifulSoup.XHTML_ENTITIES))
        html += u"</div>" + lb  # /#outer
        if style.hasValidConfig:
            html += style.get_extra_body()
        html += u"</body></html>"
        html = html.encode("utf8")
        # JR: Eliminamos los atributos de las ecuaciones
        aux = re.compile('exe_math_latex="[^"]*"')
        html = aux.sub("", html)
        aux = re.compile('exe_math_size="[^"]*"')
        html = aux.sub("", html)
        # JR: Cambio el & en los enlaces del glosario
        html = html.replace("&concept", "&amp;concept")
        # Remove "resources/" from data="resources/ and the url param
        html = html.replace('video/quicktime" data="resources/', 'video/quicktime" data="')
        html = html.replace('application/x-mplayer2" data="resources/', 'application/x-mplayer2" data="')
        html = html.replace('audio/x-pn-realaudio-plugin" data="resources/', 'audio/x-pn-realaudio-plugin" data="')
        html = html.replace('<param name="url" value="resources/', '<param name="url" value="')

        common.setExportDocType(old_dT)
        return html
Ejemplo n.º 36
0
    def render(self, prevPage, nextPage, pages):
        """
        Returns an XHTML string rendering this page.
        """
        lenguaje = G.application.config.locale
        if self.node.package.dublinCore.language!="":
            lenguaje = self.node.package.dublinCore.language
        
        dT = common.getExportDocType()
        themeHasXML = common.themeHasConfigXML(self.node.package.style)
        lb = "\n" #Line breaks
        sectionTag = "div"
        articleTag = "div"
        headerTag = "div"
        navTag = "div"
        if dT == "HTML5":
            html = '<!doctype html>'+lb
            html += '<html lang="'+lenguaje+'">'+lb
            sectionTag = "section"
            articleTag = "article"
            headerTag = "header"
            navTag = "nav"
        else:
            html = u'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'+lb
            html += u"<html lang=\"" + lenguaje + "\" xml:lang=\"" + lenguaje + "\" xmlns=\"http://www.w3.org/1999/xhtml\">"+lb
        html += u"<head>"+lb
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"base.css\" />"+lb
        if common.hasWikipediaIdevice(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_wikipedia.css\" />"+lb    
        if common.hasGalleryIdevice(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_lightbox.css\" />"+lb
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"content.css\" />"+lb
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"nav.css\" />"+lb
        html += u"<meta http-equiv=\"content-type\" content=\"text/html; "
        html += u" charset=utf-8\" />"+lb        
        html += u"<title>"
        if self.node.id=='0':
            if self.node.package.title!='':
                html += escape(self.node.package.title)
            else:
                html += escape(self.node.titleLong)
        else:
            if self.node.package.title!='':
                html += escape(self.node.titleLong)+" | "+escape(self.node.package.title)
            else:
                html += escape(self.node.titleLong)
        html += u" </title>"+lb
        html += u"<link rel=\"shortcut icon\" href=\"favicon.ico\" type=\"image/x-icon\" />"+lb
        if dT != "HTML5" and self.node.package.dublinCore.language!="":
            html += '<meta http-equiv="content-language" content="'+lenguaje+'" />'+lb
        if self.node.package.author!="":
            html += '<meta name="author" content="'+self.node.package.author+'" />'+lb
        html += '<meta name="generator" content="eXeLearning '+release+' - exelearning.net" />'+lb
        if self.node.id=='0':
            if self.node.package.description!="":
                html += '<meta name="description" content="'+self.node.package.description+'" />'+lb
        if dT == "HTML5" or common.nodeHasMediaelement(self.node):
            html += u'<!--[if lt IE 9]><script type="text/javascript" src="exe_html5.js"></script><![endif]-->'+lb
        style = G.application.config.styleStore.getStyle(self.node.package.style)
        
        # jQuery
        if style.hasValidConfig:
            if style.get_jquery()==True:
                html += u'<script type="text/javascript" src="exe_jquery.js"></script>'+lb
            else:
                html += u'<script type="text/javascript" src="'+style.get_jquery()+'"></script>'+lb
        else:
            html += u'<script type="text/javascript" src="exe_jquery.js"></script>'+lb
        
        if common.hasGalleryIdevice(self.node):
            html += u'<script type="text/javascript" src="exe_lightbox.js"></script>'+lb
        html += common.getJavaScriptStrings()+lb
        html += u'<script type="text/javascript" src="common.js"></script>'+lb
        html += u'<script type="text/javascript" src="lernmodule_net.js"></script>'+lb
        if common.hasMagnifier(self.node):
            html += u'<script type="text/javascript" src="mojomagnify.js"></script>'+lb
        # Some styles might have their own JavaScript files (see their config.xml file)
        if style.hasValidConfig:
            html += style.get_extra_head()
        html += u"</head>"+lb
        html += u'<body class="exe-web-site"><script type="text/javascript">document.body.className+=" js"</script>'+lb
        html += u"<div id=\"content\">"+lb
        html += '<p id="skipNav"><a href="#main" class="sr-av">' + c_('Skip navigation')+'</a></p>'+lb

        if self.node.package.backgroundImg or self.node.package.title:
            html += u"<"+headerTag+" id=\"header\" "

            if self.node.package.backgroundImg:
                html += u" style=\"background-image: url("
                html += quote(self.node.package.backgroundImg.basename())
                html += u"); "

                if self.node.package.backgroundImgTile:
                    html += "background-repeat: repeat-x;"
                else:
                    html += "background-repeat: no-repeat;"

                html += u"\""
            html += u">"
            #html += escape(self.node.package.title)
            html += u"</"+headerTag+">"+lb
        else:
            html += "<"+sectionTag+" id=\"emptyHeader\"></"+sectionTag+">"+lb
        
        # add left navigation html
        html += u"<"+navTag+" id=\"siteNav\">"+lb
        html += self.leftNavigationBar(pages)
        html += u"</"+navTag+">"+lb
        html += "<div id='topPagination'>"+lb
        html += self.getNavigationLink(prevPage, nextPage)
        html += "</div>"+lb
        html += u"<div id=\"main-wrapper\">"+lb
        html += u"<"+sectionTag+" id=\"main\">"
        if dT != "HTML5":
            html += "<a name=\"main\"></a>"
        html += lb

        html += '<'+headerTag+' id=\"nodeDecoration\">'
        html += '<h1 id=\"nodeTitle\">'
        html += escape(self.node.titleLong)
        html += '</h1>'
        html += '</'+headerTag+'>'+lb

        for idevice in self.node.idevices:
            if idevice.klass != 'NotaIdevice':
                e=" em_iDevice"
                if unicode(idevice.emphasis)=='0':
                    e=""
                html += u'<'+articleTag+' class="iDevice_wrapper %s%s" id="id%s">%s' %  (idevice.klass, e, idevice.id, lb)
                block = g_blockFactory.createBlock(None, idevice)
                if not block:
                    log.critical("Unable to render iDevice.")
                    raise Error("Unable to render iDevice.")
                if hasattr(idevice, "isQuiz"):
                    html += block.renderJavascriptForWeb()
                if idevice.title != "Forum Discussion":
                    html += self.processInternalLinks(self.node.package,
                        block.renderView(self.node.package.style))
                html += u'</'+articleTag+'>'+lb # iDevice div

        html += "<"+sectionTag+" id=\"lmsubmit\"></"+sectionTag+"><script type=\"text/javascript\" language=\"javascript\">doStart();</script>"+lb
        if not themeHasXML:
            html += "<div id='bottomPagination'>"+lb
            html += self.getNavigationLink(prevPage, nextPage)
            html += "</div>"+lb
        # writes the footer for each page 
        html += self.renderLicense()
        if not themeHasXML:
        #if not style.hasValidConfig:
            html += self.renderFooter()
        html += u"</"+sectionTag+">"+lb # /main
        html += u"</div>"+lb # /main-wrapper
        if themeHasXML:
        #if style.hasValidConfig:
            html += "<div id='bottomPagination'>"+lb
            html += self.getNavigationLink(prevPage, nextPage)
            html += "</div>"+lb        
            html += self.renderFooter()
        html += u"</div>"+lb # /content
        if themeHasXML:
        #if style.hasValidConfig:
            html += style.get_extra_body()        
        html += u'</body>'
        html += u'<script type="text/javascript" src="lernmodule_net_custom.js"></script>'+lb
        html += u'</html>'
        html = html.encode('utf8')
        # JR: Eliminamos los atributos de las ecuaciones
        aux = re.compile("exe_math_latex=\"[^\"]*\"")
	html = aux.sub("", html)
	aux = re.compile("exe_math_size=\"[^\"]*\"")
	html = aux.sub("", html)
	#JR: Cambio el & en los enlaces del glosario
	html = html.replace("&concept", "&amp;concept")
    # Remove "resources/" from data="resources/ and the url param
	html = html.replace("video/quicktime\" data=\"resources/", "video/quicktime\" data=\"")
	html = html.replace("application/x-mplayer2\" data=\"resources/", "application/x-mplayer2\" data=\"")
	html = html.replace("audio/x-pn-realaudio-plugin\" data=\"resources/", "audio/x-pn-realaudio-plugin\" data=\"")
	html = html.replace("<param name=\"url\" value=\"resources/", "<param name=\"url\" value=\"")
        return html
Ejemplo n.º 37
0
    def render(self):
        """
        Returns an XHTML string rendering this page.
        """
        html = common.docType()
        #html += u"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
        lenguaje = G.application.config.locale
        html += u"<html lang=\"" + lenguaje + "\" xml:lang=\"" + lenguaje + "\" xmlns=\"http://www.w3.org/1999/xhtml\">\n"
        html += u"<head>\n"
        html += u"<title>" + _("eXe") + "</title>\n"
        html += u"<meta http-equiv=\"Content-Type\" content=\"text/html; "
        html += u" charset=utf-8\" />\n"
        html += u"<!-- Created using eXe: http://exelearning.org -->\n"
        html += u"<style type=\"text/css\">\n"
        html += u"@import url(base.css);\n"
        html += u"@import url(content.css);\n"
        html += u"</style>\n"
        html += u'<script type="text/javascript" src="common.js"></script>\n'
        #html += u"</head>\n"
        if self.scormType == 'commoncartridge':
            html += u"</head>\n"
            html += u"<body>"
        else:
            html += u"<script type=\"text/javascript\" "
            html += u"src=\"APIWrapper.js\"></script>\n"
            html += u"<script type=\"text/javascript\" "
            html += u"src=\"SCOFunctions.js\"></script>\n"
            html += u"</head>\n"
            html += u'<body onload="loadPage()" '
            html += u'onunload="unloadPage()">'
        html += u"<div id=\"outer\">\n"
        html += u"<div id=\"main\">\n"
        html += u"<div id=\"nodeDecoration\">\n"
        html += u"<h1 id=\"nodeTitle\">\n"
        html += escape(self.node.titleLong)
        html += u'</h1></div>\n'

        for idevice in self.node.idevices:
            html += u'<div class="%s" id="id%s">\n' % (idevice.klass,
                                                       idevice.id)
            block = g_blockFactory.createBlock(None, idevice)
            if not block:
                log.critical("Unable to render iDevice.")
                raise Error("Unable to render iDevice.")
            if hasattr(idevice, "isQuiz"):
                html += block.renderJavascriptForScorm()
            html += self.processInternalLinks(
                block.renderView(self.node.package.style))
            html += u'</div>\n'  # iDevice div

        html += u"</div>\n"
        html += u"</div>\n"
        if self.node.package.scolinks:
            html += u'<div class="previousnext">'
            html += u'<a class="previouslink" '
            html += u'href="javascript: goBack();">%s</a> | <a class="nextlink" ' % _(
                'Previous')
            html += u'href="javascript: goForward();">%s</a>' % _('Next')
            html += u'</div>'
        html += self.renderLicense()
        html += self.renderFooter()
        html += u"</body></html>\n"
        html = html.encode('utf8')
        # JR: Eliminamos los atributos de las ecuaciones
        aux = re.compile("exe_math_latex=\"[^\"]*\"")
        html = aux.sub("", html)
        aux = re.compile("exe_math_size=\"[^\"]*\"")
        html = aux.sub("", html)
        #JR: Cambio el & en los enlaces del glosario
        html = html.replace("&concept", "&amp;concept")
        return html
Ejemplo n.º 38
0
    def render(self):
        """
        Returns an XHTML string rendering this page.
        """
        dT = common.getExportDocType()
        lb = "\n" #Line breaks
        sectionTag = "div"
        articleTag = "div"
        headerTag = "div"
        if dT == "HTML5":
            sectionTag = "section"
            articleTag = "article"
            headerTag = "header"
        html  = common.docType()
        lenguaje = G.application.config.locale
        style = G.application.config.styleStore.getStyle(self.node.package.style)
        if self.node.package.dublinCore.language!="":
            lenguaje = self.node.package.dublinCore.language
        html += u"<html lang=\"" + lenguaje + "\" xml:lang=\"" + lenguaje + "\" xmlns=\"http://www.w3.org/1999/xhtml\">"+lb
        html += u"<head>"+lb
        html += u"<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />"+lb
        html += u"<title>"
        if self.node.id=='0':
            if self.node.package.title!='':
                html += escape(self.node.package.title)
            else:
                html += escape(self.node.titleLong)
        else:
            if self.node.package.title!='':
                html += escape(self.node.titleLong)+" | "+escape(self.node.package.title)
            else:
                html += escape(self.node.titleLong)
        html += u" </title>"+lb
        if dT != "HTML5" and self.node.package.dublinCore.language!="":
            html += '<meta http-equiv="content-language" content="'+lenguaje+'" />'+lb
        if self.node.package.author!="":
            html += '<meta name="author" content="'+self.node.package.author+'" />'+lb
        html += '<meta name="generator" content="eXeLearning '+release+' - exelearning.net" />'+lb
        if self.node.id=='0':
            if self.node.package.description!="":
                html += '<meta name="description" content="'+self.node.package.description+'" />'+lb
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"base.css\" />"+lb
        if common.hasWikipediaIdevice(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_wikipedia.css\" />"+lb
        if common.hasGalleryIdevice(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_lightbox.css\" />"+lb
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"content.css\" />"+lb
        if dT == "HTML5" or common.nodeHasMediaelement(self.node):
            html += u'<!--[if lt IE 9]><script type="text/javascript" src="exe_html5.js"></script><![endif]-->'+lb
        
        # jQuery
        if style.hasValidConfig:
            if style.get_jquery() == True:
                html += u'<script type="text/javascript" src="exe_jquery.js"></script>'+lb
            else:
                html += u'<script type="text/javascript" src="'+style.get_jquery()+'"></script>'+lb
        else:
            html += u'<script type="text/javascript" src="exe_jquery.js"></script>'+lb
        
        if common.hasGalleryIdevice(self.node):
            html += u'<script type="text/javascript" src="exe_lightbox.js"></script>'+lb
        html += common.getJavaScriptStrings()+lb
        html += u'<script type="text/javascript" src="common.js"></script>'+lb
        if common.hasMagnifier(self.node):
            html += u'<script type="text/javascript" src="mojomagnify.js"></script>'+lb
        if self.scormType == 'commoncartridge':
            if style.hasValidConfig:
                html += style.get_extra_head()        
            html += u"</head>"+lb
            html += u"<body class=\"exe-scorm\">"
        else:
            html += u"<script type=\"text/javascript\" src=\"SCORM_API_wrapper.js\"></script>"+lb
            html += u"<script type=\"text/javascript\" src=\"SCOFunctions.js\"></script>"+lb
            if style.hasValidConfig:
                html += style.get_extra_head()
            html += u"</head>"+lb            
            html += u'<body class=\"exe-scorm\" onload="loadPage()" '
            html += u'onunload="unloadPage()">'
        html += u'<script type="text/javascript">document.body.className+=" js"</script>'+lb
        html += u"<div id=\"outer\">"+lb
        html += u"<"+sectionTag+" id=\"main\">"+lb
        html += u"<"+headerTag+" id=\"nodeDecoration\">"
        html += u"<h1 id=\"nodeTitle\">"
        html += escape(self.node.titleLong)
        html += u'</h1></'+headerTag+'>'+lb

        for idevice in self.node.idevices:
            if idevice.klass != 'NotaIdevice':
                e=" em_iDevice"
                if unicode(idevice.emphasis)=='0':
                    e=""
                html += u'<'+articleTag+' class="iDevice_wrapper %s%s" id="id%s">%s' % (idevice.klass, e, idevice.id, lb)
                block = g_blockFactory.createBlock(None, idevice)
                if not block:
                    log.critical("Unable to render iDevice.")
                    raise Error("Unable to render iDevice.")
                if hasattr(idevice, "isQuiz"):
                    html += block.renderJavascriptForScorm()
                html += self.processInternalLinks(
                    block.renderView(self.node.package.style))
                html += u'</'+articleTag+'>'+lb # iDevice div

        html += u"</"+sectionTag+">"+lb # /#main
        themeHasXML = common.themeHasConfigXML(self.node.package.style)
        if themeHasXML:
        #if style.hasValidConfig:
            html += self.renderLicense()
            html += self.renderFooter()
        html += u"</div>"+lb # /#outer
        if self.node.package.scolinks:
            html += u'<'+sectionTag+' class="previousnext">'+lb
            html += u'<a class="previouslink" '
            html += u'href="javascript:goBack();">%s</a> | <a class="nextlink" ' % c_('Previous')
            html += u'href="javascript:goForward();">%s</a>' % c_('Next')
            html += u'</'+sectionTag+'>'+lb
        if not themeHasXML:
        #if not style.hasValidConfig:
            html += self.renderLicense()
            html += self.renderFooter()
        else:
            html += style.get_extra_body()
        html += u'</body></html>'
        html = html.encode('utf8')
        # JR: Eliminamos los atributos de las ecuaciones
        aux = re.compile("exe_math_latex=\"[^\"]*\"")
        html = aux.sub("", html)
        aux = re.compile("exe_math_size=\"[^\"]*\"")
        html = aux.sub("", html)
        #JR: Cambio el & en los enlaces del glosario
        html = html.replace("&concept", "&amp;concept")
        # Remove "resources/" from data="resources/ and the url param
        html = html.replace("video/quicktime\" data=\"resources/", "video/quicktime\" data=\"")
        html = html.replace("application/x-mplayer2\" data=\"resources/", "application/x-mplayer2\" data=\"")
        html = html.replace("audio/x-pn-realaudio-plugin\" data=\"resources/", "audio/x-pn-realaudio-plugin\" data=\"")
        html = html.replace("<param name=\"url\" value=\"resources/", "<param name=\"url\" value=\"")
        return html
Ejemplo n.º 39
0
    def render(self, pages):
        """
        Returns an XHTML string rendering this page.
        """
        old_dT = common.getExportDocType()
        common.setExportDocType('HTML5')
        dT = common.getExportDocType()
        lb = "\n"  # Line breaks
        sectionTag = "div"
        articleTag = "div"
        headerTag = "div"
        if dT == "HTML5":
            sectionTag = "section"
            articleTag = "article"
            headerTag = "header"
        html = common.docType()
        lenguaje = G.application.config.locale
        if self.node.package.lang != "":
            lenguaje = self.node.package.lang
        html += u"<html lang=\"" + lenguaje + "\" xml:lang=\"" + lenguaje + "\" xmlns=\"http://www.w3.org/1999/xhtml\">" + lb
        html += u"<head>" + lb
        html += u"<title>"
        if self.node.id == '0':
            if self.node.package.title != '':
                html += escape(self.node.package.title)
            else:
                html += escape(self.node.titleLong)
        else:
            if self.node.package.title != '':
                html += escape(self.node.titleLong) + " | " + escape(
                    self.node.package.title)
            else:
                html += escape(self.node.titleLong)
        html += u" </title>" + lb
        html += u'<meta charset="utf-8" />' + lb
        if dT != "HTML5" and self.node.package.lang != "":
            html += '<meta http-equiv="content-language" content="' + lenguaje + '" />' + lb
        if self.node.package.author != "":
            html += '<meta name="author" content="' + escape(
                self.node.package.author, True) + '" />' + lb
        html += common.getLicenseMetadata(self.node.package.license)
        html += '<meta name="generator" content="eXeLearning ' + release + ' - exelearning.net" />' + lb
        if self.node.id == '0':
            if self.node.package.description != "":
                html += '<meta name="description" content="' + escape(
                    self.node.package.description, True) + '" />' + lb
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"base.css\" />" + lb
        if common.hasWikipediaIdevice(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_wikipedia.css\" />" + lb
        if common.hasGalleryIdevice(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_lightbox.css\" />" + lb
        if common.hasFX(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_effects.css\" />" + lb
        if common.hasSH(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_highlighter.css\" />" + lb
        if common.hasGames(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_games.css\" />" + lb
        if common.hasABCMusic(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_abcmusic.css\" />" + lb
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"content.css\" />" + lb
        if dT == "HTML5" or common.nodeHasMediaelement(self.node):
            html += u'<!--[if lt IE 9]><script type="text/javascript" src="exe_html5.js"></script><![endif]-->' + lb
        style = G.application.config.styleStore.getStyle(
            self.node.package.style)

        # jQuery
        if style.hasValidConfig:
            if style.get_jquery() == True:
                html += u'<script type="text/javascript" src="exe_jquery.js"></script>' + lb
            else:
                html += u'<script type="text/javascript" src="' + style.get_jquery(
                ) + '"></script>' + lb
        else:
            html += u'<script type="text/javascript" src="exe_jquery.js"></script>' + lb

        if common.hasGalleryIdevice(self.node):
            html += u'<script type="text/javascript" src="exe_lightbox.js"></script>' + lb
        if common.hasFX(self.node):
            html += u'<script type="text/javascript" src="exe_effects.js"></script>' + lb
        if common.hasSH(self.node):
            html += u'<script type="text/javascript" src="exe_highlighter.js"></script>' + lb
        html += u'<script type="text/javascript" src="common_i18n.js"></script>' + lb
        if common.hasGames(self.node):
            html += u'<script type="text/javascript" src="exe_games.js"></script>' + lb
        if common.hasABCMusic(self.node):
            html += u'<script type="text/javascript" src="exe_abcmusic.js"></script>' + lb
        html += u'<script type="text/javascript" src="common.js"></script>' + lb

        html += common.printJavaScriptIdevicesScripts('export', self)

        if common.hasMagnifier(self.node):
            html += u'<script type="text/javascript" src="mojomagnify.js"></script>' + lb
        # Some styles might have their own JavaScript files (see their config.xml file)
        if style.hasValidConfig:
            html += style.get_extra_head()
        html += common.getExtraHeadContent(self.node.package)
        html += u"</head>" + lb
        html += u'<body class="exe-epub3" id="exe-node-' + self.node.id + '">' + lb
        html += u"<div id=\"outer\">" + lb
        html += u"<" + sectionTag + " id=\"main\">" + lb
        html += u"<" + headerTag + " id=\"nodeDecoration\">"
        html += u"<div id=\"headerContent\">"
        html += u'<h1 id=\"nodeTitle\">'
        html += escape(self.node.titleLong)
        html += u'</h1>'
        html += u'</div>'
        html += u"</" + headerTag + ">" + lb

        self.node.exportType = 'epub'

        for idevice in self.node.idevices:
            if idevice.klass != 'NotaIdevice':
                e = " em_iDevice"
                if unicode(idevice.emphasis) == '0':
                    e = ""
                html += u'<' + articleTag + ' class="iDevice_wrapper %s%s" id="id%s">%s' % (
                    idevice.klass, e, idevice.id, lb)
                block = g_blockFactory.createBlock(None, idevice)
                if not block:
                    log.critical("Unable to render iDevice.")
                    raise Error("Unable to render iDevice.")
                if hasattr(idevice, "isQuiz"):
                    html += htmlentitydecode(block.renderJavascriptForWeb())
                if idevice.title != "Forum Discussion":
                    html += htmlentitydecode(
                        self.processInternalLinks(
                            block.renderView(self.node.package.style)))
                html += u'</' + articleTag + '>' + lb  # iDevice div

        html += u"</" + sectionTag + ">" + lb  # /#main

        if self.node.package.get_addPagination():
            html += "<p class='pagination page-counter'>" + c_(
                'Page %s of %s') % ('<strong>' + str(
                    pages.index(self)) + '</strong>', '<strong>' + str(
                        (len(pages) - 1)) + '</strong>') + "</p>" + lb

        html += self.renderLicense()
        html += unicode(
            BeautifulSoup(self.renderFooter(),
                          convertEntities=BeautifulSoup.XHTML_ENTITIES))
        html += u"</div>" + lb  # /#outer
        if style.hasValidConfig:
            html += style.get_extra_body()
        html += u'</body></html>'
        html = html.encode('utf8')
        # JR: Eliminamos los atributos de las ecuaciones
        aux = re.compile("exe_math_latex=\"[^\"]*\"")
        html = aux.sub("", html)
        aux = re.compile("exe_math_size=\"[^\"]*\"")
        html = aux.sub("", html)
        # JR: Cambio el & en los enlaces del glosario
        html = html.replace("&concept", "&amp;concept")
        # Remove "resources/" from data="resources/ and the url param
        html = html.replace("video/quicktime\" data=\"resources/",
                            "video/quicktime\" data=\"")
        html = html.replace("application/x-mplayer2\" data=\"resources/",
                            "application/x-mplayer2\" data=\"")
        html = html.replace("audio/x-pn-realaudio-plugin\" data=\"resources/",
                            "audio/x-pn-realaudio-plugin\" data=\"")
        html = html.replace("<param name=\"url\" value=\"resources/",
                            "<param name=\"url\" value=\"")

        common.setExportDocType(old_dT)
        return html
    def render(self, prevPage, nextPage, pages):
        """
        Returns an XHTML string rendering this page.
        """
    
        html  = u"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
        html += u'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 '
        html += u'Transitional//EN" '
        html += u'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n'
        html += u"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
        html += u"<!-- Created using eXe: http://exelearning.org -->\n"
        html += u"<head>\n"
        html += u"<style type=\"text/css\">\n"
        html += u"@import url(base.css);\n"
        html += u"@import url(content.css);\n"
        html += u"@import url(nav.css);</style>\n"
        html += u"<title> " 
        html += escape(self.node.titleLong)
        html += u" </title>\n" 
        html += u"<meta http-equiv=\"Content-Type\" content=\"text/html; "
        html += u" charset=utf-8\" />\n";
        html += u'<script type="text/javascript" src="common.js"></script>\n'
#modification by lernmodule.net
        html += u'<script type="text/javascript" src="lernmodule_net.js"></script>\n'
#end modification
        html += u"</head>\n"
        html += u"<body>\n"
        html += u"<div id=\"content\">\n"

        if self.node.package.backgroundImg or self.node.package.title:
            html += u"<div id=\"header\" "

            if self.node.package.backgroundImg:
                html += u" style=\"background-image: url("
                html += quote(self.node.package.backgroundImg.basename())
                html += u"); "

                if self.node.package.backgroundImgTile:
                    html += "background-repeat: repeat-x;"
                else:
                    html += "background-repeat: no-repeat;"

                html += u"\""
            html += u">\n"
            html += escape(self.node.package.title)
            html += u"</div>\n"
        
        # add left navigation html
        html += u"<div id=\"navcontainer\">\n"
        html += self.leftNavigationBar(pages)
        html += u"</div>\n"
        html += u"<div id=\"main\">\n"

        style = self.node.package.style
        html += '<div id=\"nodeDecoration\">'
        html += '<p id=\"nodeTitle\">'
        html += escape(self.node.titleLong)
        html += '</p></div>\n'

        for idevice in self.node.idevices:
            html += u'<div class="%s" id="id%s">\n' %  (idevice.klass,
                    idevice.id)
            block = g_blockFactory.createBlock(None, idevice)
            if not block:
                log.critical("Unable to render iDevice.")
                raise Error("Unable to render iDevice.")
            if hasattr(idevice, "isQuiz"):
                html += block.renderJavascriptForWeb()
            if idevice.title != "Forum Discussion":
                html += self.processInternalLinks(self.node.package,
                        block.renderView(style))
            html += u'</div>\n'     # iDevice div

#modification by lernmodule.net
        html += u"<script type=\"text/javascript\" language=\"javascript\">doStart();</script>\n"
#end modification       

        html += self.getNavigationLink(prevPage, nextPage)
        # writes the footer for each page 
        html += self.renderLicense()
        html += self.renderFooter()
        html += u"</div>\n"
        html += u"</div>\n"
        html += u"</body></html>\n"
        html = html.encode('utf8')
        return html
Ejemplo n.º 41
0
 def testBlockFactory(self):
     myidevice = DummyIdevice()
     myblock   = g_blockFactory.createBlock(None, myidevice)
     self.assertEquals(type(myblock), DummyBlock)
Ejemplo n.º 42
0
    def renderNode(self, node, docType, level):
        """
        Returns an XHTML string for this node and recurse for the children
        """

        # Get section and header tags
        headerTag = u'div'
        articleTag = u'div'
        if docType == 'HTML5':
            headerTag = u'header'
            articleTag = u'article'

        headerLevel = level
        if (level > 6):
            headerLevel = 6

        html = u''
        # Main node container
        html += u'<%s class="node level-%d-node">%s' % (articleTag, level,
                                                        lineBreak)

        # Node header container
        html += u'<%s class="nodeDecoration">%s' % (headerTag, lineBreak)
        # Node title
        html += u'<h%d id="%s" class="nodeTitle">%s</h1>%s' % (
            headerLevel, node.GetAnchorName(), escape(
                node.titleLong), lineBreak)
        # Close Node header container
        html += u'</%s>%s' % (headerTag, lineBreak)

        # Get the node Style
        style = self.node.package.style

        # Set node export type
        node.exportType = 'singlepage'

        # Render node iDevices
        for idevice in node.idevices:
            if idevice.klass != 'NotaIdevice':
                e = " em_iDevice"
                if unicode(idevice.emphasis) == '0':
                    e = ""
                # iDevice container
                html += u'<%s class="iDevice_wrapper %s%s" id="id%s">%s' % (
                    articleTag, idevice.klass, e,
                    (idevice.id + '-' + node.id), lineBreak)

                # Try to render the iDevice
                block = g_blockFactory.createBlock(None, idevice)
                if not block:
                    log.critical('Unable to render iDevice %s.' %
                                 (idevice.klass))
                    raise Error('Unable to render iDevice.')

                if hasattr(idevice, "isQuiz"):
                    html += block.renderJavascriptForWeb()

                # Process iDevice internal links
                html += helper.processInternalLinks(self.node.package,
                                                    block.renderView(style))

                # Replace top links with "empty" links
                html = helper.replaceTopLinks(html)

                # Close iDevice container
                html += u'</%s>%s' % (articleTag, lineBreak)

        # Close main node container
        html += u'</%s>%s' % (articleTag, lineBreak)

        # Render all child nodes
        for child in node.children:
            html += self.renderNode(child, docType, level + 1)

        return html
Ejemplo n.º 43
0
 def testBlockFactory(self):
     myidevice = DummyIdevice()
     myblock = g_blockFactory.createBlock(None, myidevice)
     self.assertEquals(type(myblock), DummyBlock)
Ejemplo n.º 44
0
    def render(self):
        """
        Returns an XHTML string rendering this page.
        """
        dT = common.getExportDocType()
        lb = "\n" #Line breaks
        sectionTag = "div"
        articleTag = "div"
        headerTag = "div"
        if dT == "HTML5":
            sectionTag = "section"  
            articleTag = "article"
            headerTag = "header"
        html  = common.docType()
        lenguaje = G.application.config.locale
        if self.node.package.dublinCore.language!="":
            lenguaje = self.node.package.dublinCore.language
        html += u"<html lang=\"" + lenguaje + "\" xml:lang=\"" + lenguaje + "\" xmlns=\"http://www.w3.org/1999/xhtml\">"+lb
        html += u"<head>"+lb
        html += u"<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />"+lb
        html += u"<title>"
        if self.node.id=='0':
            if self.node.package.title!='':
                html += escape(self.node.package.title)
            else:
                html += escape(self.node.titleLong)
        else:
            if self.node.package.title!='':
                html += escape(self.node.titleLong)+" | "+escape(self.node.package.title)
            else:
                html += escape(self.node.titleLong)
        html += u" </title>"+lb   
        if dT != "HTML5" and self.node.package.dublinCore.language!="":
            html += '<meta http-equiv="content-language" content="'+lenguaje+'" />'+lb
        if self.node.package.author!="":
            html += '<meta name="author" content="'+self.node.package.author+'" />'+lb
        html += common.getLicenseMetadata(self.node.package.license)      
        html += '<meta name="generator" content="eXeLearning '+release+' - exelearning.net" />'+lb
        if self.node.id=='0':
            if self.node.package.description!="":
                desc = self.node.package.description
                desc = desc.replace('"', '&quot;')            
                html += '<meta name="description" content="'+desc+'" />'+lb
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"base.css\" />"+lb
        if common.hasWikipediaIdevice(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_wikipedia.css\" />"+lb    
        if common.hasGalleryIdevice(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_lightbox.css\" />"+lb
        if common.hasFX(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_effects.css\" />"+lb
        if common.hasSH(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_highlighter.css\" />"+lb
        if common.hasGames(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_games.css\" />"+lb
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"content.css\" />"+lb
        if dT == "HTML5" or common.nodeHasMediaelement(self.node):
            html += u'<!--[if lt IE 9]><script type="text/javascript" src="exe_html5.js"></script><![endif]-->'+lb
        style = G.application.config.styleStore.getStyle(self.node.package.style)
        
        # jQuery
        if style.hasValidConfig:
            if style.get_jquery() == True:
                html += u'<script type="text/javascript" src="exe_jquery.js"></script>'+lb
            else:
                html += u'<script type="text/javascript" src="'+style.get_jquery()+'"></script>'+lb
        else:
            html += u'<script type="text/javascript" src="exe_jquery.js"></script>'+lb
        
        if common.hasGalleryIdevice(self.node):
            html += u'<script type="text/javascript" src="exe_lightbox.js"></script>'+lb
        if common.hasFX(self.node):
            html += u'<script type="text/javascript" src="exe_effects.js"></script>'+lb
        if common.hasSH(self.node):
            html += u'<script type="text/javascript" src="exe_highlighter.js"></script>'+lb
        html += common.getJavaScriptStrings()+lb
        if common.hasGames(self.node):
            # The games require additional strings
            html += common.getGamesJavaScriptStrings() + lb
            html += u'<script type="text/javascript" src="exe_games.js"></script>'+lb
        html += u'<script type="text/javascript" src="common.js"></script>'+lb
        if common.hasMagnifier(self.node):
            html += u'<script type="text/javascript" src="mojomagnify.js"></script>'+lb
        # Some styles might have their own JavaScript files (see their config.xml file)
        if style.hasValidConfig:
            html += style.get_extra_head()
        html += u"</head>"+lb
        html += u'<body class="exe-ims"><script type="text/javascript">document.body.className+=" js"</script>'+lb
        html += u"<div id=\"outer\">"+lb
        html += u"<"+sectionTag+" id=\"main\">"+lb
        html += u"<"+headerTag+" id=\"nodeDecoration\">"
        html += u"<div id=\"headerContent\">"
        html += u'<h1 id=\"nodeTitle\">'
        html += escape(self.node.titleLong)
        html += u'</h1>'
        html += u'</div>'
        html += u"</"+headerTag+">"+lb

        self.node.exportType = 'ims'
        
        for idevice in self.node.idevices:
            if idevice.klass != 'NotaIdevice':
                e=" em_iDevice"
                if unicode(idevice.emphasis)=='0':
                    e=""
                html += u'<'+articleTag+' class="iDevice_wrapper %s%s" id="id%s">%s' % (idevice.klass, e, idevice.id, lb)
                block = g_blockFactory.createBlock(None, idevice)
                if not block:
                    log.critical("Unable to render iDevice.")
                    raise Error("Unable to render iDevice.")
                if hasattr(idevice, "isQuiz"):
                    html += block.renderJavascriptForWeb()
                if idevice.title != "Forum Discussion":
                    html += self.processInternalLinks(
                        block.renderView(self.node.package.style))
            html += u'</'+articleTag+'>'+lb # iDevice div

        html += u"</"+sectionTag+">"+lb # /#main
        html += self.renderLicense()
        html += self.renderFooter()
        html += u"</div>"+lb # /#outer
        if style.hasValidConfig:
            html += style.get_extra_body() 
        html += u'</body></html>'
        html = html.encode('utf8')
        # JRJ: Eliminamos los atributos de las ecuaciones
        # Let's elliminate the attibutes of the equations
        aux = re.compile("exe_math_latex=\"[^\"]*\"")
        html = aux.sub("", html)
        aux = re.compile("exe_math_size=\"[^\"]*\"")
        html = aux.sub("", html)
        #JRJ: Cambio el & en los enlaces del glosario
        # Then let's change the & of the glossary links
        html = html.replace("&concept", "&amp;concept")
        # Remove "resources/" from data="resources/ and the url param
        html = html.replace("video/quicktime\" data=\"resources/", "video/quicktime\" data=\"")
        html = html.replace("application/x-mplayer2\" data=\"resources/", "application/x-mplayer2\" data=\"")
        html = html.replace("audio/x-pn-realaudio-plugin\" data=\"resources/", "audio/x-pn-realaudio-plugin\" data=\"")
        html = html.replace("<param name=\"url\" value=\"resources/", "<param name=\"url\" value=\"")
        return html
Ejemplo n.º 45
0
    def render(self, prevPage, nextPage, pages):
        """
        Returns an XHTML string rendering this page.
        """

        html = u"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
        html += u'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 '
        html += u'Transitional//EN" '
        html += u'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n'
        #html += u"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
        lenguaje = G.application.config.locale
        html += u"<html lang=\"" + lenguaje + "\" xml:lang=\"" + lenguaje + "\" xmlns=\"http://www.w3.org/1999/xhtml\">\n"
        html += u"<!-- Created using eXe: http://exelearning.org -->\n"
        html += u"<head>\n"
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"base.css\" />"
        if common.hasGalleryIdevice(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_lightbox.css\" />"
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"content.css\" />"
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"nav.css\" />"
        html += u"<title>"
        if self.node.id == '0':
            if self.node.package.title != '':
                html += escape(self.node.package.title)
            else:
                html += escape(self.node.titleLong)
        else:
            if self.node.package.title != '':
                html += escape(self.node.titleLong) + " | " + escape(
                    self.node.package.title)
            else:
                html += escape(self.node.titleLong)
        html += u" </title>\n"
        html += u"<link rel=\"shortcut icon\" href=\"favicon.ico\" type=\"image/x-icon\" />\n"
        html += u"<meta http-equiv=\"Content-Type\" content=\"text/html; "
        html += u" charset=utf-8\" />\n"
        html += u'<script type="text/javascript" src="common.js"></script>\n'
        #modification by lernmodule.net
        html += u'<script type="text/javascript" src="lernmodule_net.js"></script>\n'
        #end modification
        html += u"</head>\n"
        html += u"<body>\n"
        html += u"<div id=\"content\">\n"

        if self.node.package.backgroundImg or self.node.package.title:
            html += u"<div id=\"header\" "

            if self.node.package.backgroundImg:
                html += u" style=\"background-image: url("
                html += quote(self.node.package.backgroundImg.basename())
                html += u"); "

                if self.node.package.backgroundImgTile:
                    html += "background-repeat: repeat-x;"
                else:
                    html += "background-repeat: no-repeat;"

                html += u"\""
            html += u">\n"
            html += escape(self.node.package.title)
            html += u"</div>\n"
        else:
            html += "<div id=\"emptyHeader\"></div>"

        # add left navigation html
        html += u"<div id=\"siteNav\">\n"
        html += self.leftNavigationBar(pages)
        html += u"</div>\n"
        html += "<div id='topPagination'>"
        html += self.getNavigationLink(prevPage, nextPage)
        html += "</div>"
        html += u"<div id=\"main\">\n"

        style = self.node.package.style
        html += '<div id=\"nodeDecoration\">'
        html += '<h1 id=\"nodeTitle\">'
        html += escape(self.node.titleLong)
        html += '</h1></div>\n'

        for idevice in self.node.idevices:
            html += u'<div class="%s" id="id%s">\n' % (idevice.klass,
                                                       idevice.id)
            block = g_blockFactory.createBlock(None, idevice)
            if not block:
                log.critical("Unable to render iDevice.")
                raise Error("Unable to render iDevice.")
            if hasattr(idevice, "isQuiz"):
                html += block.renderJavascriptForWeb()
            if idevice.title != "Forum Discussion":
                html += self.processInternalLinks(self.node.package,
                                                  block.renderView(style))
            html += u'</div>\n'  # iDevice div

        html += "<div id='bottomPagination'>"

        #modification by lernmodule.net
        html += u"<div id=\"lmsubmit\"></div><script type=\"text/javascript\" language=\"javascript\">doStart();</script></body></html>\n"
        #end modification
        html += self.getNavigationLink(prevPage, nextPage)
        html += "</div>"
        # writes the footer for each page
        html += self.renderLicense()
        html += self.renderFooter()
        html += u"</div>\n"
        html += u"</div>\n"
        html += u"</body></html>\n"
        html = html.encode('utf8')
        # JR: Eliminamos los atributos de las ecuaciones
        aux = re.compile("exe_math_latex=\"[^\"]*\"")
        html = aux.sub("", html)
        aux = re.compile("exe_math_size=\"[^\"]*\"")
        html = aux.sub("", html)
        #JR: Cambio el & en los enlaces del glosario
        html = html.replace("&concept", "&amp;concept")
        # Remove "resources/" from data="resources/ and the url param
        html = html.replace("video/quicktime\" data=\"resources/",
                            "video/quicktime\" data=\"")
        html = html.replace("application/x-mplayer2\" data=\"resources/",
                            "application/x-mplayer2\" data=\"")
        html = html.replace("audio/x-pn-realaudio-plugin\" data=\"resources/",
                            "audio/x-pn-realaudio-plugin\" data=\"")
        html = html.replace("<param name=\"url\" value=\"resources/",
                            "<param name=\"url\" value=\"")
        return html
Ejemplo n.º 46
0
    def render(self):
        """
        Returns an XHTML string rendering this page.
        """
        dT = common.getExportDocType()
        lb = "\n" #Line breaks
        sectionTag = "div"
        articleTag = "div"
        headerTag = "div"
        if dT == "HTML5":
            sectionTag = "section"
            articleTag = "article"
            headerTag = "header"
        html  = common.docType()
        lenguaje = G.application.config.locale
        style = G.application.config.styleStore.getStyle(self.node.package.style)
        if self.node.package.dublinCore.language!="":
            lenguaje = self.node.package.dublinCore.language
        html += u"<html lang=\"" + lenguaje + "\" xml:lang=\"" + lenguaje + "\" xmlns=\"http://www.w3.org/1999/xhtml\">"+lb
        html += u"<head>"+lb
        html += u"<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />"+lb
        html += u"<title>"
        if self.node.id=='0':
            if self.node.package.title!='':
                html += escape(self.node.package.title)
            else:
                html += escape(self.node.titleLong)
        else:
            if self.node.package.title!='':
                html += escape(self.node.titleLong)+" | "+escape(self.node.package.title)
            else:
                html += escape(self.node.titleLong)
        html += u" </title>"+lb
        if dT != "HTML5" and self.node.package.dublinCore.language!="":
            html += '<meta http-equiv="content-language" content="'+lenguaje+'" />'+lb
        if self.node.package.author!="":
            html += '<meta name="author" content="'+self.node.package.author+'" />'+lb
        html += common.getLicenseMetadata(self.node.package.license)
        html += '<meta name="generator" content="eXeLearning '+release+' - exelearning.net" />'+lb
        if self.node.id=='0':
            if self.node.package.description!="":
                desc = self.node.package.description
                desc = desc.replace('"', '&quot;')            
                html += '<meta name="description" content="'+desc+'" />'+lb
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"base.css\" />"+lb
        if common.hasWikipediaIdevice(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_wikipedia.css\" />"+lb
        if common.hasGalleryIdevice(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_lightbox.css\" />"+lb
        if common.hasFX(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_effects.css\" />"+lb
        if common.hasSH(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_highlighter.css\" />"+lb
        if common.hasGames(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_games.css\" />"+lb
        if common.hasABCMusic(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_abcmusic.css\" />"+lb            
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"content.css\" />"+lb
        if dT == "HTML5" or common.nodeHasMediaelement(self.node):
            html += u'<!--[if lt IE 9]><script type="text/javascript" src="exe_html5.js"></script><![endif]-->'+lb
        
        # jQuery
        if style.hasValidConfig:
            if style.get_jquery() == True:
                html += u'<script type="text/javascript" src="exe_jquery.js"></script>'+lb
            else:
                html += u'<script type="text/javascript" src="'+style.get_jquery()+'"></script>'+lb
        else:
            html += u'<script type="text/javascript" src="exe_jquery.js"></script>'+lb
        
        if common.hasGalleryIdevice(self.node):
            html += u'<script type="text/javascript" src="exe_lightbox.js"></script>'+lb
        if common.hasFX(self.node):
            html += u'<script type="text/javascript" src="exe_effects.js"></script>'+lb
        if common.hasSH(self.node):
            html += u'<script type="text/javascript" src="exe_highlighter.js"></script>'+lb
        html += common.getJavaScriptStrings()+lb
        if common.hasGames(self.node):
            # The games require additional strings
            html += common.getGamesJavaScriptStrings() + lb
            html += u'<script type="text/javascript" src="exe_games.js"></script>'+lb
        if common.hasABCMusic(self.node):
            html += u'<script type="text/javascript" src="exe_abcmusic.js"></script>'+lb
        html += u'<script type="text/javascript" src="common.js"></script>'+lb
        if common.hasMagnifier(self.node):
            html += u'<script type="text/javascript" src="mojomagnify.js"></script>'+lb
        if self.scormType == 'commoncartridge':
            if style.hasValidConfig:
                html += style.get_extra_head()        
            html += u"</head>"+lb
            html += u"<body id=\""+self.node.id+"\" class=\"exe-scorm\" "
        else:
            html += u"<script type=\"text/javascript\" src=\"SCORM_API_wrapper.js\"></script>"+lb
            html += u"<script type=\"text/javascript\" src=\"SCOFunctions.js\"></script>"+lb
            if style.hasValidConfig:
                html += style.get_extra_head()
            html += u"</head>"+lb            
            html += u'<body id="exe-node-'+self.node.id+'" class=\"exe-scorm\" '
        if common.hasQuizTest(self.node):
            html += u'onunload="unloadPage(true)">'
        else:
            html += u'onunload="unloadPage()">'
        html += u'<script type="text/javascript">document.body.className+=" js";jQuery(function(){loadPage()})</script>'+lb
        html += u"<div id=\"outer\">"+lb
        html += u"<"+sectionTag+" id=\"main\">"+lb
        html += u"<"+headerTag+" id=\"nodeDecoration\">"
        html += u"<div id=\"headerContent\">"
        html += u"<h1 id=\"nodeTitle\">"
        html += escape(self.node.titleLong)
        html += u'</h1>'
        html += u'</div>'
        html += u'</'+headerTag+'>'+lb

        self.node.exportType = 'scorm'
        
        for idevice in self.node.idevices:
            if idevice.klass != 'NotaIdevice':
                e=" em_iDevice"
                if unicode(idevice.emphasis)=='0':
                    e=""
                html += u'<'+articleTag+' class="iDevice_wrapper %s%s" id="id%s">%s' % (idevice.klass, e, idevice.id, lb)
                block = g_blockFactory.createBlock(None, idevice)
                if not block:
                    log.critical("Unable to render iDevice.")
                    raise Error("Unable to render iDevice.")
                if hasattr(idevice, "isQuiz"):
                    html += block.renderJavascriptForScorm()
                html += self.processInternalLinks(
                    block.renderView(self.node.package.style))
                html += u'</'+articleTag+'>'+lb # iDevice div

        html += u"</"+sectionTag+">"+lb # /#main
        themeHasXML = common.themeHasConfigXML(self.node.package.style)
        if themeHasXML:
        #if style.hasValidConfig:
            html += self.renderLicense()
            html += self.renderFooter()
        html += u"</div>"+lb # /#outer
        if self.node.package.scolinks:
            html += u'<'+sectionTag+' class="previousnext">'+lb
            html += u'<a class="previouslink" '
            html += u'href="javascript:goBack();">%s</a> | <a class="nextlink" ' % c_('Previous')
            html += u'href="javascript:goForward();">%s</a>' % c_('Next')
            html += u'</'+sectionTag+'>'+lb
        if not themeHasXML:
        #if not style.hasValidConfig:
            html += self.renderLicense()
            html += self.renderFooter()
        else:
            html += style.get_extra_body()
        html += u'</body></html>'
        html = html.encode('utf8')
        # JR: Eliminamos los atributos de las ecuaciones
        aux = re.compile("exe_math_latex=\"[^\"]*\"")
        html = aux.sub("", html)
        aux = re.compile("exe_math_size=\"[^\"]*\"")
        html = aux.sub("", html)
        #JR: Cambio el & en los enlaces del glosario
        html = html.replace("&concept", "&amp;concept")
        # Remove "resources/" from data="resources/ and the url param
        html = html.replace("video/quicktime\" data=\"resources/", "video/quicktime\" data=\"")
        html = html.replace("application/x-mplayer2\" data=\"resources/", "application/x-mplayer2\" data=\"")
        html = html.replace("audio/x-pn-realaudio-plugin\" data=\"resources/", "audio/x-pn-realaudio-plugin\" data=\"")
        html = html.replace("<param name=\"url\" value=\"resources/", "<param name=\"url\" value=\"")
        return html
Ejemplo n.º 47
0
    def render(self, prevPage, nextPage, pages):
        """
        Returns an XHTML string rendering this page.
        """

        html = u"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
        html += u'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 '
        html += u'Transitional//EN" '
        html += u'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n'
        html += u"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
        html += u"<!-- Created using eXe: http://exelearning.org -->\n"
        html += u"<head>\n"
        html += u"<style type=\"text/css\">\n"
        html += u"@import url(base.css);\n"
        html += u"@import url(content.css);\n"
        html += u"@import url(nav.css);</style>\n"
        html += u"<title> "
        html += escape(self.node.titleLong)
        html += u" </title>\n"
        html += u"<meta http-equiv=\"Content-Type\" content=\"text/html; "
        html += u" charset=utf-8\" />\n"
        html += u'<script type="text/javascript" src="common.js"></script>\n'
        html += u"</head>\n"
        html += u"<body>\n"
        html += u"<div id=\"content\">\n"

        if self.node.package.backgroundImg or self.node.package.title:
            html += u"<div id=\"header\" "

            if self.node.package.backgroundImg:
                html += u" style=\"background-image: url("
                html += quote(self.node.package.backgroundImg.basename())
                html += u"); "

                if self.node.package.backgroundImgTile:
                    html += "background-repeat: repeat-x;"
                else:
                    html += "background-repeat: no-repeat;"

                html += u"\""
            html += u">\n"
            html += escape(self.node.package.title)
            html += u"</div>\n"

        # add left navigation html
        html += u"<div id=\"navcontainer\">\n"
        html += self.leftNavigationBar(pages)
        html += u"</div>\n"
        html += u"<div id=\"main\">\n"

        style = self.node.package.style
        html += '<div id=\"nodeDecoration\">'
        html += '<p id=\"nodeTitle\">'
        html += escape(self.node.titleLong)
        html += '</p></div>\n'
        html += self.getNavigationLink(prevPage, nextPage)

        for idevice in self.node.idevices:
            html += u'<div class="%s" id="id%s">\n' % (idevice.klass,
                                                       idevice.id)
            block = g_blockFactory.createBlock(None, idevice)
            if not block:
                log.critical("Unable to render iDevice.")
                raise Error("Unable to render iDevice.")
            if hasattr(idevice, "isQuiz"):
                html += block.renderJavascriptForWeb()
            if idevice.title != "Forum Discussion":
                html += self.processInternalLinks(self.node.package,
                                                  block.renderView(style))
            html += u'</div>\n'  # iDevice div

        html += self.getNavigationLink(prevPage, nextPage)
        # writes the footer for each page
        html += self.renderLicense()
        html += self.renderFooter()
        html += u"</div>\n"
        html += u"</div>\n"
        html += u"</body></html>\n"
        html = html.encode('utf8')
        return html
Ejemplo n.º 48
0
    def render(self, prevPage, nextPage, pages):
        """
        Returns an XHTML string rendering this page.
        """

        html = u'<?xml version="1.0" encoding="UTF-8"?>\n'
        html += u'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 '
        html += u'Transitional//EN" '
        html += u'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n'
        # html += u"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
        lenguaje = G.application.config.locale
        html += u'<html lang="' + lenguaje + '" xml:lang="' + lenguaje + '" xmlns="http://www.w3.org/1999/xhtml">\n'
        html += u"<!-- Created using eXe: http://exelearning.org -->\n"
        html += u"<head>\n"
        html += u'<link rel="stylesheet" type="text/css" href="base.css" />'
        if common.hasGalleryIdevice(self.node):
            html += u'<link rel="stylesheet" type="text/css" href="exe_lightbox.css" />'
        html += u'<link rel="stylesheet" type="text/css" href="content.css" />'
        html += u'<link rel="stylesheet" type="text/css" href="nav.css" />'
        html += u"<title>"
        if self.node.id == "0":
            if self.node.package.title != "":
                html += escape(self.node.package.title)
            else:
                html += escape(self.node.titleLong)
        else:
            if self.node.package.title != "":
                html += escape(self.node.titleLong) + " | " + escape(self.node.package.title)
            else:
                html += escape(self.node.titleLong)
        html += u" </title>\n"
        html += u'<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />\n'
        html += u'<meta http-equiv="Content-Type" content="text/html; '
        html += u' charset=utf-8" />\n'
        html += u'<script type="text/javascript" src="common.js"></script>\n'
        # modification by lernmodule.net
        html += u'<script type="text/javascript" src="lernmodule_net.js"></script>\n'
        # end modification
        html += u"</head>\n"
        html += u"<body>\n"
        html += u'<div id="content">\n'

        if self.node.package.backgroundImg or self.node.package.title:
            html += u'<div id="header" '

            if self.node.package.backgroundImg:
                html += u' style="background-image: url('
                html += quote(self.node.package.backgroundImg.basename())
                html += u"); "

                if self.node.package.backgroundImgTile:
                    html += "background-repeat: repeat-x;"
                else:
                    html += "background-repeat: no-repeat;"

                html += u'"'
            html += u">\n"
            html += escape(self.node.package.title)
            html += u"</div>\n"
        else:
            html += '<div id="emptyHeader"></div>'

        # add left navigation html
        html += u'<div id="siteNav">\n'
        html += self.leftNavigationBar(pages)
        html += u"</div>\n"
        html += "<div id='topPagination'>"
        html += self.getNavigationLink(prevPage, nextPage)
        html += "</div>"
        html += u'<div id="main">\n'

        style = self.node.package.style
        html += '<div id="nodeDecoration">'
        html += '<h1 id="nodeTitle">'
        html += escape(self.node.titleLong)
        html += "</h1></div>\n"

        for idevice in self.node.idevices:
            html += u'<div class="%s" id="id%s">\n' % (idevice.klass, idevice.id)
            block = g_blockFactory.createBlock(None, idevice)
            if not block:
                log.critical("Unable to render iDevice.")
                raise Error("Unable to render iDevice.")
            if hasattr(idevice, "isQuiz"):
                html += block.renderJavascriptForWeb()
            if idevice.title != "Forum Discussion":
                html += self.processInternalLinks(self.node.package, block.renderView(style))
            html += u"</div>\n"  # iDevice div

        html += "<div id='bottomPagination'>"

        # modification by lernmodule.net
        html += u'<div id="lmsubmit"></div><script type="text/javascript" language="javascript">doStart();</script></body></html>\n'
        # end modification
        html += self.getNavigationLink(prevPage, nextPage)
        html += "</div>"
        # writes the footer for each page
        html += self.renderLicense()
        html += self.renderFooter()
        html += u"</div>\n"
        html += u"</div>\n"
        html += u"</body></html>\n"
        html = html.encode("utf8")
        # JR: Eliminamos los atributos de las ecuaciones
        aux = re.compile('exe_math_latex="[^"]*"')
        html = aux.sub("", html)
        aux = re.compile('exe_math_size="[^"]*"')
        html = aux.sub("", html)
        # JR: Cambio el & en los enlaces del glosario
        html = html.replace("&concept", "&amp;concept")
        # Remove "resources/" from data="resources/ and the url param
        html = html.replace('video/quicktime" data="resources/', 'video/quicktime" data="')
        html = html.replace('application/x-mplayer2" data="resources/', 'application/x-mplayer2" data="')
        html = html.replace('audio/x-pn-realaudio-plugin" data="resources/', 'audio/x-pn-realaudio-plugin" data="')
        html = html.replace('<param name="url" value="resources/', '<param name="url" value="')
        return html
Ejemplo n.º 49
0
    def render(self):
        """
        Returns an XHTML string rendering this page.
        """
        dT = common.getExportDocType()
        lb = "\n"  #Line breaks
        sectionTag = "div"
        articleTag = "div"
        headerTag = "div"
        if dT == "HTML5":
            sectionTag = "section"
            articleTag = "article"
            headerTag = "header"
        html = common.docType()
        lenguaje = G.application.config.locale
        if self.node.package.dublinCore.language != "":
            lenguaje = self.node.package.dublinCore.language
        html += u"<html lang=\"" + lenguaje + "\" xml:lang=\"" + lenguaje + "\" xmlns=\"http://www.w3.org/1999/xhtml\">" + lb
        html += u"<head>" + lb
        html += u"<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />" + lb
        html += u"<title>"
        if self.node.id == '0':
            if self.node.package.title != '':
                html += escape(self.node.package.title)
            else:
                html += escape(self.node.titleLong)
        else:
            if self.node.package.title != '':
                html += escape(self.node.titleLong) + " | " + escape(
                    self.node.package.title)
            else:
                html += escape(self.node.titleLong)
        html += u" </title>" + lb
        if dT != "HTML5" and self.node.package.dublinCore.language != "":
            html += '<meta http-equiv="content-language" content="' + lenguaje + '" />' + lb
        if self.node.package.author != "":
            html += '<meta name="author" content="' + self.node.package.author + '" />' + lb
        html += '<meta name="generator" content="eXeLearning ' + release + ' - exelearning.net" />' + lb
        if self.node.id == '0':
            if self.node.package.description != "":
                html += '<meta name="description" content="' + self.node.package.description + '" />' + lb
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"base.css\" />" + lb
        if common.hasWikipediaIdevice(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_wikipedia.css\" />" + lb
        if common.hasGalleryIdevice(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_lightbox.css\" />" + lb
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"content.css\" />" + lb
        if dT == "HTML5" or common.nodeHasMediaelement(self.node):
            html += u'<!--[if lt IE 9]><script type="text/javascript" src="exe_html5.js"></script><![endif]-->' + lb
        style = G.application.config.styleStore.getStyle(
            self.node.package.style)

        # jQuery
        if style.hasValidConfig:
            if style.get_jquery() == True:
                html += u'<script type="text/javascript" src="exe_jquery.js"></script>' + lb
            else:
                html += u'<script type="text/javascript" src="' + style.get_jquery(
                ) + '"></script>' + lb
        else:
            html += u'<script type="text/javascript" src="exe_jquery.js"></script>' + lb

        if common.hasGalleryIdevice(self.node):
            html += u'<script type="text/javascript" src="exe_lightbox.js"></script>' + lb
        html += common.getJavaScriptStrings() + lb
        html += u'<script type="text/javascript" src="common.js"></script>' + lb
        html += u'<script type="text/javascript" src="lernmodule_net.js"></script>' + lb
        if common.hasMagnifier(self.node):
            html += u'<script type="text/javascript" src="mojomagnify.js"></script>' + lb
        # Some styles might have their own JavaScript files (see their config.xml file)
        if style.hasValidConfig:
            html += style.get_extra_head()
        html += u"</head>" + lb
        html += u'<body class="exe-ims"><script type="text/javascript">document.body.className+=" js"</script>' + lb
        html += u"<div id=\"outer\">" + lb
        html += u"<" + sectionTag + " id=\"main\">" + lb
        html += u"<" + headerTag + " id=\"nodeDecoration\">"
        html += u'<h1 id=\"nodeTitle\">'
        html += escape(self.node.titleLong)
        html += u'</h1>'
        html += u"</" + headerTag + ">" + lb

        for idevice in self.node.idevices:
            if idevice.klass != 'NotaIdevice':
                e = " em_iDevice"
                if unicode(idevice.emphasis) == '0':
                    e = ""
                html += u'<' + articleTag + ' class="iDevice_wrapper %s%s" id="id%s">%s' % (
                    idevice.klass, e, idevice.id, lb)
                block = g_blockFactory.createBlock(None, idevice)
                if not block:
                    log.critical("Unable to render iDevice.")
                    raise Error("Unable to render iDevice.")
                if hasattr(idevice, "isQuiz"):
                    html += block.renderJavascriptForWeb()
                if idevice.title != "Forum Discussion":
                    html += self.processInternalLinks(
                        block.renderView(self.node.package.style))
            html += u'</' + articleTag + '>' + lb  # iDevice div

        html += u"<div id=\"lmsubmit\"></div><script type=\"text/javascript\" language=\"javascript\">doStart();</script>" + lb
        html += u"</" + sectionTag + ">" + lb  # /#main
        html += self.renderLicense()
        html += self.renderFooter()
        html += u"</div>" + lb  # /#outer
        if style.hasValidConfig:
            html += style.get_extra_body()
        html += u'</body>'
        html += u'<script type="text/javascript" src="lernmodule_net_custom.js"></script>' + lb
        html += u'</html>'
        html = html.encode('utf8')
        # JRJ: Eliminamos los atributos de las ecuaciones
        # Let's elliminate the attibutes of the equations
        aux = re.compile("exe_math_latex=\"[^\"]*\"")
        html = aux.sub("", html)
        aux = re.compile("exe_math_size=\"[^\"]*\"")
        html = aux.sub("", html)
        #JRJ: Cambio el & en los enlaces del glosario
        # Then let's change the & of the glossary links
        html = html.replace("&concept", "&amp;concept")
        # Remove "resources/" from data="resources/ and the url param
        html = html.replace("video/quicktime\" data=\"resources/",
                            "video/quicktime\" data=\"")
        html = html.replace("application/x-mplayer2\" data=\"resources/",
                            "application/x-mplayer2\" data=\"")
        html = html.replace("audio/x-pn-realaudio-plugin\" data=\"resources/",
                            "audio/x-pn-realaudio-plugin\" data=\"")
        html = html.replace("<param name=\"url\" value=\"resources/",
                            "<param name=\"url\" value=\"")
        return html
Ejemplo n.º 50
0
    def render(self, prevPage, nextPage, pages):
        """
        Returns an XHTML string rendering this page.
        """
    
        html  = u"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
        html += u'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 '
        html += u'Transitional//EN" '
        html += u'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n'
        #html += u"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
        lenguaje = G.application.config.locale
        html += u"<html lang=\"" + lenguaje + "\" xml:lang=\"" + lenguaje + "\" xmlns=\"http://www.w3.org/1999/xhtml\">\n"
        html += u"<!-- Created using eXe: http://exelearning.org -->\n"
        html += u"<head>\n"
        html += u"<style type=\"text/css\">\n"
        html += u"@import url(base.css);\n"
        html += u"@import url(content.css);\n"
        html += u"@import url(nav.css);</style>\n"
        html += u"<title> " 
        html += escape(self.node.titleLong)+" | "+escape(self.node.package.title)
        html += u" </title>\n" 
        html += u"<link rel=\"shortcut icon\" href=\"favicon.ico\" type=\"image/x-icon\" />\n"
        html += u"<meta http-equiv=\"Content-Type\" content=\"text/html; "
        html += u" charset=utf-8\" />\n";
        html += u'<script type="text/javascript" src="common.js"></script>\n'
        html += u"</head>\n"
        html += u"<body>\n"
        html += u"<div id=\"content\">\n"

        if self.node.package.backgroundImg or self.node.package.title:
            html += u"<div id=\"header\" "

            if self.node.package.backgroundImg:
                html += u" style=\"background-image: url("
                html += quote(self.node.package.backgroundImg.basename())
                html += u"); "

                if self.node.package.backgroundImgTile:
                    html += "background-repeat: repeat-x;"
                else:
                    html += "background-repeat: no-repeat;"

                html += u"\""
            html += u">\n"
            html += escape(self.node.package.title)
            html += u"</div>\n"
        else:
            html += "<div id=\"emptyHeader\"></div>"
        
        # add left navigation html
        html += u"<div id=\"siteNav\">\n"
        html += self.leftNavigationBar(pages)
        html += u"</div>\n"
        html += "<div id='topPagination'>"
        html += self.getNavigationLink(prevPage, nextPage)
        html += "</div>"
        html += u"<div id=\"main\">\n"

        style = self.node.package.style
        html += '<div id=\"nodeDecoration\">'
        html += '<h1 id=\"nodeTitle\">'
        html += escape(self.node.titleLong)
        html += '</h1></div>\n'

        for idevice in self.node.idevices:
            html += u'<div class="%s" id="id%s">\n' %  (idevice.klass,
                    idevice.id)
            block = g_blockFactory.createBlock(None, idevice)
            if not block:
                log.critical("Unable to render iDevice.")
                raise Error("Unable to render iDevice.")
            if hasattr(idevice, "isQuiz"):
                html += block.renderJavascriptForWeb()
            if idevice.title != "Forum Discussion":
                html += self.processInternalLinks(self.node.package,
                        block.renderView(style))
            html += u'</div>\n'     # iDevice div
        
        html += "<div id='bottomPagination'>"
        html += self.getNavigationLink(prevPage, nextPage)
        html += "</div>"
        # writes the footer for each page 
        html += self.renderLicense()
        html += self.renderFooter()
        html += u"</div>\n"
        html += u"</div>\n"
        html += u"</body></html>\n"
        html = html.encode('utf8')
        # JR: Eliminamos los atributos de las ecuaciones
        aux = re.compile("exe_math_latex=\"[^\"]*\"")
	html = aux.sub("", html)
	aux = re.compile("exe_math_size=\"[^\"]*\"")
	html = aux.sub("", html)
	#JR: Cambio el & en los enlaces del glosario
	html = html.replace("&concept", "&amp;concept")
        return html
Ejemplo n.º 51
0
    def render(self, prevPage, nextPage, pages):
        """
        Returns an XHTML string rendering this page.
        """
        lenguaje = G.application.config.locale
        if self.node.package.dublinCore.language != "":
            lenguaje = self.node.package.dublinCore.language

        dT = common.getExportDocType()
        themeHasXML = common.themeHasConfigXML(self.node.package.style)
        lb = "\n"  #Line breaks
        sectionTag = "div"
        articleTag = "div"
        headerTag = "div"
        navTag = "div"
        if dT == "HTML5":
            html = '<!doctype html>' + lb
            html += '<html lang="' + lenguaje + '">' + lb
            sectionTag = "section"
            articleTag = "article"
            headerTag = "header"
            navTag = "nav"
        else:
            html = u'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' + lb
            html += u"<html lang=\"" + lenguaje + "\" xml:lang=\"" + lenguaje + "\" xmlns=\"http://www.w3.org/1999/xhtml\">" + lb
        html += u"<head>" + lb
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"base.css\" />" + lb
        if common.hasWikipediaIdevice(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_wikipedia.css\" />" + lb
        if common.hasGalleryIdevice(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_lightbox.css\" />" + lb
        if common.hasFX(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_effects.css\" />" + lb
        if common.hasSH(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_highlighter.css\" />" + lb
        if common.hasGames(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_games.css\" />" + lb
        if common.hasABCMusic(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_abcmusic.css\" />" + lb
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"content.css\" />" + lb
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"nav.css\" />" + lb
        html += u"<meta http-equiv=\"content-type\" content=\"text/html; "
        html += u" charset=utf-8\" />" + lb
        html += u"<title>"
        if self.node.id == '0':
            if self.node.package.title != '':
                html += escape(self.node.package.title)
            else:
                html += escape(self.node.titleLong)
        else:
            if self.node.package.title != '':
                html += escape(self.node.titleLong) + " | " + escape(
                    self.node.package.title)
            else:
                html += escape(self.node.titleLong)
        html += u" </title>" + lb
        html += u"<link rel=\"shortcut icon\" href=\"favicon.ico\" type=\"image/x-icon\" />" + lb
        if dT != "HTML5" and self.node.package.dublinCore.language != "":
            html += '<meta http-equiv="content-language" content="' + lenguaje + '" />' + lb
        if self.node.package.author != "":
            html += '<meta name="author" content="' + escape(
                self.node.package.author, True) + '" />' + lb
        html += common.getLicenseMetadata(self.node.package.license)
        html += '<meta name="generator" content="eXeLearning ' + release + ' - exelearning.net" />' + lb
        if self.node.id == '0':
            if self.node.package.description != "":
                desc = self.node.package.description
                desc = desc.replace('"', '&quot;')
                html += '<meta name="description" content="' + desc + '" />' + lb
        if dT == "HTML5" or common.nodeHasMediaelement(self.node):
            html += u'<!--[if lt IE 9]><script type="text/javascript" src="exe_html5.js"></script><![endif]-->' + lb
        style = G.application.config.styleStore.getStyle(
            self.node.package.style)

        # jQuery
        if style.hasValidConfig():
            if style.get_jquery() == True:
                html += u'<script type="text/javascript" src="exe_jquery.js"></script>' + lb
            else:
                html += u'<script type="text/javascript" src="' + style.get_jquery(
                ) + '"></script>' + lb
        else:
            html += u'<script type="text/javascript" src="exe_jquery.js"></script>' + lb

        if common.hasGalleryIdevice(self.node):
            html += u'<script type="text/javascript" src="exe_lightbox.js"></script>' + lb
        if common.hasFX(self.node):
            html += u'<script type="text/javascript" src="exe_effects.js"></script>' + lb
        if common.hasSH(self.node):
            html += u'<script type="text/javascript" src="exe_highlighter.js"></script>' + lb
        html += u'<script type="text/javascript" src="common_i18n.js"></script>' + lb
        if common.hasGames(self.node):
            html += u'<script type="text/javascript" src="exe_games.js"></script>' + lb
        if common.hasABCMusic(self.node):
            html += u'<script type="text/javascript" src="exe_abcmusic.js"></script>' + lb
        html += u'<script type="text/javascript" src="common.js"></script>' + lb
        html += common.printJavaScriptIdevicesScripts('export', self)
        if common.hasMagnifier(self.node):
            html += u'<script type="text/javascript" src="mojomagnify.js"></script>' + lb
        # Some styles might have their own JavaScript files (see their config.xml file)
        if style.hasValidConfig():
            html += style.get_extra_head()
        html += common.getExtraHeadContent(self.node.package)
        html += u"</head>" + lb
        extraCSS = ''
        if self.node.package.get_addSearchBox(
        ) and self.node.package.exportSource:
            extraCSS = ' exe-search-bar'
        html += u'<body class="exe-web-site' + extraCSS + '" id="exe-node-' + self.node.id + '"><script type="text/javascript">document.body.className+=" js"</script>' + lb
        html += u"<div id=\"content\">" + lb
        html += '<p id="skipNav"><a href="#main" class="sr-av">' + c_(
            'Skip navigation') + '</a></p>' + lb

        if self.node.package.backgroundImg or self.node.package.title:
            html += u"<" + headerTag + " id=\"header\" "

            if self.node.package.backgroundImg:
                html += u" style=\"background-image: url("
                html += quote(self.node.package.backgroundImg.basename())
                html += u"); "

                if self.node.package.backgroundImgTile:
                    html += "background-repeat: repeat-x;"
                else:
                    html += "background-repeat: no-repeat;"

                html += u"\""
            html += u">"
            html += '<div id="headerContent">'
            html += escape(self.node.package.title)
            html += '</div>'
            html += u"</" + headerTag + ">" + lb
        else:
            html += "<" + sectionTag + " id=\"emptyHeader\"></" + sectionTag + ">" + lb

        # add left navigation html
        html += u"<" + navTag + " id=\"siteNav\">" + lb
        html += self.leftNavigationBar(pages)
        html += u"</" + navTag + ">" + lb
        html += "<div id='topPagination'>" + lb
        html += self.getNavigationLink(prevPage, nextPage, pages)
        html += "</div>" + lb
        html += u"<div id=\"main-wrapper\">" + lb
        html += u"<" + sectionTag + " id=\"main\">"
        if dT != "HTML5":
            html += "<a name=\"main\"></a>"
        html += lb

        html += '<' + headerTag + ' id=\"nodeDecoration\">'
        html += '<h1 id=\"nodeTitle\">'
        html += escape(self.node.titleLong)
        html += '</h1>'
        html += '</' + headerTag + '>' + lb

        self.node.exportType = 'website'

        for idevice in self.node.idevices:
            if idevice.klass != 'NotaIdevice':
                e = " em_iDevice"
                if unicode(idevice.emphasis) == '0':
                    e = ""
                html += u'<' + articleTag + ' class="iDevice_wrapper %s%s" id="id%s">%s' % (
                    idevice.klass, e, idevice.id, lb)
                block = g_blockFactory.createBlock(None, idevice)
                if not block:
                    log.critical("Unable to render iDevice.")
                    raise Error("Unable to render iDevice.")
                if hasattr(idevice, "isQuiz"):
                    html += block.renderJavascriptForWeb()
                if idevice.title != "Forum Discussion":
                    html += self.processInternalLinks(
                        self.node.package,
                        block.renderView(self.node.package.style))
                html += u'</' + articleTag + '>' + lb  # iDevice div

        if not themeHasXML:
            html += "<div id='bottomPagination'>" + lb
            html += self.getNavigationLink(prevPage, nextPage, pages)
            html += "</div>" + lb
        # writes the footer for each page
        html += self.renderLicense()
        if not themeHasXML:
            #if not style.hasValidConfig():
            html += self.renderFooter()
        html += u"</" + sectionTag + ">" + lb  # /main
        html += u"</div>" + lb  # /main-wrapper
        if themeHasXML:
            #if style.hasValidConfig():
            html += "<div id='bottomPagination'>" + lb
            html += self.getNavigationLink(prevPage, nextPage, pages)
            html += "</div>" + lb
            html += self.renderFooter()
        html += u"</div>" + lb  # /content
        if themeHasXML:
            #if style.hasValidConfig():
            html += style.get_extra_body()
        html += u'</body></html>'
        html = html.encode('utf8')
        # JR: Eliminamos los atributos de las ecuaciones
        aux = re.compile("exe_math_latex=\"[^\"]*\"")
        html = aux.sub("", html)
        aux = re.compile("exe_math_size=\"[^\"]*\"")
        html = aux.sub("", html)
        #JR: Cambio el & en los enlaces del glosario
        html = html.replace("&concept", "&amp;concept")
        # Remove "resources/" from data="resources/ and the url param
        html = html.replace("video/quicktime\" data=\"resources/",
                            "video/quicktime\" data=\"")
        html = html.replace("application/x-mplayer2\" data=\"resources/",
                            "application/x-mplayer2\" data=\"")
        html = html.replace("audio/x-pn-realaudio-plugin\" data=\"resources/",
                            "audio/x-pn-realaudio-plugin\" data=\"")
        html = html.replace("<param name=\"url\" value=\"resources/",
                            "<param name=\"url\" value=\"")
        return html
Ejemplo n.º 52
0
    def renderNode(self, node, docType, level):
        """
        Returns an XHTML string for this node and recurse for the children
        """
        
        # Get section and header tags
        headerTag = u'div'
        articleTag = u'div'
        if docType == 'HTML5':
            headerTag = u'header'
            articleTag = u'article'
        
        headerLevel = level
        if(level > 6):
            headerLevel = 6
        
        html = u''
        # Main node container
        html += u'<%s class="node level-%d-node" id="exe-node-%s">%s' % (articleTag, level, node.id, lineBreak)
        
        # Node header container
        html += u'<%s class="nodeDecoration">%s' % (headerTag, lineBreak)
        # Node title
        html += u'<h1 id="%s" class="nodeTitle">%s</h1>%s' % (node.GetAnchorName(), escape(node.titleLong), lineBreak)
        # Close Node header container
        html += u'</%s>%s' % (headerTag, lineBreak)
        
        # Get the node Style
        style = self.node.package.style

        # Set node export type
        node.exportType = 'singlepage'
        
        # Render node iDevices
        for idevice in node.idevices:
            if idevice.klass != 'NotaIdevice':
                e = " em_iDevice"
                if unicode(idevice.emphasis) == '0':
                    e = ""
                # iDevice container
                html += u'<%s class="iDevice_wrapper %s%s" id="id%s">%s' % (articleTag, idevice.klass, e, (idevice.id + '-' + node.id), lineBreak)
                
                # Try to render the iDevice
                block = g_blockFactory.createBlock(None, idevice)
                if not block:
                    log.critical('Unable to render iDevice %s.' % (idevice.klass))
                    raise Error('Unable to render iDevice.')
                
                if hasattr(idevice, "isQuiz"):
                    html += block.renderJavascriptForWeb()
                
                # Process iDevice internal links
                html += helper.processInternalLinks(self.node.package, block.renderView(style))
                
                # Replace top links with "empty" links
                html = helper.replaceTopLinks(html)
                
                # Close iDevice container
                html += u'</%s>%s' % (articleTag, lineBreak)

        # Close main node container
        html += u'</%s>%s' % (articleTag, lineBreak)

        # Render all child nodes
        for child in node.children:
            html += self.renderNode(child, docType, level + 1)

        return html
Ejemplo n.º 53
0
    def render(self):
        """
        Returns an XHTML string rendering this page.
        """
        html = common.docType()
        #html += u"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
        lenguaje = G.application.config.locale
        html += u"<html lang=\"" + lenguaje + "\" xml:lang=\"" + lenguaje + "\" xmlns=\"http://www.w3.org/1999/xhtml\">\n"
        html += u"<head>\n"
        html += u"<meta http-equiv=\"Content-type\" content=\"text/html; "
        html += u" charset=utf-8\" />\n"
        # html += u"<title>"+_("eXe")+"</title>\n"
        html += u"<title>"
        if self.node.id == '0':
            if self.node.package.title != '':
                html += escape(self.node.package.title)
            else:
                html += escape(self.node.titleLong)
        else:
            if self.node.package.title != '':
                html += escape(self.node.titleLong) + " | " + escape(
                    self.node.package.title)
            else:
                html += escape(self.node.titleLong)
        html += u" </title>\n"
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"base.css\" />"
        if common.hasGalleryIdevice(self.node):
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_lightbox.css\" />"
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"content.css\" />"
        html += u'<script type="text/javascript" src="common.js"></script>\n'
        #modification by lernmodule.net
        html += u'<script type="text/javascript" src="lernmodule_net.js"></script>\n'
        #end modification
        html += u"</head>\n"
        html += u"<body class=\"exe-ims\">\n"
        html += u"<div id=\"outer\">\n"
        html += u"<div id=\"main\">\n"
        html += u"<div id=\"nodeDecoration\">\n"
        html += u'<h1 id=\"nodeTitle\">\n'
        html += escape(self.node.titleLong)
        html += u'</h1>\n'
        html += u"</div>\n"

        for idevice in self.node.idevices:
            html += u'<div class="%s" id="id%s">\n' % (idevice.klass,
                                                       idevice.id)
            block = g_blockFactory.createBlock(None, idevice)
            if not block:
                log.critical("Unable to render iDevice.")
                raise Error("Unable to render iDevice.")
            if hasattr(idevice, "isQuiz"):
                html += block.renderJavascriptForWeb()
            if idevice.title != "Forum Discussion":
                html += self.processInternalLinks(
                    block.renderView(self.node.package.style))
            html += u'</div>\n'  # iDevice div

        html += u"</div>\n"
        html += self.renderLicense()
        html += self.renderFooter()
        html += u"</div>\n"
        #modification by lernmodule.net
        html += u"<div id=\"lmsubmit\"></div><script type=\"text/javascript\" language=\"javascript\">doStart();</script></body></html>\n"
        #end modification
        html += u"</body></html>\n"
        html = html.encode('utf8')
        # JR: Eliminamos los atributos de las ecuaciones
        aux = re.compile("exe_math_latex=\"[^\"]*\"")
        html = aux.sub("", html)
        aux = re.compile("exe_math_size=\"[^\"]*\"")
        html = aux.sub("", html)
        #JR: Cambio el & en los enlaces del glosario
        html = html.replace("&concept", "&amp;concept")
        # Remove "resources/" from data="resources/ and the url param
        html = html.replace("video/quicktime\" data=\"resources/",
                            "video/quicktime\" data=\"")
        html = html.replace("application/x-mplayer2\" data=\"resources/",
                            "application/x-mplayer2\" data=\"")
        html = html.replace("audio/x-pn-realaudio-plugin\" data=\"resources/",
                            "audio/x-pn-realaudio-plugin\" data=\"")
        html = html.replace("<param name=\"url\" value=\"resources/",
                            "<param name=\"url\" value=\"")
        return html