|
|
Line 16: |
Line 16: |
| local CATEGORY_BR_TAGS = "[[Category:Infoboxes using br tags]]" | | local CATEGORY_BR_TAGS = "[[Category:Infoboxes using br tags]]" |
| local CATEGORY_BR_TAGS_GAME = "[[Category:Infoboxes using br tags in game fields]]" | | local CATEGORY_BR_TAGS_GAME = "[[Category:Infoboxes using br tags in game fields]]" |
| local CATEGORY_EXP_GAME = "[[Category:Infoboxes using exp game]]"
| |
| local CLASS_TOOLTIP = require("Module:Constants/class/tooltip") | | local CLASS_TOOLTIP = require("Module:Constants/class/tooltip") |
| local DEFAULT_IMG_SIZE = "320x320px" | | local DEFAULT_IMG_SIZE = "320x320px" |
| local MSG_BR_TAGS = "Using <code><nowiki><br></nowiki></code> tags to create lists is discouraged. See [[:Category:Infoboxes using br tags]] for more information."
| |
| local MSG_EXP_GAME = "One or more infobox fields are using {{Template|Exp Game}} when they should be using {{Template|Infobox Game Blocks}}. See [[:Category:Infoboxes using exp game]] for more information"
| |
| local VAR_IS_AFTER_INFOBOX = require("Module:Constants/var/isAfterInfobox") | | local VAR_IS_AFTER_INFOBOX = require("Module:Constants/var/isAfterInfobox") |
|
| |
|
Line 84: |
Line 81: |
| end | | end |
| return image | | return image |
| end
| |
| end
| |
|
| |
| -- Deprecated - to be removed once [[Category:Infoboxes with commas]] is cleared
| |
| function p.List(frame)
| |
| local categories = ""
| |
| listItems = frame.args[1]
| |
| listItems = listItems and utilsString.trim(listItems)
| |
| if listItems == nil or listItems == "" then
| |
| return nil
| |
| end
| |
|
| |
| if string.find(listItems, "plainlist") then
| |
| return listItems -- input is already a list
| |
| end
| |
|
| |
| if string.find(listItems, "<br") then
| |
| h.warn(MSG_BR_TAGS)
| |
| categories = categories..CATEGORY_BR_TAGS
| |
| listItems = utilsString.split(listItems, "<br/?>")
| |
| else
| |
| if string.find(listItems, ",[^%d]") then
| |
| categories = categories.."[[Category:Infoboxes with commas]]"
| |
| end
| |
| listItems = utilsString.split(listItems, '%s*,%f[^,%d]%s*') -- %f[^,%d] is so we don't split numbers on their thousands separator (e.g., 1,500)
| |
| end
| |
|
| |
| local listItemsUsingExpGame = utilsTable.filter(listItems, function(listItem)
| |
| return string.find(listItem, "exp%-game")
| |
| end)
| |
| if #listItems > 1 and #listItemsUsingExpGame == #listItems then
| |
| h.warn(MSG_EXP_GAME)
| |
| categories = categories..CATEGORY_EXP_GAME
| |
| end
| |
|
| |
| if #listItems == 1 then
| |
| return listItems[1], categories
| |
| else
| |
| return utilsMarkup.list(listItems), categories
| |
| end | | end |
| end | | end |
Line 136: |
Line 94: |
|
| |
|
| if string.find(games, "<br") then | | if string.find(games, "<br") then |
| h.warn(MSG_BR_TAGS)
| | categories = categories..CATEGORY_BR_TAGS_GAME |
| categories = categories..CATEGORY_BR_TAGS..CATEGORY_BR_TAGS_GAME | |
| games = utilsString.split(games, "<br>") | | games = utilsString.split(games, "<br>") |
| games = utilsTable.flatMap(games, utilsString._split("<br/>")) | | games = utilsTable.flatMap(games, utilsString._split("<br/>")) |
Line 227: |
Line 184: |
| end | | end |
| if listItems and string.find(listItems, "<br") then | | if listItems and string.find(listItems, "<br") then |
| h.warn(MSG_BR_TAGS) | | h.warn("Using <code><nowiki><br></nowiki></code> tags to create lists is discouraged. Use commas instead, as this template treats them as delimiters. See [[Template:Infobox Game Blocks]] for more information.") |
| categories = categories..CATEGORY_BR_TAGS | | categories = categories..CATEGORY_BR_TAGS |
| listItems = utilsString.split(listItems, "<br>") | | listItems = utilsString.split(listItems, "<br>") |
Line 454: |
Line 411: |
| args = {"{{Plural|Series|Cyber Pico Bloom}} are never seen in-game"}, | | args = {"{{Plural|Series|Cyber Pico Bloom}} are never seen in-game"}, |
| }, | | }, |
| },
| |
| },
| |
| List = {
| |
| desc = "This function is being deprecated in favor of [[Template:List]]. See [[:Category:Infoboxes with commas]] for more information.",
| |
| frameParams = {
| |
| [1] = {
| |
| name = "param",
| |
| desc = "The infobox parameter",
| |
| },
| |
| },
| |
| cases = {
| |
| {
| |
| args = {"A, B, C"}
| |
| },
| |
| {
| |
| desc = "Spaces between list elements are optional, but recommended for readability.",
| |
| args = {"A,B,C"}
| |
| },
| |
| {
| |
| desc = "Digit separators don't count.",
| |
| args = {"1,500 Rupees"},
| |
| },
| |
| {
| |
| desc = "{{Template|,}} can be used to escape commas when an item itself contains a comma.",
| |
| args = {"[[The Way of Sumo{{,}} Part I]], [[The Way of Sumo{{,}} Part II]], [[The Way of Sumo{{,}} Part III]]"},
| |
| },
| |
| {
| |
| args = {"A"},
| |
| },
| |
| {
| |
| args = {""},
| |
| },
| |
| {
| |
| args = {},
| |
| },
| |
| {
| |
| desc = "br tags are discouraged due to the poor HTML semantics.",
| |
| args = {"A<br>B<br>C"},
| |
| }
| |
| }, | | }, |
| }, | | }, |