Module:G13

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 = " %s " local colorthing = p.color(status, false) local cols = {} cols[1] = string.format(" %s ", title, short) cols[2] = string.format('%.1f kB ', size, size / 1000) local is_userspace = string.sub(frame.args["t"], 1, 4) == "User" if is_userspace then display_notes = 1 end if decline_reason and display_notes then cols[3] = string.format(" %s %s ", decline_reason, p.notes(frame)) elseif decline_reason then cols[3] = string.format(" %s ", decline_reason) elseif display_notes then cols[3] = string.format(" %s ", p.notes(frame)) else cols[3] = " " end

cols[4] = p.printuser(modified_by) cols[5] = string.format('%s ', 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('%s ', special_id, p.invoke("Module:Revision", "diff", frame, title, "prev", special_id, special_time)) end local colstring = "" for i=1, 7 do colstring = colstring .. cols[i] end return string.format(rowtemplate, colorthing, colstring) end

function p.decline(frame) local reason = "" return reason 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"]) local is_userspace = string.sub(frame.args["t"], 1, 4) == "User" 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 &#32;&#32;" end if is_userspace then result = result .. "userspace &#32;&#32;" 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