Module:Definitions: Difference between revisions
From SpiritVale Wiki
More actions
Created page with "-- Module:Definitions -- Core resolver + renderer for {{def|Domain|Key}} (Definitions v1). -- -- Data source (static): -- Module:Definitions/Definitions.json -- -- JSON shape (dynamic): -- { -- "Schema": 1, -- "UpdatedAt": "YYYY-MM-DD", -- "Stat": { "Vit": { "Name":"...", "Definition":"...", "Icon":"", "Link":"" }, ... }, -- "Target": { ... }, -- ... -- } -- -- Notes: -- - Domains + keys are discovered from JSON (no hardcoded domain lists). -- - CSS namespa..." |
No edit summary |
||
| Line 16: | Line 16: | ||
-- Notes: | -- Notes: | ||
-- - Domains + keys are discovered from JSON (no hardcoded domain lists). | -- - Domains + keys are discovered from JSON (no hardcoded domain lists). | ||
-- - CSS namespace: ONLY "sv-def" (plus sv-def--* modifiers). | -- - CSS namespace: ONLY "sv-def" (plus sv-def--* modifiers). | ||
-- - For TemplateStyles compatibility: use simple classes (sv-def-icon / sv-def-text) | |||
-- instead of attribute selectors. | |||
local p = {} | local p = {} | ||
| Line 105: | Line 107: | ||
for k, v in pairs(db) do | for k, v in pairs(db) do | ||
if type(v) == "table" and lc(k) == want then | if type(v) == "table" and lc(k) == want then | ||
if k ~= "Schema" and k ~= "UpdatedAt" then | if k ~= "Schema" and k ~= "UpdatedAt" then | ||
return k | return k | ||
| Line 122: | Line 123: | ||
-- ============================================================================= | -- ============================================================================= | ||
-- Icon rendering ( | -- Icon rendering | ||
-- - Blank icon: show "i" (generic info icon for v1) | |||
-- - Missing file: show "?" (missing asset) | |||
-- ============================================================================= | -- ============================================================================= | ||
| Line 129: | Line 132: | ||
if icon == "" then | if icon == "" then | ||
return '<span | return '<span class="sv-def-icon" aria-hidden="true">i</span>' | ||
end | end | ||
| Line 139: | Line 142: | ||
local t = mw.title.new(fileTitle) | local t = mw.title.new(fileTitle) | ||
if not t or not t.exists then | if not t or not t.exists then | ||
return '<span | return '<span class="sv-def-icon" aria-hidden="true">?</span>' | ||
end | end | ||
return '<span class="sv-def-icon">[[' .. fileTitle .. '|16px|link=]]</span>' | |||
return '<span | |||
end | end | ||
| Line 193: | Line 195: | ||
'<span ' .. table.concat(attrs, " ") .. title_attr .. '>' .. | '<span ' .. table.concat(attrs, " ") .. title_attr .. '>' .. | ||
icon_html(icon) .. | icon_html(icon) .. | ||
'<span | '<span class="sv-def-text">' .. mw.text.nowiki(name) .. '</span>' .. | ||
'</span>' | '</span>' | ||
if rec == nil then | if rec == nil then | ||
html = | html = | ||
'<span class="sv-def sv-def--missing" data-sv-def-domain="' .. enc_attr(domain) .. | '<span class="sv-def sv-def--missing" data-sv-def-domain="' .. enc_attr(domain) .. | ||