コード例 #1
0
    def getNavigationLink(self, prevPage, nextPage):
        """
        return the next link url of this page
        """
        dT = common.getExportDocType()
        lb = "\n"  #Line breaks
        navTag = "div"
        if dT == "HTML5":
            navTag = "nav"
        html = "<" + navTag + " class=\"pagination noprt\">" + lb
        ext = 'html'
        if G.application.config.cutFileName == '1':
            ext = 'htm'

        if prevPage:
            html += "<a href=\"" + quote(
                prevPage.name) + '.' + ext + "\" class=\"prev\"><span>"
            html += "<span>&laquo; </span>%s</span></a>" % c_('Previous')

        if nextPage:
            if prevPage:
                html += ' <span class="sep">| </span>'
            html += "<a href=\"" + quote(
                nextPage.name) + '.' + ext + "\" class=\"next\"><span>"
            html += "%s<span> &raquo;</span></span></a>" % c_('Next')

        html += lb + "</" + navTag + ">" + lb
        return html
コード例 #2
0
ファイル: websitepage.py プロジェクト: smmartinezlujan/iteexe
    def getNavigationLink(self, prevPage, nextPage, pages):
        """
        return the next link url of this page
        """
        dT = common.getExportDocType()
        lb = "\n"  #Line breaks
        navTag = "div"
        if dT == "HTML5":
            navTag = "nav"
        html = "<" + navTag + " class=\"pagination noprt\">" + lb
        ext = 'html'
        if G.application.config.cutFileName == '1':
            ext = 'htm'

        if prevPage:
            html += "<a href=\"" + quote(
                prevPage.name) + '.' + ext + "\" class=\"prev\"><span>"
            html += "<span>&laquo; </span>%s</span></a>" % c_('Previous')

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

        if nextPage:
            if self.node.package.get_addPagination() or prevPage:
                html += ' <span class="sep">| </span>'
            html += "<a href=\"" + quote(
                nextPage.name) + '.' + ext + "\" class=\"next\"><span>"
            html += "%s<span> &raquo;</span></span></a>" % c_('Next')

        html += lb + "</" + navTag + ">" + lb
        return html
コード例 #3
0
    def __renderHeader(self):
		#TinyMCE lang (user preference)
        myPreferencesPage = self.webServer.preferences
        
        """Generates the header for AuthoringPage"""
        html  = common.docType()
        #################################################################################
        #################################################################################
        
        html += u'<html xmlns="http://www.w3.org/1999/xhtml" lang="'+myPreferencesPage.getSelectedLanguage()+'">\n'
        html += u'<head>\n'
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/exe.css\" />"
        
        # Use the Style's base.css file if it exists
        themePath = Path(G.application.config.stylesDir/self.package.style)
        themeBaseCSS = themePath.joinpath("base.css")
        if themeBaseCSS.exists():
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"/style/%s/base.css\" />" % self.package.style
        else:
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"/style/base.css\" />"
            
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/exe_wikipedia.css\" />"
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"/scripts/exe_effects/exe_effects.css\" />"
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"/scripts/exe_highlighter/exe_highlighter.css\" />"
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"/scripts/exe_games/exe_games.css\" />"
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"/style/%s/content.css\" />" % self.package.style
        if G.application.config.assumeMediaPlugins: 
            html += u"<script type=\"text/javascript\">var exe_assume_media_plugins = true;</script>\n"
        #JR: anado una variable con el estilo
        estilo = u'/style/%s/content.css' % self.package.style
        html += common.getJavaScriptStrings()
        # The games require additional strings
        html += common.getGamesJavaScriptStrings()
        html += u"<script type=\"text/javascript\">"
        html += u"var exe_style = '%s';top.exe_style = exe_style;" % estilo
        # editorpane.py uses exe_style_dirname to auto-select the current style (just a provisional solution)
        html += u"var exe_style_dirname = '%s'; top.exe_style_dirname = exe_style_dirname;" % self.package.style
        html += u"var exe_package_name='"+self.package.name+"';"
        html += 'var exe_export_format="'+common.getExportDocType()+'".toLowerCase();'
        html += 'var exe_editor_mode="'+myPreferencesPage.getEditorMode()+'";'
        html += 'var exe_editor_version="'+myPreferencesPage.getEditorVersion()+'";'
        html += '</script>\n'        
        html += u'<script type="text/javascript" src="../jsui/native.history.js"></script>\n'
        html += u'<script type="text/javascript" src="/scripts/authoring.js"></script>\n'
        html += u'<script type="text/javascript" src="/scripts/exe_jquery.js"></script>\n'
        html += u'<script type="text/javascript" src="/scripts/exe_lightbox/exe_lightbox.js"></script>\n'
        html += u'<script type="text/javascript" src="/scripts/exe_effects/exe_effects.js"></script>\n'
        html += u'<script type="text/javascript" src="/scripts/exe_highlighter/exe_highlighter.js"></script>\n'
        html += u'<script type="text/javascript" src="/scripts/exe_games/exe_games.js"></script>\n'
        html += u'<script type="text/javascript" src="/scripts/common.js"></script>\n'
        html += '<script type="text/javascript">document.write(unescape("%3Cscript src=\'" + eXeLearning_settings.wysiwyg_path + "\' type=\'text/javascript\'%3E%3C/script%3E"));</script>';
        html += '<script type="text/javascript">document.write(unescape("%3Cscript src=\'" + eXeLearning_settings.wysiwyg_settings_path + "\' type=\'text/javascript\'%3E%3C/script%3E"));</script>';
        html += u'<title>"+_("eXe : elearning XHTML editor")+"</title>\n'
        html += u'<meta http-equiv="content-type" content="text/html; '
        html += u' charset=UTF-8" />\n'
        style = G.application.config.styleStore.getStyle(self.package.style)
        if style.hasValidConfig:
            html += style.get_edition_extra_head()        
        html += u'</head>\n'
        return html
コード例 #4
0
ファイル: truefalseelement.py プロジェクト: RichDijk/eXe
 def renderFeedbackView(self, is_preview=False):
     """
     return xhtml string for display this option's feedback
     """
     lb = "\n" #Line breaks
     dT = common.getExportDocType()
     sectionTag = "div"
     titleTag = "h4"
     if dT == "HTML5":
         sectionTag = "section"
         titleTag = "h1"     
     
     if is_preview:
         content = self.question_feedback.field.content_w_resourcePaths
     else:
         content = self.question_feedback.field.content_wo_resourcePaths        
     
     html = '<'+sectionTag+' id="s'+self.id+'" class="feedback js-feedback js-hidden">'+lb
     html += '<'+titleTag+' class="js-sr-av">'+c_("Feedback")+'</'+titleTag+'>'+lb
     if self.question.isCorrect:
         html += '<p><strong id="s'+self.id+'-result" class="right">'+c_("True")+'</strong></p>'+lb
     else:
         html += '<p><strong id="s'+self.id+'-result" class="wrong">'+c_("False")+'</strong></p>'+lb
     html += content+lb
     html += '</'+sectionTag+'>'+lb   
     
     return html
コード例 #5
0
ファイル: listablock.py プロジェクト: sthagen/iteexe
    def __init__(self, parent, idevice):
        """
        Pre-create our field ids
        """
        Block.__init__(self, parent, idevice)
        
       
        # to compensate for the strange unpickling timing when objects are 
        # loaded from an elp, ensure that proper idevices are set:
        if idevice.instructionsForLearners.idevice is None: 
            idevice.instructionsForLearners.idevice = idevice
        if idevice.content.idevice is None: 
            idevice.content.idevice = idevice
        if idevice.feedback.idevice is None: 
            idevice.feedback.idevice = idevice
            
        dT = common.getExportDocType()
        sectionTag = "div"
        if dT == "HTML5":
            sectionTag = "section"
            
        idevice.instructionsForLearners.htmlTag = sectionTag
        idevice.instructionsForLearners.class_ = "block instructions"
        idevice.feedback.htmlTag = sectionTag            

        self.instructionElement = TextAreaElement(idevice.instructionsForLearners)
        self.instructionElement.field.content_w_resourcePaths = c_(self.instructionElement.field.content_w_resourcePaths)
        self.listaElement = ListaElement(idevice.content)
        self.feedbackElement = \
            TextAreaElement(idevice.feedback)
        self.previewing        = False # In view or preview render
        if not hasattr(self.idevice,'undo'): 
            self.idevice.undo = True
コード例 #6
0
    def getNavigationLink(self, prevPage, nextPage):
        """
        return the next link url of this page
        """
        dT = common.getExportDocType()
        lb = "\n"  #Line breaks
        navTag = "div"
        if dT == "HTML5":
            navTag = "nav"
        html = "<" + navTag + " class=\"pagination noprt\">" + lb

        if prevPage:
            html += "<a href=\"" + quote(
                prevPage.name) + ".html\" class=\"prev\">"
            html += "<span>&laquo; </span>%s</a>" % c_('Previous')

        if nextPage:
            if prevPage:
                html += " | "
            html += "<a href=\"" + quote(
                nextPage.name) + ".html\" class=\"next\">"
            html += " %s<span> &raquo;</span></a>" % c_('Next')

        html += lb + "</" + navTag + ">" + lb
        return html
コード例 #7
0
    def renderView(self, preview=False):
        """
        Returns an XHTML string for viewing this element
        """
        lb = "\n"  #Line breaks
        dT = common.getExportDocType()
        sectionTag = "div"
        titleTag1 = "h3"
        titleTag2 = "h4"
        if dT == "HTML5":
            sectionTag = "section"
            titleTag1 = "h1"
            titleTag2 = "h1"
        html = ''
        html += '<' + sectionTag + ' class="question">' + lb
        html += '<' + titleTag1 + ' class="js-sr-av">' + c_(
            "Question") + '</' + titleTag1 + '>' + lb
        if preview:
            html += self.questionElement.renderPreview()
        else:
            html += self.questionElement.renderView()
        # Answers
        html += '<' + sectionTag + ' class="iDevice_answers">' + lb
        html += '<' + titleTag2 + ' class="js-sr-av">' + c_(
            "Answers") + '</' + titleTag2 + '>' + lb
        for element in self.options:
            if preview:
                html += element.renderPreview()
            else:
                html += element.renderView()
        html += "</" + sectionTag + ">" + lb

        html += "</" + sectionTag + ">" + lb

        return html
コード例 #8
0
    def __init__(self, parent, idevice):
        """
        Pre-create our field ids
        """
        Block.__init__(self, parent, idevice)
        
       
        # to compensate for the strange unpickling timing when objects are 
        # loaded from an elp, ensure that proper idevices are set:
        if idevice.instructionsForLearners.idevice is None: 
            idevice.instructionsForLearners.idevice = idevice
        if idevice.content.idevice is None: 
            idevice.content.idevice = idevice
        if idevice.feedback.idevice is None: 
            idevice.feedback.idevice = idevice
            
        dT = common.getExportDocType()
        sectionTag = "div"
        if dT == "HTML5":
            sectionTag = "section"
            
        idevice.instructionsForLearners.htmlTag = sectionTag
        idevice.instructionsForLearners.class_ = "block instructions"
        idevice.feedback.htmlTag = sectionTag            

        self.instructionElement = TextAreaElement(idevice.instructionsForLearners)
        self.instructionElement.field.content_w_resourcePaths = c_(self.instructionElement.field.content_w_resourcePaths)
        self.listaElement = ListaElement(idevice.content)
        self.feedbackElement = \
            TextAreaElement(idevice.feedback)
        self.previewing        = False # In view or preview render
        if not hasattr(self.idevice,'undo'): 
            self.idevice.undo = True
コード例 #9
0
ファイル: websitepage.py プロジェクト: exelearning/iteexe
    def getNavigationLink(self, prevPage, nextPage, pages):
        """
        return the next link url of this page
        """
        dT = common.getExportDocType()
        lb = "\n" #Line breaks
        navTag = "div"
        if dT == "HTML5":
            navTag = "nav"
        html = "<"+navTag+" class=\"pagination noprt\">"+lb
        ext = 'html'
        if G.application.config.cutFileName == '1':
            ext = 'htm'

        if prevPage:
            html += "<a href=\"" + quote(prevPage.name) + '.' + ext + "\" class=\"prev\"><span>"
            html += "<span>&laquo; </span>%s</span></a>" % c_('Previous')

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

        if nextPage:
            if self.node.package.get_addPagination() or prevPage:
                html += ' <span class="sep">| </span>'
            html += "<a href=\"" + quote(nextPage.name) + '.' + ext + "\" class=\"next\"><span>"
            html += "%s<span> &raquo;</span></span></a>" % c_('Next')

        html += lb + "</" + navTag + ">" + lb
        return html
コード例 #10
0
ファイル: truefalseelement.py プロジェクト: sthagen/iteexe
    def renderFeedbackView(self, is_preview=False):
        """
        return xhtml string for display this option's feedback
        """
        lb = "\n"  #Line breaks
        dT = common.getExportDocType()
        sectionTag = "div"
        titleTag = "h4"
        if dT == "HTML5":
            sectionTag = "section"
            titleTag = "h1"

        if is_preview:
            content = self.question_feedback.field.content_w_resourcePaths
        else:
            content = self.question_feedback.field.content_wo_resourcePaths

        html = '<' + sectionTag + ' id="s' + self.id + '" class="feedback js-feedback js-hidden">' + lb
        html += '<' + titleTag + ' class="js-sr-av">' + c_(
            "Feedback") + '</' + titleTag + '>' + lb
        if self.question.isCorrect:
            html += '<p><strong id="s' + self.id + '-result" class="right">' + c_(
                "True") + '</strong></p>' + lb
        else:
            html += '<p><strong id="s' + self.id + '-result" class="wrong">' + c_(
                "False") + '</strong></p>' + lb
        html += content + lb
        html += '</' + sectionTag + '>' + lb

        return html
コード例 #11
0
ファイル: testquestionelement.py プロジェクト: Rafav/iteexe
 def renderView(self, preview=False):
     """
     Returns an XHTML string for viewing this element
     """
     lb = "\n" #Line breaks
     dT = common.getExportDocType()
     sectionTag = "div"
     titleTag1 = "h3"
     titleTag2 = "h4"
     if dT == "HTML5":
         sectionTag = "section"
         titleTag1 = "h1"
         titleTag2 = "h1"        
     html  = ''
     html += '<'+sectionTag+' class="question">'+lb
     html += '<'+titleTag1+' class="js-sr-av">' + c_("Question")+'</'+titleTag1+'>'+lb        
     if preview: 
         html += self.questionElement.renderPreview()
     else:
         html += self.questionElement.renderView()
     # Answers
     html += '<'+sectionTag+' class="iDevice_answers">'+lb
     html += '<'+titleTag2+' class="js-sr-av">' + c_("Answers")+'</'+titleTag2+'>'+lb        
     for element in self.options:
         if preview: 
             html += element.renderPreview()      
         else:
             html += element.renderView()      
     html += "</"+sectionTag+">"+lb
     
     html += "</"+sectionTag+">"+lb
     
     return html
コード例 #12
0
    def __renderHeader(self):
        #TinyMCE lang (user preference)
        myPreferencesPage = self.webServer.preferences
        """Generates the header for AuthoringPage"""
        html = common.docType()
        #################################################################################
        #################################################################################

        html += u'<html xmlns="http://www.w3.org/1999/xhtml" lang="' + myPreferencesPage.getSelectedLanguage(
        ) + '">\n'
        html += u'<head>\n'
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/exe.css\" />"

        # Use the Style's base.css file if it exists
        themePath = Path(G.application.config.stylesDir / self.package.style)
        themeBaseCSS = themePath.joinpath("base.css")
        if themeBaseCSS.exists():
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"/style/%s/base.css\" />" % self.package.style
        else:
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"/style/base.css\" />"

        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/exe_wikipedia.css\" />"
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"/scripts/exe_effects/exe_effects.css\" />"
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"/scripts/exe_highlighter/exe_highlighter.css\" />"
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"/scripts/exe_games/exe_games.css\" />"
        html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"/style/%s/content.css\" />" % self.package.style
        if G.application.config.assumeMediaPlugins:
            html += u"<script type=\"text/javascript\">var exe_assume_media_plugins = true;</script>\n"
        #JR: anado una variable con el estilo
        estilo = u'/style/%s/content.css' % self.package.style
        html += common.getJavaScriptStrings()
        # The games require additional strings
        html += common.getGamesJavaScriptStrings()
        html += u"<script type=\"text/javascript\">"
        html += u"var exe_style = '%s';" % estilo
        html += u"var exe_package_name='" + self.package.name + "';"
        html += 'var exe_export_format="' + common.getExportDocType(
        ) + '".toLowerCase();'
        html += 'var exe_editor_mode="' + myPreferencesPage.getEditorMode(
        ) + '";'
        html += '</script>\n'
        html += u'<script type="text/javascript" src="../jsui/native.history.js"></script>\n'
        html += u'<script type="text/javascript" src="/scripts/authoring.js"></script>\n'
        html += u'<script type="text/javascript" src="/scripts/exe_jquery.js"></script>\n'
        html += u'<script type="text/javascript" src="/scripts/exe_lightbox/exe_lightbox.js"></script>\n'
        html += u'<script type="text/javascript" src="/scripts/exe_effects/exe_effects.js"></script>\n'
        html += u'<script type="text/javascript" src="/scripts/exe_highlighter/exe_highlighter.js"></script>\n'
        html += u'<script type="text/javascript" src="/scripts/exe_games/exe_games.js"></script>\n'
        html += u'<script type="text/javascript" src="/scripts/common.js"></script>\n'
        html += '<script type="text/javascript">document.write(unescape("%3Cscript src=\'" + eXeLearning_settings.wysiwyg_path + "\' type=\'text/javascript\'%3E%3C/script%3E"));</script>'
        html += '<script type="text/javascript">document.write(unescape("%3Cscript src=\'" + eXeLearning_settings.wysiwyg_settings_path + "\' type=\'text/javascript\'%3E%3C/script%3E"));</script>'
        html += u'<title>"+_("eXe : elearning XHTML editor")+"</title>\n'
        html += u'<meta http-equiv="content-type" content="text/html; '
        html += u' charset=UTF-8" />\n'
        style = G.application.config.styleStore.getStyle(self.package.style)
        if style.hasValidConfig:
            html += style.get_edition_extra_head()
        html += u'</head>\n'
        return html
コード例 #13
0
    def render(self, package, for_print=0):
        """
        Returns an XHTML string rendering this page.
        """
        dT = common.getExportDocType()
        lb = "\n" #Line breaks
        sectionTag = "div"
        headerTag = "div"
        if dT == "HTML5":
            sectionTag = "section"
            headerTag = "header"
            
        if package.title!='':
            title = escape(package.title)
        else:
            title = escape(package.root.titleLong)
        html  = self.renderHeader(title, for_print)
        if for_print:
            # include extra onload bit:
            html += u'<body class="exe-single-page" onload="print_page()">'
        else:
            html += u'<body class="exe-single-page">'
        html += u'<script type="text/javascript">document.body.className+=" js"</script>'+lb
        html += u"<div id=\"content\">"+lb
        html += u"<"+headerTag+" id=\"header\">"
        html += "<h1>"+escape(package.title)+"</h1>"
        html += u"</"+headerTag+">"+lb
        html += u"<"+sectionTag+" id=\"main\">"+lb
        html += self.renderNode(package.root, 1)
        html += u"<"+sectionTag+" id=\"lmsubmit\"></"+sectionTag+"><script type=\"text/javascript\" language=\"javascript\">doStart();</script>"
        html += u"</"+sectionTag+">"+lb
        html += self.renderLicense()+lb
        html += self.renderFooter()+lb
        html += u"</div>"+lb # Close content
        # Some styles might have their own JavaScript files (see their config.xml file)
        style = G.application.config.styleStore.getStyle(self.node.package.style)
        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>'
        
        # 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 la ruta de los enlaces del glosario y el &
        html = html.replace("../../../../../mod/glossary", "../../../../mod/glossary")
        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
コード例 #14
0
    def copyFiles(self, package):
        """
        Copy all the files used by the website.
        """
        # Copy the style files to the output dir
        # But not nav.css
        if os.path.isdir(self.stylesDir):
            styleFiles = [self.stylesDir / '..' / 'popup_bg.gif']
            styleFiles += self.stylesDir.files("*.*")
            if "nav.css" in styleFiles:
                styleFiles.remove("nav.css")
            self.stylesDir.copylist(styleFiles, self.outputDir)

        # copy the package's resource files
        package.resourceDir.copyfiles(self.outputDir)

        listCSSFiles = getFilesCSSToMinify('singlepage', self.stylesDir)
        exportMinFileCSS(listCSSFiles, self.outputDir)

        # copy script files.
        my_style = G.application.config.styleStore.getStyle(package.style)

        # jQuery
        if my_style.hasValidConfig:
            if my_style.get_jquery() == True:
                jsFile = (self.scriptsDir / 'exe_jquery.js')
                jsFile.copyfile(self.outputDir / 'exe_jquery.js')
        else:
            jsFile = (self.scriptsDir / 'exe_jquery.js')
            jsFile.copyfile(self.outputDir / 'exe_jquery.js')

        dT = common.getExportDocType()
        if dT == "HTML5":
            jsFile = (self.scriptsDir / 'exe_html5.js')
            jsFile.copyfile(self.outputDir / 'exe_html5.js')

        # Minify common.js file
        listFiles = getFilesJSToMinify('singlepage', self.scriptsDir)
        exportMinFileJS(listFiles, self.outputDir)

        # Incluide eXe's icon if the Style doesn't have one
        themePath = Path(G.application.config.stylesDir / package.style)
        themeFavicon = themePath.joinpath("favicon.ico")
        if not themeFavicon.exists():
            faviconFile = (self.imagesDir / 'favicon.ico')
            faviconFile.copyfile(self.outputDir / 'favicon.ico')

        #JR Metemos los reproductores necesarios
        self.compruebaReproductores(self.page.node)

        if package.license == "license GFDL":
            # include a copy of the GNU Free Documentation Licence
            ext = 'html'
            if G.application.config.cutFileName == "1":
                ext = 'htm'
            (self.templatesDir / 'fdl' + '.' +
             ext).copyfile(self.outputDir / 'fdl' + '.' + ext)
コード例 #15
0
    def genItemResStr(self, page):
        """
        Returning xml string for items and resources
        """
        itemId   = "ITEM-"+unicode(self.idGenerator.generate())
        resId    = "RES-"+unicode(self.idGenerator.generate())
        filename = page.name+".html"
            
        
        self.itemStr += "<item identifier=\""+itemId+"\" isvisible=\"true\" "
        self.itemStr += "identifierref=\""+resId+"\">\n"
        self.itemStr += "    <title>"
        self.itemStr += escape(page.node.titleShort)
        self.itemStr += "</title>\n"
        
        self.resStr += "<resource identifier=\""+resId+"\" "
        self.resStr += "type=\"webcontent\" "

        self.resStr += "href=\""+filename+"\"> \n"
        self.resStr += """\
    <file href="%s"/>
    <file href="base.css"/>
    <file href="content.css"/>""" % filename
        self.resStr += "\n"
        fileStr = ""
        
        dT = common.getExportDocType()
        if dT == "HTML5" or common.nodeHasMediaelement(page.node):
            self.resStr += '    <file href="exe_html5.js"/>\n'

        resources = page.node.getResources()
        my_style = G.application.config.styleStore.getStyle(page.node.package.style)
        if common.nodeHasMediaelement(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'mediaelement').files()]
        if common.nodeHasTooltips(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_tooltips').files()]
        if common.hasGalleryIdevice(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_lightbox').files()]
        if common.hasFX(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_effects').files()]
        if common.hasSH(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_highlighter').files()]
        if common.hasGames(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_games').files()]
        if common.hasABCMusic(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'tinymce_4'/'js'/'tinymce'/'plugins'/'abcmusic'/'export').files()]
        if my_style.hasValidConfig:
            if my_style.get_jquery() == True:
                self.resStr += '    <file href="exe_jquery.js"/>\n'
        else:
            self.resStr += '    <file href="exe_jquery.js"/>\n'

        for resource in resources:
            fileStr += "    <file href=\""+escape(resource)+"\"/>\n"

        self.resStr += fileStr
        self.resStr += "</resource>\n"
コード例 #16
0
    def genItemResStr(self, page):
        """
        Returning xml string for items and resources
        """
        itemId   = "ITEM-"+unicode(self.idGenerator.generate())
        resId    = "RES-"+unicode(self.idGenerator.generate())
        filename = page.name+".html"
            
        
        self.itemStr += "<item identifier=\""+itemId+"\" isvisible=\"true\" "
        self.itemStr += "identifierref=\""+resId+"\">\n"
        self.itemStr += "    <title>"
        self.itemStr += escape(page.node.titleShort)
        self.itemStr += "</title>\n"
        
        self.resStr += "<resource identifier=\""+resId+"\" "
        self.resStr += "type=\"webcontent\" "

        self.resStr += "href=\""+filename+"\"> \n"
        self.resStr += """\
    <file href="%s"/>
    <file href="base.css"/>
    <file href="content.css"/>""" % filename
        self.resStr += "\n"
        fileStr = ""
        
        dT = common.getExportDocType()
        if dT == "HTML5" or common.nodeHasMediaelement(page.node):
            self.resStr += '    <file href="exe_html5.js"/>\n'

        resources = page.node.getResources()
        my_style = G.application.config.styleStore.getStyle(page.node.package.style)
        if common.nodeHasMediaelement(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'mediaelement').files()]
        if common.nodeHasTooltips(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_tooltips').files()]
        if common.hasGalleryIdevice(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_lightbox').files()]
        if common.hasFX(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_effects').files()]
        if common.hasSH(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_highlighter').files()]
        if common.hasGames(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_games').files()]
        if my_style.hasValidConfig:
            if my_style.get_jquery() == True:
                self.resStr += '    <file href="exe_jquery.js"/>\n'
        else:
            self.resStr += '    <file href="exe_jquery.js"/>\n'

        for resource in resources:
            fileStr += "    <file href=\""+escape(resource)+"\"/>\n"

        self.resStr += fileStr
        self.resStr += "</resource>\n"
コード例 #17
0
ファイル: imsexport.py プロジェクト: RichDijk/eXe
    def genItemResStr(self, page):
        """
        Returning xml string for items and resources
        """
        itemId = "ITEM-" + unicode(self.idGenerator.generate())
        resId = "RES-" + unicode(self.idGenerator.generate())
        filename = page.name + ".html"

        self.itemStr += '<item identifier="' + itemId + '" isvisible="true" '
        self.itemStr += 'identifierref="' + resId + '">\n'
        self.itemStr += "    <title>"
        self.itemStr += escape(page.node.titleShort)
        self.itemStr += "</title>\n"

        self.resStr += '<resource identifier="' + resId + '" '
        self.resStr += 'type="webcontent" '

        self.resStr += 'href="' + filename + '"> \n'
        self.resStr += (
            """\
    <file href="%s"/>
    <file href="base.css"/>
    <file href="content.css"/>"""
            % filename
        )
        self.resStr += "\n"
        fileStr = ""

        dT = common.getExportDocType()
        if dT == "HTML5" or common.nodeHasMediaelement(page.node):
            self.resStr += '    <file href="exe_html5.js"/>\n'

        resources = page.node.getResources()
        my_style = G.application.config.styleStore.getStyle(page.node.package.style)
        if common.nodeHasMediaelement(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir / "scripts" / "mediaelement").files()]
        if common.hasGalleryIdevice(page.node):
            self.resStr += '    <file href="exe_lightbox.js"/>\n'
            self.resStr += '    <file href="exe_lightbox.css"/>\n'
            self.resStr += '    <file href="exe_lightbox_close.png"/>\n'
            self.resStr += '    <file href="exe_lightbox_loading.gif"/>\n'
            self.resStr += '    <file href="exe_lightbox_next.png"/>\n'
            self.resStr += '    <file href="exe_lightbox_prev.png"/>\n'
        if my_style.hasValidConfig:
            if my_style.get_jquery() == True:
                self.resStr += '    <file href="exe_jquery.js"/>\n'
        else:
            self.resStr += '    <file href="exe_jquery.js"/>\n'

        for resource in resources:
            fileStr += '    <file href="' + escape(resource) + '"/>\n'

        self.resStr += fileStr
        self.resStr += "</resource>\n"
コード例 #18
0
    def renderFooter(self):
        """
        Returns an XHTML string rendering the footer.
        """
        dT = common.getExportDocType()
        footerTag = "div"
        if dT == "HTML5":
            footerTag = "footer"

        html = ""
        if self.node.package.footer != "":
            html += '<' + footerTag + ' id="siteFooter">'
            html += self.node.package.footer + "</" + footerTag + ">"

        return html
コード例 #19
0
    def renderFooter(self):
        """
        Returns an XHTML string rendering the footer.
        """
        dT = common.getExportDocType()
        footerTag = "div"
        if dT == "HTML5":
            footerTag = "footer"

        html = ""
        if self.node.package.footer != "":
            html += '<' + footerTag + ' id="siteFooter">'
            html += self.node.package.footer + "</" + footerTag + ">"

        return html
コード例 #20
0
ファイル: singlepage.py プロジェクト: g-vidal/iteexe
    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
コード例 #21
0
ファイル: externalurlblock.py プロジェクト: sthagen/iteexe
 def renderViewContent(self):
     """
     Returns an XHTML string for previewing this block
     """
     lb = "\n"  #Line breaks
     dT = common.getExportDocType()
     if dT == "HTML5":
         html = '<div class="iDevice_content" style="width:100%">' + lb
         if self.idevice.url:
             html += '<iframe src="' + self.idevice.url + '" width="600" height="' + self.idevice.height + '" style="width:100%"></iframe>' + lb
     else:
         html = '<div class="iDevice_content">' + lb
         if self.idevice.url:
             html += '<iframe src="' + self.idevice.url + '" width="100%" height="' + self.idevice.height + 'px"></iframe>' + lb
     html += '</div>' + lb
     return html
コード例 #22
0
ファイル: externalurlblock.py プロジェクト: Rafav/iteexe
 def renderViewContent(self):
     """
     Returns an XHTML string for previewing this block
     """
     lb = "\n" #Line breaks
     dT = common.getExportDocType()   
     if dT == "HTML5":
         html = '<div class="iDevice_content" style="width:100%">'+lb
         if self.idevice.url:
             html += '<iframe src="'+self.idevice.url+'" width="600" height="'+self.idevice.height+'" style="width:100%"></iframe>'+lb
     else:        
         html = '<div class="iDevice_content">'+lb
         if self.idevice.url:
             html += '<iframe src="'+self.idevice.url+'" width="100%" height="'+self.idevice.height+'px"></iframe>'+lb
     html += '</div>'+lb
     return html
コード例 #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
        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
コード例 #24
0
    def renderView(self, style):
        """
        Returns an XHTML string for viewing this block
        """

        lb = "\n"  #Line breaks
        dT = common.getExportDocType()
        figureTag = "div"
        if dT == "HTML5":
            figureTag = "figure"

        html = common.ideviceHeader(self, style, "view")

        html += '<div class="iDevice_content">' + lb
        html += '<' + figureTag + ' class="image_text" style="width:' + str(
            self.idevice.imageMagnifier.width
        ) + 'px;float:' + self.idevice.float + ';'
        if self.idevice.float == 'left':
            html += 'margin:0 20px 20px 0'
        if self.idevice.float == 'right':
            html += 'margin:0 0 20px 20px'
        html += '">'
        html += lb
        html += self.imageMagnifierElement.renderView()
        if self.idevice.caption != '':
            html = html.replace(
                ' alt="" ',
                ' alt="' + self.idevice.caption.replace('"', '&quot;') + '" ',
                1)
            if dT == "HTML5":
                html += '<figcaption style="font-weight:bold">' + self.idevice.caption + '</figcaption>' + lb
            else:
                html += '<strong>' + self.idevice.caption + '</strong>' + lb
        html += '</' + figureTag + '>' + lb
        text = self.textElement.renderView()
        if text:
            text = text.replace('"block iDevice_content"', '"iDevice_text"', 1)
            html += text
        else:
            html += '&nbsp;'
        html += '</div>' + lb  # /.iDevice_content

        html += common.ideviceFooter(self, style, "view")

        return html
コード例 #25
0
ファイル: truefalseelement.py プロジェクト: sthagen/iteexe
    def renderQuestion(self, is_preview):
        """
        Returns an XHTML string for viewing and previewing this question element
        """
        log.debug("renderPreview called in the form of renderQuestion")

        lb = "\n"  #Line breaks
        dT = common.getExportDocType()
        titleTag = "h3"
        if dT == "HTML5":
            titleTag = "h1"

        if is_preview:
            html = '<' + titleTag + ' class="js-sr-av">' + c_(
                "Question") + ' ' + str(self.index +
                                        1) + '</' + titleTag + '>' + lb
            html += self.question_question.renderPreview()
            if self.question_hint.field.content:
                html += common.ideviceHint(self.question_hint.field.content,
                                           "preview", "h4")
        else:
            html = '<form name="true-false-form-' + self.id + '" action="#" class="activity-form">' + lb
            html += '<' + titleTag + ' class="js-sr-av">' + c_(
                "Question") + ' ' + str(self.index +
                                        1) + '</' + titleTag + '>' + lb
            html += self.question_question.renderView()
            if self.question_hint.field.content:
                html += common.ideviceHint(self.question_hint.field.content,
                                           "view", "h4")

        html += '<p class="iDevice_answer js-required">' + lb
        html += '<label for="true' + self.id + '">'
        html += self.__option(0, 2, "true") + ' '
        html += c_("True")
        html += '</label> ' + lb
        html += '<label for="false' + self.id + '">'
        html += self.__option(1, 2, "false") + ' '
        html += c_("False")
        html += '</label>' + lb
        html += '</p>' + lb

        if not is_preview:
            html += '</form>' + lb

        return html
コード例 #26
0
    def renderQuestion(self, is_preview):
        """
        Returns an XHTML string for viewing and previewing this question element
        """
        log.debug("renderPreview called in the form of renderQuestion")
        
        lb = "\n" #Line breaks
        dT = common.getExportDocType()
        titleTag = "h3"
        if dT == "HTML5":
            titleTag = "h1"
        
        if is_preview:
            html = '<'+titleTag+' class="js-sr-av">' + c_("Question")+' '+str(self.index+1)+'</'+titleTag+'>'+lb
            html += self.question_question.renderPreview()
            if self.question_hint.field.content:
                html += common.ideviceHint(self.question_hint.field.content,"preview","h4")
        else: 
            html = '<form name="true-false-form-'+self.id+'" action="#" class="activity-form">'+lb        
            html += '<'+titleTag+' class="js-sr-av">' + c_("Question")+' '+str(self.index+1)+'</'+titleTag+'>'+lb
            html += self.question_question.renderView()
            if self.question_hint.field.content:
                html += common.ideviceHint(self.question_hint.field.content,"view","h4")



        html += "<fieldset data-role='controlgroup' data-type='horizontal' >"+lb
        html += '<p class="iDevice_answer js-required">'+lb
        html += '<label for="true'+self.id+'">'
        html += self.__option(0, 2, "true")+' '
        html += c_("True")
        html += '</label> '+lb
        html += '<label for="false'+self.id+'">'
        html += self.__option(1, 2, "false")+' '
        html += c_("False")
        html += '</label>'+lb
        html += '</p>'+lb
        html += "</fieldset>"+lb
        
        if not is_preview:
            html += '</form>'+lb
       
        return html
コード例 #27
0
ファイル: imagemagnifierblock.py プロジェクト: Rafav/iteexe
    def renderView(self, style):
        """
        Returns an XHTML string for viewing this block
        """     

        lb = "\n" #Line breaks
        dT = common.getExportDocType()
        figureTag = "div"
        if dT == "HTML5":
            figureTag = "figure"        
        
        html = common.ideviceHeader(self, style, "view")
        
        html += '<div class="iDevice_content">'+lb
        html += '<'+figureTag+' class="image_text" style="width:'+str(self.idevice.imageMagnifier.width)+'px;float:'+self.idevice.float+';'
        if self.idevice.float == 'left':
            html += 'margin:0 20px 20px 0'
        if self.idevice.float == 'right':
            html += 'margin:0 0 20px 20px'
        html += '">'  
        html += lb
        html += self.imageMagnifierElement.renderView()
        if self.idevice.caption != '':
            html = html.replace(' alt="" ',' alt="'+self.idevice.caption.replace('"','&quot;')+'" ', 1)
            if dT == "HTML5":
                html += '<figcaption style="font-weight:bold">'+self.idevice.caption+'</figcaption>'+lb
            else:
                html += '<strong>'+self.idevice.caption+'</strong>'+lb
        html += '</'+figureTag+'>'+lb 
        text = self.textElement.renderView()
        if text:
            text = text.replace('"block iDevice_content"', '"iDevice_text"', 1)
            html += text
        else:
            html += '&nbsp;'
        html += '</div>'+lb # /.iDevice_content
        
        html += common.ideviceFooter(self, style, "view")

        return html
コード例 #28
0
ファイル: truefalseblock.py プロジェクト: UstadMobile/eXePUB
    def renderView(self, style):
        """
        Returns an XHTML string for viewing this block
        """
        lb = "\n" #Line breaks
        dT = common.getExportDocType()
        sectionTag = "div"
        if dT == "HTML5":
            sectionTag = "section"
            
        html = common.ideviceHeader(self, style, "view")
        html += self.instructionElement.renderView()
        
        for element in self.questionElements:
            html += "<"+sectionTag+" class=\"question\">"+lb
            html += element.renderQuestionView()
            html += element.renderFeedbackView()
            html += "</"+sectionTag+">"+lb
            
        html += common.ideviceFooter(self, style, "view")

        return html
コード例 #29
0
ファイル: questionelement.py プロジェクト: RichDijk/eXe
    def __init__(self, index, idevice, question):
        """
        Initialize
        'index' is our number in the list of questions
        'idevice' is a case study idevice
        'question' is a exe.engine.casestudyidevice.Question instance
        """
        self.index        = index
        self.id           = "q" + unicode(index) + "b" + idevice.id        
        self.idevice      = idevice


        self.quesId       = "quesQuestion" + unicode(index) + "b" + idevice.id
        self.feedbackId   = "quesFeedback" + unicode(index) + "b" + idevice.id

        self.question     = question
        # also split out each part for a separate TextAreaElement:

        # but first....  
        # to compensate for the strange unpickling timing when objects are 
        # loaded from an elp, ensure that proper idevices are set: 
        if question.questionTextArea.idevice is None: 
            question.questionTextArea.idevice = idevice 
        if question.feedbackTextArea.idevice is None: 
            question.feedbackTextArea.idevice = idevice
            
        dT = common.getExportDocType()
        sectionTag = "div"
        if dT == "HTML5":
            sectionTag = "section" 
        question.questionTextArea.htmlTag = sectionTag

        self.question_question = TextAreaElement(question.questionTextArea)
        self.question_question.id = self.quesId 
        
        question.feedbackTextArea.htmlTag = "div"
        
        self.question_feedback = TextAreaElement(question.feedbackTextArea)
        self.question_feedback.id = self.feedbackId 
コード例 #30
0
    def __init__(self, index, idevice, question):
        """
        Initialize
        'index' is our number in the list of questions
        'idevice' is a case study idevice
        'question' is a exe.engine.casestudyidevice.Question instance
        """
        self.index = index
        self.id = "q" + unicode(index) + "b" + idevice.id
        self.idevice = idevice

        self.quesId = "quesQuestion" + unicode(index) + "b" + idevice.id
        self.feedbackId = "quesFeedback" + unicode(index) + "b" + idevice.id

        self.question = question
        # also split out each part for a separate TextAreaElement:

        # but first....
        # to compensate for the strange unpickling timing when objects are
        # loaded from an elp, ensure that proper idevices are set:
        if question.questionTextArea.idevice is None:
            question.questionTextArea.idevice = idevice
        if question.feedbackTextArea.idevice is None:
            question.feedbackTextArea.idevice = idevice

        dT = common.getExportDocType()
        sectionTag = "div"
        if dT == "HTML5":
            sectionTag = "section"
        question.questionTextArea.htmlTag = sectionTag

        self.question_question = TextAreaElement(question.questionTextArea)
        self.question_question.id = self.quesId

        question.feedbackTextArea.htmlTag = "div"

        self.question_feedback = Feedback2Element(question.feedbackTextArea)
        self.question_feedback.id = self.feedbackId
コード例 #31
0
    def renderView(self, preview=False):
        """
        Returns an XHTML string for viewing this option element
        """
        log.debug("renderView called")

        lb = "\n"  #Line breaks
        dT = common.getExportDocType()
        sectionTag = "div"
        if dT == "HTML5":
            sectionTag = "section"

        html = '<' + sectionTag + ' class="iDevice_answer">' + lb

        # Checkbox
        fieldId = self.keyId + unicode((self.index + 1))
        html += '<p class="iDevice_answer-field js-required">' + lb
        html += '<label for="' + fieldId + '" class="sr-av"><a href="#answer-' + fieldId + '">' + c_(
            "Option") + ' ' + unicode((self.index + 1)) + '</a></label>'
        html += '<input type="radio" name="' + self.keyId + '" id="' + fieldId + '" value="' + unicode(
            self.index) + '" />'
        html += lb
        html += '</p>' + lb

        # Answer content
        html += '<div class="iDevice_answer-content" id="answer-' + fieldId + '">'
        if dT != "HTML5":
            html += '<a name="answer-' + fieldId + '"></a>'
        html += lb
        if preview:
            html += self.answerElement.renderPreview()
        else:
            html += self.answerElement.renderView()
        html += '</div>' + lb

        html += "</" + sectionTag + ">" + lb

        return html
コード例 #32
0
    def getNavigationLink(self, prevPage, nextPage):
        """
        return the next link url of this page
        """
        dT = common.getExportDocType()
        lb = "\n" #Line breaks
        navTag = "div"
        if dT == "HTML5":
            navTag = "nav"
        html = "<"+navTag+" class=\"pagination noprt\">"+lb

        if prevPage:
            html += "<a href=\""+quote(prevPage.name)+".html\" class=\"prev\">"
            html += "<span>&laquo; </span>%s</a>" % c_('Previous')

        if nextPage:
            if prevPage:
                html += " | "
            html += "<a href=\""+quote(nextPage.name)+".html\" class=\"next\">"
            html += " %s<span> &raquo;</span></a>" % c_('Next')
            
        html += lb+"</"+navTag+">"+lb
        return html
コード例 #33
0
    def getNavigationLink(self, prevPage, nextPage):
        """
        return the next link url of this page
        """
        dT = common.getExportDocType()
        lb = "\n"  # Line breaks
        navTag = "div"
        if dT == "HTML5":
            navTag = "nav"
        html = "<" + navTag + ' class="pagination noprt">' + lb

        if prevPage:
            html += '<a href="' + quote(prevPage.name) + '.html" class="prev">'
            html += "<span>&laquo; </span>%s</a>" % c_("Previous")

        if nextPage:
            if prevPage:
                html += " | "
            html += '<a href="' + quote(nextPage.name) + '.html" class="next">'
            html += " %s<span> &raquo;</span></a>" % c_("Next")

        html += lb + "</" + navTag + ">" + lb
        return html
コード例 #34
0
ファイル: testoptionelement.py プロジェクト: Rafav/iteexe
 def renderView(self, preview=False):
     """
     Returns an XHTML string for viewing this option element
     """
     log.debug("renderView called")
     
     lb = "\n" #Line breaks
     dT = common.getExportDocType()
     sectionTag = "div"
     if dT == "HTML5":
         sectionTag = "section"
     
     html = '<'+sectionTag+' class="iDevice_answer">'+lb
     
     # Checkbox
     fieldId = self.keyId+unicode((self.index+1));
     html += '<p class="iDevice_answer-field js-required">'+lb
     html += '<label for="'+fieldId+'" class="sr-av"><a href="#answer-'+fieldId+'">' + c_("Option")+' '+unicode((self.index+1))+'</a></label>'
     html += '<input type="radio" name="'+self.keyId+'" id="'+fieldId+'" value="'+unicode(self.index)+'" />'
     html += lb
     html += '</p>'+lb       
     
     # Answer content
     html += '<div class="iDevice_answer-content" id="answer-'+fieldId+'">'
     if dT != "HTML5":
         html += '<a name="answer-'+fieldId+'"></a>'
     html += lb
     if preview: 
         html += self.answerElement.renderPreview()
     else:
         html += self.answerElement.renderView()
     html += '</div>'+lb
     
     html += "</"+sectionTag+">"+lb
    
     return html    
コード例 #35
0
    def __init__(self, parent, idevice):
        """
        Initialize a new Block object
        """
        Block.__init__(self, parent, idevice)
        self.idevice           = idevice
        self.questionElements  = []

        # to compensate for the strange unpickling timing when objects are 
        # loaded from an elp, ensure that proper idevices are set:
        if idevice.storyTextArea.idevice is None: 
            idevice.storyTextArea.idevice = idevice
            
        dT = common.getExportDocType()
        sectionTag = "div"
        if dT == "HTML5":
            sectionTag = "section"
            
        idevice.storyTextArea.htmlTag = sectionTag
        idevice.storyTextArea.class_ = "block story"

        self.storyElement      = TextAreaElement(idevice.storyTextArea)

        self.questionInstruc   = idevice.questionInstruc
        self.storyInstruc      = idevice.storyInstruc
        self.feedbackInstruc   = idevice.feedbackInstruc
        self.previewing        = False # In view or preview render 

        if not hasattr(self.idevice,'undo'): 
            self.idevice.undo = True

        i = 0
        
        for question in idevice.questions:
            self.questionElements.append(QuestionElement(i, idevice, question))
            i += 1
コード例 #36
0
    def compruebaReproductores(self, node):
        """
        Comprobamos si hay que meter algun reproductor
        """

        # copy players for media idevices.
        hasFlowplayer = False
        hasMagnifier = False
        hasXspfplayer = False
        hasGallery = False
        hasFX = False
        hasSH = False
        hasGames = False
        hasWikipedia = False
        hasInstructions = False
        hasMediaelement = False
        hasTooltips = False
        hasABCMusic = False

        for idevice in node.idevices:
            if (hasFlowplayer and hasMagnifier and hasXspfplayer and hasGallery
                    and hasFX and hasSH and hasGames and hasWikipedia
                    and hasInstructions and hasMediaelement and hasTooltips
                    and hasABCMusic):
                break
            if not hasFlowplayer:
                if 'flowPlayer.swf' in idevice.systemResources:
                    hasFlowplayer = True
            if not hasMagnifier:
                if 'mojomagnify.js' in idevice.systemResources:
                    hasMagnifier = True
            if not hasXspfplayer:
                if 'xspf_player.swf' in idevice.systemResources:
                    hasXspfplayer = True
            if not hasGallery:
                hasGallery = common.ideviceHasGallery(idevice)
            if not hasFX:
                hasFX = common.ideviceHasFX(idevice)
            if not hasSH:
                hasSH = common.ideviceHasSH(idevice)
            if not hasGames:
                hasGames = common.ideviceHasGames(idevice)
            if not hasWikipedia:
                if 'WikipediaIdevice' == idevice.klass:
                    hasWikipedia = True
            if not hasInstructions:
                if 'TrueFalseIdevice' == idevice.klass or 'MultichoiceIdevice' == idevice.klass or 'VerdaderofalsofpdIdevice' == idevice.klass or 'EleccionmultiplefpdIdevice' == idevice.klass:
                    hasInstructions = True
            if not hasMediaelement:
                hasMediaelement = common.ideviceHasMediaelement(idevice)
            if not hasTooltips:
                hasTooltips = common.ideviceHasTooltips(idevice)
            if not hasABCMusic:
                hasABCMusic = common.ideviceHasABCMusic(idevice)

        if hasFlowplayer:
            videofile = (self.templatesDir / 'flowPlayer.swf')
            videofile.copyfile(self.outputDir / 'flowPlayer.swf')
            controlsfile = (self.templatesDir / 'flowplayer.controls.swf')
            controlsfile.copyfile(self.outputDir / 'flowplayer.controls.swf')
        if hasMagnifier:
            videofile = (self.templatesDir / 'mojomagnify.js')
            videofile.copyfile(self.outputDir / 'mojomagnify.js')
        if hasXspfplayer:
            videofile = (self.templatesDir / 'xspf_player.swf')
            videofile.copyfile(self.outputDir / 'xspf_player.swf')
        if hasGallery:
            exeLightbox = (self.scriptsDir / 'exe_lightbox')
            exeLightbox.copyfiles(self.outputDir)
        if hasFX:
            exeEffects = (self.scriptsDir / 'exe_effects')
            exeEffects.copyfiles(self.outputDir)
        if hasSH:
            exeSH = (self.scriptsDir / 'exe_highlighter')
            exeSH.copyfiles(self.outputDir)
        if hasGames:
            exeGames = (self.scriptsDir / 'exe_games')
            exeGames.copyfiles(self.outputDir)
        if hasWikipedia:
            wikipediaCSS = (self.cssDir / 'exe_wikipedia.css')
            wikipediaCSS.copyfile(self.outputDir / 'exe_wikipedia.css')
        if hasInstructions:
            common.copyFileIfNotInStyle('panel-amusements.png', self,
                                        self.outputDir)
            common.copyFileIfNotInStyle('stock-stop.png', self, self.outputDir)
        if hasMediaelement:
            mediaelement = (self.scriptsDir / 'mediaelement')
            mediaelement.copyfiles(self.outputDir)
            dT = common.getExportDocType()
            if dT != "HTML5":
                jsFile = (self.scriptsDir / 'exe_html5.js')
                jsFile.copyfile(self.outputDir / 'exe_html5.js')
        if hasTooltips:
            exe_tooltips = (self.scriptsDir / 'exe_tooltips')
            exe_tooltips.copyfiles(self.outputDir)
        if hasABCMusic:
            pluginScripts = (self.scriptsDir /
                             'tinymce_4/js/tinymce/plugins/abcmusic/export')
            pluginScripts.copyfiles(self.outputDir)

        for child in node.children:
            self.compruebaReproductores(child)
コード例 #37
0
ファイル: websiteexport.py プロジェクト: g-vidal/iteexe
    def copyFiles(self, package, outputDir):
        """
        Copy all the files used by the website.
        """

        if os.path.isdir(self.stylesDir):
            # Copy the style sheet files to the output dir
            styleFiles = [self.stylesDir / '..' / 'base.css']
            styleFiles += [self.stylesDir / '..' / 'popup_bg.gif']
            styleFiles += self.stylesDir.files("*.css")
            styleFiles += self.stylesDir.files("*.jpg")
            styleFiles += self.stylesDir.files("*.gif")
            styleFiles += self.stylesDir.files("*.png")
            styleFiles += self.stylesDir.files("*.js")
            styleFiles += self.stylesDir.files("*.html")
            styleFiles += self.stylesDir.files("*.ico")
            styleFiles += self.stylesDir.files("*.ttf")
            styleFiles += self.stylesDir.files("*.eot")
            styleFiles += self.stylesDir.files("*.otf")
            styleFiles += self.stylesDir.files("*.woff")
            self.stylesDir.copylist(styleFiles, outputDir)

        # copy the package's resource files
        package.resourceDir.copyfiles(outputDir)

        # copy script files.
        my_style = G.application.config.styleStore.getStyle(package.style)
        # jQuery
        if my_style.hasValidConfig:
            if my_style.get_jquery() == True:
                jsFile = (self.scriptsDir / 'exe_jquery.js')
                jsFile.copyfile(outputDir / 'exe_jquery.js')
        else:
            jsFile = (self.scriptsDir / 'exe_jquery.js')
            jsFile.copyfile(outputDir / 'exe_jquery.js')

        jsFile = (self.scriptsDir / 'common.js')
        jsFile.copyfile(outputDir / 'common.js')
        #dT = common.getExportDocType()
        dT = common.getExportDocType()
        if dT == "HTML5":
            jsFile = (self.scriptsDir / 'exe_html5.js')
            jsFile.copyfile(outputDir / 'exe_html5.js')

        # Incluide eXe's icon if the Style doesn't have one
        themePath = Path(G.application.config.stylesDir / package.style)
        themeFavicon = themePath.joinpath("favicon.ico")
        if not themeFavicon.exists():
            faviconFile = (self.imagesDir / 'favicon.ico')
            faviconFile.copyfile(outputDir / 'favicon.ico')

        # copy players for media idevices.
        hasFlowplayer = False
        hasMagnifier = False
        hasXspfplayer = False
        hasGallery = False
        hasFX = False
        hasSH = False
        hasGames = False
        hasWikipedia = False
        isBreak = False
        hasInstructions = False
        hasMediaelement = False
        hasTooltips = False

        for page in self.pages:
            if isBreak:
                break
            for idevice in page.node.idevices:
                if (hasFlowplayer and hasMagnifier and hasXspfplayer
                        and hasGallery and hasFX and hasSH and hasGames
                        and hasWikipedia and hasInstructions
                        and hasMediaelement and hasTooltips):
                    isBreak = True
                    break
                if not hasFlowplayer:
                    if 'flowPlayer.swf' in idevice.systemResources:
                        hasFlowplayer = True
                if not hasMagnifier:
                    if 'mojomagnify.js' in idevice.systemResources:
                        hasMagnifier = True
                if not hasXspfplayer:
                    if 'xspf_player.swf' in idevice.systemResources:
                        hasXspfplayer = True
                if not hasGallery:
                    hasGallery = common.ideviceHasGallery(idevice)
                if not hasFX:
                    hasFX = common.ideviceHasFX(idevice)
                if not hasSH:
                    hasSH = common.ideviceHasSH(idevice)
                if not hasGames:
                    hasGames = common.ideviceHasGames(idevice)
                if not hasWikipedia:
                    if 'WikipediaIdevice' == idevice.klass:
                        hasWikipedia = True
                if not hasInstructions:
                    if 'TrueFalseIdevice' == idevice.klass or 'MultichoiceIdevice' == idevice.klass or 'VerdaderofalsofpdIdevice' == idevice.klass or 'EleccionmultiplefpdIdevice' == idevice.klass:
                        hasInstructions = True
                if not hasMediaelement:
                    hasMediaelement = common.ideviceHasMediaelement(idevice)
                if not hasTooltips:
                    hasTooltips = common.ideviceHasTooltips(idevice)

        if hasFlowplayer:
            videofile = (self.templatesDir / 'flowPlayer.swf')
            videofile.copyfile(outputDir / 'flowPlayer.swf')
            controlsfile = (self.templatesDir / 'flowplayer.controls.swf')
            controlsfile.copyfile(outputDir / 'flowplayer.controls.swf')
        if hasMagnifier:
            videofile = (self.templatesDir / 'mojomagnify.js')
            videofile.copyfile(outputDir / 'mojomagnify.js')
        if hasXspfplayer:
            videofile = (self.templatesDir / 'xspf_player.swf')
            videofile.copyfile(outputDir / 'xspf_player.swf')
        if hasGallery:
            exeLightbox = (self.scriptsDir / 'exe_lightbox')
            exeLightbox.copyfiles(outputDir)
        if hasFX:
            exeEffects = (self.scriptsDir / 'exe_effects')
            exeEffects.copyfiles(outputDir)
        if hasSH:
            exeSH = (self.scriptsDir / 'exe_highlighter')
            exeSH.copyfiles(outputDir)
        if hasGames:
            exeGames = (self.scriptsDir / 'exe_games')
            exeGames.copyfiles(outputDir)
        if hasWikipedia:
            wikipediaCSS = (self.cssDir / 'exe_wikipedia.css')
            wikipediaCSS.copyfile(outputDir / 'exe_wikipedia.css')
        if hasInstructions:
            common.copyFileIfNotInStyle('panel-amusements.png', self,
                                        outputDir)
            common.copyFileIfNotInStyle('stock-stop.png', self, outputDir)
        if hasMediaelement:
            mediaelement = (self.scriptsDir / 'mediaelement')
            mediaelement.copyfiles(outputDir)
            dT = common.getExportDocType()
            if dT != "HTML5":
                jsFile = (self.scriptsDir / 'exe_html5.js')
                jsFile.copyfile(outputDir / 'exe_html5.js')
        if hasTooltips:
            exe_tooltips = (self.scriptsDir / 'exe_tooltips')
            exe_tooltips.copyfiles(outputDir)

        if hasattr(package, 'exportSource') and package.exportSource:
            (G.application.config.webDir / 'templates' /
             'content.xsd').copyfile(outputDir / 'content.xsd')
            (outputDir / 'content.data').write_bytes(encodeObject(package))
            (outputDir / 'contentv3.xml').write_bytes(
                encodeObjectToXML(package))

        if package.license == "license GFDL":
            # include a copy of the GNU Free Documentation Licence
            (self.templatesDir / 'fdl.html').copyfile(outputDir / 'fdl.html')
コード例 #38
0
ファイル: singlepage.py プロジェクト: jsanchez91/iteexe
    def render(self, package, for_print=0):
        """
        Returns an XHTML string rendering this page.
        """

        # Get the DocType
        docType = common.getExportDocType()

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

        # Get package title
        if package.title != '':
            title = escape(package.title)
        else:
            title = escape(package.root.titleLong)

        # Render HTML header
        html = self.renderHeader(title, docType, for_print)

        if for_print:
            # Include extra onload bit:
            html += u'<body class="exe-single-page" onload="print_page()">'
        else:
            html += u'<body class="exe-single-page">'

        # Script to check if JS is enabled
        html += u'<script type="text/javascript">document.body.className+=" js"</script>' + lineBreak

        # Main content block
        html += u'<div id="content">' + lineBreak

        # Header
        html += u'<%s id="header">%s' % (headerTag, lineBreak)
        # Header content block
        html += u'<div id="headerContent">' + lineBreak
        # Package title
        html += u'<h1>%s</h1>%s' % (escape(title), lineBreak)
        # Close header content block
        html += u'</div>' + lineBreak
        # Close header
        html += u'</%s>%s' % (headerTag, lineBreak)

        # Main section
        html += u'<%s id="main">%s' % (sectionTag, lineBreak)

        # Render node contents
        html += self.renderNode(package.root, docType, 1)

        # Close main section
        html += u'</%s>%s' % (sectionTag, lineBreak)

        # Render the license
        html += self.renderLicense() + lineBreak

        # Render the footer
        html += self.renderFooter() + lineBreak

        # Close main content block
        html += u'</div>' + lineBreak

        # Some styles might have their own JavaScript files (see their config.xml file)
        style = G.application.config.styleStore.getStyle(
            self.node.package.style)
        if style.hasValidConfig:
            html += style.get_extra_body()

        # Close body and HTML tags
        html += u'</body>' + lineBreak
        html += u'</html>'

        # Remove ecuation attributes
        html = helper.removeEcuationAttr(html)
        # Change glosary path
        html = helper.changeGlossaryPath(html)
        # Escape &
        html = helper.escapeAmp(html)
        # Remove "resources/" from data="resources/ and the url param
        html = helper.removeResources(html)

        return html
コード例 #39
0
ファイル: imsexport.py プロジェクト: gcantallops-apsl/iteexe
    def export(self, package):
        """
        Export SCORM package
        """
        # First do the export to a temporary directory
        outputDir = TempDirPath()

        self.metadataType = package.exportMetadataType


        # Copy the style files to the output dir
        # But not nav.css
        styleFiles = [self.styleDir/'..'/'popup_bg.gif']
        styleFiles += self.styleDir.files("*.*")
        if "nav.css" in styleFiles:
            styleFiles.remove("nav.css")
        self.styleDir.copylist(styleFiles, outputDir)

        # copy the package's resource files
        for resourceFile in package.resourceDir.walkfiles():
            file = package.resourceDir.relpathto(resourceFile)

            if ("/" in file):
                Dir = Path(outputDir/file[:file.rindex("/")])
                if not Dir.exists():
                    Dir.makedirs()

                resourceFile.copy(outputDir/Dir)
            else:
                resourceFile.copy(outputDir)

        listCSSFiles=getFilesCSSToMinify('ims', self.styleDir)
        exportMinFileCSS(listCSSFiles, outputDir)

        # Export the package content
        self.pages = [ IMSPage("index", 1, package.root,
           metadataType=self.metadataType) ]

        self.generatePages(package.root, 2)
        uniquifyNames(self.pages)

        for page in self.pages:
            page.save(outputDir, self.pages)

        # Create the manifest file
        manifest = Manifest(self.config, outputDir, package, self.pages, self.metadataType)
        manifest.save("imsmanifest.xml")

        # Create lang file
        langGameFile = open(outputDir + '/common_i18n.js', "w")
        langGameFile.write(common.getJavaScriptStrings(False))
        langGameFile.close()

        # jQuery
        my_style = G.application.config.styleStore.getStyle(page.node.package.style)
        if my_style.hasValidConfig():
            if my_style.get_jquery() == True:
                jsFile = (self.scriptsDir/'exe_jquery.js')
                jsFile.copyfile(outputDir/'exe_jquery.js')

        else:
            jsFile = (self.scriptsDir/'exe_jquery.js')
            jsFile.copyfile(outputDir/'exe_jquery.js')

        dT = common.getExportDocType()
        if dT == "HTML5":
            jsFile = (self.scriptsDir/'exe_html5.js')
            jsFile.copyfile(outputDir/'exe_html5.js')

        listFiles=getFilesJSToMinify('ims', self.scriptsDir)
        exportMinFileJS(listFiles, outputDir)

        self.schemasDir.copylist(('imscp_v1p1.xsd',
                                  'imsmd_v1p2p2.xsd',
                                  'lom.xsd',
                                  'lomCustom.xsd',
                                  'ims_xml.xsd'), outputDir)

        # copy players for media idevices.
        hasFlowplayer     = False
        hasMagnifier      = False
        hasXspfplayer     = False
        hasGallery        = False
        hasFX             = False
        hasSH             = False
        hasGames          = False
        hasElpLink        = False
        hasWikipedia      = False
        isBreak           = False
        hasInstructions   = False
        hasMediaelement   = False
        hasTooltips       = False
        hasABCMusic       = False
        listIdevicesFiles = []

        for page in self.pages:
            if isBreak:
                break
            for idevice in page.node.idevices:
                if (hasFlowplayer and hasMagnifier and hasXspfplayer and hasGallery and hasFX and hasSH and hasGames and hasElpLink and hasWikipedia and hasInstructions and hasMediaelement and hasTooltips and hasABCMusic):
                    isBreak = True
                    break
                if not hasFlowplayer:
                    if 'flowPlayer.swf' in idevice.systemResources:
                        hasFlowplayer = True
                if not hasMagnifier:
                    if 'mojomagnify.js' in idevice.systemResources:
                        hasMagnifier = True
                if not hasXspfplayer:
                    if 'xspf_player.swf' in idevice.systemResources:
                        hasXspfplayer = True
                if not hasGallery:
                    hasGallery = common.ideviceHasGallery(idevice)
                if not hasFX:
                    hasFX = common.ideviceHasFX(idevice)
                if not hasSH:
                    hasSH = common.ideviceHasSH(idevice)
                if not hasGames:
                    hasGames = common.ideviceHasGames(idevice)
                if not hasElpLink:
                    hasElpLink = common.ideviceHasElpLink(idevice,package)
                if not hasWikipedia:
                    if 'WikipediaIdevice' == idevice.klass:
                        hasWikipedia = True
                if not hasInstructions:
                    if 'TrueFalseIdevice' == idevice.klass or 'MultichoiceIdevice' == idevice.klass or 'VerdaderofalsofpdIdevice' == idevice.klass or 'EleccionmultiplefpdIdevice' == idevice.klass:
                        hasInstructions = True
                if not hasMediaelement:
                    hasMediaelement = common.ideviceHasMediaelement(idevice)
                if not hasTooltips:
                    hasTooltips = common.ideviceHasTooltips(idevice)
                if not hasABCMusic:
                    hasABCMusic = common.ideviceHasABCMusic(idevice)
                if hasattr(idevice, "_iDeviceDir"):
                    listIdevicesFiles.append((idevice.get_jsidevice_dir()/'export'))

            common.exportJavaScriptIdevicesFiles(page.node.idevices, outputDir);

        if hasFlowplayer:
            videofile = (self.templatesDir/'flowPlayer.swf')
            videofile.copyfile(outputDir/'flowPlayer.swf')
            controlsfile = (self.templatesDir/'flowplayer.controls.swf')
            controlsfile.copyfile(outputDir/'flowplayer.controls.swf')
        if hasMagnifier:
            videofile = (self.templatesDir/'mojomagnify.js')
            videofile.copyfile(outputDir/'mojomagnify.js')
        if hasXspfplayer:
            videofile = (self.templatesDir/'xspf_player.swf')
            videofile.copyfile(outputDir/'xspf_player.swf')
        if hasGallery:
            exeLightbox = (self.scriptsDir/'exe_lightbox')
            exeLightbox.copyfiles(outputDir)
        if hasFX:
            exeEffects = (self.scriptsDir/'exe_effects')
            exeEffects.copyfiles(outputDir)
        if hasSH:
            exeSH = (self.scriptsDir/'exe_highlighter')
            exeSH.copyfiles(outputDir)
        if hasGames:
            exeGames = (self.scriptsDir/'exe_games')
            exeGames.copyfiles(outputDir)
            # Add game js string to common_i18n
            langGameFile = open(outputDir + '/common_i18n.js', "a")
            langGameFile.write(common.getGamesJavaScriptStrings(False))
            langGameFile.close()
        if hasElpLink or package.get_exportElp():
            # Export the elp file
            currentPackagePath = Path(package.filename)
            currentPackagePath.copyfile(outputDir/package.name+'.elp')
        if hasWikipedia:
            wikipediaCSS = (self.cssDir/'exe_wikipedia.css')
            wikipediaCSS.copyfile(outputDir/'exe_wikipedia.css')
        if hasInstructions:
            common.copyFileIfNotInStyle('panel-amusements.png', self, outputDir)
            common.copyFileIfNotInStyle('stock-stop.png', self, outputDir)
        if hasMediaelement:
            mediaelement = (self.scriptsDir/'mediaelement')
            mediaelement.copyfiles(outputDir)
            if dT != "HTML5":
                jsFile = (self.scriptsDir/'exe_html5.js')
                jsFile.copyfile(outputDir/'exe_html5.js')
        if hasTooltips:
            exe_tooltips = (self.scriptsDir/'exe_tooltips')
            exe_tooltips.copyfiles(outputDir)
        if hasABCMusic:
            pluginScripts = (self.scriptsDir/'tinymce_4/js/tinymce/plugins/abcmusic/export')
            pluginScripts.copyfiles(outputDir)
        if hasattr(package, 'exportSource') and package.exportSource:
            (G.application.config.webDir/'templates'/'content.xsd').copyfile(outputDir/'content.xsd')
            (outputDir/'content.data').write_bytes(encodeObject(package))
            (outputDir/'contentv3.xml').write_bytes(encodeObjectToXML(package))


        if package.license == "license GFDL":
            # include a copy of the GNU Free Documentation Licence
            (self.templatesDir/'fdl.html').copyfile(outputDir/'fdl.html')

        # Zip it up!
        self.filename.safeSave(self.doZip, _('EXPORT FAILED!\nLast succesful export is %s.'), outputDir)
        # Clean up the temporary dir
        outputDir.rmtree()
コード例 #40
0
    def export(self, package):
        """ 
        Export SCORM package
        """
        # First do the export to a temporary directory
        outputDir = TempDirPath()

        self.metadataType = package.exportMetadataType


        # Copy the style sheet files to the output dir
        # But not nav.css
        styleFiles = [self.styleDir/'..'/'popup_bg.gif']
        styleFiles += self.styleDir.files("*.css")
        if "nav.css" in styleFiles:
            styleFiles.remove("nav.css")
        styleFiles += self.styleDir.files("*.jpg")
        styleFiles += self.styleDir.files("*.gif")
        styleFiles += self.styleDir.files("*.png")
        styleFiles += self.styleDir.files("*.js")
        styleFiles += self.styleDir.files("*.html")
        styleFiles += self.styleDir.files("*.ttf")
        styleFiles += self.styleDir.files("*.eot")
        styleFiles += self.styleDir.files("*.otf")
        styleFiles += self.styleDir.files("*.woff")
        self.styleDir.copylist(styleFiles, outputDir)

        # copy the package's resource files
        package.resourceDir.copyfiles(outputDir)
        
        listCSSFiles=getFilesCSSToMinify('ims', self.styleDir)
        exportMinFileCSS(listCSSFiles, outputDir)
            
        # Export the package content
        self.pages = [ IMSPage("index", 1, package.root,
           metadataType=self.metadataType) ]

        self.generatePages(package.root, 2)
        uniquifyNames(self.pages)

        for page in self.pages:
            page.save(outputDir)

        # Create the manifest file
        manifest = Manifest(self.config, outputDir, package, self.pages, self.metadataType)
        manifest.save("imsmanifest.xml")
        
        # Copy the scripts
        
        # jQuery
        my_style = G.application.config.styleStore.getStyle(page.node.package.style)
        if my_style.hasValidConfig:
            if my_style.get_jquery() == True:
                jsFile = (self.scriptsDir/'exe_jquery.js')
                jsFile.copyfile(outputDir/'exe_jquery.js')
                
        else:
            jsFile = (self.scriptsDir/'exe_jquery.js')
            jsFile.copyfile(outputDir/'exe_jquery.js')   
                
        dT = common.getExportDocType()
        if dT == "HTML5":
            jsFile = (self.scriptsDir/'exe_html5.js')
            jsFile.copyfile(outputDir/'exe_html5.js')

        listFiles=getFilesJSToMinify('ims', self.scriptsDir)        
        exportMinFileJS(listFiles, outputDir)
        
        self.schemasDir.copylist(('imscp_v1p1.xsd',
                                  'imsmd_v1p2p2.xsd',
                                  'lom.xsd',
                                  'lomCustom.xsd',
                                  'ims_xml.xsd'), outputDir)

        # copy players for media idevices.                
        hasFlowplayer     = False
        hasMagnifier      = False
        hasXspfplayer     = False
        hasGallery        = False
        hasFX             = False
        hasSH             = False
        hasGames          = False
        hasWikipedia      = False
        isBreak           = False
        hasInstructions   = False
        hasMediaelement   = False
        hasTooltips       = False
        
        for page in self.pages:
            if isBreak:
                break
            for idevice in page.node.idevices:
                if (hasFlowplayer and hasMagnifier and hasXspfplayer and hasGallery and hasFX and hasSH and hasGames and hasWikipedia and hasInstructions and hasMediaelement and hasTooltips):
                    isBreak = True
                    break
                if not hasFlowplayer:
                    if 'flowPlayer.swf' in idevice.systemResources:
                        hasFlowplayer = True
                if not hasMagnifier:
                    if 'mojomagnify.js' in idevice.systemResources:
                        hasMagnifier = True
                if not hasXspfplayer:
                    if 'xspf_player.swf' in idevice.systemResources:
                        hasXspfplayer = True
                if not hasGallery:
                    hasGallery = common.ideviceHasGallery(idevice)
                if not hasFX:
                    hasFX = common.ideviceHasFX(idevice)
                if not hasSH:
                    hasSH = common.ideviceHasSH(idevice)
                if not hasGames:
                    hasGames = common.ideviceHasGames(idevice)
                if not hasWikipedia:
                    if 'WikipediaIdevice' == idevice.klass:
                        hasWikipedia = True
                if not hasInstructions:
                    if 'TrueFalseIdevice' == idevice.klass or 'MultichoiceIdevice' == idevice.klass or 'VerdaderofalsofpdIdevice' == idevice.klass or 'EleccionmultiplefpdIdevice' == idevice.klass:
                        hasInstructions = True
                if not hasMediaelement:
                    hasMediaelement = common.ideviceHasMediaelement(idevice)
                if not hasTooltips:
                    hasTooltips = common.ideviceHasTooltips(idevice)

        if hasFlowplayer:
            videofile = (self.templatesDir/'flowPlayer.swf')
            videofile.copyfile(outputDir/'flowPlayer.swf')
            controlsfile = (self.templatesDir/'flowplayer.controls.swf')
            controlsfile.copyfile(outputDir/'flowplayer.controls.swf')
        if hasMagnifier:
            videofile = (self.templatesDir/'mojomagnify.js')
            videofile.copyfile(outputDir/'mojomagnify.js')
        if hasXspfplayer:
            videofile = (self.templatesDir/'xspf_player.swf')
            videofile.copyfile(outputDir/'xspf_player.swf')
        if hasGallery:
            exeLightbox = (self.scriptsDir/'exe_lightbox')
            exeLightbox.copyfiles(outputDir)
        if hasFX:
            exeEffects = (self.scriptsDir/'exe_effects')
            exeEffects.copyfiles(outputDir)
        if hasSH:
            exeSH = (self.scriptsDir/'exe_highlighter')
            exeSH.copyfiles(outputDir)
        if hasGames:
            exeGames = (self.scriptsDir/'exe_games')
            exeGames.copyfiles(outputDir)
        if hasWikipedia:
            wikipediaCSS = (self.cssDir/'exe_wikipedia.css')
            wikipediaCSS.copyfile(outputDir/'exe_wikipedia.css')
        if hasInstructions:
            common.copyFileIfNotInStyle('panel-amusements.png', self, outputDir)
            common.copyFileIfNotInStyle('stock-stop.png', self, outputDir)
        if hasMediaelement:
            mediaelement = (self.scriptsDir/'mediaelement')
            mediaelement.copyfiles(outputDir)
            if dT != "HTML5":
                jsFile = (self.scriptsDir/'exe_html5.js')
                jsFile.copyfile(outputDir/'exe_html5.js')
        if hasTooltips:
            exe_tooltips = (self.scriptsDir/'exe_tooltips')
            exe_tooltips.copyfiles(outputDir)
        if hasattr(package, 'exportSource') and package.exportSource:
            (G.application.config.webDir/'templates'/'content.xsd').copyfile(outputDir/'content.xsd')
            (outputDir/'content.data').write_bytes(encodeObject(package))
            (outputDir/'contentv3.xml').write_bytes(encodeObjectToXML(package))


        if package.license == "license GFDL":
            # include a copy of the GNU Free Documentation Licence
            (self.templatesDir/'fdl.html').copyfile(outputDir/'fdl.html')
        # Zip it up!
        self.filename.safeSave(self.doZip, _('EXPORT FAILED!\nLast succesful export is %s.'), outputDir)
        # Clean up the temporary dir
        outputDir.rmtree()
コード例 #41
0
ファイル: scormexport.py プロジェクト: RichDijk/eXe
    def export(self, package):
        """ 
        Export SCORM package
        """
        # First do the export to a temporary directory
        outputDir = TempDirPath()

        self.metadataType = package.exportMetadataType

        # copy the package's resource files
        package.resourceDir.copyfiles(outputDir)

        # copy the package's resource files, only non existant in outputDir
        #        outputDirFiles = outputDir.files()
        #        for rfile in package.resourceDir.files():
        #            if rfile not in outputDirFiles:
        #                rfile.copy(outputDir)

        # copy the package's resource files, only indexed in package.resources
        #        for md5 in package.resources.values():
        #            for resource in md5:
        #                resource.path.copy(outputDir)

        # Export the package content
        # Import the Scorm Page class , if the secure mode is off.  If the style has it's own page class
        # use that, else use the default one.
        if self.styleSecureMode == "0":
            if (self.styleDir / "scormpage.py").exists():
                global ScormPage
                module = imp.load_source("ScormPage", self.styleDir / "scormpage.py")
                ScormPage = module.ScormPage

        self.pages = [ScormPage("index", 1, package.root, scormType=self.scormType, metadataType=self.metadataType)]

        self.generatePages(package.root, 2)
        uniquifyNames(self.pages)

        for page in self.pages:
            page.save(outputDir)
            if not self.hasForum:
                for idevice in page.node.idevices:
                    if hasattr(idevice, "isForum"):
                        if idevice.forum.lms.lms == "moodle":
                            self.hasForum = True
                            break

        # Create the manifest file
        manifest = Manifest(self.config, outputDir, package, self.pages, self.scormType, self.metadataType)
        manifest.save("imsmanifest.xml")
        if self.hasForum:
            manifest.save("discussionforum.xml")

        # Copy the style sheet files to the output dir
        styleFiles = [self.styleDir / ".." / "base.css"]
        styleFiles += [self.styleDir / ".." / "popup_bg.gif"]
        # And with all the files of the style we avoid problems:
        styleFiles += self.styleDir.files("*.*")
        if self.scormType == "commoncartridge":
            for sf in styleFiles[:]:
                if sf.basename() not in manifest.dependencies:
                    styleFiles.remove(sf)
        self.styleDir.copylist(styleFiles, outputDir)

        # Copy the scripts
        dT = common.getExportDocType()
        if dT == "HTML5":
            jsFile = self.scriptsDir / "exe_html5.js"
            jsFile.copyfile(outputDir / "exe_html5.js")

        # jQuery
        my_style = G.application.config.styleStore.getStyle(page.node.package.style)
        if my_style.hasValidConfig:
            if my_style.get_jquery() == True:
                jsFile = self.scriptsDir / "exe_jquery.js"
                jsFile.copyfile(outputDir / "exe_jquery.js")
        else:
            jsFile = self.scriptsDir / "exe_jquery.js"
            jsFile.copyfile(outputDir / "exe_jquery.js")

        if self.scormType == "commoncartridge":
            jsFile = self.scriptsDir / "common.js"
            jsFile.copyfile(outputDir / "common.js")

        if self.scormType == "scorm2004" or self.scormType == "scorm1.2":
            self.scriptsDir.copylist(("SCORM_API_wrapper.js", "SCOFunctions.js", "common.js"), outputDir)
        # about SCHEMAS:
        schemasDir = ""
        if self.scormType == "scorm1.2":
            schemasDir = self.schemasDir / "scorm1.2"
            schemasDir.copylist(
                (
                    "imscp_rootv1p1p2.xsd",
                    "imsmd_rootv1p2p1.xsd",
                    "adlcp_rootv1p2.xsd",
                    "lom.xsd",
                    "lomCustom.xsd",
                    "ims_xml.xsd",
                ),
                outputDir,
            )
        elif self.scormType == "scorm2004":
            schemasDir = self.schemasDir / "scorm2004"
            schemasDir.copylist(
                (
                    "adlcp_v1p3.xsd",
                    "adlnav_v1p3.xsd",
                    "adlseq_v1p3.xsd",
                    "datatypes.dtd",
                    "imscp_v1p1.xsd",
                    "imsssp_v1p0.xsd",
                    "imsss_v1p0.xsd",
                    "imsss_v1p0auxresource.xsd",
                    "imsss_v1p0control.xsd",
                    "imsss_v1p0delivery.xsd",
                    "imsmd_rootv1p2p1.xsd",
                    "imsss_v1p0limit.xsd",
                    "imsss_v1p0objective.xsd",
                    "imsss_v1p0random.xsd",
                    "imsss_v1p0rollup.xsd",
                    "imsss_v1p0seqrule.xsd",
                    "imsss_v1p0util.xsd",
                    "ims_xml.xsd",
                    "lom.xsd",
                    "lomCustom.xsd",
                    "xml.xsd",
                    "XMLSchema.dtd",
                ),
                outputDir,
            )
            try:
                import shutil, errno

                shutil.copytree(schemasDir / "common", outputDir / "common")
                shutil.copytree(schemasDir / "extend", outputDir / "extend")
                shutil.copytree(schemasDir / "unique", outputDir / "unique")
                shutil.copytree(schemasDir / "vocab", outputDir / "vocab")
            except OSError as exc:
                if exc.errno == errno.ENOTDIR:
                    shutil.copy(schemasDir, outputDir)
                else:
                    raise

        # copy players for media idevices.
        hasFlowplayer = False
        hasMagnifier = False
        hasXspfplayer = False
        hasGallery = False
        hasWikipedia = False
        isBreak = False
        hasInstructions = False
        hasMediaelement = False

        for page in self.pages:
            if isBreak:
                break
            for idevice in page.node.idevices:
                if (
                    hasFlowplayer
                    and hasMagnifier
                    and hasXspfplayer
                    and hasGallery
                    and hasWikipedia
                    and hasInstructions
                    and hasMediaelement
                ):
                    isBreak = True
                    break
                if not hasFlowplayer:
                    if "flowPlayer.swf" in idevice.systemResources:
                        hasFlowplayer = True
                if not hasMagnifier:
                    if "mojomagnify.js" in idevice.systemResources:
                        hasMagnifier = True
                if not hasXspfplayer:
                    if "xspf_player.swf" in idevice.systemResources:
                        hasXspfplayer = True
                if not hasGallery:
                    hasGallery = common.ideviceHasGallery(idevice)
                if not hasWikipedia:
                    if "WikipediaIdevice" == idevice.klass:
                        hasWikipedia = True
                if not hasInstructions:
                    if (
                        "TrueFalseIdevice" == idevice.klass
                        or "MultichoiceIdevice" == idevice.klass
                        or "VerdaderofalsofpdIdevice" == idevice.klass
                        or "EleccionmultiplefpdIdevice" == idevice.klass
                    ):
                        hasInstructions = True
                if not hasMediaelement:
                    hasMediaelement = common.ideviceHasMediaelement(idevice)

        if hasFlowplayer:
            videofile = self.templatesDir / "flowPlayer.swf"
            videofile.copyfile(outputDir / "flowPlayer.swf")
            controlsfile = self.templatesDir / "flowplayer.controls.swf"
            controlsfile.copyfile(outputDir / "flowplayer.controls.swf")
        if hasMagnifier:
            videofile = self.templatesDir / "mojomagnify.js"
            videofile.copyfile(outputDir / "mojomagnify.js")
        if hasXspfplayer:
            videofile = self.templatesDir / "xspf_player.swf"
            videofile.copyfile(outputDir / "xspf_player.swf")
        if hasGallery:
            imageGalleryCSS = self.cssDir / "exe_lightbox.css"
            imageGalleryCSS.copyfile(outputDir / "exe_lightbox.css")
            imageGalleryJS = self.scriptsDir / "exe_lightbox.js"
            imageGalleryJS.copyfile(outputDir / "exe_lightbox.js")
            self.imagesDir.copylist(
                (
                    "exe_lightbox_close.png",
                    "exe_lightbox_loading.gif",
                    "exe_lightbox_next.png",
                    "exe_lightbox_prev.png",
                ),
                outputDir,
            )
        if hasWikipedia:
            wikipediaCSS = self.cssDir / "exe_wikipedia.css"
            wikipediaCSS.copyfile(outputDir / "exe_wikipedia.css")
        if hasInstructions:
            common.copyFileIfNotInStyle("panel-amusements.png", self, outputDir)
            common.copyFileIfNotInStyle("stock-stop.png", self, outputDir)
        if hasMediaelement:
            mediaelement = self.scriptsDir / "mediaelement"
            mediaelement.copyfiles(outputDir)
            if dT != "HTML5":
                jsFile = self.scriptsDir / "exe_html5.js"

        if self.scormType == "scorm1.2" or self.scormType == "scorm2004":
            if package.license == "license GFDL":
                # include a copy of the GNU Free Documentation Licence
                (self.templatesDir / "fdl.html").copyfile(outputDir / "fdl.html")

        if hasattr(package, "scowsinglepage") and package.scowsinglepage:
            page = SinglePage("singlepage_index", 1, package.root)
            page.save(outputDir / "singlepage_index.html")
            # Incluide eXe's icon if the Style doesn't have one
            themePath = Path(G.application.config.stylesDir / package.style)
            themeFavicon = themePath.joinpath("favicon.ico")
            if not themeFavicon.exists():
                faviconFile = self.imagesDir / "favicon.ico"
                faviconFile.copyfile(outputDir / "favicon.ico")
        if hasattr(package, "scowwebsite") and package.scowwebsite:
            website = WebsiteExport(self.config, self.styleDir, outputDir, "website_")
            website.export(package)
            (self.styleDir / "nav.css").copyfile(outputDir / "nav.css")
            # Incluide eXe's icon if the Style doesn't have one
            themePath = Path(G.application.config.stylesDir / package.style)
            themeFavicon = themePath.joinpath("favicon.ico")
            if not themeFavicon.exists():
                faviconFile = self.imagesDir / "favicon.ico"
                faviconFile.copyfile(outputDir / "favicon.ico")
        if hasattr(package, "exportSource") and package.exportSource:
            (G.application.config.webDir / "templates" / "content.xsd").copyfile(outputDir / "content.xsd")
            (outputDir / "content.data").write_bytes(encodeObject(package))
            (outputDir / "contentv3.xml").write_bytes(encodeObjectToXML(package))

        # Zip it up!
        self.filename.safeSave(self.doZip, _("EXPORT FAILED!\nLast succesful export is %s."), outputDir)
        # Clean up the temporary dir
        outputDir.rmtree()
コード例 #42
0
ファイル: listablock.py プロジェクト: sthagen/iteexe
    def renderView(self, feedbackId=None, preview=False):
        
        # Shows the text with inputs for the missing parts
       
        dT = common.getExportDocType()
        sectionTag = "div"
        if dT == "HTML5":
            sectionTag = "section"

        html = ['<%s class="activity" id="activity-%s">' % (sectionTag,self.id)]
        
        if preview: 
            # to render, use the content with the preview-able resource paths:
            self.field.encodedContent = self.field.content_w_resourcePaths
            html += ['<div class="activity-form">']
        else:
            # to render, use the flattened content, withOUT resource paths: 
            self.field.encodedContent = self.field.content_wo_resourcePaths
            html += ['<form name="cloze-form-'+self.id+'" action="#" class="activity-form cloze-form">']

        html += ['<div id="cloze%s">' % self.id]
        # Store our args in some hidden fields
        def storeValue(name):
            value = str(bool(getattr(self.field, name))).lower()
            return common.hiddenField('clozeFlag%s.%s' % (self.id, name), value)
        #html.append(storeValue('showScore'))
      
        if feedbackId:
            html.append(common.hiddenField('clozeVar%s.feedbackId' % self.id,'ta'+feedbackId))
        # Mix the parts together
        words = ""
        wordslista='<option selected="selected"> </option>'
        wordsarray=[]
        listaotras=[]
        listaotras2=[]
        wordsarraylimpo=[] 
        
        for i, (text, missingWord) in enumerate(self.field.parts):
            if missingWord:
                wordsarray.append([missingWord])
        listaotras=self.field.otras.split('|')
        for i, (missingWord) in enumerate(listaotras):
            if missingWord:
                listaotras2.append([missingWord])
        wordsarray=wordsarray + listaotras2 
        wordsarraylimpo= [wordsarray[i] for i in range(len(wordsarray)) if wordsarray[i] not in wordsarray[:i]]
        random.shuffle(wordsarraylimpo)
        for wdlista in wordsarraylimpo:
           wordslista +='<option value="%s">%s</option>' % (escape(wdlista[0], True), wdlista[0])
          
        for i, (text, missingWord) in enumerate(self.field.parts):
            if text:
                html.append(text)
            if missingWord:
                words += "'" + missingWord + "',"
                # The edit box for the user to type into
                inputHtml = ['<label for="clozeBlank%s.%s" class="sr-av">%s (%s):</label>' % (self.id, i, c_("Cloze"), (i+1))]
                inputHtml += ['<select id="clozeBlank%s.%s">' % (self.id, i),wordslista,'</select>']
                html += inputHtml
                            
                # Hidden span with correct answer
                html += ['<span style="display:none" id="clozeAnswer%s.%s">%s</span>' % (self.id, i, self.ecrypt(missingWord))]

        # Score string
        html += ['<div class="block iDevice_buttons">']
        html += ['<p>']
        
        if preview:
            html += [common.button('getScore%s' % self.id, c_(u"Check"), id='getScore%s' % self.id, class_ = "cloze-score-toggler")]
        else:
            html += [common.submitButton('getScore%s' % self.id, c_(u"Check"), id='getScore%s' % self.id)]
        if feedbackId:
            html += [common.button('feedback%s' % self.id, c_(u"Show Feedback"), class_ = "feedbackbutton cloze-feedback-toggler")]
         
        codotras=self.ecrypt(self.field.otras)
        html += [common.hiddenField('clozeOtras%s' % self.id,codotras)]   
        html += ['<input type="hidden" name="clozeFlag%s.strictMarking" id="clozeFlag%s.strictMarking" value="false" />' % (self.id,self.id)]
        html += ['<input type="hidden" name="clozeFlag%s.checkCaps" id="clozeFlag%s.checkCaps" value="false" />' % (self.id,self.id)]
        html += ['<input type="hidden" name="clozeFlag%s.instantMarking" id="clozeFlag%s.instantMarking" value="false" />' % (self.id,self.id)]
        html += [common.javaScriptIsRequired()]
        html += ['</p>']
        html += ['</div>']
        html += ['<div class="score js-feedback" id="clozeScore%s"></div>' % self.id]        
        html += ['</div>']
        if preview: 
            html += ['</div>']
        else:
            html += ['</form>']
        html += ['</%s>' % sectionTag]
        return '\n'.join(html)
コード例 #43
0
    def compruebaReproductores(self, node):
        """
        Comprobamos si hay que meter algun reproductor
        """
        
    	# copy players for media idevices.                
        hasFlowplayer     = False
        hasMagnifier      = False
        hasXspfplayer     = False
        hasGallery        = False
        hasWikipedia      = False
        hasInstructions   = False
        hasMediaelement   = False

    	for idevice in node.idevices:
    	    if (hasFlowplayer and hasMagnifier and hasXspfplayer and hasGallery and hasWikipedia and hasInstructions and hasMediaelement):
    	    	break
    	    if not hasFlowplayer:
    	    	if 'flowPlayer.swf' in idevice.systemResources:
    	    		hasFlowplayer = True
    	    if not hasMagnifier:
    	    	if 'mojomagnify.js' in idevice.systemResources:
    	    		hasMagnifier = True
    	    if not hasXspfplayer:
    		    if 'xspf_player.swf' in idevice.systemResources:
    			    hasXspfplayer = True
            if not hasGallery:
                hasGallery = common.ideviceHasGallery(idevice)
            if not hasWikipedia:
    			if 'WikipediaIdevice' == idevice.klass:
    				hasWikipedia = True
            if not hasInstructions:
    			if 'TrueFalseIdevice' == idevice.klass or 'MultichoiceIdevice' == idevice.klass or 'VerdaderofalsofpdIdevice' == idevice.klass or 'EleccionmultiplefpdIdevice' == idevice.klass:
    				hasInstructions = True
            if not hasMediaelement:
                    hasMediaelement = common.ideviceHasMediaelement(idevice)
                            
        if hasFlowplayer:
            videofile = (self.templatesDir/'flowPlayer.swf')
            videofile.copyfile(self.outputDir/'flowPlayer.swf')
            controlsfile = (self.templatesDir/'flowplayer.controls.swf')
            controlsfile.copyfile(self.outputDir/'flowplayer.controls.swf')
        if hasMagnifier:
            videofile = (self.templatesDir/'mojomagnify.js')
            videofile.copyfile(self.outputDir/'mojomagnify.js')
        if hasXspfplayer:
            videofile = (self.templatesDir/'xspf_player.swf')
            videofile.copyfile(self.outputDir/'xspf_player.swf')
        if hasGallery:
            imageGalleryCSS = (self.cssDir/'exe_lightbox.css')
            imageGalleryCSS.copyfile(self.outputDir/'exe_lightbox.css') 
            imageGalleryJS = (self.scriptsDir/'exe_lightbox.js')
            imageGalleryJS.copyfile(self.outputDir/'exe_lightbox.js') 
            self.imagesDir.copylist(('exe_lightbox_close.png', 'exe_lightbox_loading.gif', 'exe_lightbox_next.png', 'exe_lightbox_prev.png'), self.outputDir)
        if hasWikipedia:
            wikipediaCSS = (self.cssDir/'exe_wikipedia.css')
            wikipediaCSS.copyfile(self.outputDir/'exe_wikipedia.css')
        if hasInstructions:
            common.copyFileIfNotInStyle('panel-amusements.png', self, self.outputDir)
            common.copyFileIfNotInStyle('stock-stop.png', self, self.outputDir)
        if hasMediaelement:
            mediaelement = (self.scriptsDir/'mediaelement')
            mediaelement.copyfiles(self.outputDir)
            dT = common.getExportDocType()
            if dT != "HTML5":
                jsFile = (self.scriptsDir/'exe_html5.js')
                jsFile.copyfile(self.outputDir/'exe_html5.js')

        for child in node.children:
            self.compruebaReproductores(child)
コード例 #44
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
コード例 #45
0
ファイル: scormexport.py プロジェクト: RichDijk/eXe
    def genItemResStr(self, page):
        """
        Returning xml string for items and resources
        """
        itemId = "ITEM-" + unicode(self.idGenerator.generate())
        resId = "RES-" + unicode(self.idGenerator.generate())
        filename = page.name + ".html"

        self.itemStr += '<item identifier="' + itemId + '" '
        if self.scormType != "commoncartridge":
            self.itemStr += 'isvisible="true" '
        self.itemStr += 'identifierref="' + resId + '">\n'
        self.itemStr += "    <title>"
        if self.scormType == "scorm2004" and page.node.children:
            self.itemStr += escape("<-")
        else:
            self.itemStr += escape(page.node.titleShort)
        self.itemStr += "</title>\n"

        ## RESOURCES

        self.resStr += '  <resource identifier="' + resId + '" '
        self.resStr += 'type="webcontent" '

        # FIXME force dependency on popup_bg.gif on every page
        # because it isn't a "resource" so we can't tell which
        # pages will use it from content.css
        if self.scormType == "commoncartridge":
            fileStr = ""
            self.resStr += """href="%s">
    <file href="%s"/>
    <file href="base.css"/>
    <file href="content.css"/>
    <file href="popup_bg.gif"/>
    <file href="exe_jquery.js"/>
    <file href="common.js"/>""" % (
                filename,
                filename,
            )
            # CC export require content.* any place inside the manifest:
            if page.node.package.exportSource and page.depth == 1:
                self.resStr += '    <file href="content.xsd"/>\n'
                self.resStr += '    <file href="content.data"/>\n'
                self.resStr += '    <file href="contentv3.xml"/>\n'
            if page.node.package.backgroundImg:
                self.resStr += '\n    <file href="%s"/>' % page.node.package.backgroundImg.basename()
            self.dependencies["base.css"] = True
            self.dependencies["content.css"] = True
            self.dependencies["popup_bg.gif"] = True
        else:
            if self.scormType == "scorm2004":
                self.resStr += 'adlcp:scormType="sco" '
                self.resStr += 'href="' + filename + '"> \n'
                self.resStr += '    <file href="' + filename + '"/> \n'
                fileStr = ""
            if self.scormType == "scorm1.2":
                self.resStr += 'adlcp:scormtype="sco" '
                self.resStr += 'href="' + filename + '"> \n'
                self.resStr += '    <file href="' + filename + '"/> \n'
                fileStr = ""

        dT = common.getExportDocType()
        if dT == "HTML5" or common.nodeHasMediaelement(page.node):
            self.resStr += '    <file href="exe_html5.js"/>\n'

        resources = page.node.getResources()

        if common.nodeHasMediaelement(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir / "scripts" / "mediaelement").files()]
            if dT != "HTML5":
                self.scriptsDir = self.config.webDir / "scripts"
                jsFile = self.scriptsDir / "exe_html5.js"
                jsFile.copyfile(self.outputDir / "exe_html5.js")

        if common.hasGalleryIdevice(page.node):
            self.resStr += "\n"
            self.resStr += '    <file href="exe_lightbox.js"/>\n'
            self.resStr += '    <file href="exe_lightbox.css"/>\n'
            self.resStr += '    <file href="exe_lightbox_close.png"/>\n'
            self.resStr += '    <file href="exe_lightbox_loading.gif"/>\n'
            self.resStr += '    <file href="exe_lightbox_next.png"/>\n'
            self.resStr += '    <file href="exe_lightbox_prev.png"/>\n'

        for resource in resources:
            fileStr += '    <file href="' + escape(resource) + '"/>\n'
            self.dependencies[resource] = True

        self.resStr += fileStr

        # adding the dependency with the common files collected:
        if self.scormType != "commoncartridge":
            self.resStr += """    <dependency identifierref="COMMON_FILES"/>"""

        # and no more:
        self.resStr += "\n"
        self.resStr += "  </resource>\n"
コード例 #46
0
ファイル: singlepage.py プロジェクト: Rafav/iteexe
    def render(self, package, for_print=0):
        """
        Returns an XHTML string rendering this page.
        """
        dT = common.getExportDocType()
        lb = "\n"  #Line breaks
        sectionTag = "div"
        headerTag = "div"
        if dT == "HTML5":
            sectionTag = "section"
            headerTag = "header"

        if package.title != '':
            title = escape(package.title)
        else:
            title = escape(package.root.titleLong)
        html = self.renderHeader(title, for_print)
        if for_print:
            # include extra onload bit:
            html += u'<body class="exe-single-page" onload="print_page()">'
        else:
            html += u'<body class="exe-single-page">'
        html += u'<script type="text/javascript">document.body.className+=" js"</script>' + lb
        html += u"<div id=\"content\">" + lb
        html += u"<" + headerTag + " id=\"header\">"
        html += u"<div id=\"headerContent\">"
        html += "<h1>" + escape(package.title) + "</h1>"
        html += u"</div>"
        html += u"</" + headerTag + ">" + lb
        html += u"<" + sectionTag + " id=\"main\">" + lb
        html += self.renderNode(package.root, 1)
        html += u"</" + sectionTag + ">" + lb
        html += self.renderLicense() + lb
        html += self.renderFooter() + lb
        html += u"</div>" + lb  # Close content
        # Some styles might have their own JavaScript files (see their config.xml file)
        style = G.application.config.styleStore.getStyle(
            self.node.package.style)
        if style.hasValidConfig:
            html += style.get_extra_body()
        html += u'</body></html>'

        # 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 la ruta de los enlaces del glosario y el &
        html = html.replace("../../../../../mod/glossary",
                            "../../../../mod/glossary")
        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
コード例 #47
0
ファイル: singlepage.py プロジェクト: Rafav/iteexe
    def renderHeader(self, name, for_print=0):
        """
        Returns an XHTML string for the header of this page.
        """
        lb = "\n"  #Line breaks

        def hasGalleryIdevice(node):
            hasGallery = common.hasGalleryIdevice(node)
            if not hasGallery:
                for child in node.children:
                    if hasGalleryIdevice(child):
                        return True
            return hasGallery

        hasGallery = hasGalleryIdevice(self.node)

        def hasFX(node):
            hasEffects = common.hasFX(node)
            if not hasEffects:
                for child in node.children:
                    if hasFX(child):
                        return True
            return hasEffects

        hasEffects = hasFX(self.node)

        def hasSH(node):
            hasHighlighter = common.hasSH(node)
            if not hasHighlighter:
                for child in node.children:
                    if hasSH(child):
                        return True
            return hasHighlighter

        hasHighlighter = hasSH(self.node)

        def hasGames(node):
            hasJSGames = common.hasGames(node)
            if not hasJSGames:
                for child in node.children:
                    if hasGames(child):
                        return True
            return hasJSGames

        hasJSGames = hasGames(self.node)

        def hasWikipediaIdevice(node):
            hasWikipedia = common.hasWikipediaIdevice(node)
            if not hasWikipedia:
                for child in node.children:
                    if hasWikipediaIdevice(child):
                        return True
            return hasWikipedia

        hasWikipedia = hasWikipediaIdevice(self.node)

        def nodeHasMediaelement(node):
            hasMediaelement = common.nodeHasMediaelement(node)
            if not hasMediaelement:
                for child in node.children:
                    if nodeHasMediaelement(child):
                        return True
            return hasMediaelement

        self.hasMediaelement = nodeHasMediaelement(self.node)

        lenguaje = G.application.config.locale
        if self.node.package.dublinCore.language != "":
            lenguaje = self.node.package.dublinCore.language
        dT = common.getExportDocType()
        if dT == "HTML5":
            html = '<!doctype html>' + lb
            html += '<html lang="' + lenguaje + '">' + lb
        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"<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />" + lb
        html += u"<title>"
        html += name
        html += "</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 += common.getLicenseMetadata(self.node.package.license)
        html += '<meta name="generator" content="eXeLearning ' + release + ' - exelearning.net" />' + lb
        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 hasWikipedia:
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_wikipedia.css\" />" + lb
        if hasGallery:
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_lightbox.css\" />" + lb
        if hasEffects:
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_effects.css\" />" + lb
        if hasHighlighter:
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_highlighter.css\" />" + lb
        if hasJSGames:
            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 self.hasMediaelement:
            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 hasGallery:
            html += u'<script type="text/javascript" src="exe_lightbox.js"></script>' + lb
        if hasEffects:
            html += u'<script type="text/javascript" src="exe_effects.js"></script>' + lb
        if hasHighlighter:
            html += u'<script type="text/javascript" src="exe_highlighter.js"></script>' + lb
        html += common.getJavaScriptStrings() + lb
        if hasJSGames:
            # 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
        if for_print:
            # include extra print-script for onload bit
            html += u'<script type="text/javascript">' + lb
            html += u'var interval;' + lb
            html += u'function checkClose() {' + lb
            html += u'    if (document.hasFocus()) {' + lb
            html += u'        alert("' + _(
                "You can close this window") + '");' + lb
            html += u'        clearInterval(interval);' + lb
            #             html += u'        window.close();' + lb
            html += u'    }' + lb
            html += u'}' + lb
            html += u'function print_page() {' + lb
            html += u'     if(typeof document.hasFocus === "undefined") {' + lb
            html += u'         document.hasFocus = function () {' + lb
            html += u'             return document.visibilityState == "visible";' + lb
            html += u'         }' + lb
            html += u'     }' + lb
            html += u'     window.print();' + lb
            html += u'     interval = setInterval(checkClose, 300);' + lb
            html += u'}' + lb
            html += u'</script>' + lb
        if style.hasValidConfig:
            html += style.get_extra_head()
        html += u"</head>" + lb
        return html
コード例 #48
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
コード例 #49
0
    def copyFiles(self, package):
        """
        Copy all the files used by the website.
        """
        # Copy the style sheet files to the output dir
        # But not nav.css
        if os.path.isdir(self.stylesDir):
            # Copy the style sheet files to the output dir
            styleFiles  = [self.stylesDir/'..'/'base.css']
            styleFiles += [self.stylesDir/'..'/'popup_bg.gif']
            styleFiles += self.stylesDir.files("*.css")
            if "nav.css" in styleFiles:
                styleFiles.remove("nav.css")
            styleFiles += self.stylesDir.files("*.jpg")
            styleFiles += self.stylesDir.files("*.gif")
            styleFiles += self.stylesDir.files("*.png")
            styleFiles += self.stylesDir.files("*.js")
            styleFiles += self.stylesDir.files("*.html")
            styleFiles += self.stylesDir.files("*.ico")
            styleFiles += self.stylesDir.files("*.ttf")
            styleFiles += self.stylesDir.files("*.eot")
            styleFiles += self.stylesDir.files("*.otf")
            styleFiles += self.stylesDir.files("*.woff")
            self.stylesDir.copylist(styleFiles, self.outputDir)
            
        # copy the package's resource files
        package.resourceDir.copyfiles(self.outputDir)

        # copy script files.
        my_style = G.application.config.styleStore.getStyle(package.style)
        
        # jQuery
        if my_style.hasValidConfig:
            if my_style.get_jquery() == True:
                jsFile = (self.scriptsDir/'exe_jquery.js')
                jsFile.copyfile(self.outputDir/'exe_jquery.js')
        else:
            jsFile = (self.scriptsDir/'exe_jquery.js')
            jsFile.copyfile(self.outputDir/'exe_jquery.js')
            
        jsFile = (self.scriptsDir/'common.js')
        jsFile.copyfile(self.outputDir/'common.js')
        jsFile = (self.scriptsDir/'lernmodule_net.js')
        jsFile.copyfile(self.outputDir/'lernmodule_net.js')
        dT = common.getExportDocType()
        if dT == "HTML5":
            jsFile = (self.scriptsDir/'exe_html5.js')
            jsFile.copyfile(self.outputDir/'exe_html5.js')
            
        # Incluide eXe's icon if the Style doesn't have one
        themePath = Path(G.application.config.stylesDir/package.style)
        themeFavicon = themePath.joinpath("favicon.ico")
        if not themeFavicon.exists():
            faviconFile = (self.imagesDir/'favicon.ico')
            faviconFile.copyfile(self.outputDir/'favicon.ico')

        #JR Metemos los reproductores necesarios
        self.compruebaReproductores(self.page.node)


        if package.license == "license GFDL":
            # include a copy of the GNU Free Documentation Licence
            (self.templatesDir/'fdl.html').copyfile(self.outputDir/'fdl.html')
コード例 #50
0
ファイル: scormpage.py プロジェクト: RichDijk/eXe
    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
コード例 #51
0
    def renderHeader(self, name, for_print=0):
        """
        Returns an XHTML string for the header of this page.
        """
        lb = "\n" #Line breaks
        def hasGalleryIdevice(node):
            hasGallery = common.hasGalleryIdevice(node)
            if not hasGallery:
                for child in node.children:
                    if hasGalleryIdevice(child):
                        return True
            return hasGallery
        
        hasGallery = hasGalleryIdevice(self.node)
        def hasWikipediaIdevice(node):
            hasWikipedia = common.hasWikipediaIdevice(node)
            if not hasWikipedia:
                for child in node.children:
                    if hasWikipediaIdevice(child):
                        return True
            return hasWikipedia
        
        hasWikipedia = hasWikipediaIdevice(self.node)

        def nodeHasMediaelement(node):
            hasMediaelement = common.nodeHasMediaelement(node)
            if not hasMediaelement:
                for child in node.children:
                    if nodeHasMediaelement(child):
                        return True
            return hasMediaelement

        self.hasMediaelement = nodeHasMediaelement(self.node)

        lenguaje = G.application.config.locale
        if self.node.package.dublinCore.language!="":
            lenguaje = self.node.package.dublinCore.language
        dT = common.getExportDocType()
        if dT == "HTML5":
            html = '<!doctype html>'+lb
            html += '<html lang="'+lenguaje+'">'+lb
        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"<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />"+lb
        html += u"<title>"
        html += name
        html += "</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.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 hasWikipedia:
            html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_wikipedia.css\" />"+lb
        if hasGallery:
            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 self.hasMediaelement:
            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 hasGallery:
            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
        if for_print:
            # include extra print-script for onload bit 
            html += u'<script type="text/javascript">' + lb
            html += u'var interval;' + lb
            html += u'function checkClose() {' + lb
            html += u'    if (document.hasFocus()) {' + lb
            html += u'        alert("' + _("You can close this window") + '");' + lb
            html += u'        clearInterval(interval);' + lb
#             html += u'        window.close();' + lb
            html += u'    }' + lb
            html += u'}' + lb
            html += u'function print_page() {' + lb
            html += u'     if(typeof document.hasFocus === "undefined") {' + lb
            html += u'         document.hasFocus = function () {' + lb
            html += u'             return document.visibilityState == "visible";' + lb
            html += u'         }' + lb
            html += u'     }' + lb
            html += u'     window.print();' + lb
            html += u'     interval = setInterval(checkClose, 300);' + lb
            html += u'}' + lb
            html += u'</script>' + lb
        if style.hasValidConfig:
            html += style.get_extra_head()
        html += u"</head>"+lb
        return html
コード例 #52
0
ファイル: scormpage.py プロジェクト: duyMinhCSE/eXe_handmake
    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
コード例 #53
0
ファイル: epub3export.py プロジェクト: exelearning/iteexe
    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
コード例 #54
0
ファイル: scormexport.py プロジェクト: kiolalis/iteexe
    def export(self, package):
        """
        Export SCORM package
        """
        # First do the export to a temporary directory
        outputDir = TempDirPath()

        self.metadataType = package.exportMetadataType

        # copy the package's resource files
        for resourceFile in package.resourceDir.walkfiles():
            file = package.resourceDir.relpathto(resourceFile)

            if ("/" in file):
                Dir = Path(outputDir / file[:file.rindex("/")])

                if not Dir.exists():
                    Dir.makedirs()

                resourceFile.copy(outputDir / Dir)
            else:
                resourceFile.copy(outputDir)

        # copy the package's resource files, only non existant in outputDir
#        outputDirFiles = outputDir.files()
#        for rfile in package.resourceDir.files():
#            if rfile not in outputDirFiles:
#                rfile.copy(outputDir)

# copy the package's resource files, only indexed in package.resources
#        for md5 in package.resources.values():
#            for resource in md5:
#                resource.path.copy(outputDir)

# Export the package content
# Import the Scorm Page class , if the secure mode is off.  If the style has it's own page class
# use that, else use the default one.
        if self.styleSecureMode == "0":
            if (self.styleDir / "scormpage.py").exists():
                global ScormPage
                module = imp.load_source("ScormPage",
                                         self.styleDir / "scormpage.py")
                ScormPage = module.ScormPage

        self.pages = [
            ScormPage("index",
                      1,
                      package.root,
                      scormType=self.scormType,
                      metadataType=self.metadataType)
        ]

        self.generatePages(package.root, 2)
        uniquifyNames(self.pages)

        for page in self.pages:
            page.save(outputDir, self.pages)
            if not self.hasForum:
                for idevice in page.node.idevices:
                    if hasattr(idevice, "isForum"):
                        if idevice.forum.lms.lms == "moodle":
                            self.hasForum = True
                            break

        # Create the manifest file
        manifest = Manifest(self.config, outputDir, package, self.pages,
                            self.scormType, self.metadataType)
        modifiedMetaData = manifest.save("imsmanifest.xml")

        # Create lang file
        langFile = open(outputDir + '/common_i18n.js', "w")
        langFile.write(common.getJavaScriptStrings(False))
        langFile.close()

        if self.hasForum:
            manifest.save("discussionforum.xml")

        # Copy the style files to the output dir

        styleFiles = [self.styleDir / '..' / 'popup_bg.gif']
        # And with all the files of the style we avoid problems:
        styleFiles += self.styleDir.files("*.*")
        if self.scormType == "commoncartridge":
            for sf in styleFiles[:]:
                if sf.basename() not in manifest.dependencies:
                    styleFiles.remove(sf)
        self.styleDir.copylist(styleFiles, outputDir)

        listCSSFiles = getFilesCSSToMinify('scorm', self.styleDir)
        exportMinFileCSS(listCSSFiles, outputDir)

        # Copy the scripts

        dT = common.getExportDocType()
        if dT == "HTML5":
            #listFiles+=[self.scriptsDir/'exe_html5.js']
            #listOutFiles+=[outputDir/'exe_html5.js']
            jsFile = (self.scriptsDir / 'exe_html5.js')
            jsFile.copyfile(outputDir / 'exe_html5.js')

        # jQuery
        my_style = G.application.config.styleStore.getStyle(
            page.node.package.style)
        if my_style.hasValidConfig():
            if my_style.get_jquery() == True:
                #listFiles+=[self.scriptsDir/'exe_jquery.js']
                #listOutFiles+=[outputDir/'exe_jquery.js']
                jsFile = (self.scriptsDir / 'exe_jquery.js')
                jsFile.copyfile(outputDir / 'exe_jquery.js')
        else:
            #listFiles+=[self.scriptsDir/'exe_jquery.js']
            #listOutFiles+=[outputDir/'exe_jquery.js']
            jsFile = (self.scriptsDir / 'exe_jquery.js')
            jsFile.copyfile(outputDir / 'exe_jquery.js')

        if self.scormType == "commoncartridge" or self.scormType == "scorm2004" or self.scormType == "scorm1.2":
            listFiles = getFilesJSToMinify('scorm', self.scriptsDir)

        exportMinFileJS(listFiles, outputDir)

        if self.scormType == "scorm2004" or self.scormType == "scorm1.2":
            self.scriptsDir.copylist(
                ('SCORM_API_wrapper.js', 'SCOFunctions.js'), outputDir)

        # about SCHEMAS:
        schemasDir = ""
        if self.scormType == "scorm1.2":
            schemasDir = self.schemasDir / "scorm1.2"
            schemasDir.copylist(('imscp_rootv1p1p2.xsd',
                                 'imsmd_rootv1p2p1.xsd', 'adlcp_rootv1p2.xsd',
                                 'lom.xsd', 'lomCustom.xsd', 'ims_xml.xsd'),
                                outputDir)
        elif self.scormType == "scorm2004":
            schemasDir = self.schemasDir / "scorm2004"
            schemasDir.copylist(
                ('adlcp_v1p3.xsd', 'adlnav_v1p3.xsd', 'adlseq_v1p3.xsd',
                 'datatypes.dtd', 'imscp_v1p1.xsd', 'imsssp_v1p0.xsd',
                 'imsss_v1p0.xsd', 'imsss_v1p0auxresource.xsd',
                 'imsss_v1p0control.xsd', 'imsss_v1p0delivery.xsd',
                 'imsmd_rootv1p2p1.xsd', 'imsss_v1p0limit.xsd',
                 'imsss_v1p0objective.xsd', 'imsss_v1p0random.xsd',
                 'imsss_v1p0rollup.xsd', 'imsss_v1p0seqrule.xsd',
                 'imsss_v1p0util.xsd', 'ims_xml.xsd', 'lom.xsd',
                 'lomCustom.xsd', 'xml.xsd', 'XMLSchema.dtd'), outputDir)
            try:
                import shutil, errno
                shutil.copytree(schemasDir / "common", outputDir / "common")
                shutil.copytree(schemasDir / "extend", outputDir / "extend")
                shutil.copytree(schemasDir / "unique", outputDir / "unique")
                shutil.copytree(schemasDir / "vocab", outputDir / "vocab")
            except OSError as exc:
                if exc.errno == errno.ENOTDIR:
                    shutil.copy(schemasDir, outputDir)
                else:
                    raise

        # copy players for media idevices.
        hasFlowplayer = False
        hasMagnifier = False
        hasXspfplayer = False
        hasGallery = False
        hasFX = False
        hasSH = False
        hasGames = False
        hasElpLink = False
        hasWikipedia = False
        isBreak = False
        hasInstructions = False
        hasMediaelement = False
        hasTooltips = False
        hasABCMusic = False
        listIdevicesFiles = []

        for page in self.pages:
            if isBreak:
                break
            for idevice in page.node.idevices:
                if (hasFlowplayer and hasMagnifier and hasXspfplayer
                        and hasGallery and hasFX and hasSH and hasGames
                        and hasElpLink and hasWikipedia and hasInstructions
                        and hasMediaelement and hasTooltips and hasABCMusic):
                    isBreak = True
                    break
                if not hasFlowplayer:
                    if 'flowPlayer.swf' in idevice.systemResources:
                        hasFlowplayer = True
                if not hasMagnifier:
                    if 'mojomagnify.js' in idevice.systemResources:
                        hasMagnifier = True
                if not hasXspfplayer:
                    if 'xspf_player.swf' in idevice.systemResources:
                        hasXspfplayer = True
                if not hasGallery:
                    hasGallery = common.ideviceHasGallery(idevice)
                if not hasFX:
                    hasFX = common.ideviceHasFX(idevice)
                if not hasSH:
                    hasSH = common.ideviceHasSH(idevice)
                if not hasGames:
                    hasGames = common.ideviceHasGames(idevice)
                if not hasElpLink:
                    hasElpLink = common.ideviceHasElpLink(idevice, package)
                if not hasWikipedia:
                    if 'WikipediaIdevice' == idevice.klass:
                        hasWikipedia = True
                if not hasInstructions:
                    if 'TrueFalseIdevice' == idevice.klass or 'MultichoiceIdevice' == idevice.klass or 'VerdaderofalsofpdIdevice' == idevice.klass or 'EleccionmultiplefpdIdevice' == idevice.klass:
                        hasInstructions = True
                if not hasMediaelement:
                    hasMediaelement = common.ideviceHasMediaelement(idevice)
                if not hasTooltips:
                    hasTooltips = common.ideviceHasTooltips(idevice)
                if not hasABCMusic:
                    hasABCMusic = common.ideviceHasABCMusic(idevice)
                if hasattr(idevice, "_iDeviceDir"):
                    listIdevicesFiles.append(
                        (idevice.get_jsidevice_dir() / 'export'))

            common.exportJavaScriptIdevicesFiles(page.node.idevices, outputDir)

        if hasFlowplayer:
            videofile = (self.templatesDir / 'flowPlayer.swf')
            videofile.copyfile(outputDir / 'flowPlayer.swf')
            controlsfile = (self.templatesDir / 'flowplayer.controls.swf')
            controlsfile.copyfile(outputDir / 'flowplayer.controls.swf')
        if hasMagnifier:
            videofile = (self.templatesDir / 'mojomagnify.js')
            videofile.copyfile(outputDir / 'mojomagnify.js')
        if hasXspfplayer:
            videofile = (self.templatesDir / 'xspf_player.swf')
            videofile.copyfile(outputDir / 'xspf_player.swf')
        if hasGallery:
            exeLightbox = (self.scriptsDir / 'exe_lightbox')
            exeLightbox.copyfiles(outputDir)
        if hasFX:
            exeEffects = (self.scriptsDir / 'exe_effects')
            exeEffects.copyfiles(outputDir)
        if hasSH:
            exeSH = (self.scriptsDir / 'exe_highlighter')
            exeSH.copyfiles(outputDir)
        if hasGames:
            exeGames = (self.scriptsDir / 'exe_games')
            exeGames.copyfiles(outputDir)
            # Add game js string to common_i18n
            langGameFile = open(outputDir + '/common_i18n.js', "a")
            langGameFile.write(common.getGamesJavaScriptStrings(False))
            langGameFile.close()
        if hasElpLink or package.get_exportElp():
            # Export the elp file
            currentPackagePath = Path(package.filename)
            currentPackagePath.copyfile(outputDir / package.name + '.elp')
        if hasWikipedia:
            wikipediaCSS = (self.cssDir / 'exe_wikipedia.css')
            wikipediaCSS.copyfile(outputDir / 'exe_wikipedia.css')
        if hasInstructions:
            common.copyFileIfNotInStyle('panel-amusements.png', self,
                                        outputDir)
            common.copyFileIfNotInStyle('stock-stop.png', self, outputDir)
        if hasMediaelement:
            mediaelement = (self.scriptsDir / 'mediaelement')
            mediaelement.copyfiles(outputDir)
            if dT != "HTML5":
                jsFile = (self.scriptsDir / 'exe_html5.js')
        if hasTooltips:
            exe_tooltips = (self.scriptsDir / 'exe_tooltips')
            exe_tooltips.copyfiles(outputDir)
        if hasABCMusic:
            pluginScripts = (self.scriptsDir /
                             'tinymce_4/js/tinymce/plugins/abcmusic/export')
            pluginScripts.copyfiles(outputDir)
        ext = ".html"
        if G.application.config.cutFileName == "1":
            ext = ".htm"

        if self.scormType == "scorm1.2" or self.scormType == "scorm2004":
            if package.license == "license GFDL":
                # include a copy of the GNU Free Documentation Licence
                (self.templatesDir / 'fdl' + ext).copyfile(outputDir / 'fdl' +
                                                           ext)

        if hasattr(package, 'scowsinglepage') and package.scowsinglepage:
            page = SinglePage("singlepage_index", 1, package.root)
            page.save(outputDir / "singlepage_index" + ext)
            # Incluide eXe's icon if the Style doesn't have one
            themePath = Path(G.application.config.stylesDir / package.style)
            themeFavicon = themePath.joinpath("favicon.ico")
            if not themeFavicon.exists():
                faviconFile = (self.imagesDir / 'favicon.ico')
                faviconFile.copyfile(outputDir / 'favicon.ico')
        if hasattr(package, 'scowwebsite') and package.scowwebsite:
            website = WebsiteExport(self.config, self.styleDir, outputDir,
                                    "website_")
            website.export(package)
            (self.styleDir / 'nav.css').copyfile(outputDir / 'nav.css')
            # Incluide eXe's icon if the Style doesn't have one
            themePath = Path(G.application.config.stylesDir / package.style)
            themeFavicon = themePath.joinpath("favicon.ico")
            if not themeFavicon.exists():
                faviconFile = (self.imagesDir / 'favicon.ico')
                faviconFile.copyfile(outputDir / 'favicon.ico')
        if hasattr(package, 'exportSource') and package.exportSource:
            (G.application.config.webDir / 'templates' /
             'content.xsd').copyfile(outputDir / 'content.xsd')
            (outputDir / 'content.data').write_bytes(encodeObject(package))
            (outputDir / 'contentv3.xml').write_bytes(
                encodeObjectToXML(package))

        # Zip it up!
        self.filename.safeSave(
            self.doZip, _('EXPORT FAILED!\nLast succesful export is %s.'),
            outputDir)
        # Clean up the temporary dir
        outputDir.rmtree()

        return modifiedMetaData
コード例 #55
0
ファイル: scormexport.py プロジェクト: kiolalis/iteexe
    def genItemResStr(self, page):
        """
        Returning xml string for items and resources
        """
        itemId = "ITEM-" + unicode(self.idGenerator.generate())
        resId = "RES-" + unicode(self.idGenerator.generate())
        ext = 'html'
        if G.application.config.cutFileName == "1":
            ext = 'htm'

        filename = page.name + '.' + ext

        self.itemStr += '<item identifier="' + itemId + '" '
        if self.scormType != "commoncartridge":
            self.itemStr += 'isvisible="true" '
        self.itemStr += 'identifierref="' + resId + '">\n'
        self.itemStr += "    <title>"
        self.itemStr += escape(page.node.titleShort)
        self.itemStr += "</title>\n"

        ## SCORM 12 specific metadata: Mastery Score is an ADL extension to the IMS Content Packaging Information Model
        ## Added for FR [#2501] Add masteryscore to manifest in evaluable nodes
        if self.scormType == "scorm1.2" and common.hasQuizTest(page.node):
            self.itemStr += "    <adlcp:masteryscore>%s</adlcp:masteryscore>\n" % common.getQuizTestPassRate(
                page.node)

        ## RESOURCES

        self.resStr += "  <resource identifier=\"" + resId + "\" "
        self.resStr += "type=\"webcontent\" "

        # FIXME force dependency on popup_bg.gif on every page
        # because it isn't a "resource" so we can't tell which
        # pages will use it from content.css
        if self.scormType == "commoncartridge":
            fileStr = ""
            self.resStr += """href="%s">
    <file href="%s"/>
    <file href="base.css"/>
    <file href="popup_bg.gif"/>
    <file href="exe_jquery.js"/>
    <file href="common_i18n.js"/>
    <file href="common.js"/>\n""" % (filename, filename)
            my_style = G.application.config.styleStore.getStyle(
                page.node.package.style)
            for x in my_style.get_style_dir().files('*.*'):
                fileStr += """    <file href="%s"/>\n""" % x.basename()
                self.dependencies[x.basename()] = True
            # CC export require content.* any place inside the manifest:
            if page.node.package.exportSource and page.depth == 1:
                self.resStr += '    <file href="content.xsd"/>\n'
                self.resStr += '    <file href="content.data"/>\n'
                self.resStr += '    <file href="contentv3.xml"/>\n'
            if page.node.package.backgroundImg:
                self.resStr += '\n    <file href="%s"/>' % \
                        page.node.package.backgroundImg.basename()
            self.dependencies["base.css"] = True
            self.dependencies["content.css"] = True
            self.dependencies["popup_bg.gif"] = True
        else:
            if self.scormType == "scorm2004":
                self.resStr += "adlcp:scormType=\"sco\" "
                self.resStr += "href=\"" + filename + "\"> \n"
                self.resStr += "    <file href=\"" + filename + "\"/> \n"
                fileStr = ""
            if self.scormType == "scorm1.2":
                self.resStr += "adlcp:scormtype=\"sco\" "
                self.resStr += "href=\"" + filename + "\"> \n"
                self.resStr += "    <file href=\"" + filename + "\"/> \n"
                fileStr = ""

        dT = common.getExportDocType()
        if dT == "HTML5" or common.nodeHasMediaelement(page.node):
            self.resStr += '    <file href="exe_html5.js"/>\n'

        resources = page.node.getResources()

        if common.nodeHasMediaelement(page.node):
            resources = resources + [
                f.basename() for f in (self.config.webDir / "scripts" /
                                       'mediaelement').files()
            ]
            if dT != "HTML5":
                self.scriptsDir = self.config.webDir / "scripts"
                jsFile = (self.scriptsDir / 'exe_html5.js')
                jsFile.copyfile(self.outputDir / 'exe_html5.js')

        if common.nodeHasTooltips(page.node):
            resources = resources + [
                f.basename() for f in (self.config.webDir / "scripts" /
                                       'exe_tooltips').files()
            ]

        if common.hasGalleryIdevice(page.node):
            resources = resources + [
                f.basename() for f in (self.config.webDir / "scripts" /
                                       'exe_lightbox').files()
            ]

        if common.hasFX(page.node):
            resources = resources + [
                f.basename() for f in (self.config.webDir / "scripts" /
                                       'exe_effects').files()
            ]

        if common.hasSH(page.node):
            resources = resources + [
                f.basename() for f in (self.config.webDir / "scripts" /
                                       'exe_highlighter').files()
            ]

        if common.hasGames(page.node):
            resources = resources + [
                f.basename() for f in (self.config.webDir / "scripts" /
                                       'exe_games').files()
            ]

        if common.hasABCMusic(page.node):
            resources = resources + [
                f.basename()
                for f in (self.config.webDir / "scripts" / 'tinymce_4' / 'js' /
                          'tinymce' / 'plugins' / 'abcmusic' /
                          'export').files()
            ]

        for resource in resources:
            fileStr += "    <file href=\"" + escape(resource) + "\"/>\n"
            self.dependencies[resource] = True

        if common.hasElpLink(page.node):
            fileStr += "    <file href=\"" + page.node.package.name + ".elp\"/>\n"

        self.resStr += fileStr

        self.resStr += common.getJavascriptIdevicesResources(page,
                                                             xmlOutput=True)

        # adding the dependency with the common files collected:
        if self.scormType != "commoncartridge":
            self.resStr += """    <dependency identifierref="COMMON_FILES"/>"""

        # and no more:
        self.resStr += '\n'
        self.resStr += "  </resource>\n"
コード例 #56
0
ファイル: websitepage.py プロジェクト: smmartinezlujan/iteexe
    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
コード例 #57
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
コード例 #58
0
    def genItemResStr(self, page):
        """
        Returning xml string for items and resources
        """
        itemId   = "ITEM-"+unicode(self.idGenerator.generate())
        resId    = "RES-"+unicode(self.idGenerator.generate())
        filename = page.name+".html"
            
        
        self.itemStr += '<item identifier="'+itemId+'" '
        if self.scormType != "commoncartridge":
            self.itemStr += 'isvisible="true" '
        self.itemStr += 'identifierref="'+resId+'">\n'
        self.itemStr += "    <title>"
        if self.scormType == "scorm2004" and page.node.children:
            self.itemStr += escape('<-')
        else:
            self.itemStr += escape(page.node.titleShort)
        self.itemStr += "</title>\n"

        ## SCORM 12 specific metadata: Mastery Score is an ADL extension to the IMS Content Packaging Information Model
        ## Added for FR [#2501] Add masteryscore to manifest in evaluable nodes
        if self.scormType == "scorm1.2" and common.hasQuizTest(page.node):
            self.itemStr += "    <adlcp:masteryscore>%s</adlcp:masteryscore>\n" % common.getQuizTestPassRate(page.node)
        
        ## RESOURCES
        
        self.resStr += "  <resource identifier=\""+resId+"\" "
        self.resStr += "type=\"webcontent\" "

        # FIXME force dependency on popup_bg.gif on every page
        # because it isn't a "resource" so we can't tell which
        # pages will use it from content.css
        if self.scormType == "commoncartridge":
            fileStr = ""
            self.resStr += """href="%s">
    <file href="%s"/>
    <file href="base.css"/>
    <file href="content.css"/>
    <file href="popup_bg.gif"/>
    <file href="exe_jquery.js"/>
    <file href="common.js"/>""" % (filename, filename)
            # CC export require content.* any place inside the manifest:
            if page.node.package.exportSource and page.depth == 1:
                self.resStr += '    <file href="content.xsd"/>\n'
                self.resStr += '    <file href="content.data"/>\n'
                self.resStr += '    <file href="contentv3.xml"/>\n'       
            if page.node.package.backgroundImg:
                self.resStr += '\n    <file href="%s"/>' % \
                        page.node.package.backgroundImg.basename()
            self.dependencies["base.css"] = True
            self.dependencies["content.css"] = True
            self.dependencies["popup_bg.gif"] = True
        else:
            if self.scormType == "scorm2004":
                self.resStr += "adlcp:scormType=\"sco\" "
                self.resStr += "href=\""+filename+"\"> \n"
                self.resStr += "    <file href=\""+filename+"\"/> \n"
                fileStr = ""
            if self.scormType == "scorm1.2":
                self.resStr += "adlcp:scormtype=\"sco\" "    
                self.resStr += "href=\""+filename+"\"> \n"              
                self.resStr += "    <file href=\""+filename+"\"/> \n"
                fileStr = ""

        dT = common.getExportDocType()
        if dT == "HTML5" or common.nodeHasMediaelement(page.node):
            self.resStr += '    <file href="exe_html5.js"/>\n'

        resources = page.node.getResources()
        
        if common.nodeHasMediaelement(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'mediaelement').files()]
            if dT != "HTML5":
                self.scriptsDir = self.config.webDir/"scripts"
                jsFile = (self.scriptsDir/'exe_html5.js')
                jsFile.copyfile(self.outputDir/'exe_html5.js')
                
        if common.nodeHasTooltips(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_tooltips').files()]
        
        if common.hasGalleryIdevice(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_lightbox').files()]
            
        if common.hasFX(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_effects').files()]
            
        if common.hasSH(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_highlighter').files()]
            
        if common.hasGames(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_games').files()]

        for resource in resources:            
            fileStr += "    <file href=\""+escape(resource)+"\"/>\n"
            self.dependencies[resource] = True

        self.resStr += fileStr

        # adding the dependency with the common files collected:
        if self.scormType != "commoncartridge":
            self.resStr += """    <dependency identifierref="COMMON_FILES"/>"""
            
        # and no more:
        self.resStr += '\n'
        self.resStr += "  </resource>\n"