Jump to content

Module:IA Citation/doc

From Wikipedia, the free encyclopedia

This module is the core engine for specific-source templates that cite books hosted at the Internet Archive.

This module acts as a dynamic wrapper and dispatcher. It intercepts specific parameters to build Internet Archive URLs, and passes the remaining formatted data to {{cite book}} or {{cite journal}}.

Usage

[edit]

Single edition

[edit]
<includeonly>{{#invoke:IA Citation|BOOK_NAME}}</includeonly><noinclude>
{{Documentation}}
</noinclude>

The BOOK_NAME has an entry in the appropriate Module:IA Citation/data/x file. Example: {{Template:Bosworth-The New Islamic Dynasties}}

Multiple editions

[edit]

Books with multiple editions are routed via |edition=

<includeonly>{{#switch:{{#invoke:Normalize volume and edition|edition|{{{edition|}}}}}
  | 1 = {{#invoke:IA Citation|BOOK_NAME_1990}}
  | 2 | #default = {{#invoke:IA Citation|BOOK_NAME_2007}}
}}</includeonly><noinclude>
{{Documentation}}
</noinclude>

Each edition (BOOK_NAME_1990 and BOOK_NAME_2007) has an entry in the Module:IA Citation/data/x file. Example: {{Daftary-The Ismailis}}.

Note: {{Normalize volume and edition}} will match on "Second", "2nd", "ii", etc..

Multiple volumes

[edit]

Books with multiple volumes are routed via |volume=.

<includeonly>{{#switch:{{#invoke:Normalize volume and edition|volume|{{{volume|}}}}}
  | 1 = {{#invoke:IA Citation|BOOK_NAME_V1}}
  | 2 = {{#invoke:IA Citation|BOOK_NAME_V2}}
  | 3 = {{#invoke:IA Citation|BOOK_NAME_V3}}
  | {{#invoke:IA Citation|BOOK_NAME_V1}}
}}</includeonly><noinclude>
{{Documentation}}
</noinclude>

Each volume has an entry in the Module:IA Citation/data/x file. Example: {{Catalogue of Byzantine Seals at Dumbarton Oaks and in the Fogg Museum of Art}}

Note: {{Normalize volume and edition}} will match on "1", "i", "Vol. 1", etc..

Features

[edit]
  • Rich page linking features:
    • Link URL(s) to a single page, a range of pages, or groupings of pages eg. 42-44, 64-65
    • Link a URL to Roman Numeral, photos, or any page with or without a printed page number.
    • Link a URL to a chapter or section with the custom |chapter-page= parameter in combination with |chapter=
  • Include search key terms that are highlighted, and shows other pages with the same search terms.
    • Each page link can have its own search terms e.g search on "Atlantic" in 42-44 and "Pacific" in 64-65
    • Optional "Dummy search" feature (advantage explained)
  • Optional full-screen mode
  • A single URL links to a group of books e.g. the multi-volume set of Encyclopaedia Britannica published in 1911.
  • A single URL links to multiple works by an author, or any custom combination, using the powerful search capabilities of IA's logical operators e.g. AND, OR, (), etc..
  • Link a URL for Google Books, Haithi Trust and elsewhere (but no support for page/chapter linking and most other features)

Architecture & Data Sharding

[edit]

To avoid loading a single large data table into memory, configuration data is split into alphabetical subpages (shards).

  • When invoked, the module extracts the first letter of the Book Key (e.g., "A" from "AIA4").
  • It uses `mw.loadData()` to retrieve the corresponding subpage (e.g., Module:IA Citation/data/A).
  • If the key does not start with a standard letter, it falls back to Module:IA Citation/data/OTHER.

Parameter Parsing & The "Trap and Drop"

[edit]

The module intercepts template-specific parameters (such as |ia-search= and |ia-display=) to prevent them from causing "unknown parameter" errors in the underlying CS1 template.

Custom Syntaxes

[edit]

The module parses the page= and pages= fields using `mw.ustring` to extract custom routing commands:

  • Leaf Mapping (n#): Extracted using the regex pattern %s*%(n([0-9]+)%) to route URLs to specific physical leaves when printed page numbers (like Roman numerals) do not match the digital structure.
  • Inline Search [term]: Extracted using %s*%[(.-)%] to pass a specific search term to the IA viewer.

These markers are stripped from the display text before being rendered in the final Wikipedia citation.

[edit]

A core feature of this module is its handling of the Internet Archive's restricted viewing modes.

If an editor provides a page number, the module automatically appends that number as a "dummy" search string (e.g., ?q=42). This is a necessary architectural workaround: supplying a search string forces the IA viewer to open and highlight specific pages that might be blocked due to restrictions (similar to Google Books snippet view with search strings).

Hierarchy of Overrides

[edit]

To accommodate various IA viewing restrictions, display and search behaviors are resolved in the following priority order (Highest to Lowest):

  1. Inline Brackets: page=42 [search term]
  2. User Parameter: |ia-search= or |ia-display= in the Wikipedia template call.
  3. Global Shard Default: Defined in the `Module:IA Citation/data/X` module.
  4. System Default: The alphanumeric page number (for searches) or the standard 2-up viewer (for display).

Testcases

[edit]

Testcases: Template:Catalogue of Byzantine Seals at Dumbarton Oaks and in the Fogg Museum of Art/testcases