Module:DPLA/doc

Category:Module documentation#DPLA/doc

This module provides helper functions for the {{DPLA metadata}} template family, which displays Digital Public Library of America file metadata directly from Structured Data on Commons (SDC). It is part of the broader DPLA partner-uploads pipeline; the same metadata that an automated bot (User:DPLA bot) writes to a file's MediaInfo via the sdc-sync step is what this module reads back out for display.

Each function filters the file's SDC statements on the determination-method qualifier (determination method or standard (P459) = determined by GLAM institution and stated at its website (Q61848113), "heuristic"). Statements without that qualifier are ignored — this is the marker that distinguishes statements added by the DPLA workflow from statements added by other tools or editors, and ensures we only surface metadata we own.

The module is meant to be invoked from wikitext via {{#invoke:DPLA|function}}; it does not currently expose a module-to-module API (use {{DPLA metadata}} or the individual functions from your template instead).

Example

A file page rendered via {{DPLA metadata}} will populate the standard {{Information}} block from SDC alone. To inspect a single field directly:

Creator: {{#invoke:DPLA|creator}}

On File:Baist's real estate atlas of surveys of Denver, Col. (Plate 29) - DPLA - e676ae8aea3e4a855bce073ba419bb4e.jpg the result would look like this:

Creator: Baist, G. Wm. (George William), 1859-1927

For testing or reuse on non-file pages, every function accepts a |page= argument pointing at a specific Commons file:

{{#invoke:DPLA|creator|page=File:Foo.jpg}}

Functions

All functions take optional named arguments. |page= overrides the entity to read from (default: the current page's MediaInfo). |sep= (where supported) overrides the separator used to join multiple values (default: , ).

Display / prose helpers

hub

Returns the regional DPLA hub's display name, derived from the Commons media contributed by (P9126) (Wikimedia partnership) chain. Each DPLA-determined file has two publisher entries by design — DPLA itself (Digital Public Library of America (Q2944483)) and the regional hub that aggregates the contributing institution's records (e.g. Plains to Peaks Collective (Q83878503) for the Plains to Peaks Collective). This function returns the label of the non-DPLA publisher.

Returns an empty string if no qualifying hub entry is present.

Wikitext usage:

{{#invoke:DPLA|hub}}

subjects

Returns the union of entity subjects (main subject (P921)) and string subjects (DPLA subject term (P4272)), deduplicated by exact match. Entity subjects are rendered as their Wikidata labels (no link); string subjects are rendered verbatim. Order: P921 first (in entity statement order), then any P4272 strings whose verbatim form isn't already covered by a P921 label.

This addresses a gap in the previous {{DPLA metadata}}, which read only P921 — many DPLA items have only the string form because the source data's subject headings (often Library of Congress Subject Headings) don't reconcile to Wikidata QIDs.

Wikitext usage:

{{#invoke:DPLA|subjects}}
{{#invoke:DPLA|subjects|sep= — }}

creator

Returns the creator(s). Each creator (P170) statement may be:

  • an entity (, rendered as the Wikidata label),
  • a string (rendered verbatim — used when ingestion3 had a creator name string but no entity match), or
  • a "somevalue" snak with a author name string (P2093) stated-as qualifier (used when the specific creator identity is unknown but a name string is given by the contributing institution).

Multiple statements are joined with |sep= (default , ). Returns an empty string if no creator statement is present.

Wikitext usage:

{{#invoke:DPLA|creator}}

date

Returns the date. Tries each DPLA-determined inception (P571) (point in time) statement in turn:

  • If the mainsnak is a real time value, formats it with the precision recorded in the snak: day → YYYY-MM-DD, month → YYYY-MM, year → YYYY.
  • If the mainsnak is a "somevalue" with a object named as (P1932) stated-as qualifier, returns the qualifier text. This is how DPLA encodes circa dates, date ranges, and other non-machine-readable date expressions.

Returns the first usable rendering; empty string if none.

Wikitext usage:

{{#invoke:DPLA|date}}

local_id

Returns a wikitext bullet item with the local identifier prefixed by the appropriate label:

Returns an empty string if no identifier is present.

Wikitext usage:

{{#invoke:DPLA|local_id}}

Identity / partnership helpers

hub_qid

Same lookup as {{#invoke:DPLA|hub}}, but returns the bare Q-ID string (e.g. Q83878503) rather than its label. Suitable as input to {{Label}}, {{Institution}}, or further Wikidata data lookups (e.g. fetching the hub's logo or category property). Empty string if no qualifying publisher entry is present.

institution_qid

Returns the Q-ID of the file's institution (from collection (P195), the collection property). Used to address the institution in the partnership prose and to look up the institution's category. By DPLA convention the collection (P195) institution and the Commons media contributed by (P9126) entry with role = repository (Q108296843) (aggregator) are the same Q-ID; this helper uses P195 because it matches the existing {{DPLA}} template's visible-prose convention.

dpla_id

Returns the file's DPLA item ID (the 32-character hex string from DPLA ID (P760)). Used to construct the https://dp.la/item/... link in the partnership info-box and to gate the SDC-presence check in {{DPLA metadata}}. Empty string if absent.

source_catalog_url

Returns the URL from the file's source of file (P7482) (source of file) statement's described at URL (P973) (described at URL) qualifier — i.e. the contributing institution's own page for this item. Used as the target of the "Record in source catalog" link. Empty string if absent.

Returns the |File:=-prefixed page name for the partner logo to show in the partnership info-box. Looks up the hub's Wikidata item for logo image (P154) (logo image) first, then image (P18) (image) as a fallback. If neither is set (or no hub is present), returns File:DPLA square logo.svg.

categories

Emits the full set of DPLA partner / institution categories for this file as wikitext. Replaces the {{DPLA/hub cat}} and {{DPLA/inst cat}} subpages used by the live {{DPLA}} template, and also emits the main parent category. The returned wikitext is one or more Category:Ellipses (punctuation) links, newline-separated:

Wikitext usage (typically placed at the bottom of {{DPLA metadata}}'s body, outside the divbox):

{{#invoke:DPLA|categories}}

Property reference

The module reads the following SDC properties. All are filtered by the determination method or standard (P459) = determined by GLAM institution and stated at its website (Q61848113) qualifier unless noted.

PropertyDescriptionUsed by
creator (P170)creatorcreator
collection (P195)collection (institution)institution_qid, local_id
inventory number (P217)collection-or-list identifierlocal_id
inception (P571)point in time (date)date
DPLA ID (P760)DPLA IDdpla_id
main subject (P921)main subject (Wikidata entity)subjects
U.S. National Archives Identifier (P1225)NARA archival identifierlocal_id
object named as (P1932)stated as (qualifier on P571)date
author name string (P2093)author name string (qualifier on P170)creator
object of statement has role (P3831)object has role (qualifier on P9126)hub, hub_qid, partner_logo, categories
DPLA subject term (P4272)subject headingsubjects
source of file (P7482)source of filesource_catalog_url
described at URL (P973)described at URL (qualifier on P7482)source_catalog_url
Commons media contributed by (P9126)Wikimedia partnershiphub, hub_qid, partner_logo, categories

In addition, the module performs Wikidata lookups (not SDC) on the hub's, institution's, and contributing-institutions' Q-IDs to fetch:

Testing

Template:DPLA metadata/testcases runs each function against a sample of real file pages and shows the outputs of the live module alongside the {{Module:DPLA/sandbox}} version side by side. When iterating on the module, edit the sandbox and reload the testcases page to compare.

(The wikitext-style side-by-side page lives in template namespace rather than {{Module:DPLA/testcases}} because Commons defaults pages under {{Module:}} to the Lua content model; if we add programmatic unit tests later, those would live at {{Module:DPLA/testcases}} using {{Module:UnitTests}}.)

See also

Category:Ellipses (punctuation) Category:Module documentation