FANDOM


--[=[
List format:
* Group1
** Optional group style (todo)
** User1
*** Optional user style (todo)
** User2
 
* Group2
** User3
** User4
--]=]
 
local HEADER = [=[
/***** ModularCSS/UserLinks *****/
/* todo: add link styling */]=]
local BASE_STYLE = [====[
[=[.Wall .edited-by a.subtle[href$="Message_Wall:$USER"]:after]=] {
    content: "($GROUP)" !important;
}
]====]
 
local CHUNK_CAPT = "%[=%[(.-)%]=%]"
 
return {
    page = "Project:User links",
 
    main = function(parsed)
        local styles = {}
        local piles  = {}
 
        -- create piles
        for grpName,grpObj in pairs(parsed) do
            local GRP_STYLE = BASE_STYLE:gsub("$GROUP", grpName)
            local grp_pile = {}
 
            for user in pairs(grpObj) do
                local pile_n = 0
 
                for chunk in GRP_STYLE:gmatch(CHUNK_CAPT) do
                    pile_n = pile_n + 1
                    grp_pile[pile_n] = grp_pile[pile_n] or {}
                    table.insert(grp_pile[pile_n], ( chunk:gsub("$USER", user) ))
                end
            end
 
            table.insert(styles, GRP_STYLE)
            table.insert(piles, grp_pile)
        end
 
        -- compile
        local compiledCSS = ""
        for _,style in pairs(styles) do
            compiledCSS = compiledCSS
                .. style:gsub(CHUNK_CAPT, function()
                    local compiled = ""
                    local pile_n = 0
 
                    for _,grp_pile in pairs(piles) do
                        pile_n = pile_n + 1
                        local pile = grp_pile[pile_n]
 
                        for _,chunk in pairs(pile) do
                            compiled = compiled .. chunk .. ",\n"
                        end
                    end
 
                    return compiled:sub(1,-3)
                end)
        end
 
        return HEADER .. compiledCSS
    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.