ਸਮੱਗਰੀ 'ਤੇ ਜਾਓ

ਮੌਡਿਊਲ:Icon/table

ਵਿਕੀਪੀਡੀਆ, ਇੱਕ ਆਜ਼ਾਦ ਵਿਸ਼ਵਕੋਸ਼ ਤੋਂ

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.

{{#invoke:icon/table|main}}

Output

[ਸੋਧੋ]
Icon Description Code Aliases
A-Class article {{icon|a}}
Audited article of limited subject matter {{icon|aa}}
A-Class article candidate {{icon|acc}} aac, acn
B-Class article {{icon|b}}
ਵਿਕੀਪੀਡੀਆ ਕਿਤਾਬ {{icon|book}}
Bplus-Class article {{icon|bplus}} b+
B-Class review {{icon|br}} bcr
C-Class article {{icon|c}}
ਸ਼੍ਰੇਣੀ {{icon|category}} cat, categ
Cleanup work {{icon|cleanup}}
Commons page {{icon|commons}}
Demoted article {{icon|da}}
Demoted A-Class article {{icon|dac}} daa
Delisted good article {{icon|dga}}
ਗੁੰਝਲ ਖੋਲ੍ਹ ਸਫ਼ਾ {{icon|disambiguation}} dab, disamb, disambig
ਕੀ ਤੁਸੀਂ ਜਾਣਦੇ ਹੋ? {{icon|dyk}}
ਕੀ ਤੁਸੀਂ ਜਾਣਦੇ ਹੋ? {{icon|dyk2}}
Essay {{icon|essay}}
ਚੁਣਿਆ ਹੋਇਆ ਲੇਖ {{icon|fa}}
Featured article candidate {{icon|fac}} fan
Featured article review {{icon|far}}
Featured article removal candidate {{icon|farc}}
ਪੁਰਾਣਾ ਚੁਣਿਆ ਹੋਇਆ ਲੇਖ {{icon|ffa}} dfa
Failed featured article candidate {{icon|ffac}} nofa
Former featured list {{icon|ffl}} dfl
Failed featured list candidate {{icon|fflc}} nofl
Former featured picture {{icon|ffp}}
Former featured portal {{icon|ffpo}}
Former featured sound {{icon|ffs}}
Former featured topic {{icon|fft}} dft
Failed good article nominee {{icon|fgan}} gaf, gf, noga
Featured list {{icon|fl}}
Featured list candidate {{icon|flc}} fln
Featured list removal candidate {{icon|flrc}} flr
Four Award {{icon|four}} 4a
ਚੁਣੀ ਹੋਈ ਤਸਵੀਰ {{icon|fp}}
Featured picture candidate {{icon|fpc}} fpn
Before the featured portal process ceased in 2017, this had been designated as a featured portal. {{icon|fpo}}
Featured portal candidate {{icon|fpoc}}
Featured portal review {{icon|fpor}}
Featured sound {{icon|fs}}
Featured sound candidate {{icon|fsc}}
Featured topic {{icon|ft}}
Featured topic candidate {{icon|ftc}} ftn
Featured topic removal candidate {{icon|ftrc}}
Good article {{icon|ga}}
Good article, 2nd opinion {{icon|ga2}}
Good article on hold {{icon|gah}}
Good article nominee {{icon|gan}} gac
Good article reassessment {{icon|gar}}
Guild of Copy Editors {{icon|goce}}
Good topic {{icon|gt}}
Good topic candidate {{icon|gtc}} gtn
Good topic removal candidate {{icon|gtrc}}
ਫਾਈਲ {{icon|image}} file
ਖ਼ਬਰਾਂ ਵਿੱਚ {{icon|itn}}
List-Class article {{icon|list}} comparison
MediaWiki {{icon|mediawiki}}
Meta-wiki page {{icon|meta}}
Million Award {{icon|million}}
Module {{icon|module}}
Non-article page {{icon|na}}
ਲੇਖ ਚਾਹੀਦਾ {{icon|needed}}
Unknown-Class article {{icon|no}}
Failed A-Class article candidate {{icon|noac}} faac
ਅੱਜ ਦੇ ਦਿਨ {{icon|otd}}
Outline {{icon|outline}}
Phabricator {{icon|phabricator}} phab
ਪੋਰਟਲ {{icon|portal}}
Picture of the Day {{icon|potd}}
Portal peer review {{icon|ppr}}
Peer review {{icon|pr}}
ਪ੍ਰਜੈਕਟ ਸਫ਼ਾ {{icon|project}}
ਪ੍ਰਸ਼ਨ {{icon|q}} question
Quality image on Wikimedia Commons {{icon|qi}}
ਰੀਡਾਇਰੈਕਟ {{icon|redirect}} red, redir
Start-Class article {{icon|start}}
Stub-Class article {{icon|stub}}
ਫਰਮਾ {{icon|template}} temp, templ
ਅੱਜ ਦਾ ਚੁਣਿਆ ਹੋਇਆ ਲੇਖ {{icon|tfa}}
Today's Featured List {{icon|tfl}}
Valued image on Wikimedia Commons {{icon|vi}}
Vital article {{icon|vital}}
Valued picture {{icon|vp}}
Valued picture candidate {{icon|vpc}}
Wikibooks page {{icon|wikibooks}}
Wikidata page {{icon|wikidata}}
Wikinews page {{icon|wikinews}}
ਵਿਕੀਪੀਡੀਆ ਸਫ਼ਾ {{icon|wikipedia}}
ਵਿਕੀਪ੍ਰੋਜੈਕਟ {{icon|wikiproject}}
Wikiquote page {{icon|wikiquote}}
Wikisource page {{icon|wikisource}}
Wikispecies page {{icon|wikispecies}}
Wikitech {{icon|wikitech}}
Wikiversity page {{icon|wikiversity}}
Wikivoyage page {{icon|wikivoyage}}
Wiktionary page {{icon|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