Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Join the Playtest on Steam Now: SpiritVale

Module:Definitions/doc: Difference between revisions

From SpiritVale Wiki
Created page with "== 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 Templat..."
 
m Protected "Module:Definitions/doc" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))
Tags: Mobile edit Mobile web edit
 
(One intermediate revision by the same user not shown)
Line 47: Line 47:


* If <code>Definition</code> is empty, no tooltip is shown.
* If <code>Definition</code> is empty, no tooltip is shown.
Link rule:
* If <code>Link</code> is non-empty, the term text is rendered as a real <code>&lt;a&gt;</code> (clickable).
* If <code>Link</code> is empty, the term text is rendered as plain text (tooltip-only).


=== 3) Definitions database (JSON) ===
=== 3) Definitions database (JSON) ===
Line 104: Line 109:


* <code>data-sv-def-tip</code> (tooltip text)
* <code>data-sv-def-tip</code> (tooltip text)
* <code>data-sv-def-link</code> (reserved)
* <code>data-sv-def-link</code> (reserved / optional)


== Fallback behavior ==
== Fallback behavior ==

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 Domain and Key.
  • Output HTML with sv-def classes and data-sv-def-* attributes.

Tooltip rule:

  • If Definition is empty, no tooltip is shown.

Link rule:

  • If Link is non-empty, the term text is rendered as a real <a> (clickable).
  • If Link is 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.
  • Name and Definition are user-facing fields.
  • Icon and Link may be blank.

Supported v1 domains:

  • Cast
  • Damage
  • Element
  • Aura
  • Event
  • Stance
  • Stat
  • Target

Styling

CSS is provided by TemplateStyles:

  • Page: Template:def/styles.css
  • Namespace: sv-def only

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 Name is empty, the module displays a humanized version of the Key.
  • If Definition is empty, tooltip behavior is disabled.
  • If an icon file is missing, the module displays ? instead of a redlink image.