Jump to content
Wikipedia The Free Encyclopedia

Module:World topic

From Wikipedia, the free encyclopedia
Module documentation[view] [edit] [history] [purge]
This module is rated as beta. It is considered ready for widespread use, but as it is still relatively new, it should be applied with some caution to ensure results are as expected.
Page semi-protected Editing of this module by new or unregistered users is currently disabled.
See the protection policy and protection log for more details. If you cannot edit this module and you wish to make a change, you can submit an edit request , discuss changes on the talk page, request unprotection, log in, or create an account.

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.

The above documentation is transcluded from Module:World topic/doc. (edit | history)
Editors can experiment in this module's sandbox (edit | diff) and testcases (create) pages.
Subpages of this module.

 localp={}

 localNavbox=require("Module:Navbox")
 localcountry={
 Afghanistan={""},
 Albania={""},
 Algeria={""},
 Andorra={""},
 Angola={""},
 ["Antigua and Barbuda"]={""},
 Argentina={""},
 Armenia={""},
 Australia={""},
 Austria={""},
 Azerbaijan={""},
 Bahamas={"the Bahamas"},
 Bahrain={""},
 Bangladesh={""},
 Barbados={""},
 Belarus={""},
 Belgium={""},
 Belize={""},
 Benin={""},
 Bhutan={""},
 Bolivia={""},
 ["Bosnia and Herzegovina"]={""},
 Botswana={""},
 Brazil={""},
 Brunei={""},
 Bulgaria={""},
 ["Burkina Faso"]={""},
 Burundi={""},
 Cambodia={""},
 Cameroon={""},
 Canada={""},
 ["Cape Verde"]={""},
 ["Central African Republic"]={"the Central African Republic"},
 Chad={""},
 Chile={""},
 China={""},
 Colombia={""},
 Comoros={""},
 ["Democratic Republic of the Congo"]={"the Democratic Republic of the Congo"},
 ["Republic of the Congo"]={"the Republic of the Congo"},
 ["Costa Rica"]={""},
 Croatia={""},
 Cuba={""},
 Cyprus={""},
 ["Czech Republic"]={"the Czech Republic"},
 Denmark={""},
 Djibouti={""},
 Dominica={""},
 ["Dominican Republic"]={"the Dominican Republic"},
 Ecuador={""},
 Egypt={""},
 ["El Salvador"]={""},
 ["Equatorial Guinea"]={""},
 Eritrea={""},
 Estonia={""},
 Eswatini={""},
 Ethiopia={""},
 Fiji={""},
 Finland={""},
 France={""},
 Gabon={""},
 Gambia={"the Gambia"},
 Georgia={"Georgia (country)"},
 Germany={""},
 Ghana={""},
 Greece={""},
 Grenada={""},
 Guatemala={""},
 Guinea={""},
 ["Guinea-Bissau"]={""},
 Guyana={""},
 Haiti={""},
 Honduras={""},
 Hungary={""},
 Iceland={""},
 India={""},
 Indonesia={""},
 Iran={""},
 Iraq={""},
 Ireland={"the Republic of Ireland"},
 Israel={""},
 Italy={""},
 ["Ivory Coast"]={""},
 Jamaica={""},
 Japan={""},
 Jordan={""},
 Kazakhstan={""},
 Kenya={""},
 Kiribati={""},
 Kosovo={""},
 ["North Korea"]={""},
 ["South Korea"]={""},
 Kuwait={""},
 Kyrgyzstan={""},
 Laos={""},
 Latvia={""},
 Lebanon={""},
 Lesotho={""},
 Liberia={""},
 Libya={""},
 Liechtenstein={""},
 Lithuania={""},
 Luxembourg={""},
 Madagascar={""},
 Malawi={""},
 Malaysia={""},
 Maldives={""},
 Mali={""},
 Malta={""},
 ["Marshall Islands"]={"the Marshall Islands"},
 Mauritania={""},
 Mauritius={""},
 Mexico={""},
 ["Federated States of Micronesia"]={"the Federated States of Micronesia"},
 Moldova={""},
 Monaco={""},
 Mongolia={""},
 Montenegro={""},
 Morocco={""},
 Mozambique={""},
 Myanmar={""},
 Namibia={""},
 Nauru={""},
 Nepal={""},
 Netherlands={"the Netherlands"},
 ["New Zealand"]={""},
 Nicaragua={""},
 Niger={""},
 Nigeria={""},
 ["North Macedonia"]={""},
 Norway={""},
 Oman={""},
 Pakistan={""},
 Palestine={""},
 Palau={""},
 Panama={""},
 ["Papua New Guinea"]={""},
 Paraguay={""},
 Peru={""},
 Philippines={"the Philippines"},
 Poland={""},
 Portugal={""},
 Qatar={""},
 Romania={""},
 Russia={""},
 Rwanda={""},
 ["Saint Kitts and Nevis"]={""},
 ["Saint Lucia"]={""},
 ["Saint Vincent and the Grenadines"]={""},
 Samoa={""},
 ["San Marino"]={""},
 ["São Tomé and Príncipe"]={""},
 ["Saudi Arabia"]={""},
 Senegal={""},
 Serbia={""},
 Seychelles={""},
 ["Sierra Leone"]={""},
 Singapore={""},
 Slovakia={""},
 Slovenia={""},
 ["Solomon Islands"]={""},
 Somalia={""},
 ["South Africa"]={""},
 ["South Sudan"]={""},
 Spain={""},
 ["Sri Lanka"]={""},
 Sudan={""},
 Suriname={""},
 Sweden={""},
 Switzerland={""},
 Syria={""},
 Taiwan={""},
 Tajikistan={""},
 Tanzania={""},
 Thailand={""},
 ["Timor-Leste"]={""},
 Togo={""},
 Tonga={""},
 ["Trinidad and Tobago"]={""},
 Tunisia={""},
 Turkey={""},
 Turkmenistan={""},
 Tuvalu={""},
 Uganda={""},
 Ukraine={""},
 ["United Arab Emirates"]={"the United Arab Emirates"},
 ["United Kingdom"]={"the United Kingdom"},
 ["United States"]={"the United States"},
 Uruguay={""},
 Uzbekistan={""},
 Vanuatu={""},
 ["Vatican City"]={""},
 Venezuela={""},
 Vietnam={""},
 ["Western Sahara"]={""},
 Yemen={""},
 Zambia={""},
 Zimbabwe={""},
 }

 localfunctionli(text)
 localli=mw.html.create("li")
 li
 :wikitext(text)
 :done()
 returntostring(li)
 end

 localfunctionlinktarget(x,y)
 ify~=nilandy==""then
 returnx
 else
 returny
 end
 end

 localfunctionlinks(args1,args2,argsprefix,argssuffix,sorter,redlinks,override)
 locallist={}
 localprefix=(args1orargsprefixor"").." "
 localsuffix=args2orargssuffixor""
 forx,yinpairs(sorter)do
 localtarget=nil
 ifredlinksthen
 ifoverride[y]then
 target=override[y]
 elseify=="Georgia"then
 ifmw.title.new(prefix..country[y][1]..suffix).existsthen
 target=prefix..country[y][1]..suffix
 else
 target=prefix..y..suffix
 end
 else
 target=prefix..linktarget(y,country[y][1])..suffix
 end
 else-- noredlinks
 ifoverride[y]then
 ifmw.title.new(override[y]).existsthen
 target=override[y]
 end
 elseifmw.title.new(prefix..linktarget(y,country[y][1])..suffix).existsthen
 target=prefix..linktarget(y,country[y][1])..suffix
 elseify=="Georgia"then
 ifmw.title.new(prefix..y..suffix).existsthen
 target=prefix..y..suffix
 end
 end
 end
 iftargetthen
 table.insert(list,li("[["..target.."|"..y.."]]"))
 end
 end
 returnlist
 end

 functionp.main(frame)
 localpframe=frame:getParent()
 localconfig=frame.args
 localargs=pframe.args

 returnp._main(args)
 end

 functionp._main(args)
 localstate,titlemid,title,group1
 ifmw.title.getCurrentTitle()=="Template:World topic"then
 state="autocollapse"
 else
 state=args.state
 end
 ifargs[1]~=nilorargs.prefix~=niland(args[2]==nilorargs.suffix==nil)then
 titlemid=" the"
 end
 ifargs.title~=nilthen
 title=args.title
 else
 title="[["..(args[1]orargs.prefixor"")..(titlemidor"").." World"..(args.suffixor"").."]]"
 end
 ifargs.group1~=nilandargs.group1~=""then
 group1=args.group1
 end
 localsorter={}
 forninpairs(country)do
 table.insert(sorter,n)
 end
 table.sort(sorter)

 -- parse link overrides, e.g. |link_United_States=Foo sets override["United States"] = "Foo"
 localoverride={}
 fork,vinpairs(args)do
 localcountry=mw.ustring.match(k,"^link_(.*)")
 ifcountrythen
 country=mw.ustring.gsub(country,"_"," ")
 override[country]=v
 end
 end

 localredlinks=args.noredlinks==nil
 locallist1=table.concat(links(args[1],args[2],args.prefix,args.suffix,sorter,redlinks,override))
 localnavarguments={
 name=args.nameor"World topic",
 state=state,
 navbar=args.navbaror"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=group1,
 list1=list1
 }
 returnNavbox._navbox(navarguments)
 end

 returnp

AltStyle によって変換されたページ (->オリジナル) /