Content deleted Content added
m →top: Post-move cleanup, replaced: Tropical cyclone categories → Storm categories (4) |
Switching to note-style legends |
||
Line 16:
TableTools.removeDuplicates(customKeys)
function
for k, v in pairs(_table) do
return false
end
return true
end
function p.demo(frame)
local
local errors = setmetatable({}, { refgroupname = "E" })
local warnings = setmetatable({}, { refgroupname = "W" })
function buildReflist(_group)
group = _group or legend
return frame:expandTemplate{ title = 'reflist', args = {
group = getmetatable(group)["refgroupname"]
} }
end
function createLegend(details, _group)
hash = string.sub(mw.hash.hashValue("md5", details), 0, 8)
group = _group or legend
if group[hash] == nil then
group[hash] = frame:extensionTag{
-- <ref name="hash">details</ref>
name = 'ref',
content = mw.ustring.gsub(details, "%[%[File:([^%|]+)[^%]]*%]%]", "[[:File:%1]]"),
args = {
name = hash,
group = getmetatable(group)["refgroupname"]
}
}
end
-- <ref name="hash"/>
return frame:extensionTag{ name = 'ref', args = {
name = hash,
group = getmetatable(group)["refgroupname"]
} }
end
local categoryTable = mw.html.create("table")
:addClass("wikitable")
:addClass("sortable")
:attr("style", "width: 100%")
categoryTable
:node(
mw.html.create("tr")
Line 60 ⟶ 86:
:attr("data-sort-type", "number"))
)
for name, cat in TableTools.sortedPairs(cats) do
Line 71 ⟶ 95:
:wikitext(actualIcon)
if cat["icon"] ~= nil and actualIcon ~= cat["icon"] then
icon:wikitext(
createLegend("Overriden from original icon (" .. cat["icon"] .. ")")
end
Line 92 ⟶ 109:
if actualColor ~= cat["color"] then
color:wikitext(createLegend(
"Overriden from original color ({{color box|#"
.. "}} #"
.. cat["color"]
.. ")"
))
end
Line 108 ⟶ 123:
if catColorBlackRatio == "?" or catColorLinkRatio == "?" or catColorVisitedLinkRatio == "?" then
color:wikitext(
createLegend("This color must be a hexadecimal color.", errors)
)
else
if catColorBlackRatio < 4.5 then
color:wikitext(
createLegend("This color has [[MOS:COLOR|contrast issues]] with black (not WCAG 2.0 AA-compatible). It will be unusable on all infoboxes and storm season summaries.", errors)
)
end
if catColorLinkRatio < 4.5 then
color:wikitext(
createLegend("This color has [[MOS:COLOR|contrast issues]] with links (not WCAG 2.0 AA-compatible). It should not be used in conjunction with a link.", warnings)
)
end
if catColorVisitedLinkRatio < 4.5 then
color:wikitext(
createLegend("This color has [[MOS:COLOR|contrast issues]] with visited links (not WCAG 2.0 AA-compatible with #0b0080). It should not be used in conjunction with a visited link.", warnings)
)
end
if actualCat == "c0c0c0" and cat[sortkey] ~= 0 then
color:wikitext(
createLegend("This category is using a color reserved specifically for the \"unknown\" category.", warnings)
)
end
end
Line 205 ⟶ 221:
for _, _row in TableTools.sortedPairs(rows) do
end
end
Line 243 ⟶ 259:
:wikitext("''<span style=\"color:gray\">not available</span>''"))
end
end
end
out = ""
if not tableEmpty(errors) then
out = out
.. tostring(mw.html.create("h4"):wikitext("Error"))
.. tostring(mw.html.create("p"):wikitext("This table contains errors than need to be addressed immediately, as it may cause errors on a large amount of pages."))
.. buildReflist(errors)
end
if not tableEmpty(legend) then
out = out
.. tostring(mw.html.create("h4"):wikitext("Legend"))
.. buildReflist(legend)
end
out = out .. tostring(categoryTable)
if not tableEmpty(warnings) then
out = out
.. tostring(mw.html.create("h4"):wikitext("Warnings"))
.. tostring(mw.html.create("p"):wikitext("This table contains warnings than should be addressed. Please note that some warnings cannot be fully addressed without consensus on related WikiProjects."))
.. buildReflist(warnings)
end
return mw.text.trim(out)
end
|