Beispiel #1
0
    def _prepareData(self, req, words=""):
        access = acl.AccessData(req)
        mask = self.getFullView(lang(req))
        obj = {'deleted': False, 'access': access}
        node = self
        if self.get('deleted') == 'true':
            node = self.getActiveVersion()
            obj['deleted'] = True
        if mask:
            obj['metadata'] = mask.getViewHTML(
                [node], VIEW_HIDE_EMPTY, lang(req),
                mask=mask)  # hide empty elements
        else:
            obj['metadata'] = []
        obj['node'] = node
        obj['path'] = req and req.params.get("path", "") or ""
        files, sum_size = filebrowser(node, req)

        obj['attachment'] = files
        obj['sum_size'] = sum_size

        obj['bibtex'] = False
        if node.getMask("bibtex"):
            obj['bibtex'] = True

        if node.has_object():
            obj['canseeoriginal'] = access.hasAccess(node, "data")
            if node.get('system.origname') == "1":
                obj['documentlink'] = '/doc/{}/{}'.format(
                    node.id, node.getName())
                obj['documentdownload'] = '/download/{}/{}'.format(
                    node.id, node.getName())
            else:
                obj['documentlink'] = '/doc/{}/{}.pdf'.format(node.id, node.id)
                obj['documentdownload'] = '/download/{}/{}.pdf'.format(
                    node.id, node.id)
        else:
            obj['canseeoriginal'] = False
        obj['documentthumb'] = '/thumb2/{}'.format(node.id)
        if "oogle" not in (req.get_header("user-agent") or ""):
            obj['print_url'] = '/print/{}'.format(node.id)
        else:
            # don't confuse search engines with the PDF link
            obj['print_url'] = None
            obj['documentdownload'] = None
        if "style" in req.params.keys():
            req.session["full_style"] = req.params.get("style",
                                                       "full_standard")
        elif "full_style" not in req.session.keys():
            if "contentarea" in req.session.keys():
                col = req.session["contentarea"].collection
                req.session["full_style"] = col.get("style_full")
            else:
                req.session["full_style"] = "full_standard"

        obj['parentInformation'] = self.getParentInformation(req)

        obj['style'] = req.session["full_style"]
        return obj
Beispiel #2
0
    def _prepareData(self, req):
        mask = self.getFullView(lang(req))

        tif = ""
        try:
            tifs = req.session["fullresolutionfiles"]
        except:
            tifs = []

        access = acl.AccessData(req)
        if access.hasAccess(self, "data"):
            for f in self.getFiles():
                if f.getType() == "original":
                    if self.get('system.origname') == "1":
                        tif = self.getName()
                    else:
                        tif = f.getName()

            if self.get("archive_path") != "":
                tif = "file/" + str(self.id) + "/" + self.get("archive_path")

        files, sum_size = filebrowser(self, req)

        obj = {'deleted': False, 'access': access}
        node = self
        if self.get('deleted') == 'true':
            node = self.getActiveVersion()
            obj['deleted'] = True
        obj['path'] = req and req.params.get("path", "") or ""
        obj['attachment'] = files
        obj['sum_size'] = sum_size
        obj['metadata'] = mask.getViewHTML([node], VIEW_HIDE_EMPTY)  # hide empty elements
        obj['node'] = node
        obj['tif'] = tif
        obj['zoom'] = dozoom(node)
        obj['tileurl'] = "/tile/{}/".format(node.id)
        obj['canseeoriginal'] = access.hasAccess(node, "data")
        obj['originallink'] = "getArchivedItem('{}/{}')".format(node.id, tif)
        obj['archive'] = node.get('archive_type')

        if "style" in req.params.keys():
            req.session["full_style"] = req.params.get("style", "full_standard")
        elif "full_style" not in req.session.keys():
            if "contentarea" in req.session.keys():
                col = req.session["contentarea"].collection
                req.session["full_style"] = col.get("style_full")
            else:
                req.session["full_style"] = "full_standard"

        obj['style'] = req.session["full_style"]

        obj['parentInformation'] = self.getParentInformation(req)

        return obj
Beispiel #3
0
def _prepare_document_data(node, req, words=""):
    obj = prepare_node_data(node, req)
    if obj["deleted"]:
        # no more processing needed if this object version has been deleted
        # rendering has been delegated to current version
        return obj

    files, sum_size = filebrowser(node, req)

    obj['attachment'] = files
    obj['sum_size'] = sum_size
    obj['bibtex'] = False

    if node.getMask(u"bibtex"):
        obj['bibtex'] = True

    if node.has_object():
        obj['canseeoriginal'] = node.has_data_access()
        if node.system_attrs.get('origname') == "1":
            obj['documentlink'] = u'/doc/{}/{}'.format(node.id, node.name)
            obj['documentdownload'] = u'/download/{}/{}'.format(
                node.id, node.name)
        else:
            obj['documentlink'] = u'/doc/{}/{}.pdf'.format(node.id, node.id)
            obj['documentdownload'] = u'/download/{}/{}.pdf'.format(
                node.id, node.id)

            if not node.isActiveVersion():
                version_id = unicode(version_id_from_req(req))
                obj['documentlink'] += "?v=" + version_id
                obj['documentdownload'] += "?v=" + version_id

    else:
        obj['canseeoriginal'] = False

    obj['documentthumb'] = u'/thumb2/{}'.format(node.id)
    if not node.isActiveVersion():
        version_id = unicode(version_id_from_req(req))
        obj['documentthumb'] += "?v=" + version_id
        obj['tag'] = version_id

    # XXX: do we really need this spider filtering?
    user_agent = req.get_header("user-agent") or ""
    is_spider = "oogle" in user_agent or "aidu" in user_agent

    if is_spider:
        # don't confuse search engines with the PDF link
        obj['documentdownload'] = None

    full_style = req.args.get("style", "full_standard")
    if full_style:
        obj['style'] = full_style

    return obj
Beispiel #4
0
    def _prepareData(self, req, words=""):
        access = acl.AccessData(req)
        mask = self.getFullView(lang(req))
        obj = {'deleted': False, 'access': access}
        node = self
        if self.get('deleted') == 'true':
            node = self.getActiveVersion()
            obj['deleted'] = True
        if mask:
            obj['metadata'] = mask.getViewHTML([node], VIEW_HIDE_EMPTY, lang(req), mask=mask)  # hide empty elements
        else:
            obj['metadata'] = []
        obj['node'] = node
        obj['path'] = req and req.params.get("path", "") or ""
        files, sum_size = filebrowser(node, req)

        obj['attachment'] = files
        obj['sum_size'] = sum_size

        obj['bibtex'] = False
        if node.getMask("bibtex"):
            obj['bibtex'] = True

        if node.has_object():
            obj['canseeoriginal'] = access.hasAccess(node, "data")
            if node.get('system.origname') == "1":
                obj['documentlink'] = '/doc/{}/{}'.format(node.id, node.getName())
                obj['documentdownload'] = '/download/{}/{}'.format(node.id, node.getName())
            else:
                obj['documentlink'] = '/doc/{}/{}.pdf'.format(node.id, node.id)
                obj['documentdownload'] = '/download/{}/{}.pdf'.format(node.id, node.id)
        else:
            obj['canseeoriginal'] = False
        obj['documentthumb'] = '/thumb2/{}'.format(node.id)
        if "oogle" not in (req.get_header("user-agent") or ""):
            obj['print_url'] = '/print/{}'.format(node.id)
        else:
            # don't confuse search engines with the PDF link
            obj['print_url'] = None
            obj['documentdownload'] = None
        if "style" in req.params.keys():
            req.session["full_style"] = req.params.get("style", "full_standard")
        elif "full_style" not in req.session.keys():
            if "contentarea" in req.session.keys():
                col = req.session["contentarea"].collection
                req.session["full_style"] = col.get("style_full")
            else:
                req.session["full_style"] = "full_standard"

        obj['parentInformation'] = self.getParentInformation(req)

        obj['style'] = req.session["full_style"]
        return obj
Beispiel #5
0
    def _prepareData(self, req):
        mask = self.getFullView(lang(req))

        tif = ""
        try:
            tifs = req.session["fullresolutionfiles"]
        except:
            tifs = []

        access = acl.AccessData(req)
        if access.hasAccess(self, "data"):
            for f in self.getFiles():
                if f.getType() == "original":
                    if self.get('system.origname') == "1":
                        tif = self.getName()
                    else:
                        tif = f.getName()

            if self.get("archive_path") != "":
                tif = "file/" + str(self.id) + "/" + self.get("archive_path")

        files, sum_size = filebrowser(self, req)

        obj = {'deleted': False, 'access': access}
        node = self
        if self.get('deleted') == 'true':
            node = self.getActiveVersion()
            obj['deleted'] = True
        obj['path'] = req and req.params.get("path", "") or ""
        obj['attachment'] = files
        obj['sum_size'] = sum_size
        obj['metadata'] = mask.getViewHTML(
            [node], VIEW_HIDE_EMPTY)  # hide empty elements
        obj['node'] = node
        obj['tif'] = tif
        obj['zoom'] = dozoom(node)
        obj['tileurl'] = "/tile/{}/".format(node.id)
        obj['canseeoriginal'] = access.hasAccess(node, "data")
        obj['originallink'] = "getArchivedItem('{}/{}')".format(node.id, tif)
        obj['archive'] = node.get('archive_type')

        if "style" in req.params.keys():
            req.session["full_style"] = req.params.get("style",
                                                       "full_standard")
        elif "full_style" not in req.session.keys():
            if "contentarea" in req.session.keys():
                col = req.session["contentarea"].collection
                req.session["full_style"] = col.get("style_full")
            else:
                req.session["full_style"] = "full_standard"

        obj['style'] = req.session["full_style"]
        return obj
Beispiel #6
0
def _prepare_document_data(node, req, words=""):
    obj = prepare_node_data(node, req)
    if obj["deleted"]:
        # no more processing needed if this object version has been deleted
        # rendering has been delegated to current version
        return obj

    files, sum_size = filebrowser(node, req)

    obj['attachment'] = files
    obj['sum_size'] = sum_size
    obj['bibtex'] = False

    if node.getMask(u"bibtex"):
        obj['bibtex'] = True

    if node.has_object():
        obj['canseeoriginal'] = node.has_data_access()
        if node.system_attrs.get('origname') == "1":
            obj['documentlink'] = u'/doc/{}/{}'.format(node.id, node.name)
            obj['documentdownload'] = u'/download/{}/{}'.format(node.id, node.name)
        else:
            obj['documentlink'] = u'/doc/{}/{}.pdf'.format(node.id, node.id)
            obj['documentdownload'] = u'/download/{}/{}.pdf'.format(node.id, node.id)

            if not node.isActiveVersion():
                version_id = unicode(version_id_from_req(req))
                obj['documentlink'] += "?v=" + version_id
                obj['documentdownload'] += "?v=" + version_id

    else:
        obj['canseeoriginal'] = False

    obj['documentthumb'] = u'/thumb2/{}'.format(node.id)
    if not node.isActiveVersion():
        version_id = unicode(version_id_from_req(req))
        obj['documentthumb'] += "?v=" + version_id
        obj['tag'] = version_id

    # XXX: do we really need this spider filtering?
    user_agent = req.get_header("user-agent") or ""
    is_spider = "oogle" in user_agent or "aidu" in user_agent
    
    if is_spider:
        # don't confuse search engines with the PDF link
        obj['documentdownload'] = None

    full_style = req.args.get("style", "full_standard")
    if full_style:
        obj['style'] = full_style

    return obj
Beispiel #7
0
    def _prepareData(self, req):
        obj = prepare_node_data(self, req)
        if obj["deleted"]:
            # no more processing needed if this object version has been deleted
            # rendering has been delegated to current version
            return obj

        obj["highres_url"] = None

        can_see_original = self.has_data_access()

        use_flash_zoom = config.getboolean("image.use_flash_zoom",
                                           True) and self.should_use_zoom
        image_url = '/fullsize?id=%d' % self.id if use_flash_zoom else '/image/%d' % self.id
        image_url = self._add_version_tag_to_url(image_url)

        archive = get_archive_for_node(self)
        if archive:
            if can_see_original:
                obj['highres_url'] = u"/file/{nid}/{nid}.tif".format(
                    nid=self.id)
                archive_state = archive.get_file_state(self)
                if archive_state == Archive.NOT_PRESENT:
                    obj['archive_fetch_url'] = u"/archive/{}".format(self.id)
                elif archive_state == Archive.PENDING:
                    obj['archive_fetch_url'] = u"pending"
                elif archive_state == Archive.PRESENT:
                    obj['archive_fetch_url'] = None

        files, sum_size = filebrowser(self, req)

        obj['canseeoriginal'] = can_see_original
        obj['preferred_image_url'] = self.preferred_image_url
        obj["image_formats"] = self.get_image_formats()
        obj['zoom'] = self.zoom_available
        obj['image_url'] = image_url
        obj['attachment'] = files
        obj['sum_size'] = sum_size
        obj['presentation_url'] = self.presentation_url
        obj['fullsize'] = str(self.id)
        if not self.isActiveVersion():
            obj['tag'] = self.tag
            obj['fullsize'] += "&v=" + self.tag
        obj['fullsize'] = '"' + obj['fullsize'] + '"'

        full_style = req.args.get(u"style", u"full_standard")
        if full_style:
            obj['style'] = full_style

        return obj
Beispiel #8
0
    def _prepareData(self, req):
        obj = prepare_node_data(self, req)
        if obj["deleted"]:
            # no more processing needed if this object version has been deleted
            # rendering has been delegated to current version
            return obj

        obj["highres_url"] = None

        can_see_original = self.has_data_access()

        use_flash_zoom = config.getboolean("image.use_flash_zoom", True) and self.should_use_zoom
        image_url = '/fullsize?id=%d' % self.id if use_flash_zoom else '/image/%d' % self.id
        image_url = self._add_version_tag_to_url(image_url)

        archive = get_archive_for_node(self)
        if archive:
            if can_see_original:
                obj['highres_url'] = u"/file/{nid}/{nid}.tif".format(nid=self.id)
                archive_state = archive.get_file_state(self)
                if archive_state == Archive.NOT_PRESENT:
                    obj['archive_fetch_url'] = u"/archive/{}".format(self.id)
                elif archive_state == Archive.PENDING:
                    obj['archive_fetch_url'] = u"pending"
                elif archive_state == Archive.PRESENT:
                    obj['archive_fetch_url'] = None

        files, sum_size = filebrowser(self, req)

        obj['canseeoriginal'] = can_see_original
        obj['preferred_image_url'] = self.preferred_image_url
        obj["image_formats"] = self.get_image_formats()
        obj['zoom'] = self.zoom_available
        obj['image_url'] = image_url
        obj['attachment'] = files
        obj['sum_size'] = sum_size
        obj['presentation_url'] = self.presentation_url
        obj['fullsize'] = str(self.id)
        if not self.isActiveVersion():
            obj['tag'] = self.tag
            obj['fullsize'] += "&v=" + self.tag
        obj['fullsize'] = '"' + obj['fullsize'] + '"'

        full_style = req.args.get(u"style", u"full_standard")
        if full_style:
            obj['style'] = full_style

        return obj