Module:Definitions/doc: Difference between revisions
From SpiritVale Wiki
More actions
No edit summary Tags: Mobile edit Mobile web edit |
m Protected "Module:Definitions/doc" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) Tags: Mobile edit Mobile web edit |
(No difference)
| |
Latest revision as of 20:06, 23 February 2026
Module:Definitions
This module implements the Definitions v1 system used by Template:Def. It resolves a (Domain, Key) pair against a JSON database and outputs a small inline term with optional tooltip text.
Purpose
- Provide consistent, reusable definitions across the wiki.
- Keep usage explicit to avoid collisions (no guessing).
- Allow pages to show definitions without requiring navigation.
Usage
The public interface is the template Template:Def:
{{def|Domain|Key}}
Examples:
{{def|Stat|Vit}}
{{def|Element|Fire}}
{{def|Cast|Ground}}
{{def|Target|Summon}}
System components
1) Template:def
Page: Template:def
This template calls Module:Definitions and passes the provided parameters.
2) Module:Definitions
Page: Module:Definitions
Responsibilities:
- Load the JSON database.
- Resolve
DomainandKey. - Output HTML with
sv-defclasses anddata-sv-def-*attributes.
Tooltip rule:
- If
Definitionis empty, no tooltip is shown.
Link rule:
- If
Linkis non-empty, the term text is rendered as a real<a>(clickable). - If
Linkis empty, the term text is rendered as plain text (tooltip-only).
3) Definitions database (JSON)
Page: Module:Definitions/Definitions.json
This page is the Definitions v1 database.
Schema:
{
"Schema": 1,
"UpdatedAt": "YYYY-MM-DD",
"Stat": {
"Vit": { "Name": "Vitality", "Definition": "...", "Icon": "", "Link": "" }
},
"Element": {
"Fire": { "Name": "Fire", "Definition": "", "Icon": "", "Link": "" }
}
}
Rules:
- Top-level keys are Domains (example:
Stat,Element). - Each Domain contains Keys (example:
Vit,Fire). - Keys are CamelCase and should match the intended enum key names.
NameandDefinitionare user-facing fields.IconandLinkmay be blank.
Supported v1 domains:
CastDamageElementAuraEventStanceStatTarget
Styling
CSS is provided by TemplateStyles:
- Page:
Template:def/styles.css - Namespace:
sv-defonly
JavaScript
Tooltip behavior is implemented in site JavaScript:
- Page:
MediaWiki:Common.js
The script reads:
data-sv-def-tip(tooltip text)data-sv-def-link(reserved / optional)
Fallback behavior
- Invalid arguments render an error placeholder.
- Missing records render a missing placeholder.
- If
Nameis empty, the module displays a humanized version of the Key. - If
Definitionis empty, tooltip behavior is disabled. - If an icon file is missing, the module displays
?instead of a redlink image.