Beispiel #1
0
    def show_node_big(self, req, template="", macro=""):
        if len([f.retrieveFile() for f in self.getFiles()]) == 0:
            styles = getContentStyles("bigview", contenttype=self.getContentType())
            template = styles[0].getTemplate()
            return req.getTAL(template, self._prepareData(req), macro)

        if template == "":
            styles = getContentStyles("bigview", contenttype=self.getContentType())
            if len(styles) >= 1:
                template = styles[0].getTemplate()

        captions_info = getCaptionInfoDict(self)

        if captions_info:
            logger.info("video: '%s' (%s): captions: dictionary 'captions_info': %s" % (self.name, str(self.id), str(captions_info)))

        context = self._prepareData(req)
        context["captions_info"] = json.dumps(captions_info)

        if len([m for m in [getMimeType(os.path.abspath(f.retrieveFile()))[0].split('/')[0] for f in self.getFiles() if os.path.exists(os.path.abspath(f.retrieveFile()))] if m == 'video'])>0:
            return req.getTAL(template, context, macro)
        else:
            if len([th for th in [os.path.abspath(f.retrieveFile()) for f in self.getFiles()] if th.endswith('thumb2')])>0:
                return req.getTAL(template, context, macro)
            else:
                if len([f for f in self.getFiles() if f.getType() == 'attachment'])>0:
                    return req.getTAL(template, context, macro)

                return '<h2 style="width:100%; text-align:center ;color:red">Video is not in a supported video-format.</h2>'
Beispiel #2
0
 def getContentStyles(self):
     if self.content.__class__ == ContentNode:
         return getContentStyles(
             "bigview", contenttype=self.content.node.getContentType())
     else:
         return getContentStyles(
             "smallview")  # , self.collection.get("style") or "default")
Beispiel #3
0
 def show_node_big(self, req, template="", macro=""):
     if template == "":
         styles = getContentStyles("bigview",
                                   contenttype=self.getContentType())
         if len(styles) >= 1:
             template = styles[0].getTemplate()
     return req.getTAL(template, self._prepareData(req), macro)
Beispiel #4
0
    def show_node_big(self, req, template="", macro=""):

        # if the file format is not flash video (edit area)
        if 'contentarea' not in req.session:
            files = [f.retrieveFile() for f in self.getFiles()]
            if len(files
                   ) == 1 and 'flv' != files[0].split('/')[-1].split('.')[-1]:
                return req.error(415, "Video is not in Flash Video format")

        if template == "":
            styles = getContentStyles("bigview",
                                      contenttype=self.getContentType())
            if len(styles) >= 1:
                template = styles[0].getTemplate()

        captions_info = getCaptionInfoDict(self)

        if captions_info:
            logger.info(
                "video: '%s' (%s): captions: dictionary 'captions_info': %s" %
                (self.name, str(self.id), str(captions_info)))

        context = self._prepareData(req)
        context["captions_info"] = json.dumps(captions_info)

        return req.getTAL(template, context, macro)
Beispiel #5
0
    def show_node_big(self, req, template="", macro=""):
        if template == "":
            styles = getContentStyles("bigview", contenttype=self.getContentType())
            if len(styles) >= 1:
                template = styles[0].getTemplate()

        return req.getTAL(template, self._prepareData(req), macro)
Beispiel #6
0
    def feedback(self, req):
        myid = req.params.get("id")
        if myid:
            try:
                self.nr = self.id2pos[myid]
            except KeyError:
                pass  # happens for first node (the directory)

        self.lang = lang(req)

        if "page" in req.params:
            self.page = int(req.params.get("page"))
            self.nr = -1

        if "back" in req.params:
            self.nr = -1

        for i in range(SORT_FIELDS):
            if ("sortfield%d" % i) in req.params:
                self.sortfields[i] = req.params["sortfield%d" % i]

        self.files.sort_by_fields(self.sortfields)

        self.content = None
        if self.nr >= 0 and self.nr < self.num:
            self.content = ContentNode(self.files[self.nr], self.nr, self.num,
                                       self.words, self.collection)

        # style selection
        if "style" in req.params:
            newstyle = req.params.get("style")
            if self.content.__class__ != ContentNode:
                req.session["liststyle-" +
                            self.collection.id] = getContentStyles(
                                "smallview", newstyle)
            else:
                req.session[
                    "style-" +
                    self.content.node.getContentType()] = getContentStyles(
                        "bigview",
                        name=newstyle,
                        contenttype=self.content.node.getContentType())[0]
        if self.content:
            return self.content.feedback(req)
Beispiel #7
0
    def show_node_big(self, req, template="", macro=""):
        mask = self.getFullView(lang(req))
        access = acl.AccessData(req)

        if template == "":
            styles = getContentStyles("bigview", contenttype=self.getContentType())
            if len(styles) >= 1:
                template = styles[0].getTemplate()
        # hide empty elements}, macro)
        return req.getTAL(template, {'node': self, 'metadata': mask.getViewHTML(
            [self], VIEW_HIDE_EMPTY), 'format_size': format_filesize, 'access': access})
Beispiel #8
0
    def feedback(self, req):
        myid = req.params.get("id")
        if myid:
            try:
                self.nr = self.id2pos[myid]
            except KeyError:
                pass  # happens for first node (the directory)

        self.lang = lang(req)

        if "page" in req.params:
            self.page = int(req.params.get("page"))
            self.nr = -1

        if "back" in req.params:
            self.nr = -1

        for i in range(SORT_FIELDS):
            if ("sortfield%d" % i) in req.params:
                self.sortfields[i] = req.params["sortfield%d" % i]

        self.files.sort_by_fields(self.sortfields)

        self.content = None
        if self.nr >= 0 and self.nr < self.num:
            self.content = ContentNode(self.files[self.nr], self.nr, self.num, self.words, self.collection)

        # style selection
        if "style" in req.params:
            newstyle = req.params.get("style")
            if self.content.__class__ != ContentNode:
                req.session["liststyle-" + self.collection.id] = getContentStyles("smallview", newstyle)
            else:
                req.session[
                    "style-" +
                    self.content.node.getContentType()] = getContentStyles(
                    "bigview",
                    name=newstyle,
                    contenttype=self.content.node.getContentType())[0]
        if self.content:
            return self.content.feedback(req)
Beispiel #9
0
    def show_node_big(self, req, template="", macro=""):
        mask = self.getFullView(lang(req))
        access = acl.AccessData(req)

        if template == "":
            styles = getContentStyles("bigview",
                                      contenttype=self.getContentType())
            if len(styles) >= 1:
                template = styles[0].getTemplate()
        # hide empty elements}, macro)
        return req.getTAL(
            template, {
                'node': self,
                'metadata': mask.getViewHTML([self], VIEW_HIDE_EMPTY),
                'format_size': format_filesize,
                'access': access
            })
Beispiel #10
0
 def __init__(self, files, collection=None, words=None):
     self.nr = -1
     self.page = 0
     self.lang = "en"
     self.words = words
     self.files = files
     self.num = len(files)
     self.collection = collection
     self.content = None
     self.id2pos = {}
     self.sortfields = [self.collection.get("sortfield")] * SORT_FIELDS
     if self.sortfields[0]:
         self.files.sort_by_fields(self.sortfields)
     ls = self.collection.get("style")
     if ls:
         ls = ls.split(";")[0]
     else:
         ls = "list"
     self.liststyle = getContentStyles("smallview", ls)
Beispiel #11
0
 def __init__(self, files, collection=None, words=None):
     self.nr = -1
     self.page = 0
     self.lang = "en"
     self.words = words
     self.files = files
     self.num = len(files)
     self.collection = collection
     self.content = None
     self.id2pos = {}
     self.sortfields = [self.collection.get("sortfield")] * SORT_FIELDS
     if self.sortfields[0]:
         self.files.sort_by_fields(self.sortfields)
     ls = self.collection.get("style")
     if ls:
         ls = ls.split(";")[0]
     else:
         ls = "list"
     self.liststyle = getContentStyles("smallview", ls)
Beispiel #12
0
    def show_node_big(self, req, template="", macro=""):

        # if the file format is not flash video (edit area)
        if 'contentarea' not in req.session:
            files = [f.retrieveFile() for f in self.getFiles()]
            if len(files) == 1 and 'flv' != files[0].split('/')[-1].split('.')[-1]:
                return req.error(415, "Video is not in Flash Video format")

        if template == "":
            styles = getContentStyles("bigview", contenttype=self.getContentType())
            if len(styles) >= 1:
                template = styles[0].getTemplate()

        captions_info = getCaptionInfoDict(self)

        if captions_info:
            logger.info("video: '%s' (%s): captions: dictionary 'captions_info': %s" % (self.name, str(self.id), str(captions_info)))

        context = self._prepareData(req)
        context["captions_info"] = json.dumps(captions_info)

        return req.getTAL(template, context, macro)
Beispiel #13
0
 def getContentStyles(self):
     return getContentStyles("bigview",
                             contenttype=self.node.getContentType())
Beispiel #14
0
 def getContentStyles(self):
     return getContentStyles("bigview", contenttype=self.node.getContentType())
Beispiel #15
0
 def getContentStyles(self):
     if self.content.__class__ == ContentNode:
         return getContentStyles("bigview", contenttype=self.content.node.getContentType())
     else:
         return getContentStyles("smallview")  # , self.collection.get("style") or "default")