Code Documentation

Models

class djiffy.models.Canvas(*args, **kwargs)[source]

Minimal db model representation of a canvas from an IIIF manifest

exception DoesNotExist
exception MultipleObjectsReturned
admin_thumbnail()[source]

thumbnail for convenience display in admin interface

extra_data

extra data not otherwise given its own field, serialized as json

get_absolute_url()[source]

‘url for this canvas within the django site

iiif_image_id

URL of IIIF image for this canvas

property image

Associated IIIF image for this canvas as IIIFImage

label

label

manifest

Manifest this canvas vbelongs to

next()[source]

Next canvas after this one in sequence (within manifest primary sequence). Returns an empty queryset if there is no next canvas.

order

order of this canvas within associated manifest primary sequence

property plain_text_url

Return plain text url for a canvas if one exists

prev()[source]

Previous canvas before this one in sequence (within manifest primary sequence). Returns an empty queryset if there is no next canvas.

short_id

short id extracted from URI

thumbnail

boolean flag to indicate if this canvas should be used as thumbnail

uri

URI

class djiffy.models.IIIFImage(api_endpoint=None, image_id=None, region=None, size=None, rotation=None, quality=None, fmt=None)[source]

Subclass of piffle.iiif.IIIFImageClient, for generating IIIF Image URIs for manifest canvas images.

mini_thumbnail()[source]

mini thumbnail

mini_thumbnail_size = 100

long edge size for mini thumbnail

page_size()[source]

page size for display: SINGLE_PAGE_SIZE on the long edge

single_page_size = 1000

long edge size for single page display

thumbnail()[source]
thumbnail_size = 300

long edge size for thumbnail

class djiffy.models.IIIFPresentation(*args, **kwargs)[source]

Extend iiif presentation class to add support for auth tokens when making requests on iiif urls.

classmethod get_iiif_url(url)[source]

Wrapper around requests.get() to support conditionally adding an auth tokens or other parameters.

class djiffy.models.Manifest(*args, **kwargs)[source]

Minimal db model representation of an IIIF presentation manifest

exception DoesNotExist
exception MultipleObjectsReturned
admin_thumbnail()[source]

thumbnail for convenience display in admin interface

property attribution

manifest attribution, if there is one

created

date local manifest cache was created

property creativecommons_id

short id for creative commons license

extra_data

extra data provided via a ‘seeAlso’ reference

get_absolute_url()[source]

‘url for this manifest within the django site

label

label

last_modified

date local manifest cache was last modified

property license

manifest license, if there is one

property license_image

license image, if we can generate one

license_label(lang='en')[source]

Get the text label for the rights license. Uses local value from edm rights if available; otherwise uses data for the URI to get the preferred label or title.

property license_uri

manifest license as rdflib.URIRef, if there is a license

manifest logo, if there is one

metadata

iiif presentation metadata for display

property rights_statement_id

short id for rightstatement.org license

short_id

short id extracted from URI

property thumbnail

thumbnail url for associated canvas

uri

URI

djiffy.models.get_iiif_url(url)[source]

Wrapper around requests.get() to support conditionally adding an auth token based on the domain of the request url and any AUTH_TOKENS configured in django settings.

djiffy.models.preferredLabel(graph, uri, lang)[source]

Get label or title from rdf graph for given uri with specified language. Checks for SKOS.prefLabel, RDFS.label, DC.title in that order.

Views

class djiffy.views.CanvasAutocomplete(**kwargs)[source]

Canvas autocomplete view, e.g. for admin interface lookup

get_queryset()[source]

Filter the queryset with GET[‘q’].

class djiffy.views.CanvasDetail(**kwargs)[source]

Detail view for a single Canvas. Rendered with djiffy/canvast_detail.html template.

get_object(queryset=None)[source]

Return the object the view is displaying.

Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.

model

alias of Canvas

class djiffy.views.ManifestDetail(**kwargs)[source]

Detail view for a single Manifest. Rendered with djiffy/manifest_detail.html template.

get_object(queryset=None)[source]

Return the object the view is displaying.

Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.

model

alias of Manifest

class djiffy.views.ManifestList(**kwargs)[source]

List view for Manifest. Rendered with djiffy/manifest_list.html template.

model

alias of Manifest

Import

class djiffy.importer.ManifestImporter(stdout=None, stderr=None, style=None, update=False)[source]

Manifest importer. Intended for use with Django manage commands.

Parameters:
  • stdout – optional stdout, if status output is desired

  • stderr – optional stderr, if error output is desired

  • style – optional django command style object, for styled output

canvas_short_id(canvas)[source]

Method for generating short id from canvas; default is piffle.presentation.IIIFPresentation.short_id().

error_msg(msg)[source]

Output an error message if stderr is configured (used to support output via manage command).

import_collection(manifest)[source]

Process a single IIIF collection and import all supported manifests referenced in the collection.

Parameters:

manifestIIIFPresentation

import_manifest(manifest, path)[source]

Process a single IIIF manifest and create Manifest and Canvas objects.

Parameters:
import_paths(paths)[source]

Import a list of paths - file or url, collection or manifest. Returns a list of imported manifests (includes previously imported objects for the requested URIs, if already in the database).

import_supported(manifest)[source]

Check if import is supported (currently limited to paged or individuals, left-to-right content).

output(msg)[source]

Output a message if stdout is configured (used to support output via manage command)

Manage Commands

Import manifest

Generic manage command for importing IIIF Collections or manifests into the database. Supports collections and individual manifests, and local file paths as well as URLs.

class djiffy.management.commands.import_manifest.Command(stdout=None, stderr=None, no_color=False, force_color=False)[source]

Import IIIF Collections or Manifests into the local database.

add_arguments(parser)[source]

Entry point for subclassed commands to add custom arguments.

handle(*args, **kwargs)[source]

The actual logic of the command. Subclasses must implement this method.