Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Ahecht/interwiki
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = {} function p._current() out = {} for k, v in pairs(mw.site.interwikiMap("local")) do if v.isCurrentWiki then table.insert(out, k) end end return out end function p._map(isLocal) isLocal = isLocal and "local" or nil out = {} for k, v in pairs(mw.site.interwikiMap(isLocal)) do table.insert(out, k) end return out end function p._isCurrentIW(title) for _, v in ipairs(p._current()) do pattern = "^:?" .. v .. ":" if mw.ustring.match(title, pattern) then return true end end return false end function p._isValidIW(title, isLocal) for _, v in ipairs(p._map(isLocal)) do pattern = "^:?" .. v .. ":" if mw.ustring.match(title, pattern) then return true end end return false end local function current(args) return table.concat(p._current(), (args.sep or ", ")) end local function map(args) return table.concat(p._map(args["local"]), (args.sep or ", ")) end local function isCurrentIW(args) return p._isCurrentIW((args[1] or "")) end local function ifCurrentIW(args) if p._isCurrentIW((args[1] or "")) then return args[2] or "" else return args[3] or "" end end local function isValidIW(args) return p._isValidIW((args[1] or ""), args["local"]) end local function ifValidIW(args) if p._isValidIW((args[1] or ""), args["local"]) then return args[2] or "" else return args[3] or "" end end local function makeWrapper(func) return function (frame) -- If called via #invoke, use the args passed into the invoking template. -- Otherwise, for testing purposes, assume args are being passed directly in. local origArgs if frame == mw.getCurrentFrame() then origArgs = frame:getParent().args for k, v in pairs(frame.args) do origArgs = frame.args break end else origArgs = frame end -- Strip whitespace, and treat blank arguments as nil. -- 'sep' has different behaviour depending on whether -- it is blank or nil, so keep it as it is. -- isLocal needs to be converted from a string to a bool. local args = {} for k, v in pairs(origArgs) do v = mw.text.trim(v) if v ~= '' or k == 'sep' then if k == 'local' then t = {["true"]=true,["false"]=false} args[k] = (t[v] or v==true) else args[k] = v end end end return func(args) end end return { current = makeWrapper(current), map = makeWrapper(map), isCurrentIW = makeWrapper(isCurrentIW), ifCurrentIW = makeWrapper(ifCurrentIW), isValidIW = makeWrapper(isValidIW), ifValidIW = makeWrapper(ifValidIW) }
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Break
(
edit
)
Template:Sandbox other
(
edit
)
Module:Sandbox/Ahecht/interwiki
(
edit
)
Module:Sandbox/Ahecht/interwiki/doc
(
edit
)
Module:String
(
edit
)