Module:World topic
Appearance
![]() | This module is rated as beta, and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected. |
![]() | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
Usage
This module is intended to replace the World topic template. Please see the template for usage instructions.
In order to add an country to this module, simply add it to the countries table. The countries table has an subtable. The first value in said subtable stands for the displayed title, while the second stands for the link target. The link target is only specified if it differs from the displayed title.
This module is callable from other modules. In order to do so, please call the _main function with an table of arguments.
Individual links can be overridden using link_country=title
, with any spaces in the country replaced by underscores. See {{Football in the World}} for an example.
local p = {}
local Navbox = require("Module:Navbox")
local country = {
[1] = {"Afghanistan"},
[2] = {"Albania"},
[3] = {"Algeria"},
[4] = {"Andorra"},
[5] = {"Angola"},
[6] = {"Antigua and Barbuda"},
[7] = {"Argentina"},
[8] = {"Armenia"},
[9] = {"Australia"},
[10] = {"Austria"},
[11] = {"Azerbaijan"},
[12] = {"Bahamas"},
[13] = {"Bahrain"},
[14] = {"Bangladesh"},
[15] = {"Barbados"},
[16] = {"Belarus"},
[17] = {"Belgium"},
[18] = {"Belize"},
[19] = {"Benin"},
[20] = {"Bhutan"},
[21] = {"Bolivia"},
[22] = {"Bosnia and Herzegovina"},
[23] = {"Botswana"},
[24] = {"Brazil"},
[25] = {"Brunei"},
[26] = {"Bulgaria"},
[27] = {"Burkina Faso"},
[28] = {"Burma"},
[29] = {"Burundi"},
[30] = {"Cambodia"},
[31] = {"Cameroon"},
[32] = {"Canada"},
[33] = {"Cape Verde"},
[34] = {"Central African Republic", "the Central African Republic"},
[35] = {"Chad"},
[36] = {"Chile"},
[37] = {"China"},
[38] = {"Colombia"},
[39] = {"Comoros"},
[40] = {"Costa Rica"},
[41] = {"Croatia"},
[42] = {"Cuba"},
[43] = {"Cyprus"},
[44] = {"Czech Republic", "the Czech Republic"},
[45] = {"Democratic Republic of the Congo", "the Democratic Republic of the Congo"},
[46] = {"Denmark"},
[47] = {"Djibouti"},
[48] = {"Dominica"},
[49] = {"East Timor"},
[50] = {"Dominican Republic", "the Dominican Republic"},
[51] = {"Ecuador"},
[52] = {"Egypt"},
[53] = {"El Salvador"},
[54] = {"Equatorial Guinea"},
[55] = {"Eritrea"},
[56] = {"Estonia"},
[57] = {"Ethiopia"},
[58] = {"Federated States of Micronesia", "the Federated States of Micronesia"},
[59] = {"Fiji"},
[60] = {"Finland"},
[61] = {"France"},
[62] = {"Gabon"},
[63] = {"Gambia", "the Gambia"},
[64] = {"Georgia", "Georgia (country)"},
[65] = {"Germany", "the Republic of Macedonia"},
[66] = {"Ghana"},
[67] = {"Greece"},
[68] = {"Greenland"},
[69] = {"Grenada"},
[70] = {"Guatemala"},
[71] = {"Guinea"},
[72] = {"Guinea-Bissau"},
[73] = {"Guyana"},
[74] = {"Haiti"},
[75] = {"Honduras"},
[76] = {"Hong Kong"},
[77] = {"Hungary"},
[78] = {"Iceland"},
[79] = {"India"},
[80] = {"Indonesia"},
[81] = {"Iran"},
[82] = {"Iraq"},
[83] = {"Ireland"},
[84] = {"Israel"},
[85] = {"Italy"},
[86] = {"Ivory Coast"},
[87] = {"Jamaica"},
[88] = {"Japan"},
[89] = {"Jordan"},
[90] = {"Kazakhstan"},
[91] = {"Kenya"},
[92] = {"Kiribati"},
[93] = {"Kuwait"},
[94] = {"Kyrgyzstan"},
[95] = {"Laos"},
[96] = {"Latvia"},
[97] = {"Lebanon"},
[98] = {"Lesotho"},
[99] = {"Liberia"},
[100] = {"Libya"},
[101] = {"Liechtenstein"},
[102] = {"Lithuania"},
[103] = {"Luxembourg"},
[104] = {"Macau"},
[105] = {"Republic of Macedonia"},
[106] = {"Madagascar"},
[107] = {"Malawi"},
[108] = {"Malaysia"},
[109] = {"Maldives"},
[110] = {"Mali"},
[111] = {"Malta"},
[112] = {"Marshall Islands", "the Marshall Islands"},
[113] = {"Mauritania"},
[114] = {"Mauritius"},
[115] = {"Mexico"},
[116] = {"Moldova"},
[117] = {"Monaco"},
[118] = {"Mongolia"},
[119] = {"Montenegro"},
[120] = {"Morocco"},
[121] = {"Mozambique"},
[122] = {"Namibia"},
[123] = {"Nauru"},
[124] = {"Nepal"},
[125] = {"Netherlands", "the Netherlands"},
[126] = {"New Zealand"},
[127] = {"Nicaragua"},
[128] = {"Niger"},
[129] = {"Nigeria"},
[130] = {"North Korea"},
[131] = {"Norway"},
[132] = {"Oman"},
[133] = {"Pakistan"},
[134] = {"Palau"},
[135] = {"Panama"},
[136] = {"Papua New Guinea"},
[137] = {"Paraguay"},
[138] = {"Peru"},
[139] = {"Philippines", "the Philippines"},
[140] = {"Poland"},
[141] = {"Portugal"},
[142] = {"Qatar"},
[143] = {"Republic of the Congo"},
[144] = {"Romania"},
[145] = {"Russia"},
[146] = {"Rwanda"},
[147] = {"Saint Kitts and Nevis"},
[148] = {"Saint Lucia"},
[149] = {"Saint Vincent and the Grenadines"},
[150] = {"Samoa"},
[151] = {"San Marino"},
[152] = {"São Tomé and Príncipe"},
[153] = {"Saudi Arabia"},
[154] = {"Senegal"},
[155] = {"Serbia"},
[156] = {"Seychelles"},
[157] = {"Sierra Leone"},
[158] = {"Singapore"},
[159] = {"Slovakia"},
[160] = {"Slovenia"},
[161] = {"Solomon Islands", "the Solomon Islands"},
[162] = {"Somalia"},
[163] = {"South Africa"},
[164] = {"South Korea"},
[165] = {"South Sudan"},
[166] = {"Spain"},
[167] = {"Sri Lanka"},
[168] = {"Sudan"},
[169] = {"Suriname"},
[170] = {"Swaziland"},
[171] = {"Sweden"},
[172] = {"Switzerland"},
[173] = {"Syria"},
[174] = {"Taiwan"},
[175] = {"Tajikistan"},
[176] = {"Tanzania"},
[177] = {"Thailand"},
[178] = {"Timor-Leste"},
[179] = {"Togo"},
[180] = {"Tonga"},
[181] = {"Trinidad and Tobago"},
[182] = {"Tunisia"},
[183] = {"Turkey"},
[184] = {"Turkmenistan"},
[185] = {"Tuvalu"},
[186] = {"Uganda"},
[187] = {"Ukraine"},
[188] = {"United Arab Emirates", "the United Arab Emirates"},
[189] = {"United Kingdom", "the United Kingdom"},
[190] = {"United States", "the United States"},
[191] = {"Uruguay"},
[192] = {"Uzbekistan"},
[193] = {"Vanuatu"},
[194] = {"Vatican City"},
[195] = {"Venezuela"},
[196] = {"Vietnam"},
[197] = {"Yemen"},
[198] = {"Zambia"},
[199] = {"Zimbabwe"},
}
function p.main(frame)
local pframe = frame:getParent()
local config = frame.args
local args = pframe.args
return p._main(args)
end
function p._main(args)
if mw.title.getCurrentTitle() == "Template:World topic" then
state = "autocollapse"
else
state = args.state
end
if args[1] ~= nil or args.prefix ~= nil and (args[2] == nil or ags.suffix == nil) then
titlemid = " the"
end
local title = "[["..(args[1] or args.prefix or "")..(titlemid or "").." World"..(args.suffix or "").."]]"
if args.noredlinks ~= nil then
list1 = table.concat(noredlinks(args[1], args[2], args.prefix, args.suffix) )
else
list1 = table.concat(redlinks(args[1], args[2], args.prefix, args.suffix) )
end
local navarguments = {
name = args.name or "World topic",
state = state,
navbar = args.navbar or "Tnavbar",
border = args.border,
title = title,
image = args.image,
titlestyle = args.titlestyle,
bodystyle = args.bodystyle,
abovestyle = args.abovestyle,
belowstyle = args.belowstyle,
groupstyle = args.groupstyle,
liststyle = args.liststyle,
listclass = "hlist",
above = args.above,
group1 = args.group1,
list1 = list1
}
return Navbox._navbox(navarguments)
end
function noredlinks(args1, args2, argsprefix, argssuffix)
local list = {}
local i = 1
for x, y in pairs(country) do
if mw.title.new((args1 or argsprefix or "").." "..(country[i][2] or country[i][1])..(args2 or argssuffix or "")).exists == true then
table.insert(list, li("[["..(args1 or argsprefix or "").." "..(country[i][2] or country[i][1])..(args2 or
argssuffix or "").."|"..country[i][1].."]]"))
end
i = i + 1
end
return list
end
function redlinks(args1, args2, argsprefix, argssuffix)
local list = {}
local i = 1
for x, y in pairs(country) do
table.insert(list, li("[["..(args1 or argsprefix or "").." " .. (country[i][2] or country[i][1]) .. (args2 or argssuffix or "")
.."|".. country[i][1] .. "]]") )
i = i + 1
end
return list
end
function li(text)
local li = mw.html.create("li")
li
:wikitext(text)
:done()
return tostring(li)
end
return p