FANDOM


-- <nowiki>
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 .. "[[Category:Deceased " .. type .. "]]") or
            female and (str .. "[[Category:Female "   .. type .. "]]") or
            male   and (str .. "[[Category:Male "     .. type .. "]]") 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 .. "{{tt|*|By " .. byChar .. "}}")
            or inEp and (alias2 .. "{{tt|*|In " .. inEp .. "}}")
            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 ("&nbsp;" .. 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 .. "'''<br/>"
            .. tostring(cbox) .. "&nbsp;" .. 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"}
        }
 
        -- 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 ("[[File:" .. icon .. "|" .. size .. "px|link=" .. (noname and url or "") .. "]]"))
                    .. ( nofavicon or noname and "" or "&nbsp;" )
                    .. ( 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)
        return "[[" .. str .. "]][[Category:Episodes "
            .. (args[1] or "written") .. " by " .. str .. "]]";
    end
}

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.