Module:Recipe: Difference between revisions

mNo edit summary
No edit summary
 
(5 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
if not name or tostring(name) == '' then
    return
return
  end
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 then
if sort and tostring(sort) ~= '' then
    category:wikitext('[[Category:Uses ', name, '|', sort, ']]')
category:wikitext('[[Category:Uses ', name, '|', sort, ']]')
  else
else
    category:wikitext('[[Category:Uses ', name, ']]')
category:wikitext('[[Category:Uses ', name, ']]')
  end
end
end
end


Line 75: Line 85:
     name = sName,
     name = sName,
     text = sAmt,
     text = sAmt,
     show_caption = '1',
     show_caption = '1'
    mobile = 'bulleted'
   }
   }


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',
    mobile = 'bulleted',
     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('recipe_header')
   local header = output:tag('div'):addClass('recipe-header')
   local sType = args[param.sTypeArg]
   local sType = args[param.sTypeArg]


   header:tag('span'):addClass('recipe_header_main')
   header:tag('span'):addClass('recipe-header-main')
     :tag('span'):addClass('mobileHide'):wikitext('<big>' .. sType .. '</big>'):done()
     :tag('span'):addClass('recipe-header-text'):wikitext('[[' .. sType .. ']]'):done()
    :tag('span'):addClass('mobileHide'):wikitext('<big>' .. sType .. '</big>'):done()
    :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('recipe_header_sub')
   header:tag('span'):addClass('recipe-header-sub')
     :tag('span'):addClass('mobileHide'):wikitext(' for '):done()
     :tag('span'):wikitext(' for '):done()
    :tag('span'):addClass('hidden'):wikitext(' for '):done()
     :tag('span'):addClass('recipe-header-text'):wikitext(sTime):done()
     :tag('span'):addClass('recipe_header_text'):wikitext(sTime):done()
end
end


Line 230: Line 236:
   local sCharName = args[param.sCharArg]
   local sCharName = args[param.sCharArg]


   header:tag('span'):addClass('recipe_header_sub')
   header:tag('span'):addClass('recipe-header-sub')
     :tag('span'):addClass('mobileHide'):wikitext(' with '):done()
     :tag('span'):wikitext('[[File:' .. sCharName .. ' Icon.png|24x24px|link=' .. sCharName .. ']]'):done()
    :tag('span'):addClass('hidden'):wikitext('[[File:' .. sCharName .. ' Icon.png|24x24px|link=' .. sCharName .. ']]'):done()
     :tag('span'):addClass('recipe-header-text'):wikitext('[[' .. sCharName .. ']]'):done()
     :tag('span'):addClass('recipe_header_text'):wikitext('[[' .. sCharName .. ']]'):done()
end
end


Line 243: Line 248:
   local sKitchName = args[param.sKitchArg]
   local sKitchName = args[param.sKitchArg]


   header:tag('span'):addClass('recipe_header_sub')
   header:tag('span'):addClass('recipe-header-sub')
     :tag('span'):addClass('mobileHide'):wikitext(' with '):done()
     :tag('span'):wikitext('[[File:' .. sKitchName .. ' Icon.png|24x24px|link=' .. sKitchName .. ']]'):done()
    :tag('span'):addClass('hidden'):wikitext('[[File:' .. sKitchName .. ' Icon.png|24x24px|link=' .. sKitchName .. ']]'):done()
     :tag('span'):addClass('recipe-header-text'):wikitext('[[' .. sKitchName .. ']]'):done()
     :tag('span'):addClass('recipe_header_text'):wikitext('[[' .. sKitchName .. ']]'):done()
end
end


Line 274: Line 278:


   body
   body
     :tag('div'):addClass('recipe_body_icon')
     :tag('div'):addClass('recipe-body-icon')
       :wikitext('➜'):done()
       :wikitext('➜'):done()
     :tag('div'):addClass('recipe_body_yield')
     :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('recipe_body')
   local body = output:tag('div'):addClass('recipe-body')


   local sSortDelim = param.sSortDelim
   local sSortDelim = param.sSortDelim
Line 396: Line 400:


local function renderCookingSplitTypeCard(category, body, ingredient)
local function renderCookingSplitTypeCard(category, body, ingredient)
local qualityClass = getQualityClass(ingredient.quality)
  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('recipe_body_cooking_ingredient')
     :addClass('recipe-body-cooking-ingredient')
     :addClass('recipe_body_cooking_type_cards')
     :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('recipe_body_cooking_ingredient')
     :addClass('recipe-body-cooking-ingredient')
     :addClass('recipe_body_cooking_option_cards')
     :addClass('recipe-body-cooking-option-cards')


   for _, itemName in ipairs(ingredient.options) do
   for _, itemName in ipairs(ingredient.options) do
Line 524: Line 528:


   body
   body
     :tag('div'):addClass('recipe_body_icon')
     :tag('div'):addClass('recipe-body-icon')
       :wikitext('➜'):done()
       :wikitext('➜'):done()
     :tag('div'):addClass('recipe_body_yield')
     :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('recipe_body')
     :addClass('recipe-body')
     :addClass('recipe_body_cooking')
     :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('recipe_container')
     :addClass('recipe-container')


   local category = mw.html.create()
   local category = mw.html.create()