コード例 #1
0
 def test_thumb_image_url(self):
     p = Page.objects.get(pk="3")
     self.assertEqual(p.jp2_filename,
                      "sn83030214/00175037652/1898010101/0003.jp2")
     self.assertEqual(
         image_urls.thumb_image_url(p),
         "https://oni.example.com/images/iiif/batch_curiv_ahwahnee_ver01%2Fdata%2Fsn83030214%2F00175037652%2F1898010101%2F0003.jp2/full/240,/0/default.jpg"
     )
コード例 #2
0
ファイル: models.py プロジェクト: AndrewGearhart/open-oni
    def json(self, host, serialize=True):
        j = {
            "thumbnail":
            thumb_image_url(self),
            "height":
            self.jp2_length,
            "width":
            self.jp2_width,
            "images": [{
                "resource": {
                    "service": {
                        "@id": iiif_info_for_page(self),
                        "@context": "http://iiif.io/api/image/2/context.json",
                        "profile": "http://iiif.io/api/image/2/level0.json"
                    },
                    "format": "image/jpeg",
                    "height": self.jp2_length,
                    "width": self.jp2_width,
                    "@id": iiif_info_for_page(self),
                    "@type": "dctypes:Image"
                },
                "motivation":
                "sc:painting",
                "@id":
                iiif_info_for_page(self),
                "@type":
                "oa:Annotation",
                "on":
                iiif_info_for_page(self),
                "rendering": [{
                    "@id": settings.BASE_URL + self.pdf_url,
                    "format": "application/pdf"
                }, {
                    "@id": settings.BASE_URL + self.jp2_url,
                    "format": "image/jp2"
                }, {
                    "@id": settings.BASE_URL + self.url,
                    "format": "text/html"
                }],
                "seeAlso": [{
                    "@id": settings.BASE_URL + self.ocr_url,
                    "format": "text/xml"
                }]
            }],
            "label":
            str(self.sequence),
            "@id":
            iiif_info_for_page(self),
            "@type":
            "sc:Canvas"
        }

        if serialize:
            return json.dumps(j, indent=2)
        return j
コード例 #3
0
    def json(self, host, serialize=True):
        if self.relative_image_path is None:
            # If there's no image, we have to fake all the data just so IIIF
            # isn't completely busted.  We give a fake ID and use standard U.S.
            # Broadsheet dimensions (at 300dpi) for the width / height.
            j = {
                "@id": page_iiif_info_url(self),
                "@type": "sc:Canvas",
                "label": str(self.sequence),
                "width": 4500,
                "height": 6825,
                "metadata": [
                    {"label": "Note about reproduction", "value": "Not digitized, published"},
                ],
            }
        else:
            j = {
                "thumbnail": thumb_image_url(self),
                "height": self.jp2_length,
                "width": self.jp2_width,
                "images": [{
                    "resource": {
                        "service": {
                            "@id": page_iiif_info_url(self),
                            "@context": "http://iiif.io/api/image/2/context.json",
                            "profile": "http://iiif.io/api/image/2/level0.json"
                        },
                        "format": "image/jpeg",
                        "height": self.jp2_length,
                        "width": self.jp2_width,
                        "@id": page_iiif_info_url(self),
                        "@type": "dctypes:Image"
                    },
                    "motivation": "sc:painting",
                    "@id": page_iiif_info_url(self),
                    "@type": "oa:Annotation",
                    "on": page_iiif_info_url(self),
                    "rendering": [
                        {"@id": settings.BASE_URL + self.pdf_url, "format": "application/pdf"},
                        {"@id": settings.BASE_URL + self.jp2_url, "format": "image/jp2"},
                        {"@id": settings.BASE_URL + self.url, "format": "text/html"}
                    ],
                    "seeAlso": [
                        {"@id": settings.BASE_URL + self.ocr_url, "format": "text/xml"}
                    ]
                }],
                "label": str(self.sequence),
                "@id": page_iiif_info_url(self),
                "@type": "sc:Canvas"
            }

        if serialize:
            return json.dumps(j, indent=2)
        return j
コード例 #4
0
ファイル: rdf.py プロジェクト: johnscancella/open-oni
def page_to_graph(p, g=None):
    if not g:
        g = make_graph()

    uri = abstract_uri(p)
    g.add((uri, RDF.type, NDNP['Page']))
    g.add((uri, NDNP['sequence'], Literal(p.sequence)))
    g.add((uri, ORE['isAggregatedBy'], abstract_uri(p.issue)))

    jp2_uri = URIRef(p.jp2_url)
    g.add((uri, ORE['aggregates'], jp2_uri))
    g.add((jp2_uri, DC['format'], Literal('image/jp2')))
    g.add((jp2_uri, EXIF['width'], Literal(p.jp2_width)))
    g.add((jp2_uri, EXIF['height'], Literal(p.jp2_length)))

    ocr_uri = URIRef(p.ocr_url)
    g.add((uri, ORE.aggregates, ocr_uri))
    g.add((ocr_uri, DC['format'], Literal('text/xml')))

    pdf_uri = URIRef(p.pdf_url)
    g.add((uri, ORE.aggregates, pdf_uri))
    g.add((pdf_uri, DC['format'], Literal('application/pdf')))

    txt_uri = URIRef(p.txt_url)
    g.add((uri, ORE.aggregates, txt_uri))
    g.add((txt_uri, DC['format'], Literal('text/plain')))

    thumb_uri = URIRef(image_urls.thumb_image_url(p))
    g.add((uri, ORE.aggregates, thumb_uri))
    g.add((uri, FOAF.depiction, thumb_uri))
    g.add((thumb_uri, DC['format'], Literal('image/jpeg')))
    g.add(
        (uri, DCTERMS['issued'], Literal(p.issue.date_issued,
                                         datatype=XSD.date)))
    g.add((uri, DCTERMS['title'],
           Literal(
               '%s - %s - %s' %
               (p.issue.title.display_name, p.issue.date_issued, p.sequence))))

    if p.number:
        g.add((uri, NDNP['number'], Literal(p.number)))
    if p.section_label:
        g.add((uri, NDNP['section'], Literal(p.section_label)))

    add_rem(g, uri, rdf_uri(p))

    return g
コード例 #5
0
ファイル: rdf.py プロジェクト: open-oni/open-oni
def page_to_graph(p, g=None):
    if not g:
        g = make_graph()

    uri = abstract_uri(p)
    g.add((uri, RDF.type, NDNP['Page']))
    g.add((uri, NDNP['sequence'], Literal(p.sequence)))
    g.add((uri, ORE['isAggregatedBy'], abstract_uri(p.issue)))

    jp2_uri = URIRef(p.jp2_url)
    g.add((uri, ORE['aggregates'], jp2_uri))
    g.add((jp2_uri, DC['format'], Literal('image/jp2')))
    g.add((jp2_uri, EXIF['width'], Literal(p.jp2_width)))
    g.add((jp2_uri, EXIF['height'], Literal(p.jp2_length)))

    ocr_uri = URIRef(p.ocr_url)
    g.add((uri, ORE.aggregates, ocr_uri))
    g.add((ocr_uri, DC['format'], Literal('text/xml')))

    pdf_uri = URIRef(p.pdf_url)
    g.add((uri, ORE.aggregates, pdf_uri))
    g.add((pdf_uri, DC['format'], Literal('application/pdf')))

    txt_uri = URIRef(p.txt_url)
    g.add((uri, ORE.aggregates, txt_uri))
    g.add((txt_uri, DC['format'], Literal('text/plain')))

    thumb_uri = URIRef(image_urls.thumb_image_url(p))
    g.add((uri, ORE.aggregates, thumb_uri))
    g.add((uri, FOAF.depiction, thumb_uri))
    g.add((thumb_uri, DC['format'], Literal('image/jpeg')))
    g.add((uri, DCTERMS['issued'], Literal(p.issue.date_issued,
                                           datatype=XSD.date)))
    g.add((uri, DCTERMS['title'], Literal('%s - %s - %s' %
        (p.issue.title.display_name, p.issue.date_issued, p.sequence))))

    if p.number:
        g.add((uri, NDNP['number'], Literal(p.number)))
    if p.section_label:
        g.add((uri, NDNP['section'], Literal(p.section_label)))

    add_rem(g, uri, rdf_uri(p))

    return g
コード例 #6
0
ファイル: models.py プロジェクト: open-oni/open-oni
    def json(self, host, serialize=True):
        j = {
            "thumbnail": thumb_image_url(self),
            "height": self.jp2_length,
            "width": self.jp2_width,
            "images": [{
                "resource": {
                    "service": {
                        "@id": iiif_info_for_page(self),
                        "@context": "http://iiif.io/api/image/2/context.json",
                        "profile": "http://iiif.io/api/image/2/level0.json"
                    },
                    "format": "image/jpeg",
                    "height": self.jp2_length,
                    "width": self.jp2_width,
                    "@id": iiif_info_for_page(self),
                    "@type": "dctypes:Image"
                },
                "motivation": "sc:painting",
                "@id": iiif_info_for_page(self),
                "@type": "oa:Annotation",
		"on": iiif_info_for_page(self),
                "rendering": [
                    {"@id": settings.BASE_URL + self.pdf_url, "format": "application/pdf"},
                    {"@id": settings.BASE_URL + self.jp2_url, "format": "image/jp2"},
                    {"@id": settings.BASE_URL + self.url, "format": "text/html"}
                ],
                "seeAlso": [
                    {"@id": settings.BASE_URL + self.ocr_url, "format": "text/xml"}
                ]
            }],
            "label": str(self.sequence),
            "@id": iiif_info_for_page(self),
            "@type": "sc:Canvas"
        }

        if serialize:
            return json.dumps(j, indent=2)
        return j
コード例 #7
0
ファイル: image_urls.py プロジェクト: johnscancella/open-oni
def thumb_image_url(page):
    return image_urls.thumb_image_url(page)
コード例 #8
0
ファイル: image_urls.py プロジェクト: open-oni/open-oni
def thumb_image_url(page):
    return image_urls.thumb_image_url(page)