Module:Recipe: Difference between revisions
maybe fix quality mis-displaying |
No edit summary |
||
| (8 intermediate revisions by 2 users not shown) | |||
| Line 43: | Line 43: | ||
end | end | ||
local function addUseCategory(category, name, sort) | local function addUseCategory(category, name, quality, sort) | ||
if not name or tostring(name) == '' then | |||
return | |||
end | |||
if quality and tostring(quality) ~= '' then | |||
if sort and tostring(sort) ~= '' then | |||
category:wikitext('[[Category:Uses ', quality, '-Quality ', name, '|', sort, ']]') | |||
else | |||
category:wikitext('[[Category:Uses ', quality, '-Quality ', name, ']]') | |||
end | |||
return | |||
end | |||
if sort and tostring(sort) ~= '' then | |||
category:wikitext('[[Category:Uses ', name, '|', sort, ']]') | |||
else | |||
category:wikitext('[[Category:Uses ', name, ']]') | |||
end | |||
end | end | ||
| Line 75: | Line 85: | ||
name = sName, | name = sName, | ||
text = sAmt, | text = sAmt, | ||
show_caption = '1 | show_caption = '1' | ||
} | } | ||
| Line 88: | Line 97: | ||
category, | category, | ||
sName, | sName, | ||
quality, | |||
padLeft(tostring(sAmt or ''):gsub('%D', ''), 10) | padLeft(tostring(sAmt or ''):gsub('%D', ''), 10) | ||
) | ) | ||
| Line 99: | Line 109: | ||
text = sText or '', | text = sText or '', | ||
show_caption = '1', | show_caption = '1', | ||
mini = '1' | mini = '1' | ||
} | } | ||
| Line 127: | Line 136: | ||
local function renderHeader(args, output, category) | local function renderHeader(args, output, category) | ||
local header = output:tag('div'):addClass(' | local header = output:tag('div'):addClass('recipe-header') | ||
local sType = args[param.sTypeArg] | local sType = args[param.sTypeArg] | ||
header:tag('span'):addClass(' | header:tag('span'):addClass('recipe-header-main') | ||
:tag('span'):addClass(' | :tag('span'):addClass('recipe-header-text'):wikitext('[[' .. sType .. ']]'):done() | ||
category:wikitext('[[Category:' .. sType .. ']]') | category:wikitext('[[Category:' .. sType .. ']]') | ||
| Line 217: | Line 224: | ||
end | end | ||
header:tag('span'):addClass(' | header:tag('span'):addClass('recipe-header-sub') | ||
:tag('span | :tag('span'):wikitext(' for '):done() | ||
:tag('span'):addClass('recipe-header-text'):wikitext(sTime):done() | |||
:tag('span'):addClass(' | |||
end | end | ||
| Line 230: | Line 236: | ||
local sCharName = args[param.sCharArg] | local sCharName = args[param.sCharArg] | ||
header:tag('span'):addClass(' | header:tag('span'):addClass('recipe-header-sub') | ||
:tag('span | :tag('span'):wikitext('[[File:' .. sCharName .. ' Icon.png|24x24px|link=' .. sCharName .. ']]'):done() | ||
:tag('span'):addClass('recipe-header-text'):wikitext('[[' .. sCharName .. ']]'):done() | |||
:tag('span'):addClass(' | |||
end | end | ||
| Line 243: | Line 248: | ||
local sKitchName = args[param.sKitchArg] | local sKitchName = args[param.sKitchArg] | ||
header:tag('span'):addClass(' | header:tag('span'):addClass('recipe-header-sub') | ||
:tag('span | :tag('span'):wikitext('[[File:' .. sKitchName .. ' Icon.png|24x24px|link=' .. sKitchName .. ']]'):done() | ||
:tag('span'):addClass('recipe-header-text'):wikitext('[[' .. sKitchName .. ']]'):done() | |||
:tag('span'):addClass(' | |||
end | end | ||
| Line 268: | Line 272: | ||
end | end | ||
local sYield = args[param.sYieldArg] or | local sYield = args[param.sYieldArg] or nil | ||
local pageTitle = getCurrentPageName(args) | local pageTitle = getCurrentPageName(args) | ||
| Line 274: | Line 278: | ||
body | body | ||
:tag('div'):addClass(' | :tag('div'):addClass('recipe-body-icon') | ||
:wikitext('➜'):done() | :wikitext('➜'):done() | ||
:tag('div'):addClass(' | :tag('div'):addClass('recipe-body-yield') | ||
:node(yieldCard) | :node(yieldCard) | ||
end | end | ||
| Line 288: | Line 292: | ||
renderCharacter(args, header) | renderCharacter(args, header) | ||
local body = output:tag('div'):addClass(' | local body = output:tag('div'):addClass('recipe-body') | ||
local sSortDelim = param.sSortDelim | local sSortDelim = param.sSortDelim | ||
| Line 340: | Line 344: | ||
local ingredient = { | local ingredient = { | ||
index = index, | index = index, | ||
amount = args[prefix .. '_amount'] or | amount = args[prefix .. '_amount'] or nil, | ||
quality = args[prefix .. '_quality'], | quality = args[prefix .. '_quality'], | ||
item = args[prefix], | item = args[prefix], | ||
| Line 396: | Line 400: | ||
local function renderCookingSplitTypeCard(category, body, ingredient) | local function renderCookingSplitTypeCard(category, body, ingredient) | ||
local qualityClass = getQualityClass(ingredient.quality or 'Gray') | |||
local container = body:tag('span') | local container = body:tag('span') | ||
| Line 460: | Line 464: | ||
local function renderCookingTypeFallback(category, body, ingredient) | local function renderCookingTypeFallback(category, body, ingredient) | ||
local wrapper = body:tag('div') | local wrapper = body:tag('div') | ||
:addClass(' | :addClass('recipe-body-cooking-ingredient') | ||
:addClass(' | :addClass('recipe-body-cooking-type-cards') | ||
for _, typeName in ipairs(ingredient.types) do | for _, typeName in ipairs(ingredient.types) do | ||
| Line 483: | Line 487: | ||
local function renderCookingOptionCards(category, body, ingredient) | local function renderCookingOptionCards(category, body, ingredient) | ||
local wrapper = body:tag('div') | local wrapper = body:tag('div') | ||
:addClass(' | :addClass('recipe-body-cooking-ingredient') | ||
:addClass(' | :addClass('recipe-body-cooking-option-cards') | ||
for _, itemName in ipairs(ingredient.options) do | for _, itemName in ipairs(ingredient.options) do | ||
| Line 518: | Line 522: | ||
end | end | ||
local sYield = args[param.sYieldArg] or | local sYield = args[param.sYieldArg] or nil | ||
local pageTitle = getCurrentPageName(args) | local pageTitle = getCurrentPageName(args) | ||
| Line 524: | Line 528: | ||
body | body | ||
:tag('div'):addClass(' | :tag('div'):addClass('recipe-body-icon') | ||
:wikitext('➜'):done() | :wikitext('➜'):done() | ||
:tag('div'):addClass(' | :tag('div'):addClass('recipe-body-yield') | ||
:node(yieldCard) | :node(yieldCard) | ||
end | end | ||
| Line 538: | Line 542: | ||
local body = output:tag('div') | local body = output:tag('div') | ||
:addClass(' | :addClass('recipe-body') | ||
:addClass(' | :addClass('recipe-body-cooking') | ||
local foundIngredient = false | local foundIngredient = false | ||
| Line 579: | Line 583: | ||
function p._main(args, frame) | function p._main(args, frame) | ||
local output = mw.html.create('div') | local output = mw.html.create('div') | ||
:addClass(' | :addClass('recipe-container') | ||
local category = mw.html.create() | local category = mw.html.create() | ||