Beispiel #1
0
    def create(self, static_site_id):
        config = Config.getInstance()
        self._fileHandler = ZIPFileHandler()

        # create the home page html
        self._create_home()

        # Create main and static folders
        self._mainPath = self._normalize_path(u'OfflineWebsite-{}'.format(
            self._conf.getTitle().decode('utf-8')))
        self._fileHandler.addDir(self._mainPath)
        self._staticPath = os.path.join(self._mainPath, "static")
        self._fileHandler.addDir(self._staticPath)
        # Add i18n js
        self._addFolderFromSrc(
            os.path.join(self._staticPath, 'js', 'indico', 'i18n'),
            os.path.join(config.getHtdocsDir(), 'js', 'indico', 'i18n'))
        # Add system icons (not referenced in HTML/CSS)
        for icon in Config.getInstance().getSystemIcons().itervalues():
            self._addFileFromSrc(
                os.path.join(self._staticPath, 'images', icon),
                os.path.join(config.getHtdocsDir(), 'images', icon))
        # IE compat files (in conditional comments so BS doesn't see them)
        for path in ie_compatibility.urls():
            self._addFileFromSrc(
                os.path.join(self._staticPath, path.lstrip('/')),
                os.path.join(config.getHtdocsDir(), path.lstrip('/')))
        # Mathjax plugins can't be discovered by parsing the HTML
        self._addFolderFromSrc(
            os.path.join(self._staticPath, 'js', 'lib', 'mathjax'),
            os.path.join(config.getHtdocsDir(), 'js', 'lib', 'mathjax'))

        # Getting all materials, static files (css, images, js and vars.js.tpl)
        self._getAllMaterial()
        self._html = self._get_static_files(self._html)

        # Specific changes
        self._create_other_pages()

        # Retrieve files that were not available in the file system (e.e. js/css from plugins)
        self._get_failed_paths()
        self._failed_paths = set()

        # Retrieve files referenced in CSS files
        self._get_css_refs()

        # A custom event CSS might reference an uploaded image so we need to check for failed paths again
        self._get_failed_paths()

        # Create overview.html file (main page for the event)
        conferenceDisplayPath = os.path.join(self._mainPath, 'overview.html')
        self._fileHandler.addNewFile(conferenceDisplayPath, self._html)

        # Creating index.html file
        self._fileHandler.addNewFile(
            'index.html', '<meta http-equiv="Refresh" content="0; url=%s">' %
            conferenceDisplayPath)

        self._fileHandler.close()
        return self._save_file(self._fileHandler.getPath(), static_site_id)
Beispiel #2
0
 def _process( self ):
     p = ReviewingPacker(self._conf)
     path = p.pack(ZIPFileHandler())
     filename = "accepted-papers.zip"
     cfg = Config.getInstance()
     mimetype = cfg.getFileTypeMimeType( "ZIP" )
     self._req.content_type = """%s"""%(mimetype)
     self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename
     self._req.sendfile(path)
Beispiel #3
0
 def pack( self ):
     from MaKaC.common.contribPacker import ZIPFileHandler,RegistrantPacker
     p=RegistrantPacker(self._conf)
     path=p.pack(self._list, ZIPFileHandler())
     filename = "registrants.zip"
     cfg = Config.getInstance()
     mimetype = cfg.getFileTypeMimeType( "ZIP" )
     self._rh._req.set_content_length(os.path.getsize(path))
     self._rh._req.content_type = """%s"""%(mimetype)
     self._rh._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename
     self._rh._req.sendfile(path)
 def _process(self):
     if not self._cancel:
         if self._materialTypes != []:
             p = ConferencePacker(self._conf, self._aw)
             path = p.pack(self._materialTypes, self._days,
                           self._mainResource, self._fromDate,
                           ZIPFileHandler(), self._sessionList)
             if not p.getItems():
                 raise NoReportError(
                     _("The selected package does not contain any items."))
             return send_file('full-material.zip',
                              path,
                              'ZIP',
                              inline=False)
         else:
             raise NoReportError(
                 _("You have to select at least one material type"))
     else:
         self._redirect(urlHandlers.UHConferenceDisplay.getURL(self._conf))
Beispiel #5
0
 def _process(self):
     p = ReviewingPacker(self._conf)
     path = p.pack(ZIPFileHandler())
     if not os.path.getsize(path):
         raise NoReportError(_('There are no accepted papers.'))
     return send_file('accepted-papers.zip', path, 'ZIP', inline=False)
Beispiel #6
0
    def run(self, fileHandler=None):
        publicFileURL = ""
        try:
            if fileHandler is None:
                self._fileHandler = ZIPFileHandler()
            else:
                self._fileHandler = fileHandler
            dvdPath = "Meeting-%s" % self._normalisePath(self._conf.getTitle())
            self._fileHandler.addDir(dvdPath)

            # Folder with the images
            imagesPath = os.path.join(dvdPath, "images")
            self._fileHandler.addDir(imagesPath)

            # Get all the images
            imagesPaths = self._getImagesList()
            self._getAllImages(imagesPath)
            #print ".",

            # CSS Style
            fname = os.path.join(dvdPath, "css",
                                 Config.getInstance().getCssStylesheetName())
            cssFile = open(
                os.path.join(Config.getInstance().getHtdocsDir(), "css",
                             Config.getInstance().getCssStylesheetName()),
                "rb")
            self._fileHandler.addNewFile(fname, cssFile.read())
            cssFile.close()

            commonCSSFile = open(
                os.path.join(Config.getInstance().getHtdocsDir(), "css",
                             "common.css"))
            self._fileHandler.addNewFile(
                os.path.join(dvdPath, "css", "common.css"),
                commonCSSFile.read())
            commonCSSFile.close()

            # Index web page for a conference + material/resources
            fname = os.path.join(
                dvdPath,
                urlHandlers.UHStaticConferenceDisplay.getRelativeURL())
            par = imagesPaths
            p = conferences.WPXSLMeetingStaticDisplay(self._rh, self._conf,
                                                      par)
            html = p.display()
            self._fileHandler.addNewFile(fname, html)
            materialList = self._conf.getAllMaterialList()
            if materialList is not None:
                for mat in materialList:
                    if len(mat.getResourceList()) != 1:
                        paraux = self.getRootDirPars(mat, par)
                        fname = os.path.join(
                            dvdPath,
                            urlHandlers.UHMStaticMaterialDisplay.
                            getRelativeURL(mat, escape=False))
                        p = conferences.WPMMaterialStaticDisplay(
                            self._rh, mat, paraux)
                        html = p.display()
                        self._fileHandler.addNewFile(fname, html)
                    for res in mat.getResourceList():
                        if isinstance(res, conference.LocalFile):
                            fname = os.path.join(
                                dvdPath,
                                urlHandlers.UHMStaticResourceDisplay.
                                getRelativeURL(res))
                            self._fileHandler.addNewFile(fname, res.readBin())

            # Material pages for the contributions in the meeting
            for contrib in self._conf.getContributionList():
                if contrib.isScheduled():
                    for mat in contrib.getAllMaterialList():
                        if len(mat.getResourceList()) != 1:
                            fname = os.path.join(
                                dvdPath,
                                urlHandlers.UHMStaticMaterialDisplay.
                                getRelativeURL(mat, escape=False))
                            paraux = self.getRootDirPars(mat, par)
                            p = conferences.WPMMaterialStaticDisplay(
                                self._rh, mat, paraux)
                            try:
                                html = p.display()
                            except Exception, e:
                                continue
                            self._fileHandler.addNewFile(fname, html)
                        for res in mat.getResourceList():
                            if isinstance(res, conference.LocalFile):
                                fname = os.path.join(
                                    dvdPath,
                                    urlHandlers.UHMStaticResourceDisplay.
                                    getRelativeURL(res, escape=False))
                                try:
                                    self._fileHandler.addNewFile(
                                        fname, res.readBin())
                                except Exception, e:
                                    continue
                    for subcont in contrib.getSubContributionList():
                        for mat in subcont.getAllMaterialList():
                            if len(mat.getResourceList()) != 1:
                                paraux = self.getRootDirPars(mat, par)
                                fname = os.path.join(
                                    dvdPath,
                                    urlHandlers.UHMStaticMaterialDisplay.
                                    getRelativeURL(mat, escape=False))
                                p = conferences.WPMMaterialStaticDisplay(
                                    self._rh, mat, paraux)
                                try:
                                    html = p.display()
                                except Exception, e:
                                    continue
                                self._fileHandler.addNewFile(fname, html)
                            for res in mat.getResourceList():
                                if isinstance(res, conference.LocalFile):
                                    fname = os.path.join(
                                        dvdPath,
                                        urlHandlers.UHMStaticResourceDisplay.
                                        getRelativeURL(res, escape=False))
                                    try:
                                        self._fileHandler.addNewFile(
                                            fname, res.readBin())
                                    except Exception, e:
                                        continue
Beispiel #7
0
    def run(self, fileHandler=None):
        publicFileURL = ""
        try:
            #print "[DVD] Creating offline site . . .",
            if fileHandler is None:
                self._fileHandler = ZIPFileHandler()
            else:
                self._fileHandler = fileHandler
            # Folder with the DVD
            dvdPath = "Conference-%s" % self._normalisePath(
                self._conf.getTitle())
            self._fileHandler.addDir(dvdPath)

            # Folder with the images
            imagesPath = os.path.join(dvdPath, "images")
            self._fileHandler.addDir(imagesPath)

            # Get all the images
            imagesPaths = self._getImagesList()
            self._getAllImages(imagesPath)
            #print ".",

            # CSS Style
            fname = os.path.join(dvdPath, "css",
                                 Config.getInstance().getCssStylesheetName())
            cssFile = open(
                os.path.join(Config.getInstance().getHtdocsDir(), "css",
                             Config.getInstance().getCssStylesheetName()),
                "rb")
            self._fileHandler.addNewFile(fname, cssFile.read())
            cssFile.close()

            commonCSSFile = open(
                os.path.join(Config.getInstance().getHtdocsDir(), "css",
                             "common.css"))
            self._fileHandler.addNewFile(
                os.path.join(dvdPath, "css", "common.css"),
                commonCSSFile.read())
            commonCSSFile.close()

            # Index web page for a conference + material/resources
            fname = os.path.join(
                dvdPath,
                urlHandlers.UHStaticConferenceDisplay.getRelativeURL())
            par = imagesPaths
            p = conferences.WPConferenceStaticDisplay(self._rh, self._conf,
                                                      par)
            html = p.display()
            self._fileHandler.addNewFile(fname, html)
            materialList = self._conf.getAllMaterialList()
            if materialList is not None:
                for mat in materialList:
                    if len(mat.getResourceList()) > 1 or len(
                            mat.getResourceList()) == 0:
                        fname = os.path.join(
                            dvdPath,
                            urlHandlers.UHStaticMaterialDisplay.getRelativeURL(
                                mat, escape=False))
                        p = conferences.WPMaterialStaticDisplay(
                            self._rh, mat, par)
                        html = p.display()
                        self._fileHandler.addNewFile(fname, html)
                    for res in mat.getResourceList():
                        if isinstance(res, conference.LocalFile):
                            fname = os.path.join(
                                dvdPath,
                                urlHandlers.UHStaticResourceDisplay.
                                getRelativeURL(res, escape=False))
                            self._fileHandler.addNewFile(fname, res.readBin())
            #print ".",

            # Scientific programme page
            fname = os.path.join(
                dvdPath,
                urlHandlers.UHStaticConferenceProgram.getRelativeURL())
            par = imagesPaths
            p = conferences.WPConferenceStaticProgram(self._rh, self._conf,
                                                      par)
            html = p.display()
            self._fileHandler.addNewFile(fname, html)
            #print ".",

            # AbstractBook
            fname = os.path.join(
                dvdPath, urlHandlers.UHStaticConfAbstractBook.getRelativeURL())
            from MaKaC.PDFinterface.conference import AbstractBook
            pdf = AbstractBook(self._conf, self._rh.getAW(), "")
            data = pdf.getPDFBin()
            self._fileHandler.addNewFile(fname, data)
            #print ".",

            # Author index page
            fname = os.path.join(
                dvdPath, urlHandlers.UHStaticConfAuthorIndex.getRelativeURL())
            par = imagesPaths
            p = conferences.WPStaticAuthorIndex(self._rh, self._conf, par)
            html = p.display()
            self._fileHandler.addNewFile(fname, html)
            #print ".",

            # Get every contribution order by track and by scheduled
            trackDict = {}
            for track in self._conf.getTrackList():
                trackDict[track.getId()] = []

            for session in self._conf.getSessionList():
                for slotEntry in session.getSchedule().getEntries():
                    slot = slotEntry.getOwner()
                    for contribEntry in slot.getSchedule().getEntries():
                        contrib = contribEntry.getOwner()
                        if isinstance(contribEntry,
                                      schedule.LinkedTimeSchEntry):
                            track = contrib.getTrack()
                            if track is not None:
                                trackDict[track.getId()].append(contrib)
            #print ".",

            # Contribution list page
            fname = os.path.join(
                dvdPath, urlHandlers.UHStaticContributionList.getRelativeURL())
            par = imagesPaths
            p = conferences.WPStaticContributionList(self._rh, self._conf, par,
                                                     trackDict)
            html = p.display()
            self._fileHandler.addNewFile(fname, html)
            #print ".",

            # ----- Create tracks folders, materials and contributions pages
            par = self._getSubdir(imagesPaths)
            for track in self._conf.getTrackList():
                trackDir = os.path.join(dvdPath,
                                        track.getTitle().replace(" ", "_"))
                # Track folder
                self._fileHandler.addDir(trackDir)
                # Track contribution list
                fname = os.path.join(
                    dvdPath,
                    urlHandlers.UHStaticTrackContribList.getRelativeURL(
                        track, escape=False))
                p = conferences.WPTrackStaticContribList(
                    self._rh, track, imagesPaths, trackDict)
                html = p.display()
                self._fileHandler.addNewFile(fname, html)
                # Contribs
                for contrib in track.getContributionList():
                    fname = os.path.join(
                        dvdPath,
                        urlHandlers.UHStaticContributionDisplay.getRelativeURL(
                            contrib, escape=False))
                    p = conferences.WPContributionStaticDisplay(
                        self._rh, contrib, par)
                    html = p.display()
                    self._fileHandler.addNewFile(fname, html)
                    materialList = contrib.getAllMaterialList()
                    if materialList is not None:
                        for mat in materialList:
                            if len(mat.getResourceList()) > 1 or len(
                                    mat.getResourceList()) == 0:
                                fname = os.path.join(
                                    trackDir,
                                    urlHandlers.UHStaticMaterialDisplay.
                                    getRelativeURL(mat, escape=False))
                                p = conferences.WPMaterialStaticDisplay(
                                    self._rh, mat, par)
                                html = p.display()
                                self._fileHandler.addNewFile(fname, html)
                            for res in mat.getResourceList():
                                if isinstance(res, conference.LocalFile):
                                    fname = os.path.join(
                                        trackDir,
                                        urlHandlers.UHStaticResourceDisplay.
                                        getRelativeURL(res))
                                    self._fileHandler.addNewFile(
                                        fname, res.readBin())
                #print ".",

            # ------ Other contributions not within a track -------
            otherContribsDir = os.path.join(dvdPath, "other_contributions")
            # Other Contribs folder
            self._fileHandler.addDir(otherContribsDir)
            for contrib in self._conf.getContributionList():
                if contrib.getTrack() is None:
                    fname = os.path.join(
                        dvdPath,
                        urlHandlers.UHStaticContributionDisplay.getRelativeURL(
                            contrib, escape=False))
                    p = conferences.WPContributionStaticDisplay(
                        self._rh, contrib, par)
                    html = p.display()
                    self._fileHandler.addNewFile(fname, html)
                    materialList = contrib.getAllMaterialList()
                    if materialList is not None:
                        for mat in materialList:
                            if len(mat.getResourceList()) > 1 or len(
                                    mat.getResourceList()) == 0:
                                fname = os.path.join(
                                    otherContribsDir,
                                    urlHandlers.UHStaticMaterialDisplay.
                                    getRelativeURL(mat, escape=False))
                                p = conferences.WPMaterialStaticDisplay(
                                    self._rh, mat, par)
                                html = p.display()
                                self._fileHandler.addNewFile(fname, html)
                            for res in mat.getResourceList():
                                if isinstance(res, conference.LocalFile):
                                    fname = os.path.join(
                                        otherContribsDir,
                                        urlHandlers.UHStaticResourceDisplay.
                                        getRelativeURL(res))
                                    self._fileHandler.addNewFile(
                                        fname, res.readBin())
                    #print ".",

            # Timetable
            fname = os.path.join(
                dvdPath,
                urlHandlers.UHStaticConferenceTimeTable.getRelativeURL())
            par = imagesPaths
            p = conferences.WPConferenceStaticTimeTable(
                self._rh, self._conf, par)
            html = p.display()
            self._fileHandler.addNewFile(fname, html)
            #print ".",

            # Session in Timetable
            sessionsDir = os.path.join(dvdPath, "sessions")
            par = self._getSubdir(imagesPaths)
            for session in self._conf.getSessionList():
                fname = os.path.join(
                    dvdPath,
                    urlHandlers.UHStaticSessionDisplay.getRelativeURL(session))
                p = conferences.WPSessionStaticDisplay(self._rh, session, par)
                html = p.display()
                self._fileHandler.addNewFile(fname, html)
                materialList = session.getAllMaterialList()
                if materialList is not None:
                    for mat in materialList:
                        if len(mat.getResourceList()) > 1 or len(
                                mat.getResourceList()) == 0:
                            fname = os.path.join(
                                sessionsDir,
                                urlHandlers.UHStaticMaterialDisplay.
                                getRelativeURL(mat, escape=False))
                            p = conferences.WPMaterialStaticDisplay(
                                self._rh, mat, par)
                            html = p.display()
                            self._fileHandler.addNewFile(fname, html)
                        for res in mat.getResourceList():
                            if isinstance(res, conference.LocalFile):
                                fname = os.path.join(
                                    sessionsDir,
                                    urlHandlers.UHStaticResourceDisplay.
                                    getRelativeURL(res))
                                self._fileHandler.addNewFile(
                                    fname, res.readBin())

            self._fileHandler.close()

            #print "[DONE]\nmaking public the DVD...",
            self._outputFileName = self._publicFile(
                self._fileHandler.getPath())
            #print "[DONE]"
            publicFileURL = "%s/%s" % (Config.getInstance().getPublicURL(),
                                       self._outputFileName)
            #print "sending email...",
            self._sendEmail(publicFileURL)
            #print "[DONE]"
        except Exception, e:
            #print "[ERROR]"
            self._sendErrorEmail(e)
Beispiel #8
0
 def pack(self):
     from MaKaC.common.contribPacker import ZIPFileHandler, RegistrantPacker
     p = RegistrantPacker(self._conf)
     path = p.pack(self._list, ZIPFileHandler())
     return send_file('registrants.zip', path, 'ZIP', inline=False)