Marvel Wiki
Advertisement

La documentación para este módulo puede ser creada en Módulo:Appearances/doc

local A = { }

local HF = require("Module:HF")
local parent = nil

local build = function(arg, arg2, category)
  local built = ""

  local link = ""
  local text = ""

  if not HF.isempty(arg) then
    
    link = arg
    
    if not HF.isempty(arg2) then
      text = arg2
    else
      link = string.match(arg, "([^%[%|%]]+)")
      text = string.match(arg, "%|([^%]%|]+)")
    end
    
    if string.find(link, "w:c:") == nil and string.find(link, "Glossary:") == nil and string.find(link, "#") == nil then
      if not HF.isempty(link) and not HF.isempty(text) then
          built = "[[" .. link .. "|" .. text .. "]][[Category:" .. link .. category .. "]]"
      elseif not HF.isempty(link) and HF.isempty(text) then
          built = "[[" .. link ..  "]][[Category:" .. link .. category .. "]]"
      else
          built = arg
      end
    else
      built = arg
    end
  end
  
  return built

end

local suffixTag = function(text)
    local tag = mw.html.create( 'span' )
        :css( 'color', 'darkgreen' )
        :css( 'font-weight', 'bold' )
        :css( 'font-style', 'italic' )
        :css( 'font-size', 'smaller' )
        :wikitext('('..text..')')
        :done()
    return tostring(tag)
end

function A.Apariciones(frame)
  parent = frame:getParent()
  local arg = parent.args[1]
  local arg2 = parent.args[2]
  local arg3 = parent.args[3]
  local category = '/Apariciones'
  local output = ''
  
  if HF.isempty(arg3) then
    output = build(arg, arg2, category)
  else
    output = build(arg, arg2, category) .. ' ' .. suffixTag(arg3)
  end

  return output
end

function A.apn(frame)
  parent = frame:getParent()
  local arg = parent.args[1]
  local arg2 = nil
  local category = '/Apariciones'
  local output = ''
    output = build(arg, arg2, category)
  return output
end

function A.Menciones(frame)
  parent = frame:getParent()
  local arg = parent.args[1]
  local arg2 = parent.args[2]
  local arg3 = parent.args[3]
  local category = '/Menciones'
  local output = ''
  
  if HF.isempty(arg3) then
    output = build(arg, arg2, category) .. ' ' .. suffixTag('Mencionado')
  else
    output = build(arg, arg2, category) .. ' ' .. suffixTag(arg3)
  end
  
  return output
end

function A.menor(frame)
  parent = frame:getParent()
  local arg = parent.args[1]
  local arg2 = parent.args[2]
  local arg3 = parent.args[3]
  local category = '/Apariciones_Menores'
  local output = ''
  
  if HF.isempty(arg3) then
    output = build(arg, arg2, category)
  else
    output = build(arg, arg2, category) .. ' ' .. suffixTag(arg3)
  end

  return output
end

function A.Invocaciones(frame)
  parent = frame:getParent()
  local arg = parent.args[1]
  local arg2 = parent.args[2]
  local arg3 = parent.args[3]
  local category = '/Invocaciones'
  local output = ''
  
  if HF.isempty(arg3) then
    output = build(arg, arg2, category) .. ' ' .. suffixTag('Invocado')
  else
    output = build(arg, arg2, category) .. ' ' .. suffixTag(arg3)
  end
  
  return output
end

return A
Advertisement