Module:Lockbox: Difference between revisions

Content deleted Content added
ns, rest
playing dirty
Line 1:
local export = {}
 
-- XXX: OUTRAGEOUS ABUSE OF SCRIBUNTO API
-- generates a transclusion without incrementing the "expensive function" count
local generate_transclusion
do
local mock_title = mw.title.new(mw.title.getCurrentTitle().id)
rawset(mock_title, 'getContent', mock_title.getContent)
function generate_transclusion(title)
rawset(mock_title, 'fullText', title)
mock_title:getContent()
end
end
 
function export.lock(frame)
Line 12 ⟶ 24:
local match = string.match
local args = { }
 
for _, item in ipairs(frame.args) do
Line 19 ⟶ 30:
local ns, rest = match(item, "^(.-):(.*)")
if not ns or not mw.site.namespaces[ns] then
mw.title.makeTitlegenerate_transclusion('Template:', .. item):getContent()
table.insert(output, '* [[Template:' .. item .. ']]\n')
elseif (ns == "File") or (ns == "Image") then
generate_transclusion(item)
mw.title.makeTitle('File', rest):getContent()
table.insert(output, '* [[:' .. item .. ']]\n')
elseif ns == "Category" then
generate_transclusion(item)
mw.title.makeTitle('Category', rest):getContent()
table.insert(output, '* [[:' .. item .. ']]\n')
elseif rest ~= '' then
generate_transclusion(item)
mw.title.makeTitle(ns, rest):getContent()
table.insert(output, '* [[' .. item .. ']]\n')
end