Module:LuaLink

local utils = {}

function emptyCheck(value) if value == nil then return false elseif value == "" then return false elseif value == {} then return false else return true end end

function utils.user(frame) local name = frame.args[1] or frame:getParent.args[1] local users = mw.loadData("Module:LuaLink/users") if emptyCheck(users[name]) then local nick local color local icon local icon2 local page local disp local style if emptyCheck(users[name]["nick"]) then nick = users[name]["nick"] else nick = name end if emptyCheck(users[name]["color"]) then color = users[name]["color"] else color = "#000000" end if emptyCheck(users[name]["icon"]) then icon = users[name]["icon"] else icon = "Centrist-yellow.png" end if emptyCheck(users[name]["icon2"]) then icon = users[name]["icon2"] else icon = "Centrist-yellow.png" end if emptyCheck(users[name]["style"]) then style = users[name]["style"] else style = "" end if emptyCheck(frame.args[2]) or emptyCheck(frame:getParent.args[2]) then page = frame.args[2] or frame:getParent.args[2] else page = "User:" .. name end if emptyCheck(frame.args[3]) or emptyCheck(frame:getParent.args[3]) then disp = frame.args[3] or frame:getParent.args[3] elseif emptyCheck(frame.args[2]) or emptyCheck(frame:getParent.args[2]) then disp = page else disp = nick end return " ".. disp .." " else return "Invalid user" end end

function utils.category(frame) local name = frame.args[1] or frame:getParent.args[1] local ideo = mw.loadData("Module:LuaLink/categories") if emptyCheck(ideo[name]) then local nick local color local icon local disp local style local page = ":Category:" .. name if emptyCheck(ideo[name]["nick"]) then nick = ideo[name]["nick"] else nick = name end if emptyCheck(ideo[name]["color"]) then color = ideo[name]["color"] else color = "#000000" end if emptyCheck(ideo[name]["icon"]) then icon = ideo[name]["icon"] else icon = "Centrist-yellow.png" end if emptyCheck(ideo[name]["style"]) then style = ideo[name]["style"] else style = "" end if emptyCheck(frame.args[2]) or emptyCheck(frame:getParent.args[2]) then disp = frame.args[2] or frame:getParent.args[2] else disp = nick end return " ".. disp .." " else return "Invalid category" end end

function utils.ideologies(frame) local name = frame.args[1] or frame:getParent.args[1] local cats = mw.loadData("Module:LuaLink/ideologies") if emptyCheck(cats[name]) then local nick local color local icon local icon2 local disp local style local page = "".. name if emptyCheck(cats[name]["nick"]) then nick = cats[name]["nick"] else nick = name end if emptyCheck(cats[name]["color"]) then color = cats[name]["color"] else color = "#000000" end if emptyCheck(cats[name]["icon"]) then icon = cats[name]["icon"] else icon = "Centrist-yellow.png" end if emptyCheck(cats[name]["icon2"]) then icon = cats[name]["icon2"] else icon = "Centrist-yellow.png" end if emptyCheck(cats[name]["style"]) then style = cats[name]["style"] else style = "" end if emptyCheck(frame.args[2]) or emptyCheck(frame:getParent.args[2]) then disp = frame.args[2] or frame:getParent.args[2] else disp = nick end return " ".. disp .." " else return "Invalid ideology" end end

return utils