Module:SST/hosts/doc
| This is a documentation subpage for Module:SST/hosts. It may contain usage information, categories and other content that is not part of the original module page. |
| This is a documentation subpage for Module:SST/hosts. It may contain usage information, categories and other content that is not part of the original module page. |
This module is the core processing engine for the Specific-Source Template System (SSTS). It is called exclusively by the router (Module:SST) and is responsible for parsing custom page string syntaxes, generating host-specific URLs, and deep-linking to digital archives.
Architecture
[edit]The module is divided into three main operational phases: the Orchestrator, the Parser, and the Engines.
1. The Orchestrator (Parameter Parsing)
[edit]When called by the router, the p.process function iterates through the arguments passed by the Wikipedia editor.
- It intercepts the
|page=,|pages=, and|chapter-page=parameters and sends them to the parser. - It safely "traps and drops" system-specific parameters (such as
|ia-search=and|ia-display=) to prevent them from causing "unknown parameter" errors when the final arguments are passed to the underlying CS1/CS2 template. - If no deep-links are generated from the page numbers, it calls the engine's
build_base_urlfunction to ensure the main title of the citation is linked to the book's landing page.
2. The Parser (Custom Syntaxes)
[edit]The module parses the page fields by splitting them at commas and extracting custom routing commands for each page grouping.
- Machine Leaf Mapping
(@): Extracted using string matching to route URLs to specific physical leaves when printed page numbers (like Roman numerals) do not match the digital structure. The display text remains on the left, while the machine code is processed on the right. - Search Highlighting
([ ]): Extracted using the pattern%[(.-)%]to pass a specific search term directly into the digital viewer.
These markers are stripped from the display text before being rendered in the final Wikipedia citation, leaving clean, standard CS1 output.
3. The Engines (Host Logic)
[edit]SSTS supports multiple digital libraries. Each host has its own sub-table in the module (e.g., p.IA, p.Hathi) defining exactly how to construct its URLs.
- Internet Archive (IA): Constructs URLs for the BookReader. It supports the
ia-display="full screen"override (switching the endpoint from/details/to/stream/). - HathiTrust (Hathi): Converts the machine leaf into a
seq=parameter and passes search terms toq1=. - Project Gutenberg (Gutenberg): Deep-links using HTML anchors (
#page-). Strips the leading "u" from the machine code. - Wikisource (Wikisrc): Bypasses external URLs entirely. It constructs an internal wikilink to the exact Page namespace (
s:Page:File/Leaf) using the file extension defined in the shard. - Google Books (GBook): Converts the machine leaf to a
pg=parameter and passes search terms todq=. - Web: For books hosted on other web pages as PDFs etc. It ignores page-level deep-linking and search highlighting.
- Physical: For books without a digital footprint. It suppresses deep-linking and base URLs, ensuring only the physical printed page numbers are displayed.
The Internet Archive "Dummy Search"
[edit]A core feature of the IA engine is its handling of restricted viewing modes.
If an editor provides a page number, the IA engine automatically appends that number as a "dummy" search string (e.g., ?q=42) unless an explicit bracketed search term is provided. This is a necessary architectural workaround: supplying a search string forces the IA viewer to open and highlight specific pages that might otherwise be blocked due to lending restrictions (similar to Google Books snippet view).
Hierarchy of Overrides (IA)
[edit]To accommodate various IA viewing restrictions, display and search behaviors are resolved in the following priority order (Highest to Lowest):
- Inline Brackets:
page=42 [search term] - User Parameter:
|ia-search=in the Wikipedia template call. - Global Shard Default: Defined in the
Module:SST/shards/Xfile (e.g., settingiasearch="none"disables the dummy search). - System Default: The alphanumeric printed page number.