Modul:Small scan link
Pidangan
Dokuméntasi pikeun modul ieu tiasa dijieun dina kaca Modul:Small scan link/doc.
local p = {} --p stands for package
local getArgs = require('Module:Arguments').getArgs
-- simple function to make a link to a give index page
local function index_link(index, display)
return "[[" .. "Index:" .. index .. "|" .. display .. "]]"
end
-- get the n'th link in the args, inclusing name if given
local function get_link(args, n)
local display = n
local argname = 'name' .. n
if args[argname] ~= nil then
display = args[argname]
end
return index_link(args[n], display)
end
--[=[
Return a formatted small scan link
Args:
1,2,3.... : The index pages to link to
name1, name2, ...: Display text for corresponding index page
]=]
function _small_scan_link(args)
local s = ''
if args[1] == nil then
error("At least an Index page is required", 0)
end
if args[2] == nil then
-- single argument
local target = args[1]
local link_text = ""
-- use the provided name if there is one
if args['name1'] ~= nil then
link_text = args['name1']
else
-- name based on existance of target
if mw.title.new("Index:" .. target).exists then
link_text = "proyék transkripsi"
else
link_text = "ngamimitian transkripsi"
end
end
s = index_link(target, link_text)
else
-- multiple positional args
local i = 1
s = "transcription volumes: "
-- iterate positional parameters
while args[i] ~= nil do
s = s .. get_link(args, i)
i = i + 1
if args[i] ~= nil then
s = s .. ", "
end
end
end
return "<span class=\"scanlink\" style=\"font-size: 83%;\">(" .. s .. ")</span>"
end
function p.small_scan_link(frame)
local args = getArgs(frame)
return _small_scan_link(args)
end
return p