Module:FormatSocials: Difference between revisions
Jump to navigation
Jump to search
MIXERRULES (talk | contribs) Added social formatter script |
MIXERRULES (talk | contribs) m Fixed issue |
||
Line 29: | Line 29: | ||
if DisplayTitle then | if DisplayTitle then | ||
table.insert(Result, string.format(" | table.insert(Result, string.format("[%s %s]", Part, DisplayTitle)) | ||
else -- HEY MIXER, this is the bad case when nothing is found so it just displays the url | else -- HEY MIXER, this is the bad case when nothing is found so it just displays the url | ||
table.insert(Result, string.format(" | table.insert(Result, string.format("[%s Other Website]", Part, Part)) | ||
end | end | ||
end | end |
Revision as of 23:52, 15 December 2024
Documentation for this module may be created at Module:FormatSocials/doc
local FormatSocials= {}
local SiteNames = {
["https://x.com/"] = "Twitter/X",
["https://www.youtube.com/"] = "YouTube",
["https://github.com/"] = "GitHub",
["https://bsky.app/"] = "BlueSky",
["https://www.youtube.com/"] = "YouTube",
["https://steamcommunity.com/"] = "Steam",
["https://discord.com/"] = "Discord",
}
function FormatSocials.Format(frame)
local Input = frame.args[1] or ""
local Parts = {}
for Word in string.gmatch(Input, '([^,]+)') do
table.insert(Parts, Word)
end
local Result = {}
for i, Part in ipairs(Parts) do
local DisplayTitle = nil
for url, name in pairs(SiteNames) do
if string.find(Part, url) then
DisplayTitle = name
break
end
end
if DisplayTitle then
table.insert(Result, string.format("[%s %s]", Part, DisplayTitle))
else -- HEY MIXER, this is the bad case when nothing is found so it just displays the url
table.insert(Result, string.format("[%s Other Website]", Part, Part))
end
end
return table.concat(Result, "<br>")
end
return FormatSocials