Ejemplo n.º 1
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.º 2
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