From Omniversalis

Documentation for this module may be created at Module:G13/doc

local p = {}
revlib = require("Module:Revision");
function p.row(frame)
    local status = frame.args["s"]
    local title = frame.args["t"]
    local short = p.shorttitle(title, 40)
    local size = frame.args["z"]
    local modified_by = frame.args["mr"]
    local modified_at = frame.args["md"]
    local old_id = frame.args["mi"]
    local special_user = frame.args["sr"]
    local special_time = frame.args["sd"]
    local special_id = tonumber(frame.args["si"])
    local decline_reason = frame.args["d"]
    local display_notes = tonumber(frame.args["n"])
    local rowtemplate = "<tr style=\"background-color: %s;\"> %s </tr>"
    local colorthing =  p.color(status, false)
    local cols = {}
    cols[1] = string.format("<td>[[:%s|%s]]</td>", title, short)
    cols[2] = string.format('<td data-sort-type="number" data-sort-value="%d">%.1f kB</td>', size, size / 1000)
    local is_userspace = string.sub(frame.args["t"], 1, 4) == "User"
    if is_userspace then
        display_notes = 1
    if decline_reason and display_notes then
    	cols[3] = string.format("<td>%s %s</td>", decline_reason, p.notes(frame))
    elseif decline_reason then
    	cols[3] = string.format("<td>%s</td>", decline_reason)
    elseif display_notes then
        cols[3] = string.format("<td>%s</td>", p.notes(frame))
        cols[3] = "<td></td>"

    cols[4] = p.printuser(modified_by)
    cols[5] = string.format('<td data-sort-value="%s">%s</td>', old_id, p.invoke("Module:Revision", "diff", frame, title, "prev", old_id, modified_at))
    if special_id then
        cols[6] = p.printuser(special_user)
        cols[7] = string.format('<td data-sort-value="%s">%s</td>', special_id, p.invoke("Module:Revision", "diff", frame, title, "prev", special_id, special_time))
    local colstring = ""
    for i=1, 7 do colstring = colstring .. cols[i] end
    return string.format(rowtemplate, colorthing, colstring)

function p.decline(frame)
	local reason = ""
	return reason	

function p.notes(frame)
    local result = ""
    local is_suspected_copyvio = tonumber(frame.args["nc"])
    local is_unsourced = tonumber(frame.args["nu"])
    local no_inline = tonumber(frame.args["ni"])
    local is_short = tonumber(frame.args["ns"])
    local is_resubmit = tonumber(frame.args["nr"])
    local is_old = tonumber(frame.args["no"])
    local submitter_is_blocked = tonumber(frame.args["nb"])
    local is_userspace = string.sub(frame.args["t"], 1, 4) == "User"
    if is_suspected_copyvio then result = result .. "<abbr title=\"Submission is a suspected copyright violation\">copyvio</abbr>&#32;&#32;" end
    if is_unsourced then result = result .. "<abbr title=\"Submission lacks references completely\">unsourced</abbr>&#32;&#32;" end
    if no_inline then result = result .. "<abbr title=\"Submission has no inline citations\">no-inline</abbr>&#32;&#32;" end
    if is_short then result  = result .."<abbr title=\"Submission is less than a kilobyte in length\">short</abbr>&#32;&#32;" end
    if is_resubmit then result  = result .. "<abbr title=\"Submission was resubmitted after a previous decline\">resubmit</abbr>&#32;&#32;" end
    if is_old then result  = result .. "<abbr title=\"Submission has not been touched in over four days\">old</abbr>&#32;&#32;" end
    if submitter_is_blocked then result  = result .. "<abbr title=\"Submitter is currently blocked\">blocked</abbr>&#32;&#32;" end
    if is_userspace then result  = result .. "<abbr title=\"Submission is located in the User or User Talk space\">userspace</abbr>&#32;&#32;" end
    return result

function p.color(status, dark)
    local result
    local dark_colors = {
        p = "#979158",
        d = "#a07980",
        r = "#708a92",
        a = "#5f9e5f"
    local normal_colors = {
        p = "#f3eba3",
        d = "#ffcdd5",
        r = "#b1dae8",
        a = "#adfcad"
    if dark then
        return dark_colors[status] or "#7e7f7a"
        return normal_colors[status] or "#d2d3cc"

function p.printuser(user)
  return string.format("<td>[[User:%s|%s]] ([[User talk:%s|t]])</td>", user, user, user)

function p.shorttitle(fulltitle, maxlength)
    --strip off namespace:basepage/ if it exists and anything is left
    --if not, strip off namespace
    --truncate to maxlength
    local startindex, size, namespace, basetitle, subtitle = mw.ustring.find(fulltitle, "([^:]*):([^\/]*)\/?(.*)")
    local effective_title = subtitle or basetitle
    if (effective_title == nil or string.len(effective_title) == 0) then effective_title = fulltitle end
    effective_title = string.gsub(effective_title, "^Submissions/", "")
    -- return mw.text.truncate( effective_title, maxlength ) (mw.text is not yet deployed!)
    if (mw.ustring.len(effective_title) > maxlength) then
        return mw.ustring.sub(effective_title, 1, maxlength - 3) .. "..."
        return effective_title

--equivalent of {{#Invoke:module|function|arg1|arg2|namedarg=arg3|namedarg2=arg4}} becomes
--p.invoke("module", "function", frame, arg1, arg2, {namedarg=arg3}, {namedarg2=arg4})
function p.invoke(modname, call, frame, ...)
    local mymod = require(modname)
    local nargs = {}
    for i,v in ipairs(arg) do
        if type(v) == "table" then
            local argname, argv = ipairs(v)
            nargs[argname] = tostring(argv)
            nargs[i] = tostring(v)
    local childframe = frame:newChild{title = nil, args = nargs}
    return mymod[call](childframe)

return p