Modules¶
-
class
digital_milliet.lib.commentaries.
CommentaryHandler
(db=None, authors=None, config=None, auth=None)[source]¶ Parses data for retrieval/storage to/from the database
-
__init__
(db=None, authors=None, config=None, auth=None)[source]¶ CommentaryHandler object
Parameters: - db (PyMongo) – Mongo Db Handle
- authors (AuthorBuilder) – helper for building new Author records
- config (dict) – configuration dictionary
-
__weakref__
¶ list of weak references to the object (if defined)
-
create_commentary
(form)[source]¶ Save a new set of annotations from the input form
Parameters: form (dict) – key/value pairs from input form Returns: the Milliet number for the saved annotations or None if the record couldn’t be saved Return type: string
-
create_tag_annotation
(tag, target, creator, date)[source]¶ Create a tag annotation
Parameters: - tag (string) – the tag (text or a URI)
- target (string) – the target of the annotation
- creator (dict) – the creator of the annotation
- date (date) – the date the annotation was created
Returns: Annotation content to set at annotation[“tags”]
-
form_to_OpenAnnotation
(form)[source]¶ Make a structure for the annotation from a set of key/value pairs
Parameters: form (dict) – key/value pairs from the form Returns: the annotation Return type: dict
-
format_manifests_from_form
(manifest_uri, publisher, date, milnum, update_anno=None)[source]¶ Helper to format IIIF Manifests given a form
Parameters: - manifest_uri – Manifest URI
- publisher – Publisher
- date – Current date (Isocode)
- milnum – Current milnum
Returns: Value to set at annotation[“images”]
-
format_person_from_authentificated_user
()[source]¶ Make a Person for an annotation (i.e for contributor or creator) Uses the URI identifier for the user of the currently authenticated session
Returns: Person properties suitable for inclusion in the annotation Return type: dict
-
format_translation_annotation
(num, milnum, text, uri, own_uri, lang)[source]¶ Build the body of a translation annotation.
Parameters: - num (string) – the translation identifier (t1 or t2)
- milnum (string) – the Milliet number for the annotation
- text (String) – the text of the translation (None if uri or own_uri is supplied)
- uri (string) – the uri of a translation - this is expected to be a CTS URN that appears in the linked cts repository
- own_uri (string) – an user-supplied uri for a translation - this is for an externally linked translation text
- lang (string) – the language code of the translation (‘fra’ or ‘eng’)
Returns: the body of the translation annotation
Return type: string (for a URI) or dict (if an embedded body)
-
format_uri
(milliet_id, subcollection_id=None)[source]¶ Make a Cite Collection URI for an annotation
N.B. this is not a valid implementation of the CITE protocol, as it does not support CITE collections. Future implementations should consider replacing this with a different identifier syntax.
Param: milliet_id: The Milliet number Type: milliet_id: string Param: subcollection_id: the subcollection identifier (e.g. commentary, bibliography, etc.) Type: string Returns: the compiled URI Return type: string
List all existing tag body values
Returns: tags and semantic tags Return type: tuple
-
get_milliet
(milliet_id, simplify=True)[source]¶ Get the first set of annotations that target the supplied Milliet Number
Parameters: - milliet_id – Milliet Number
- simplify (bool) – If set to True, simplify for the view
Returns: Tuple where first element is the set of annotations and the second the author informations
Return type: Raises: 404 Not Found Exception – if the annotation is not found
-
get_milliet_identifier_list
()[source]¶ List all known milliet numbers
Returns: List of Milliet Numbers and their commentary ID ? Return type: tuple
-
get_surrounding_identifier
(cid)[source]¶ Given a Milliet number, return the previous and next numbers available
Parameters: cid (string) – Milliet number Returns: pair of Milliet numbers Return type: (string, string)
-
remove_milliet
(milliet_id)[source]¶ Remove the annotation set that targets the supplied Milliet Number
Parameters: millnum – Milliet Number Returns: the number of records removed Return type: int Raises: 404 Not Found Exception – if the annotation is not found
-
retrieve_millietId_in_commentaries
(commentaries)[source]¶ Extract a sorted list of Milliet ID from a set of commentary annotations
Parameters: commentaries (list) – set of commentary annotations Returns: sorted list of extracted Milliet numbers Return type: list
-
search
(query, tags=None)[source]¶ Search commentary record (Filters are exclusive) currently only searching in tags is supported
Parameters: - query – String to search
- tags – Search in tags
Returns: List of matching records
-
simplify_milliet
(annotation_set)[source]¶ Parse a db record into a dict setup for views
Parameters: annotation_set (dict) – the db record Returns: Parsed version of the record Return type: dict
-
update_commentary
(form)[source]¶ Save an edited set of annotations to the db
Parameters: form (dict) – key/value pairs from edit form Returns: True if successful False if not Return type: bool
-
update_contributors
(annotation_dict=None)[source]¶ Update the contributors for an annotation
Inserts a Person object for the currently authenticated user if she doesn’t already appear as either creator or contributor.
Parameters: annotation_dict (dict) – the annotation to update
-
validate_annotation
(annotation)[source]¶ Validate the structure of an annotation.
This is not foolproof but it attempts to catch some errors that could come in from mistakes in data entry. It would be good to make sure these all couldn’t occur to begin with.
Parameters: annotation (dict) – the annotation record Returns: True if valid False if not Return type: bool
-
Provides methods for building new Author records in the database
Constructor
Parameters: - db (PyMongo) – Mongo Db Handle
- catalog (Catalog) – Catalog API Manager
list of weak references to the object (if defined)
Adds or Updates Author Records in the Annotation Database
Author Records contain authority name and work information and are populated as annotations referencing an author and work are added to the annotator store so that they can be used for browsing
Parameters: data_dict (dict) – the full annotation
Get a list of authors
Returns: List of authors record
Quick access to Mongo collection
Retrieve an author record by CTS ID
Parameters: cts_id – CTS Identifier Returns: Author Record
Retrieve an author record by Mongo Id
Parameters: _id – Mongo Unique Identifier Returns: Author Record
” Make an Author db record from a catalog record and insert it in the database
Parameters: resp (dict) – the response from teh catalog lookup Returns: the new Author db record Return type: dict
Make a work record from a catalog record
Parameters: - work_id (string) – the CTS URN of a work
- millnum (string) – the Milliet number
- pasg (string) – the passage component from the work
Returns: the work record
Return type:
Extract a sorted list of milliet numbers from a set of commentary annotations
Parameters: comm_list (list) – set of commentary annotations Returns: sorted list of milliet numbers Return type: list
Remove milliet number mapping from an author record
Parameters: millnum (string) – the milliet number to remove Returns: Number of mappings removed
Search authors record (Filters are exclusive)
Parameters: - query – String to search
- name – Search in Name
- works – Search in Works
Returns: List of matching records
Update author identified by CTS_ID
Parameters: - cts_id – CTS Identifier
- author_record – Updated Author Record
Returns: Result of update
-
class
digital_milliet.lib.catalog.
Catalog
(app=None)[source]¶ Provides an interface to a Catalog API Endpoint which can lookup author and work records by CTS URN
-
__weakref__
¶ list of weak references to the object (if defined)
Looks up an Author by authority id in the remote Catalog API endpoint
Parameters: urn (string) – The authority id (i.e textgroup CTS URN) Returns: response from the API (this should be abstracted) Return type: dict
-
-
class
digital_milliet.lib.oauth.
OAuthHelper
(app)[source]¶ Helper class providing OAuth2 functionality to the application Implements flask_oauthlib.client
-
__weakref__
¶ list of weak references to the object (if defined)
-
static
current_user
()[source]¶ Gets the current user from the session
Returns: { uri => <uri>, name => <name> } Return type: dict
-
static
oauth_required
(f)[source]¶ decorator to add to a view to require an oauth user
Returns: decorated function Return type: func
-
static
oauth_token
(token=None)[source]¶ tokengetter function
Parameters: token (string) – the Oauth token Returns: the current access token Return type: string
Route for OAuth2 Authorization callback
Returns: renders template
-
r_oauth_login
()[source]¶ Route for OAuth2 Login
Parameters: next (string) – next url Returns: Redirects to OAuth Provider Login URL
-
static
r_oauth_logout
()[source]¶ Route to clear the oauth data from the session
Parameters: next (string) – next url Returns: redirects to next or renders template
-
user_in_community
(user_communities=None)[source]¶ Checks to see if the user is the authorized community for editing
This is a hack specific to the Perseids OAuth provider used as a way to limit editing of DM records to members of a specific community in Perseids Eventually editing could be delegated entirely to Perseids
Returns: True if the user name is listed in the configured community members, False if the user name is not listed Return type: bool
-
-
class
digital_milliet.lib.mirador.
Mirador
(db, app, parser)[source]¶ Parses data for retrieval/storage to/from the database
-
__init__
(db, app, parser)[source]¶ Mirador object
Parameters: - db (PyMongo) – Mongo Db Handle
- app (Flask) – Flask App
- parser (CommentaryHandler) – CommentaryHandler
-
__weakref__
¶ list of weak references to the object (if defined)
-
static
dump
(content, code=200)[source]¶ (View system) Returns a response in json with given code
Parameters: - content – BSON encodable object
- code – HTTP Status Code
Returns: Response
-
from_collection
(digitial_milliet_id)[source]¶ Retrieve a list of annotations from a collection
Parameters: digitial_milliet_id (str) – ID of the Digital Milliet Collection Returns: List of annotation
-
get
(image_uri=None, anno_id=None, _id=None, single=False)[source]¶ Retrieve annotations
Parameters: Returns: List of Annotations matching the filters
-