Module:Taxonbar
{{Taxonbar}} (edit talk history links # /subpages /doc /doc edit /sbox /sbox diff /test)
![]() | This Lua module is used on approximately 473,000 pages, or roughly 1% of all pages. To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them. |
![]() | This module is rated as ready for general use. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing. |
![]() | 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. |
![]() | This module depends on the following other modules: |
Related pages |
---|
This module contains the code of {{Taxonbar}}. To use Taxonbar, follow instructions at Template:Taxonbar/doc.
Configuration
Parameters and databases are set by Module:Taxonbar/conf.
Taxon identifiers
Testcases
For testcases use: {{Taxonbar | from=QID}}
Rhododendron maximum Lua error in package.lua at line 80: module 'Module:No globals' not found. Asclepias syriaca Lua error in package.lua at line 80: module 'Module:No globals' not found. Peach (Prunus persica) Lua error in package.lua at line 80: module 'Module:No globals' not found. Puma (genus) Lua error in package.lua at line 80: module 'Module:No globals' not found. Dog (Canis lupus familiaris) Lua error in package.lua at line 80: module 'Module:No globals' not found. Eastern bluebird (Sialia sialis) Lua error in package.lua at line 80: module 'Module:No globals' not found. Honey bee (Apis) Lua error in package.lua at line 80: module 'Module:No globals' not found. Western honey bee (Apis mellifera) Lua error in package.lua at line 80: module 'Module:No globals' not found. Clipper butterfly (Parthenos sylvia) Lua error in package.lua at line 80: module 'Module:No globals' not found. Turkey tail (Trametes versicolor) Lua error in package.lua at line 80: module 'Module:No globals' not found. Button/portobello mushroom (Agaricus bisporus) Lua error in package.lua at line 80: module 'Module:No globals' not found.
Module editing — to-do list
See also
- Module:Taxonbar/conf – the configuration module to add/remove/edit sources
- {{Taxonbar/exists}} – tests for {{Taxonbar}} existence
- {{Taxonbar/candidate}} – categorize highly-likely and potentially-likely {{Taxonbar}} candidates
- Module:Authority control – a {{Taxonbar}}-like module for unique subjects
- gl:Módulo:Taxonbar – original code source for this module
require('Module:No globals')
local function getCatForId( id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
return '[[Category:Wikipedia articles with ' .. id .. ' identifiers]]'
elseif namespace == 2 and not title.isSubpage then
return '[[Category:User pages with ' .. id .. ' identifiers]]'
else
return '[[Category:Miscellaneous pages with ' .. id .. ' identifiers]]'
end
end
local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end
--Links
local function araneaeLink( id )
return '[http://www.araneae.unibe.ch/data/' .. id .. ' ' .. id .. ']' .. getCatForId( 'Araneae' )
end
local function plantlistLink( id )
return '[http://www.theplantlist.org/tpl1.1/record/' .. id .. ' ' .. id .. ']' .. getCatForId( 'PlantList' )
end
local function ncbiLink ( id )
return '[https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Info&id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'NCBI' )
end
local function taxrefLink ( id )
return '[https://inpn.mnhn.fr/espece/cd_nom/' .. id .. ' ' .. id .. ']' .. getCatForId( 'TAXREF' )
end
local function spratLink ( id )
return '[http://www.environment.gov.au/cgi-bin/sprat/public/publicspecies.pl?taxon_id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'SPRAT' )
end
local function zoobankLink ( id )
return '[http://zoobank.org/NomenclaturalActs/' .. id .. ' ID]' .. getCatForId( 'ZooBank' )
end
local function plaziLink ( id )
return '[http://treatment.plazi.org/id/' .. id .. ' ID]' .. getCatForId( 'Plazi' )
end
local function nbnLink ( id )
return '[https://data.nbn.org.uk/Taxa/' .. id .. ' ' .. id .. ']' .. getCatForId( 'NBN' )
end
local function dyntaxaLink ( id )
return '[https://www.dyntaxa.se/taxon/info/' .. id .. ' ' .. id .. ']' .. getCatForId( 'Dyntaxa' )
end
local function lepindexLink( id )
return '[http://www.nhm.ac.uk/jdsml/research-curation/research/projects/lepindex/detail.dsml?TaxonNo=' .. id .. ' ' .. id .. ']' .. getCatForId( 'LepIndex' )
end
local function butmothLink( id )
return '[http://www.nhm.ac.uk/jdsml/research-curation/research/projects/butmoth/GenusDetails.dsml?NUMBER=' .. id .. ' ' .. id .. ']' .. getCatForId( 'ButMoth' )
end
local function bacdiveLink( id )
return '[http://bacdive.dsmz.de/index.php?rd=' .. id .. ' ' .. id .. ']' .. getCatForId( 'BacDive' )
end
local function tropicosLink( id )
return '[http://www.tropicos.org/Name/' .. id .. ' ' .. id .. ']' .. getCatForId( 'Tropicos' )
end
local function eppoLink( id )
return '[https://gd.eppo.int/taxon/' .. id .. ' ' .. id .. ']' .. getCatForId( 'EPPO' )
end
local function eolLink ( id )
return '[http://eol.org/pages/' .. id .. ' ' .. id .. ']' .. getCatForId( 'EOL' )
end
local function biolibLink ( id )
return '[http://www.biolib.cz/en/taxon/id' .. id .. ' ' .. id .. ']' .. getCatForId( 'BioLib' )
end
local function ictvLink ( id )
return '[http://ictvdb.bio-mirror.cn/ICTVdB/' .. id .. 'htm ' .. id .. ']' .. getCatForId( 'ICTV' )
end
local function fwLink ( id )
return '[http://fossilworks.org/bridge.pl?a=taxonInfo&taxon_no=' .. id .. ' ' .. id .. ']' ..getCatForId( 'FW' )
end
local function mswLink ( id )
return '[http://www.departments.bucknell.edu/biology/resources/msw3/browse.asp?s=y&id=' .. id .. ' ' .. id .. ']' ..getCatForId( 'MSW' )
end
local function arkiveLink ( id )
return '[http://www.arkive.org/' .. id .. ' ID]' ..getCatForId( 'ARKive' )
end
local function ipniLink ( id )
return '[http://www.ipni.org/ipni/idPlantNameSearch.do?id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'IPNI' )
end
local function speciesLink ( id )
return '[http://speciesplus.net/#/taxon_concepts/' .. id .. '/legal ' .. id .. ']' .. getCatForId( 'Species+' )
end
local function grassbaseLink ( id )
return '[http://www.kew.org/data/grasses-db/www/' .. id .. '.htm ' .. id .. ']' .. getCatForId( 'GrassBase' )
end
local function mycobankLink ( id )
return '[http://www.mycobank.org/MycoTaxo.aspx?Link=T&Rec=' .. id .. ' ' .. id .. ']' .. getCatForId( 'MycoBank' )
end
local function faunaEuropaeaLink ( id )
return '[http://fauna.naturkundemuseum-berlin.de/full_results.php?id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'FE' )
end
local function wormsLink ( id )
return '[http://www.marinespecies.org/aphia.php?p=taxdetails&id=' .. id .. ' ' .. id .. ']' .. getCatForId('WoRMS')
end
local function itisLink ( id )
return '[http://www.itis.gov/servlet/SingleRpt/SingleRpt?search_topic=TSN&search_value=' .. id .. ' ' .. id .. ']' .. getCatForId('ITIS')
end
local function iucnLink ( id )
return '[http://www.iucnredlist.org/details/' .. id .. '/0 ' .. id .. ']' .. getCatForId('IUCN')
end
local function fishbaseLink ( id )
return '[http://www.fishbase.org/Summary/speciesSummary.php?id=' .. id .. ' ' .. id .. ']' .. getCatForId('FishBase')
end
local function fungorumLink ( id )
return '[http://www.indexfungorum.org/names/NamesRecord.asp?RecordID=' .. id .. ' ' .. id .. ']' .. getCatForId('Fungorum')
end
local function gbifLink ( id )
return '[http://www.gbif.org/species/' .. id .. ' ' .. id .. ']' .. getCatForId('GBIF')
end
local function avibaseLink ( id )
return '[http://avibase.bsc-eoc.org/species.jsp?avibaseid=' .. id .. ' ' .. id .. ']' .. getCatForId( 'Avibase' )
end
local function inaturalistLink ( id )
return '[http://www.inaturalist.org/taxa/' .. id .. ' ' .. id .. ']' .. getCatForId( 'iNaturalist' )
end
local function xenocantoLink ( id )
return '[http://www.xeno-canto.org/species/' .. id .. ' ' .. id .. ']' .. getCatForId( 'Xenocanto')
end
local function fnaLink ( id )
return '[http://www.efloras.org/florataxon.aspx?flora_id=1&taxon_id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'FNA')
end
local function focLink ( id )
return '[http://www.efloras.org/florataxon.aspx?flora_id=2&taxon_id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'FoC')
end
local function vascanLink ( id )
return '[http://data.canadensys.net/vascan/taxon/' .. id .. ' ' .. id .. ']' .. getCatForId( 'VASCAN')
end
local function vlindernetLink ( id )
return '[http://www.vlindernet.nl/vlindersoort.php?vlinderid=' .. id .. ' ' .. id .. ']' .. getCatForId( 'Vlindernet')
end
local function usdaplantsLink ( id )
return '[http://plants.usda.gov/core/profile?symbol=' .. id .. ' ' .. id .. ']' .. getCatForId( 'USDAPLANTS')
end
local function apdbLink ( id )
return '[http://www.ville-ge.ch/musinfo/bd/cjb/africa/details.php?langue=an&id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'APDB')
end
local function foaoLink ( id )
return '[http://www.anbg.gov.au/abrs/online-resources/flora/stddisplay.xsql?pnid=' .. id .. ' ' .. id .. ']' .. getCatForId( 'FoAO')
end
local function florabaseLink ( id )
return '[http://florabase.dec.wa.gov.au/browse/profile/' .. id .. ' ' .. id .. ']' .. getCatForId( 'FloraBase')
end
local function plantariumLink ( id )
return '[http://www.plantarium.ru/page/view/item/' .. id .. '.html ' .. id .. ']' .. getCatForId( 'Plantarium')
end
local function soortenregisterLink ( id )
return '[http://www.nederlandsesoorten.nl/linnaeus_ng/app/views/species/nsr_taxon.php?id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'Soortenregister')
end
local function telabotanicaLink ( id )
return '[http://www.tela-botanica.org/bdtfx-nn-' .. id .. ' ' .. id .. ']' .. getCatForId( 'TelaBotanica')
end
local function wcspfLink ( id )
return '[http://apps.kew.org/wcsp/namedetail.do?name_id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'WCSPF')
end
local function wscLink ( id )
return '[http://www.wsc.nmbe.ch/lsid/' .. id .. ' ' .. id .. ']' .. getCatForId( 'WSC')
end
local function ibcLink ( id )
return '[http://www.hbw.com/ibc/species/' .. id .. ' ID]' .. getCatForId( 'IBC')
end
local function bugguideLink ( id )
return '[http://bugguide.net/node/view/' .. id .. ' ' .. id .. ']' .. getCatForId( 'BugGuide')
end
-------
local function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
return ids
end
local function matchesWikidataRequirements( item, reqs )
for _, group in pairs( reqs ) do
local property = 'p' .. group[1]
local qid = group[2]
if item.claims[property] ~= nil then
for _, statement in pairs ( item.claims[property] ) do
if statement.mainsnak.datavalue ~= nil then
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
return true
end
end
end
end
end
return false
end
local function createRow( id, label, rawValue, link, withUid )
if link then
if withUid then
return '*<span style="white-space:nowrap;">' .. label .. ' <span class="uid">' .. link .. '</span></span>\n'
else
return '*<span style="white-space:nowrap;">' .. label .. ' ' .. link .. '</span>\n'
end
else
return '* <span class="error">O identificador ' .. id .. ' ' .. rawValue .. ' non é válido.</span>[[Categoría:Wikipedia:Artigos con identificadores de control de autoridades non válidos]]\n'
end
end
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function
local conf = {
--Bioloxía
{ 'APDB', 'APDB', 2036, apdbLink},
{ 'Araneae', 'Araneae', 3594, araneaeLink},
{ 'ARKive', '[[ARKive]]', 2833, arkiveLink},
{ 'Avibase', 'Avibase', 2026, avibaseLink},
{ 'BacDive', '[[BacDive]]', 2946, bacdiveLink},
{ 'BioLib', 'BioLib', 838, biolibLink},
{ 'BugGuide', '[[BugGuide]]', 2464, bugguideLink},
{ 'ButMoth', '[[Natural History Museum#Butterflies and Moths of the World|ButMoth]]', 3060, butmothLink},
{ 'Dyntaxa', 'Dyntaxa', 1939, dyntaxaLink},
{ 'EOL', '[[Encyclopedia of Life|EOL]]', 830, eolLink},
{ 'EPPO', '[[Organización Europea e Mediterránea de Protección Vexetal|EPPO]]', 3031, eppoLink},
{ 'FE', '[[Fauna Europaea|FE]]', 1895, faunaEuropaeaLink},
{ 'FishBase', '[[FishBase]]', 938, fishbaseLink},
{ 'FloraBase', '[[FloraBase]]', 3101, florabaseLink},
{ 'FNA', '[[Flora of North America|FNA]]', 1727, fnaLink},
{ 'FoAO', 'FoAO', 3100, foaoLink},
{ 'FoC', '[[Flora of China|FoC]]', 1747, focLink},
{ 'Fungorum', '[[Index Fungorum|Fungorum]]', 1391, fungorumLink},
{ 'FW', '[[Fossilworks]]', 842, fwLink},
{ 'GBIF', '[[Global Biodiversity Information Facility|GBIF]]', 846, gbifLink},
{ 'GrassBase', '[[Reais Xardíns Botánicos de Kew|GrassBase]]', 1832, grassbaseLink},
{ 'IBC', '[[Handbook of the Birds of the World|IBC]]', 3099, ibcLink},
{ 'ICTV', '[[Comité Internacional de Taxonomía dos Virus|ICTV]]', 1076, ictvLink},
{ 'iNaturalist', '[[iNaturalist]]', 3151, inaturalistLink},
{ 'IPNI', '[[International Plant Names Index|IPNI]]', 961, ipniLink},
{ 'ITIS', '[[Sistema Integrado de Información Taxonómica|ITIS]]', 815, itisLink},
{ 'IUCN', '[[IUCN]]', 627, iucnLink},
{ 'LepIndex', '[[Natural History Museum#The Global Lepidoptera Names Index|LepIndex]]', 3064, lepindexLink},
{ 'MSW', '[[Mammal Species of the World|MSW]]', 959, mswLink},
{ 'MycoBank', '[[MycoBank]]', 962, mycobankLink},
{ 'NBN', '[[National Biodiversity Network|NBN]]', 3240, nbnLink},
{ 'NCBI', '[[National Center for Biotechnology Information|NCBI]]', 685, ncbiLink},
{ 'Plantarium', 'Plantarium', 3102, plantariumLink},
{ 'PlantList', '[[The Plant List|PlantList]]', 1070, plantlistLink},
{ 'Plazi', '[[Plazi]]', 1992, plaziLink},
{ 'Soortenregister', 'Soortenregister', 3405, soortenregisterLink},
{ 'Species+', '[[CITES|Species+]]', 2040, speciesLink},
{ 'SPRAT', '[[Species Profile and Threats Database|SPRAT]]', 2455, spratLink},
{ 'TAXREF', 'TAXREF', 3186, taxrefLink},
{ 'TelaBotanica', '[[Tela Botanica]]', 3105, telabotanicaLink},
{ 'Tropicos', '[[Tropicos]]', 960, tropicosLink},
{ 'USDAPLANTS', '[[Departamento de Agricultura dos Estados Unidos|PLANTS]]', 1772, usdaplantsLink},
{ 'VASCAN', 'VASCAN', 1745, vascanLink},
{ 'Vlindernet', 'Vlindernet', 3322, vlindernetLink},
{ 'WCSPF', '[[World Checklist of Selected Plant Families|WCSPF]]', 3591, wcspfLink},
{ 'WoRMS', '[[World Register of Marine Species|WoRMS]]', 850, wormsLink},
{ 'WSC', '[[World Spider Catalog|WSC]]', 3288, wscLink},
{ 'Xenocanto', 'Xeno-canto', 2426, xenocantoLink},
{ 'ZooBank', '[[ZooBank]]', 1746, zoobankLink}
}
-- Check that the Wikidata item has this property-->value before adding it
local reqs = {}
local p = {}
function p.authorityControlTaxon( frame )
local parentArgs = frame:getParent().args
--Create rows
local elements = {}
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then --Só no espazo de nomes principal
--redirect PND to GND
if (parentArgs.GND == nil or parentArgs.GND == '') and parentArgs.PND ~= nil and parentArgs.PND ~= '' then
parentArgs.GND = parentArgs.PND
end
--Wikidata fallback if requested
local item = mw.wikibase.getEntityObject()
if item ~= nil and item.claims ~= nil then
for _, params in pairs( conf ) do
if params[3] ~= 0 then
local val = parentArgs[params[1]]
if not val or val == '' then
local canUseWikidata = nil
if reqs[params[1]] ~= nil then
canUseWikidata = matchesWikidataRequirements( item, reqs[params[1]] )
else
canUseWikidata = true
end
if canUseWikidata then
local wikidataIds = getIdsFromWikidata( item, 'P' .. params[3] )
if wikidataIds[1] then
parentArgs[params[1]] = wikidataIds[1]
end
end
end
end
end
end
--Configured rows
local rct = 0
for k, params in pairs( conf ) do
local val = parentArgs[params[1]]
if val and val ~= '' then
table.insert( elements, createRow( params[1], params[2] .. ':', val, params[4]( val ), true ) )
rct = rct + 1
end
end
local Navbox = require('Módulo:Navbox')
--local elementscats = ''
--if rct > 13 then
-- elementscats = '[[Categoría:Wikipedia:Control de autoridades con ' .. rct .. ' elementos]]'
--end
if #elements ~= 0 then
return Navbox._navbox( {
name = 'Taxonbar',
bodyclass = 'hlist',
listclass = 'plainlinks',
groupstyle = 'width: 15%; text-align:center;',
group1 = 'Identificadores Taxonómicos', --.. elementscats,
list1 = table.concat( elements )
} )
else
return ""
end
end
end
return p