local title = "WoRMS taxon details: AphiaID " .. id
local url = data.WoRMS.customArgs['baseURL'] .. data.WoRMS.customArgs['searchStr'] .. id
return title, url  
end
data.WoRMS.default = function
if templateArgs['db'] then
data.WoRMS.db (templateArgs['db'])
end
end
data.WoRMS.db = function(db) -- if database hosted by WoRMS  
db = string.lower( db )
if db == "world of copepods database" or db == "copepoda" or db == "copepods" or db == "copepod" then
templateArgs['author'] = "World of Copepods Database"
templateArgs['editor-last1']="Walter"; templateArgs['editor-first1']="T.C."
templateArgs['editor-last2']="Boxshall"; templateArgs['editor-first2']="G."
-- year ? (2022).
elseif db == "world amphipoda database" or db == "amphipoda" or db == "amphipod"then
templateArgs['author'] = "World Amphipoda Database"
templateArgs['editor-last1']="Horton"; templateArgs['editor-first1']="T."
templateArgs['editor-last2']="Lowry"; templateArgs['editor-first2']="J."
templateArgs['editor-last3']="De Broyer"; templateArgs['editor-first3']="C."
templateArgs['display-editors']="etal"; -- full list is about 20 names
elseif db == "world isopoda database" or db == "isopoda" or db == "isopod"then
templateArgs['author'] = "World Marine, Freshwater and Terrestrial Isopod Crustaceans database"
templateArgs['editor-last1']="Boyko"; templateArgs['editor-first1']="C.B."
templateArgs['editor-last2']="Bruce"; templateArgs['editor-first2']="N.L."
templateArgs['editor-last3']="Hadfield"; templateArgs['editor-first3']="K.A."
templateArgs['editor-last4']="Merrin"; templateArgs['editor-first4']="K.L."
templateArgs['editor-last5']="Ota."; templateArgs['editor-first5']="Y."
templateArgs['editor-last6']="Poore"; templateArgs['editor-first6']="G.C.B."
templateArgs['editor-last7']="Taiti"; templateArgs['editor-first7']="S."
elseif db == "millibase" or db == "diplopoda" or db == "diplopod"then
templateArgs['author'] = "MilliBase"
templateArgs['editor-last1']="Sierwald"; templateArgs['editor-first1']="P."
templateArgs['editor-last2']="Spelda"; templateArgs['editor-first2']="J."
elseif db == "molluscabase" or db == "mollusca" or db == "mollusc" then
templateArgs['author'] = "MolluscaBase"
else
templateArgs['author'] = templateArgs['db'] -- this is recommended by WoRMS
end
end
-- ITIS - Integrated Taxonomic Information System
https://www.itis.gov/servlet/SingleRpt/SingleRpt?search_topic=TSN&search_value=95601#null  
data.itis = {
citationArgs = {
website = "Integrated Taxonomic Information System",
--publisher = "",
},
customArgs = {exclude="id,1,2,3,4,5",
baseURL = "https://www.itis.gov/",
searchStr = "servlet/SingleRpt/SingleRpt?search_topic=TSN&search_value=",
defaultTitle="Integrated Taxonomic Information System"
}
}
data.itis.id = function(id)  
local title = "ITIS id=" .. id
local url = data.itis.customArgs['baseURL'] .. data.itis.customArgs['searchStr'] .. id  
return title, url  
end  
-- Catalogue of Life:
Roskov Y., Ower G., Orrell T., Nicolson D., Bailly N., Kirk P.M., Bourgoin T., DeWalt R.E., Decock W., van Nieukerken E.J., Penev L. (eds.) (2020).
Species 2000 & ITIS Catalogue of Life, 2020-12-01.
Digital resource at www.catalogueoflife.org. Species 2000: Naturalis, Leiden, the Netherlands. ISSN 2405-8858.
Species 2000 & ITIS Catalogue of Life, 2020-12-01. Digital resource at www.catalogueoflife.org.
Species 2000: Naturalis, Leiden, the Netherlands. ISSN 2405-8858.  
data.col = {
db = "col", -- need rethink this
citationArgs = {
--author = "Catalogue of Life",
--['editor-last1'] = "Roskov", ['editor-first1'] = "Y.", ['editor-last2'] = "Ower", ['editor-first2'] = "G.", ['editor-last3'] = "Orrell", ['editor-first3'] = "T.", ['editor-last4'] = "Nicolson", ['editor-first4'] = "D.", ['editor-last5'] = "Bailly", ['editor-first5'] = "N.", ['editor-last6'] = "Kirk", ['editor-first6'] = "P.M.", ['editor-last7'] = "Bourgoin", ['editor-first7'] = "T.", ['editor-last8'] = "DeWalt", ['editor-first8'] = "R.E.", ['editor-last9'] = "Decock", ['editor-first9'] = "W.", ['editor-last10'] = "van Nieukerken", ['editor-first10'] = "E.J.", ['editor-last11'] = "Penev", ['editor-first11'] = "L.",
--website = "Catalogue of Life",
--website = "Species 2000 & ITIS Catalogue of Life",
-- website = "Species 2000 & ITIS Catalogue of Life",
website = "Catalogue of Life",
publisher = "Species 2000: Leiden, the Netherlands",
--others = "Species 2000 & ITIS"  
},
customArgs = {exclude="id,db,1,2,3,4,5,legacy,option",
baseURL = "https://www.catalogueoflife.org/data/",
searchStr = "browse?taxonKey=",
defaultTitle="Catalogue of Life"
}
}
data.col.id = function(id)  
-- Catalogue of Life
browse option: https://www.catalogueoflife.org/data/browse?taxonKey=4JQ8
use id for taxoKey  
taxon option https://www.catalogueoflife.org/data/taxon/6HR5M  
local title = "Catalogue of Life taxonKey " .. id
local url = data.col.customArgs['baseURL']  
-- some new CoL are numbers e.g. 64553 in https://www.catalogueoflife.org/data/taxon/64553
if not tonumber(id) and string.find( id, "^[0-9abcdef]+$" ) then -- if old-style id
local year = "2019" -- last old-style version available
if templateArgs['version'] and string.find( templateArgs['version'], "^%d%d%d%d$" ) then --if version specied
year = templateArgs['version']
end
if templateArgs['option'] == "browse" then
url = "http://www.catalogueoflife.org/annual-checklist/" .. year .. "/browse/tree/id/" .. id
else -- default to option=taxon
url = "http://www.catalogueoflife.org/annual-checklist/" .. year .. "/details/species/id/" .. id
end
else -- else use current version
if templateArgs['option'] == "browse" then
url = url .. "browse?taxonKey=" .. id
else -- default to option=taxon
url = url .. "taxon/" .. id
end
end  
return title, url  
end
-- current links
https://www.catalogueoflife.org/data/search?q=" Chinchilla+chinchilla&type=EXACT
legacy links with redirect
Species pages: http://www.catalogueoflife.org/col/details/species/id/12dca9c49741815f82400bb7bff50553
Species searches: http://www.catalogueoflife.org/col/search/all/key/Dracula+antonii/
old-style links
http://www.catalogueoflife.org/col/details/species/id/7539827da517bd6273a4a3836578cb24
http://www.catalogueoflife.org/col/search/scientific/genus/Chinchilla/species/chinchilla/match/1/
http://www.catalogueoflife.org/col/browse/tree/id/003e480e646d0e7647ab67efc1218197
year specific links
2019 http://www.catalogueoflife.org/annual-checklist/2019/details/species/id/7539827da517bd6273a4a3836578cb24
http://www.catalogueoflife.org/annual-checklist/2019/search/all/key/Chinchilla+chinchilla/fossil/1/match/1
http://www.catalogueoflife.org/annual-checklist/2019/search/scientific/genus/Chinchilla/species/chinchilla/match/1/
? http://www.catalogueoflife.org/annual-checklist/2016/browse/tree?6d600f4985f19b1207d41d847424edd0
? http://www.catalogueoflife.org/col/browse/tree/id/003e480e646d0e7647ab67efc1218197
browse http://www.catalogueoflife.org/annual-checklist/2019/browse/tree/id/003e480e646d0e7647ab67efc1218197  
data.col.default = function(mode) -- this handles the old style template with positional parameters (mode unused?)  
local para1 = templateArgs[1]
local para2 = templateArgs[2]
local para3 = templateArgs[3]
local para4 = templateArgs[4]
if para1 then para1 = mw.text.trim(para1) end
if para2 then para2 = mw.text.trim(para2) end
if para3 then para3 = mw.text.trim(para3) end
if para4 then para4 = mw.text.trim(para4) end  
local title, url  
if para1 then
--local match = "7539827da517bd6273a4a3836578cb24"
local match = "^[0-9abcdef]+$"
if string.find( para1, match ) then
url = "http://www.catalogueoflife.org/col/details/species/id/" .. para1 -- ""Old style id"
--url ="https://www.catalogueoflife.org/data/search?q=" .. para1
if para2 then
title = para2
else
title = "Oldstyle id: " .. para1
end  
else  
--https://www.catalogueoflife.org/data/search?q=" Chinchilla+chinchilla&type=EXACT  
if para1 ~= "" then
url = "https://www.catalogueoflife.org/data/search?q=" .. para1
title = "''" .. para1
if para2 then
url = url .. "+" .. para2