local export = {}
local function makeUrl(title, queryType, from)
if title and title.fullUrl then
if from then
if queryType then
local query = { = from }
return title:fullUrl(query, "https")
else
return title:fullUrl(nil, "https")
end
end
end
end
local function link(title, queryType, from, display)
local url = makeUrl(title, queryType, from)
if url then
return ""
end
end
function export.show(frame)
local output = {}
local queryType
local params = {
= { list = true },
= { type = "boolean" },
= { },
= {}, -- for Coptic
}
local args = require("Module:parameters").process(frame.args and frame.args or frame:getParent().args, params)
local title = mw.title.getCurrentTitle()
local froms = args
local display = {}
for i, from in pairs(froms) do
if mw.ustring.match(from, ":") then
local from, linktext = mw.ustring.match(from, "(+):(.+)")
if from then
froms = from
display = linktext
else
error('Parameter ' .. i .. ' is badly formatted. It should contain a key to use in the link, a colon, and then the displayed text.')
end
end
end
if args then
for character in mw.ustring.gmatch(args.CopticDisplay, ".") do
table.insert(display, character)
end
end
local subcat = args
if subcat then
queryType = "subcatfrom"
-- ]
require("Module:debug").track("table-of-contents/subcat")
else
queryType = "from"
end
if args then
local link = link(title, nil, args)
table.insert(output, link)
end
if args and froms and froms then
table.insert(output, " – ")
end
for i, from in ipairs(froms) do
local link = link(title, queryType, from, display)
table.insert(output, link)
end
return table.concat(output, " ")
end
return export