Module:FormatDownloads
Documentation for this module may be created at Module:FormatDownloads/doc
local FormatSocials = {}
local SiteNames = {
["https://github.com/"] = "GitHub",
["https://store.steampowered.com/app/"] = "Steam Page",
["https://www.mediafire.com/"] = "MediaFire",
["https://www.dropbox.com/"] = "Dropbox",
["https://www.moddb.com/"] = "ModDB",
["https://gamebanana.com/"] = "Game Banana",
}
function FormatSocials.Format(frame)
local Input = frame.args[1] or ""
local Parts = {}
-- Split by comma
for Word in string.gmatch(Input, '([^,]+)') do
table.insert(Parts, mw.text.trim(Word))
end
local Result = {}
for _, Part in ipairs(Parts) do
-- Detect prefix (e.g., "Linux: ", "Windows: ")
local Prefix, URL = Part:match("^(.-:%s*)(https?://.+)$")
-- If no prefix, assume whole part is URL
if not URL then
URL = Part
Prefix = ""
end
-- Determine display title
local DisplayTitle = nil
for url, name in pairs(SiteNames) do
if string.find(URL, url, 1, true) then
DisplayTitle = name
break
end
end
if DisplayTitle then
table.insert(Result, string.format("%s[%s %s]", Prefix, URL, DisplayTitle))
else
table.insert(Result, string.format("%s[%s Website]", Prefix, URL))
end
end
return table.concat(Result, "<br>")
end
return FormatSocials