< 模块:Icon
This module creates a test case template using data aggregated from Module:Icon/data and Module:Icon/data/sandbox. It is intended to be displayed at Template:Icon/testcases.
Usage
{{#invoke:icon/table|main}}
Output
Icon | Description | Code | Aliases |
---|---|---|---|
A-Class article | a}} | ||
Audited article of limited subject matter | aa}} | ||
A-Class article candidate | acc}} | aac , acn
| |
Black alert | alert}} | ||
Black, white, and red alert | alert-blackred}} | ||
Green alert | alert-constructive}} | ||
Alert | alert-imagewarning}} | ||
B-Class article | b}} | ||
Original barnstar | barnstar}} | ||
Original barnstar hires | barnstar2}} | ||
Wikipedia book | book}} | ||
Bplus-Class article | bplus}} | b+
| |
B-Class review | br}} | bcr
| |
C-Class article | c}} | ||
Category | category}} | cat , categ
| |
Cleanup work | cleanup}} | ||
Commons page | commons}} | ||
Demoted article | da}} | ||
Demoted A-Class article | dac}} | daa
| |
Delisted good article | dga}} | ||
Disambiguation page | disambiguation}} | dab , disamb , disambig
| |
Discussion | discussionnotificaion}} | ||
Draft-Class article | draft}} | ||
Did You Know? | dyk}} | ||
Did You Know? | dyk2}} | ||
Essay | essay}} | ||
Featured article | fa}} | ||
Featured article candidate | fac}} | fan
| |
Featured article review | far}} | ||
Featured article removal candidate | farc}} | ||
Former featured article | ffa}} | dfa
| |
Failed featured article candidate | ffac}} | nofa
| |
Former featured list | ffl}} | dfl
| |
Failed featured list candidate | fflc}} | nofl
| |
Former featured picture | ffp}} | ||
Former featured portal | ffpo}} | ||
Former featured sound | ffs}} | ||
Former featured topic | fft}} | dft
| |
Failed good article nominee | fgan}} | gaf , gf , noga
| |
Featured list | fl}} | ||
Featured list candidate | flc}} | fln
| |
Featured list removal candidate | flrc}} | flr
| |
Four Award | four}} | 4a
| |
Featured picture | fp}} | ||
Featured picture candidate | fpc}} | fpn
| |
Before the featured portal process ceased in 2017, this had been designated as a featured portal. | fpo}} | ||
Featured portal candidate | fpoc}} | ||
Featured portal review | fpor}} | ||
Featured sound | fs}} | ||
Featured sound candidate | fsc}} | ||
Featured topic | ft}} | ||
Featured topic candidate | ftc}} | ftn
| |
Featured topic removal candidate | ftrc}} | ||
Good article | ga}} | ||
Good article, 2nd opinion | ga2}} | ||
Good article on hold | gah}} | ||
Good article nominee | gan}} | gac
| |
Good article reassessment | gar}} | ||
Guild of Copy Editors | goce}} | ||
Good topic | gt}} | ||
Good topic candidate | gtc}} | gtn
| |
Good topic removal candidate | gtrc}} | ||
File | image}} | file
| |
Information | info}} | ||
In The News | itn}} | ||
List-Class article | list}} | comparison
| |
MediaWiki | mediawiki}} | ||
Meta-wiki page | meta}} | ||
Million Award | million}} | ||
Module | module}} | ||
Non-article page | na}} | ||
Needed article | needed}} | ||
Unknown-Class article | no}} | ||
Failed A-Class article candidate | noac}} | faac
| |
On This Day | otd}} | ||
Outline | outline}} | ||
Phabricator | phabricator}} | phab
| |
Portal | portal}} | ||
Picture of the Day | potd}} | ||
Portal peer review | ppr}} | ||
Peer review | pr}} | ||
Project page | project}} | ||
Question | q}} | question
| |
Quality image on Wikimedia Commons | qi}} | ||
Redirect | redirect}} | red , redir
| |
Start-Class article | start}} | ||
Stub-Class article | stub}} | ||
Template | template}} | temp , templ
| |
Today's Featured Article | tfa}} | ||
Today's Featured List | tfl}} | ||
Valued image on Wikimedia Commons | vi}} | ||
Vital article | vital}} | ||
Valued picture | vp}} | ||
Valued picture candidate | vpc}} | ||
Wikibooks page | wikibooks}} | ||
Wikidata page | wikidata}} | ||
Wikinews page | wikinews}} | ||
Wikipedia page | wikipedia}} | ||
WikiProject | wikiproject}} | ||
Wikiquote page | wikiquote}} | ||
Wikisource page | wikisource}} | ||
Wikispecies page | wikispecies}} | ||
Wikitech | wikitech}} | ||
Wikiversity page | wikiversity}} | ||
Wikivoyage page | wikivoyage}} | ||
Wiktionary page | wiktionary}} |
-- Create a table of icons to display on the template test case page
require('strict')
local p = {}
local m_iconData = mw.loadData("Module:Icon/data")
local m_iconSandboxData = mw.loadData("Module:Icon/data/sandbox")
local function mergeTables(...)
local ret = {}
for _, t in ipairs{...} do
for k, v in pairs(t) do
ret[k] = v
end
end
return ret
end
local function reconstituteAliases(iconDataCollection)
local ret = {}
for code, iconData in pairs(iconDataCollection) do
local outputData = ret[iconData.canonicalCode] or {
aliases = {},
image = iconData.image,
tooltip = iconData.tooltip,
link = iconData.link,
}
if code ~= iconData.canonicalCode then
table.insert(outputData.aliases, code)
end
ret[iconData.canonicalCode] = outputData
end
return ret
end
local function makeTableData(iconDataCollection)
local ret = {}
for code, iconData in pairs(reconstituteAliases(iconDataCollection)) do
if code ~= '_DEFAULT' then
table.insert(ret, {code = code, description = iconData.tooltip, aliases = iconData.aliases})
end
end
table.sort(
ret,
function(t1, t2)
return t1.code < t2.code
end
)
for _, t in ipairs(ret) do
table.sort(t.aliases)
end
return ret
end
function p.testcases(frame)
local tableData = makeTableData(mergeTables(m_iconData, m_iconSandboxData))
local ret = {
'{| class="wikitable sortable"',
'! Code',
'! [[Template:Icon|Template]]',
'! [[Template:Icon/sandbox|Sandbox]]',
'! Description',
}
local function addRow(code, description)
table.insert(ret, '|-')
table.insert(ret, '| <code>' .. mw.text.nowiki('{{icon|' .. code .. '}}') .. '</code>')
table.insert(ret, '| style="text-align: center" | ' .. frame:expandTemplate{title = 'icon', args = {code}})
table.insert(ret, '| style="text-align: center" | ' .. frame:expandTemplate{title = 'icon/sandbox', args = {code}})
table.insert(ret, '| ' .. description)
end
for _, rowData in ipairs(tableData) do
addRow(rowData.code, rowData.description)
for _, alias in ipairs(rowData.aliases) do
addRow(alias, rowData.description)
end
end
table.insert(ret, '|}')
return table.concat(ret, '\n')
end
function p.main(frame)
local tableData = makeTableData(m_iconData)
local ret = {
'{| class="wikitable sortable"',
'! Icon',
'! Description',
'! Code',
'! Aliases'
}
for _, rowData in ipairs(tableData) do
table.insert(ret, '|-')
table.insert(ret, '| style="text-align: center" | ' .. frame:expandTemplate{title = 'icon', args = {rowData.code}})
table.insert(ret, '| ' .. rowData.description)
table.insert(ret, '| <code>' .. mw.text.nowiki('{{icon|' .. rowData.code .. '}}') .. '</code>')
local aliasText = {}
for _, alias in ipairs(rowData.aliases) do
table.insert(aliasText, '<code>' .. alias .. '</code>')
end
table.insert(ret, '| ' .. table.concat(aliasText, ', '))
end
table.insert(ret, '|}')
return table.concat(ret, '\n')
end
return p