| Latest revision |
Your text |
| Line 1: |
Line 1: |
| local p = {} | | local p = {} |
|
| |
| function p.gallery(frame)
| |
| local text = frame.args[1] or ""
| |
| local entries = {}
| |
|
| |
| for entry in mw.text.gsplit(text, ";") do
| |
| entry = mw.text.trim(entry)
| |
|
| |
| if entry ~= "" then
| |
| local separator = string.find(entry, "::", 1, true)
| |
|
| |
| local file
| |
| local description
| |
|
| |
| if separator then
| |
| file = mw.text.trim(string.sub(entry, 1, separator - 1))
| |
| description = mw.text.trim(string.sub(entry, separator + 2))
| |
| else
| |
| file = entry
| |
| description = ""
| |
| end
| |
|
| |
| if file ~= "" then
| |
| local galleryEntry = "File:" .. file
| |
|
| |
| if description ~= "" then
| |
| galleryEntry = galleryEntry .. "|" .. description
| |
| end
| |
|
| |
| table.insert(entries, galleryEntry)
| |
| end
| |
| end
| |
| end
| |
|
| |
| if #entries == 0 then
| |
| return ""
| |
| end
| |
|
| |
| return '<div class="character-gallery">' ..
| |
| frame:extensionTag{
| |
| name = "gallery",
| |
| content = table.concat(entries, "\n")
| |
| } ..
| |
| '</div>'
| |
| end
| |
|
| |
|
| function p.processTitle(frame) | | function p.processTitle(frame) |
| local input = frame.args[1] or "" | | local input = frame.args[1] or "" |
| | |
| | -- Check if input already looks like a {{Title}} template |
| if mw.ustring.match(input, "^%s*%{%{%s*[Tt]itle%s*[|}]") then | | if mw.ustring.match(input, "^%s*%{%{%s*[Tt]itle%s*[|}]") then |
| return input | | return input |
| end | | end |
| return frame:expandTemplate{
| |
| title = "Title",
| |
| args = { name = input }
| |
| }
| |
| end
| |
|
| |
| function p.stripHouse(frame)
| |
| local name = frame.args[1]
| |
| if not name or name == "" then
| |
| name = mw.title.getCurrentTitle().text
| |
| end
| |
|
| |
| local prefixes = { "House", "Clan", "Family", "Dynasty" }
| |
|
| |
| for _, prefix in ipairs(prefixes) do
| |
| local pattern = "^[" .. mw.ustring.sub(prefix,1,1):lower() .. mw.ustring.sub(prefix,1,1):upper() .. "]" ..
| |
| mw.ustring.sub(prefix,2):lower() .. "%s+"
| |
| name = mw.ustring.gsub(name, pattern, "")
| |
| end
| |
|
| |
| return name
| |
| end
| |
|
| |
|
| function p.unlink(frame)
| | -- Otherwise wrap it in {{Title|name=...}} |
| local text = frame.args[1] or "" | | return string.format("{{Title|name=%s}}", input) |
| text = mw.ustring.gsub(text, "[%[%]]", "") | |
| return text
| |
| end | | end |
|
| |
|
| return p | | return p |