Module:AfC

local p = {} revlib = require("Module:Revision"); -- current call example: function p.row(frame) local status = frame.args["s"] local title = frame.args["t"] local short = p.shorttitle(title, 30); 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 display_notes = tonumber(frame.args["n"]) local rowtemplate = " %s " local colorthing = p.color(status, false) local cols = {} cols[1] = string.format("%s", title, short) cols[2] = size if display_notes then cols[3] = p.notes(frame) else cols[3] = "" end if special_id then cols[4] = p.printuser(special_user) cols[5] = string.format(' %s %s', special_id, p.invoke("Module:Revision", "diff", frame, title, "prev", special_id, special_time)) else cols[4] = "Unknown" cols[5] = "Unknown" end cols[6] = p.printuser(modified_by) cols[7] = p.invoke("Module:Revision", "diff", frame, title, "prev", old_id, modified_at) local colstring = "" for i=1, 7 do colstring = colstring .. string.format(" %s ", cols[i]) end return string.format(rowtemplate, colorthing, colstring) end

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"]) if is_suspected_copyvio then result = result .. "copyvio &#32;&#32;" end if is_unsourced then result = result .. "unsourced &#32;&#32;" end if no_inline then result = result .. "no-inline &#32;&#32;" end if is_short then result = result .."short &#32;&#32;" end if is_resubmit then result = result .. "resubmit &#32;&#32;" end if is_old then result = result .. "old &#32;&#32;" end if submitter_is_blocked then result = result .. "blocked |}}" end return result end

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" else return normal_colors[status] or "#d2d3cc" end end

function p.printuser(user) return string.format("%s (t)", user, user, user) end

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) .. "..."   else return effective_title end end

--equivalent of 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) else nargs[i] = tostring(v) end end local childframe = frame:newChild{title = nil, args = nargs} return mymod[call](childframe) end

return p