Module:Shortcut

--- This module is used by Shortcut. -- local links = require("Dev:Links") local utils = require("Module:Utils")

local p = {}

function p._main(args) local box = mw.html.create("div") :addClass("module-shortcut-box") :addClass("noprint") :attr("role", "note") -- This will not work until https://gerrit.wikimedia.org/r/514974 -- is reverted. -- :css("border-color", "var(--theme-border-color)") :css("border-radius", "3px") :css("border-style", "solid") :css("border-width", "1px") :css("padding", "0.5em") :css("text-align", "center") if args.float then box:css("float", args.float) end if args.clear then box:css("clear", args.clear) end if not args[1] then return error("At least one shortcut is required.") end if args[4] then return error("That is not a reasonable number of shortcuts.") end local label = "Shortcut" if args[2] then label = "Shortcuts" end box:tag("p") :addClass("module-shortcut-box-heading") :css("border-bottom-style", "solid") :css("border-bottom-width", "1px") -- :css("border-bottom-color", "var(--theme-border-color)") :css("margin-bottom", "0") :wikitext(label) if args[2] then local list = box:tag("ul") :addClass("module-shortcut-list") :css("list-style-type", "none") :css("margin", "0") local i = 1 repeat list:tag("li") :wikitext(links.link( tostring(mw.uri.fullUrl(args[i], {redirect="no"})), args[i], "ext" ))           i = i + 1 until not args[i] else box:tag("p") :css("margin", "0") :wikitext(links.link( tostring(mw.uri.fullUrl(args[1], {redirect="no"})), args[1], "ext" ))   end return box end

p.main = utils.make_wrapper_function(p._main)

return p