Module:List/custom

-- modes = require("Module:List/modes")

return { -- Infobox character - ["categorize_bio"] = function(str, args) local dead  = str:match("^[Dd]eceased"); local female = str:match("^[Ff]emale"); local male  = str:match("^[Mm]ale"); local type = args[1] or "characters"; return dead  and (str .. "") or            female and (str .. "") or            male   and (str .. "") or            str; end, ["char_alias"] = function(str) local frm_str     = str:gsub("\"", "&quot;");        local alias1,byChar = frm_str:match("^(.-) by (.+)");        local alias2,inEp   = frm_str:match("^(.-) in (.+)");        return            byChar  and (alias1 .. "")            or inEp and (alias2 .. "")            or str;    end,    ["color"] = function(str, args)        local hex_color,excess = str:match("^(#%w+)(.*)");        if (not hex_color) then return str; end;        local ntc_match = require("Module:Ntc").name(hex_color);        local closest_cHex, closest_cName, exact = unpack(ntc_match);        local cbox = mw.html.create "div"            :addClass "palette"            :css {                width  = "12px",                height = "12px",                ["background-color"] = hex_color,                border = '1px black solid',                ["border-radius"] = '2px',                float  = 'left'            }; if args[1] then cbox:addClass(args[1]) end; return tostring(cbox) .. (args[2]               and ""                or (" " .. closest_cName .. excess)); end, ["other_colors"] = function(str) local sect,hex_color,excess = str:match("^([^:]+): ?(#%w+)(.*)"); if (not hex_color) then return str; end; local ntc_match = require("Module:Ntc").name(hex_color); local closest_cHex, closest_cName, exact = unpack(ntc_match); local cbox = mw.html.create "div" :css { width = "12px", height = "12px", ["background-color"] = hex_color, border = '1px black solid', ["border-radius"] = '2px', ["margin-left"]  = '10px', float = 'left', };       return "'''" .. sect .. "''' "           .. tostring(cbox) .. " " .. closest_cName .. excess; end, -- Infobox episode ["ext_media"] = function(url, args) -- Hold arg props local nofavicon = false; local noname   = false; local size     = "16"; -- Parse args for i=1,4 do if args[i] then nofavicon = nofavicon or args[i]:match("nofavicon"); noname   = noname or args[i]:match("noname"); size     = args[i]:match("size(%d+)") or size; end end -- Get pure url (no wiki formattng) local url = url :match("^%[?(.-)%]?$") :match("^%S+"); local test_str = url:lower;      -- the normalized url to test local frm_link = '[' .. url .. ']'; -- to hold the formatted link local url_formats = { ["facebook.com"]    = {"Facebook", "FB-favicon.png"}, ["twitter.com"]     = {"Twitter", "TW-favicon.png"}, ["youtube.com"]     = {"YouTube", "YT-favicon.png"}, ["roosterteeth.com"] = {"Rooster Teeth", "RT-favicon.png"}, ["vrv.co"]          = {"VRV", "VRV-favicon.png"}, ["linkedin.com"]    = {"LinkedIn", "LI-favicon.png"}, ["reddit.com"]      = {"Reddit", "Reddit-favicon.png"}, ["tumblr.com"]      = {"Tumblr", "Tumblr-favicon.png"}, ["soundcloud.com"]  = {"Soundcloud", "SNDCLD-favicon.png"}, ["instagram.com"]   = {"Instagram", "Insta_Icon.png"}, ["deviantart.com"]  = {"Deviantart", "Devianart_Icon.jpg"} }       -- Get link display for domain,data in pairs(url_formats) do           if test_str:match(domain) then local name, icon = data[1], data[2] frm_link = (nofavicon and ""                       or ("")) .. ( nofavicon or noname and "" or " " ) .. ( noname and "" or ('[' .. url .. ' ' .. name .. ']') );

break; end end return tostring(           mw.html.create "div"                :wikitext (frm_link)                :css {                    ["margin-right"] = "15px",                    ["display"]      = "inline-block"                }        ); end, ["categorize_writers"] = function(str, args) local writer, fluff = modes.with_links(str, true) writer = writer or str fluff = fluff or '' return "" .. writer .. "" .. fluff .. "[[Category:Episodes "           .. (args[1] or "written") .. " by " .. writer .. "]]"; end }