Module:Card: Difference between revisions
No edit summary |
i can't make this fully ZZZ or old-style without screwing up CSS. |
||
| Line 13: | Line 13: | ||
} | } | ||
local CARD_ARGS = { | local CARD_ARGS = { | ||
{ | { | ||
| Line 37: | Line 35: | ||
{ | { | ||
name = 'type', | name = 'type', | ||
}, | }, | ||
{ | { | ||
| Line 171: | Line 168: | ||
out.name = out.name or 'Unknown' | out.name = out.name or 'Unknown' | ||
-- | -- Use only a manually supplied type for lookup. | ||
out.type, out.data = p.getTypeAndData(out.name, | -- This allows {{Card|Sockeye Salmon}} to search Creature, Item, etc. | ||
local requestedType = out.nonDefaults and out.nonDefaults.type or nil | |||
out.type, out.data = p.getTypeAndData(out.name, requestedType) | |||
-- Boolean | -- Boolean params | ||
out.mini = normalizeBool(out.mini) | out.mini = normalizeBool(out.mini) | ||
out.first = normalizeBool(out.first) | out.first = normalizeBool(out.first) | ||
| Line 194: | Line 193: | ||
end | end | ||
-- Data-driven name | -- Data-driven defaults | ||
if out.data then | |||
if out.data.name then | |||
out.defaults.label = out.data.name | |||
out.defaults.caption = out.data.name | |||
end | |||
if out.data.title then | |||
out.defaults.caption = out.data.title | |||
end | |||
if out.data.quality then | |||
out.defaults.quality = out.data.quality | |||
-- Safety fallback in case TemplateData does not re-resolve | |||
-- defaults after processArgs. | |||
if not (out.nonDefaults and out.nonDefaults.quality) then | |||
out.quality = out.data.quality | |||
end | |||
end | |||
if out.data.galaxy then | |||
out.defaults.galaxy = out.data.galaxy | |||
if not (out.nonDefaults and out.nonDefaults.galaxy) then | |||
out.galaxy = out.data.galaxy | |||
end | |||
end | |||
end | end | ||
-- Quality / rarity | |||
out.quality = normalizeQuality(out.quality) | out.quality = normalizeQuality(out.quality) | ||
-- Label/text handling | -- Label/text handling | ||
if out.show_label then | if out.show_label then | ||
out.label = out. | out.label = out.data and (out.data.name or out.data.title) or out.name | ||
end | end | ||
| Line 238: | Line 255: | ||
-- Caption handling | -- Caption handling | ||
if out.show_caption and lib.isEmpty(out.caption) then | if out.show_caption and lib.isEmpty(out.caption) then | ||
out.caption = out. | if out.data then | ||
out.caption = out.data.title or out.data.name or out.name | |||
else | |||
out.caption = out.name | |||
end | |||
end | end | ||
| Line 282: | Line 303: | ||
local node_container = mw.html.create('div') | local node_container = mw.html.create('div') | ||
:addClass('card-container') | :addClass('card-container') | ||
:addClass('card-quality-' .. a.quality) | |||
if a.mini then | if a.mini then | ||
| Line 287: | Line 309: | ||
end | end | ||
-- Old-style wrapper/body structure | -- Old-style wrapper/body structure | ||
local node_card = node_container:tag('span') | local node_card = node_container:tag('span') | ||
:addClass('card-wrapper') | :addClass('card-wrapper') | ||
| Line 294: | Line 315: | ||
:addClass('card-body') | :addClass('card-body') | ||
-- Main image | -- Galaxy class on body | ||
if not a.mini and ne(a.galaxy) then | |||
node_card:addClass('card-galaxy-' .. normalizeClassName(a.galaxy)) | |||
end | |||
-- Main image | |||
node_card:tag('span') | node_card:tag('span') | ||
:addClass('card-image-container') | :addClass('card-image-container') | ||
| Line 302: | Line 328: | ||
-- Galaxy icon | -- Galaxy icon | ||
if not a.mini and ne(a.galaxy) then | if not a.mini and ne(a.galaxy) then | ||
node_card:tag('span') | node_card:tag('span') | ||
:addClass('card-icon-galaxy') | :addClass('card-icon-galaxy') | ||