Difference between revisions of "Module:FishRef/sandbox"
Jump to navigation
Jump to search
blackwiki>Jts1882 (create) |
blackwiki>Jts1882 (change structure to us main entry function instead of seperate functions) |
||
| Line 2: | Line 2: | ||
local p = {} | local p = {} | ||
| + | local data = {} | ||
local templateArgs = {} -- contains arguments passed to cite web | local templateArgs = {} -- contains arguments passed to cite web | ||
| − | local target = {} -- target table, e.g. fishbase, cof, etc | + | local target = {} -- short cut to target table, e.g. fishbase, cof, etc |
local function firstToUpper(str) | local function firstToUpper(str) | ||
| Line 11: | Line 12: | ||
--####################### FISH ##################################### | --####################### FISH ##################################### | ||
--======================== Fishbase ================================= | --======================== Fishbase ================================= | ||
| − | + | data.fishbase = { | |
| − | + | citationArgs = { | |
['editor1-last']="Froese", ['editor1-first']="Rainer", ['editor1-link']="Rainer Froese", | ['editor1-last']="Froese", ['editor1-first']="Rainer", ['editor1-link']="Rainer Froese", | ||
['editor2-last']="Pauly", ['editor2-first']="Daniel", | ['editor2-last']="Pauly", ['editor2-first']="Daniel", | ||
| Line 19: | Line 20: | ||
--['publisher'] = "" | --['publisher'] = "" | ||
}, | }, | ||
| − | + | customArgs = { exclude= "order, family,genus, species, subspecies, 1, 2, 3, 4", | |
baseURL = "http://www.fishbase.org/", | baseURL = "http://www.fishbase.org/", | ||
defaultTitle = "Search FishBase" | defaultTitle = "Search FishBase" | ||
| − | } | + | }, |
} | } | ||
| − | fishbase.species = function(genus, species, subspecies) | + | data.fishbase.species = function(genus, species, subspecies) |
local title = genus .. " " .. species | local title = genus .. " " .. species | ||
| − | local url = fishbase. | + | local url = data.fishbase.customArgs['baseURL'] |
.. "summary/SpeciesSummary.php?genusname=" .. genus .. "&speciesname=" .. species | .. "summary/SpeciesSummary.php?genusname=" .. genus .. "&speciesname=" .. species | ||
if subspecies then | if subspecies then | ||
| Line 36: | Line 37: | ||
return title, url | return title, url | ||
end | end | ||
| − | fishbase.genus = function(genus) | + | data.fishbase.genus = function(genus) |
local title = "Species in genus ''" .. firstToUpper(genus) .. "''" | local title = "Species in genus ''" .. firstToUpper(genus) .. "''" | ||
| − | local url = fishbase. | + | local url = data.fishbase.customArgs['baseURL'] .. "identification/SpeciesList.php?genus=" .. genus |
return title, url | return title, url | ||
end | end | ||
| − | fishbase.order = function(order) | + | data.fishbase.order = function(order) |
local title = "Order " .. firstToUpper(order) | local title = "Order " .. firstToUpper(order) | ||
| − | local url = fishbase. | + | local url = data.fishbase.customArgs['baseURL'] .. "Summary/OrdersSummary.php?order=" .. order |
return title, url | return title, url | ||
end | end | ||
| − | fishbase.family = function(family) | + | data.fishbase.family = function(family) |
local title = "Family " .. firstToUpper(family) | local title = "Family " .. firstToUpper(family) | ||
| − | local url = fishbase. | + | local url = data.fishbase.customArgs['baseURL'] .. "Summary/FamilySummary.php?family=" .. family |
return title, url | return title, url | ||
end | end | ||
| − | fishbase.error = function() | + | data.fishbase.error = function() |
| − | return "No recognised taxon options: order, | + | return "No recognised taxon options: order, family, genus, species, subspecies." |
end | end | ||
| − | fishbase.custom = function() | + | data.fishbase.custom = function() |
--TODO decide what to do with default date | --TODO decide what to do with default date | ||
local version = "April 2006 version" -- Should we have a default (probably not) | local version = "April 2006 version" -- Should we have a default (probably not) | ||
| Line 63: | Line 64: | ||
end | end | ||
--================================ Catalog of Fishes ================================================ | --================================ Catalog of Fishes ================================================ | ||
| − | + | data.cof = { | |
| − | + | citationArgs = { | |
--baseURL = "http://researcharchive.calacademy.org/research/ichthyology/catalog/fishcatget.asp?", | --baseURL = "http://researcharchive.calacademy.org/research/ichthyology/catalog/fishcatget.asp?", | ||
['editor1-last']="Eschmeyer", ['editor1-first']="William N.", ['editor1-link']="William N. Eschmeyer", | ['editor1-last']="Eschmeyer", ['editor1-first']="William N.", ['editor1-link']="William N. Eschmeyer", | ||
| Line 73: | Line 74: | ||
['publisher'] = "[[California Academy of Sciences]]" | ['publisher'] = "[[California Academy of Sciences]]" | ||
}, | }, | ||
| − | + | customArgs = { exclude= "family,genus,species,genid,spid,id,list,1,2,3", | |
baseURL = "http://researcharchive.calacademy.org/research/ichthyology/catalog/fishcatget.asp?", | baseURL = "http://researcharchive.calacademy.org/research/ichthyology/catalog/fishcatget.asp?", | ||
defaultTitle = "CAS - Eschmeyer's Catalog of Fishes" | defaultTitle = "CAS - Eschmeyer's Catalog of Fishes" | ||
} | } | ||
} | } | ||
| − | cof.species = function(genus, species, subspecies) | + | data.cof.species = function(genus, species, subspecies) |
local taxon = genus .. " " .. species | local taxon = genus .. " " .. species | ||
| − | local url = cof. | + | local url = data.cof.customArgs['baseURL'] .. 'tbl=species&genus=' .. genus .. '&species=' .. species |
local title = "Species related to " .. "''" .. firstToUpper(taxon) .. "''" -- .. "" species synonyms" | local title = "Species related to " .. "''" .. firstToUpper(taxon) .. "''" -- .. "" species synonyms" | ||
return title, url | return title, url | ||
end | end | ||
| − | cof.genus = function(genus) | + | data.cof.genus = function(genus) |
| − | local url = cof. | + | local url = data.cof.customArgs['baseURL'] .. 'tbl=species&genus=' .. genus |
local title = 'Species in the genus ' .. firstToUpper(genus) | local title = 'Species in the genus ' .. firstToUpper(genus) | ||
return title, url | return title, url | ||
end | end | ||
-- note the family works with subfamilies using &family=SUBFAMILY | -- note the family works with subfamilies using &family=SUBFAMILY | ||
| − | cof.family = function(family) | + | data.cof.family = function(family) |
local list = templateArgs['list'] or "genus" | local list = templateArgs['list'] or "genus" | ||
| − | local url = cof. | + | local url = data.cof.customArgs['baseURL'] .. 'tbl=' .. list .. '&family=' .. family |
local title = "Species" | local title = "Species" | ||
if list == "genus" then title = "Genera" end | if list == "genus" then title = "Genera" end | ||
| Line 98: | Line 99: | ||
return title, url | return title, url | ||
end | end | ||
| − | cof.genid = function(genid) | + | data.cof.genid = function(genid) |
local searchStr = "genid" .. '=' .. genid | local searchStr = "genid" .. '=' .. genid | ||
local title = searchStr | local title = searchStr | ||
| − | local url = cof. | + | local url = data.cof.customArgs['baseURL'] .. searchStr |
return title, url | return title, url | ||
end | end | ||
| − | cof.spid = function(spid) | + | data.cof.spid = function(spid) |
local searchStr = "spid" .. '=' .. spid | local searchStr = "spid" .. '=' .. spid | ||
local title = searchStr | local title = searchStr | ||
| − | local url = cof. | + | local url = data.cof.customArgs['baseURL'] .. searchStr |
return title, url | return title, url | ||
end | end | ||
| − | cof.error = function() | + | data.cof.error = function() |
return "Error. No recognised option set by template (need one of family, genus, species (also requires genus), spid, or genid" | return "Error. No recognised option set by template (need one of family, genus, species (also requires genus), spid, or genid" | ||
end | end | ||
--======================Fishes of the World 5=============================== | --======================Fishes of the World 5=============================== | ||
| − | + | data.fotw5 = { | |
| − | + | citeTemplate = "Cite book", | |
| − | + | citationArgs = { | |
--['website'] = "[[]]", | --['website'] = "[[]]", | ||
first1 = "Joseph S.", last1 = "Nelson", | first1 = "Joseph S.", last1 = "Nelson", | ||
| Line 126: | Line 127: | ||
isbn = "978-1-118-34233-6", doi="10.1002/9781119174844" , | isbn = "978-1-118-34233-6", doi="10.1002/9781119174844" , | ||
}, | }, | ||
| − | + | customArgs = {exclude="q,dq,1", | |
baseURL = "https://sites.google.com/site/fotw5th/", | baseURL = "https://sites.google.com/site/fotw5th/", | ||
defaultTitle = "Fishes of the World", | defaultTitle = "Fishes of the World", | ||
| Line 135: | Line 136: | ||
} | } | ||
} | } | ||
| − | fotw5.default2 = function(targs) | + | data.fotw5.default2 = function(targs) |
| − | local title = fotw5. | + | local title = data.fotw5.citationArgs['work'] |
| − | local url = fotw5. | + | local url = data.fotw5.customArgs['baseURL'] |
local chapterParams = { title = title, | local chapterParams = { title = title, | ||
| − | ['chapter-url']= fotw5. | + | ['chapter-url']= data.fotw5.customArgs['googleBooks'] |
} | } | ||
--return title, url, chapterParams | --return title, url, chapterParams | ||
| Line 146: | Line 147: | ||
--====================TODO FishWisePro================================================== | --====================TODO FishWisePro================================================== | ||
| − | + | data.fishwisepro = { | |
| − | + | citationArgs = { | |
['website'] = "[[FishWisePro]]", | ['website'] = "[[FishWisePro]]", | ||
}, | }, | ||
| − | + | customArgs = {exclude="family,genus,species,1", | |
baseURL = "" | baseURL = "" | ||
} | } | ||
| Line 170: | Line 171: | ||
minimul = /content/search?taxon=Allophryn*&subtree | minimul = /content/search?taxon=Allophryn*&subtree | ||
]] | ]] | ||
| − | + | data.ASW6 ={ | |
| − | + | citationArgs = { | |
website ="Amphibian Species of the World, an Online Reference.", | website ="Amphibian Species of the World, an Online Reference.", | ||
version = "Version 6.0", | version = "Version 6.0", | ||
| Line 177: | Line 178: | ||
['last1']="Frost", ['first1']="Darrel R.", ['author1-link']="Darrel R. Frost", | ['last1']="Frost", ['first1']="Darrel R.", ['author1-link']="Darrel R. Frost", | ||
}, | }, | ||
| − | + | customArgs = { exclude = "taxon,species,genus,family, superfamily,1,2,3", | |
baseURL = "http://research.amnh.org/herpetology/amphibia/", | baseURL = "http://research.amnh.org/herpetology/amphibia/", | ||
defaultSuffix = "index.html", | defaultSuffix = "index.html", | ||
| Line 184: | Line 185: | ||
} | } | ||
| − | ASW6.species = function(genus, species, subspecies) | + | data.ASW6.species = function(genus, species, subspecies) |
-- search for genus+species () | -- search for genus+species () | ||
| Line 193: | Line 194: | ||
local search = "content/search?taxon=" -- guided search for taxon name | local search = "content/search?taxon=" -- guided search for taxon name | ||
| − | local url = ASW6. | + | local url = data.ASW6.customArgs['baseURL'] .. search -- .. genus .. '+AND+' .. species |
.. '"' .. genus .. '+' .. species .. '"' | .. '"' .. genus .. '+' .. species .. '"' | ||
return title, url | return title, url | ||
end | end | ||
| − | ASW6.genus = function(genus) | + | data.ASW6.genus = function(genus) |
| − | return ASW6.taxon(genus) | + | return data.ASW6.taxon(genus) -- use genus as alias of taxon |
end | end | ||
| − | ASW6.taxon = function(taxon) | + | data.ASW6.taxon = function(taxon) |
local title = "Search for Taxon: " .. taxon | local title = "Search for Taxon: " .. taxon | ||
| − | local url= ASW6. | + | local url= data.ASW6.customArgs['baseURL'] .. "content/search?taxon=" .. taxon |
return title, url | return title, url | ||
end | end | ||
| − | ASW6.family = function(family) | + | data.ASW6.family = function(family) |
| − | local order = ASW6.checkOrder(family) | + | local order = data.ASW6.checkOrder(family) |
| − | local url= ASW6. | + | local url= data.ASW6.customArgs['baseURL'] .. "Amphibia/" .. order .. "/" .. firstToUpper(family) |
local title = firstToUpper(family) | local title = firstToUpper(family) | ||
return title, url | return title, url | ||
end | end | ||
| − | ASW6.checkOrder = function(family) | + | data.ASW6.checkOrder = function(family) |
local gymnophiona={ "Caeciliidae", "Chikilidae", "Dermophiidae", "Herpelidae", "Ichthyophiidae", "Indotyphlidae", "Rhinatrematidae", "Scolecomorphidae", "Siphonopidae", "Typhlonectidae" } | local gymnophiona={ "Caeciliidae", "Chikilidae", "Dermophiidae", "Herpelidae", "Ichthyophiidae", "Indotyphlidae", "Rhinatrematidae", "Scolecomorphidae", "Siphonopidae", "Typhlonectidae" } | ||
| Line 230: | Line 231: | ||
Code: {{BioRef|amphibiaweb |title=Amphibia |year=2019 |url=https://amphibiaweb.org/taxonomy/AW_FamilyPhylogeny.html |access-date=27 September 2019}} | Code: {{BioRef|amphibiaweb |title=Amphibia |year=2019 |url=https://amphibiaweb.org/taxonomy/AW_FamilyPhylogeny.html |access-date=27 September 2019}} | ||
--]] | --]] | ||
| − | + | data.amphibiaweb = { | |
| − | + | citationArgs = { | |
website = "AmphibiaWeb", | website = "AmphibiaWeb", | ||
publisher = "University of California, Berkeley", | publisher = "University of California, Berkeley", | ||
--['editor1-last']="", ['editor1-first']="", ['editor1-link']="", | --['editor1-last']="", ['editor1-first']="", ['editor1-link']="", | ||
}, | }, | ||
| − | + | customArgs = { exclude = "taxon,species,genus,family,1,2,3", | |
baseURL = "https://amphibiaweb.org/", | baseURL = "https://amphibiaweb.org/", | ||
defaultSuffix = "taxonomy/AW_FamilyPhylogeny.html", | defaultSuffix = "taxonomy/AW_FamilyPhylogeny.html", | ||
| Line 242: | Line 243: | ||
} | } | ||
} | } | ||
| − | amphibiaweb.species = function (genus, species, subspecies) | + | data.amphibiaweb.species = function (genus, species, subspecies) |
local title = "''" .. genus .. " " .. species .. "''" | local title = "''" .. genus .. " " .. species .. "''" | ||
--https://amphibiaweb.org/cgi/amphib_query?where-genus=Altiphrynoides&where-species=malcolmi | --https://amphibiaweb.org/cgi/amphib_query?where-genus=Altiphrynoides&where-species=malcolmi | ||
| − | local url = amphibiaweb. | + | local url = data.amphibiaweb.customArgs['baseURL'] .. "cgi/amphib_query?rel-genus=equals&where-genus=" |
.. genus .. "&rel-species=equals&where-species=" .. species | .. genus .. "&rel-species=equals&where-species=" .. species | ||
return title, url | return title, url | ||
end | end | ||
| − | amphibiaweb.genus = function (genus) | + | data.amphibiaweb.genus = function (genus) |
local title = "''" .. genus .. "''" | local title = "''" .. genus .. "''" | ||
--https://amphibiaweb.org/cgi/amphib_query?where-genus=Altiphrynoides&where-species=malcolmi | --https://amphibiaweb.org/cgi/amphib_query?where-genus=Altiphrynoides&where-species=malcolmi | ||
| − | local url = amphibiaweb. | + | local url = data.amphibiaweb.customArgs['baseURL'] .. "cgi/amphib_query?rel-genus=equals&where-genus=" |
.. genus .. "&include_synonymies=Yes&show_photos=Yes" | .. genus .. "&include_synonymies=Yes&show_photos=Yes" | ||
return title, url | return title, url | ||
end | end | ||
| − | amphibiaweb.family = function (family) -- if family use standardised url | + | data.amphibiaweb.family = function (family) -- if family use standardised url |
| − | local url = amphibiaweb. | + | local url = data.amphibiaweb.customArgs['baseURL'] .. "lists/" .. firstToUpper(templateArgs['family']) .. ".shtml" |
local title = templateArgs['family'] | local title = templateArgs['family'] | ||
return title, url | return title, url | ||
| Line 265: | Line 266: | ||
--=========================== The Reptile Database | --=========================== The Reptile Database | ||
| − | + | data.reptileDB = { | |
-- http://reptile-database.reptarium.cz/species?genus=Epacrophis&species=boulengeri | -- http://reptile-database.reptarium.cz/species?genus=Epacrophis&species=boulengeri | ||
-- recommended citation: Uetz, P., Freed, P. & Hošek, J. (eds.) (2019) The Reptile Database, http://www.reptile-database.org, accessed [insert date here] | -- recommended citation: Uetz, P., Freed, P. & Hošek, J. (eds.) (2019) The Reptile Database, http://www.reptile-database.org, accessed [insert date here] | ||
| − | + | citationArgs = { | |
--website="reptile-database.org", | --website="reptile-database.org", | ||
website="[[The Reptile Database]]", | website="[[The Reptile Database]]", | ||
| Line 277: | Line 278: | ||
}, | }, | ||
| − | + | customArgs = { exclude = "taxon,species,genus,family,1,2,3", | |
baseURL = "http://reptile-database.reptarium.cz/" | baseURL = "http://reptile-database.reptarium.cz/" | ||
} | } | ||
} | } | ||
| − | reptileDB.species = function(genus, species) | + | data.reptileDB.species = function(genus, species) |
local title = "''" .. genus .. " " .. species .. "''" | local title = "''" .. genus .. " " .. species .. "''" | ||
--http://reptile-database.reptarium.cz/species?genus=Loxocemus&species=bicolor | --http://reptile-database.reptarium.cz/species?genus=Loxocemus&species=bicolor | ||
| − | local url = reptileDB. | + | local url = data.reptileDB.customArgs['baseURL'] .. "species?genus=" .. genus .. "&species=" .. species |
return title, url | return title, url | ||
end | end | ||
| − | reptileDB.genus = function(genus) | + | data.reptileDB.genus = function(genus) |
local title = "''" .. genus .. "''" | local title = "''" .. genus .. "''" | ||
--http://reptile-database.reptarium.cz/advanced_search?genus=Malayopython&submit=Search | --http://reptile-database.reptarium.cz/advanced_search?genus=Malayopython&submit=Search | ||
| − | local url = reptileDB. | + | local url = data.reptileDB.customArgs['baseURL'] .. "advanced_search?genus=" .. genus .. "&exact%5B0%5D=taxon&submit=search" |
return title, url | return title, url | ||
end | end | ||
| − | reptileDB.taxon = function(taxon) | + | data.reptileDB.taxon = function(taxon) |
local title = templateArgs['taxon'] | local title = templateArgs['taxon'] | ||
--http://reptile-database.reptarium.cz/advanced_search?taxon=Viperidae&exact%5B0%5D=taxon&submit=Search | --http://reptile-database.reptarium.cz/advanced_search?taxon=Viperidae&exact%5B0%5D=taxon&submit=Search | ||
| − | local url = reptileDB. | + | local url = data.reptileDB.customArgs['baseURL'] .. "advanced_search?taxon=" .. templateArgs['taxon'] .. "&exact%5B0%5D=taxon&submit=search" |
return title, url | return title, url | ||
end | end | ||
| Line 306: | Line 307: | ||
--################################### BIRDS ######################################## | --################################### BIRDS ######################################## | ||
--====================Handbook of the Birds of the World Alive (HBW Alive)============== | --====================Handbook of the Birds of the World Alive (HBW Alive)============== | ||
| − | + | data.HBWalive = { | |
| − | + | citationArgs = { | |
website="[[Handbook of the Birds of the World|Handbook of the Birds of the World Alive]]", | website="[[Handbook of the Birds of the World|Handbook of the Birds of the World Alive]]", | ||
publisher="Lynx Edicions" | publisher="Lynx Edicions" | ||
}, | }, | ||
| − | + | customArgs = { exclude="order,family,genus,species,taxon,id,1", | |
baseURL = "https://www.hbw.com/", | baseURL = "https://www.hbw.com/", | ||
defaultSuffix = "family/home", | defaultSuffix = "family/home", | ||
| Line 321: | Line 322: | ||
-- family and species entries have mix of common name and taxon name so cannot be prempted; | -- family and species entries have mix of common name and taxon name so cannot be prempted; | ||
-- must use title + url (which uses default functions in this module) | -- must use title + url (which uses default functions in this module) | ||
| − | HBWalive.order = function(order) | + | data.HBWalive.order = function(order) |
local title = "Order " .. firstToUpper(order) | local title = "Order " .. firstToUpper(order) | ||
--https://www.hbw.com/order/struthioniformes | --https://www.hbw.com/order/struthioniformes | ||
| − | local url = target. | + | local url = target.customArgs['baseURL'] .. "order/" .. order |
return title, url | return title, url | ||
end | end | ||
| Line 331: | Line 332: | ||
--======================IOC World Bird List========================== | --======================IOC World Bird List========================== | ||
-- Gill, F & D Donsker (Eds). 2019. IOC World Bird List (v9.2). doi : 10.14344/IOC.ML.9.2. | -- Gill, F & D Donsker (Eds). 2019. IOC World Bird List (v9.2). doi : 10.14344/IOC.ML.9.2. | ||
| − | + | data.IOC = { | |
| − | + | citationArgs = { | |
website="[[IOC World Bird List]]", | website="[[IOC World Bird List]]", | ||
version="Version 9.2", | version="Version 9.2", | ||
| Line 340: | Line 341: | ||
publisher="International Ornithological Congress" | publisher="International Ornithological Congress" | ||
}, | }, | ||
| − | + | customArgs = { exclude="order,family,genus,species,taxon,id,1", | |
baseURL = "https://www.worldbirdnames.org/", | baseURL = "https://www.worldbirdnames.org/", | ||
defaultSuffix = "", | defaultSuffix = "", | ||
| Line 347: | Line 348: | ||
}, | }, | ||
} | } | ||
| − | IOC.order = function(order) | + | data.IOC.order = function(order) |
local IOCorders = {Struthioniformes='ratites',Rheiformes='ratites',Apterygiformes='ratites',Casuariiformes='ratites',Tinamiformes='ratites',Galliformes='megapodes',Anseriformes='waterfowl',Caprimulgiformes='nightjars',Apodiformes='swifts',Musophagiformes='turacos',Otidiformes='turacos',Cuculiformes='turacos',Mesitornithiformes='turacos',Pterocliformes='turacos',Columbiformes='pigeons',Gruiformes='flufftails',Podicipediformes='grebes',Phoenicopteriformes='grebes',Charadriiformes='sandpipers',Eurypygiformes='loons',Phaethontiformes='loons',Gaviiformes='loons',Sphenisciformes='loons',Procellariiformes='loons',Ciconiiformes='storks',Suliformes='storks',Pelecaniformes='pelicans',Opisthocomiformes='raptors',Accipitriformes='raptors',Strigiformes='owls',Coliiformes='mousebirds',Leptosomiformes='mousebirds',Trogoniformes='mousebirds',Bucerotiformes='mousebirds',Coraciiformes='rollers',Piciformes='woodpeckers',Cariamiformes='falcons',Falconiformes='falcons',Psittaciformes='parrots', | local IOCorders = {Struthioniformes='ratites',Rheiformes='ratites',Apterygiformes='ratites',Casuariiformes='ratites',Tinamiformes='ratites',Galliformes='megapodes',Anseriformes='waterfowl',Caprimulgiformes='nightjars',Apodiformes='swifts',Musophagiformes='turacos',Otidiformes='turacos',Cuculiformes='turacos',Mesitornithiformes='turacos',Pterocliformes='turacos',Columbiformes='pigeons',Gruiformes='flufftails',Podicipediformes='grebes',Phoenicopteriformes='grebes',Charadriiformes='sandpipers',Eurypygiformes='loons',Phaethontiformes='loons',Gaviiformes='loons',Sphenisciformes='loons',Procellariiformes='loons',Ciconiiformes='storks',Suliformes='storks',Pelecaniformes='pelicans',Opisthocomiformes='raptors',Accipitriformes='raptors',Strigiformes='owls',Coliiformes='mousebirds',Leptosomiformes='mousebirds',Trogoniformes='mousebirds',Bucerotiformes='mousebirds',Coraciiformes='rollers',Piciformes='woodpeckers',Cariamiformes='falcons',Falconiformes='falcons',Psittaciformes='parrots', | ||
Passeriformes='nz_wrens'} -- passeriformes link not very useful | Passeriformes='nz_wrens'} -- passeriformes link not very useful | ||
local title = "Order " .. firstToUpper(order) | local title = "Order " .. firstToUpper(order) | ||
| − | local url = IOC. | + | local url = data.IOC.customArgs['baseURL'] .. "/bow/" .. IOCorders[order] |
return title, url | return title, url | ||
end | end | ||
| − | IOC.family = function(family) | + | data.IOC.family = function(family) |
local title = "Family " .. firstToUpper(family) | local title = "Family " .. firstToUpper(family) | ||
--https://www.worldbirdnames.org/Family/Struthionidae | --https://www.worldbirdnames.org/Family/Struthionidae | ||
| − | local url = IOC. | + | local url = data.IOC.customArgs['baseURL'] .. "Family/" .. family |
return title, url | return title, url | ||
end | end | ||
-- ============================= ASM Mammal Diversity Database ======================== | -- ============================= ASM Mammal Diversity Database ======================== | ||
| − | + | data.asm = { | |
| − | + | citationArgs = { | |
website="ASM Mammal Diversity Database", | website="ASM Mammal Diversity Database", | ||
publisher="[[American Society of Mammalogists]]" | publisher="[[American Society of Mammalogists]]" | ||
}, | }, | ||
| − | + | customArgs = { exclude="family,genus,species,taxon,id,1", | |
baseURL = "https://mammaldiversity.org/", | baseURL = "https://mammaldiversity.org/", | ||
defaultTitle="ASM Mammal Diversity Database" | defaultTitle="ASM Mammal Diversity Database" | ||
| Line 375: | Line 376: | ||
} | } | ||
| − | asm.species = function(genus, species) | + | data.asm.species = function(genus, species) |
local title = "''" .. genus .. " " .. species .. "''" | local title = "''" .. genus .. " " .. species .. "''" | ||
--https://mammaldiversity.org/species-account.php?genus=ursus&species=arctos | --https://mammaldiversity.org/species-account.php?genus=ursus&species=arctos | ||
| − | local url = asm. | + | local url = data.asm.customArgs['baseURL'] .. "species-account.php?genus=" .. genus .. "&species=" .. species |
return title, url | return title, url | ||
end | end | ||
| − | asm.id = function(id) | + | data.asm.id = function(id) |
| − | local url = asm. | + | local url = data.asm.customArgs['baseURL'] .. "species-account/species-id=" .. templateArgs['id'] |
local title = "Species-id=" .. id | local title = "Species-id=" .. id | ||
return title, url | return title, url | ||
end | end | ||
| − | asm.genus = function(genus) return asm.taxon(genus, "TITLE_ITALICS") end | + | data.asm.genus = function(genus) return data.asm.taxon(genus, "TITLE_ITALICS") end |
| − | asm.family = function(family) return asm.taxon(family) end | + | data.asm.family = function(family) return data.asm.taxon(family) end |
| − | asm.order = function(order) return asm.taxon(order) end | + | data.asm.order = function(order) return data.asm.taxon(order) end |
| − | asm.taxon = function(taxon, titleItalics) | + | data.asm.taxon = function(taxon, titleItalics) |
--https://mammaldiversity.org/#ZmVsaWRhZSZnbG9iYWxfc2VhcmNoPXRydWUmbG9vc2U9dHJ1ZQ | --https://mammaldiversity.org/#ZmVsaWRhZSZnbG9iYWxfc2VhcmNoPXRydWUmbG9vc2U9dHJ1ZQ | ||
-- Base64.encode(felidae&global_search=true&loose=true) | -- Base64.encode(felidae&global_search=true&loose=true) | ||
local title = firstToUpper(taxon) | local title = firstToUpper(taxon) | ||
if titleItalics then title = "''" .. title .. "''" end | if titleItalics then title = "''" .. title .. "''" end | ||
| − | local url = asm. | + | local url = data.asm.customArgs['baseURL'] |
| + | .. '#' .. data.asm.Base64.encode(taxon.."&global_search=true&loose=false") | ||
return title, url | return title, url | ||
end | end | ||
| Line 400: | Line 402: | ||
local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' | local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' | ||
-- encoding | -- encoding | ||
| − | asm.Base64 = {} | + | data.asm.Base64 = {} |
| − | asm.Base64.encode = function(data) | + | data.asm.Base64.encode = function(data) |
return ((data:gsub('.', function(x) | return ((data:gsub('.', function(x) | ||
local r,b='',x:byte() | local r,b='',x:byte() | ||
| Line 414: | Line 416: | ||
end | end | ||
-- decoding | -- decoding | ||
| − | asm.Base64.decode=function(data) | + | data.asm.Base64.decode=function(data) |
data = string.gsub(data, '[^'..b..'=]', '') | data = string.gsub(data, '[^'..b..'=]', '') | ||
return (data:gsub('.', function(x) | return (data:gsub('.', function(x) | ||
| Line 434: | Line 436: | ||
3) use WoRMSa as website and designate DB as author (recommended by WoRMS) CURRENT | 3) use WoRMSa as website and designate DB as author (recommended by WoRMS) CURRENT | ||
]] | ]] | ||
| − | + | data.WoRMS = { | |
| − | + | citationArgs = { | |
author = "WoRMS", | author = "WoRMS", | ||
website = "[[World Register of Marine Species]]", | website = "[[World Register of Marine Species]]", | ||
| Line 442: | Line 444: | ||
}, | }, | ||
| − | + | customArgs = {exclude="id,db,1", | |
baseURL = "http://www.marinespecies.org/aphia.php?", | baseURL = "http://www.marinespecies.org/aphia.php?", | ||
searchStr = "p=taxdetails&id=", | searchStr = "p=taxdetails&id=", | ||
| Line 448: | Line 450: | ||
} | } | ||
} | } | ||
| − | WoRMS.id = function(id) | + | data.WoRMS.id = function(id) |
--[[ Two styles | --[[ Two styles | ||
1. http://www.marinespecies.org/aphia.php?p=taxdetails&id=14712 | 1. http://www.marinespecies.org/aphia.php?p=taxdetails&id=14712 | ||
| Line 468: | Line 470: | ||
--page <title>WoRMS - World Register of Marine Species - Heterobranchia</title> | --page <title>WoRMS - World Register of Marine Species - Heterobranchia</title> | ||
local title = "WoRMS taxon details: AphiaID " .. id | local title = "WoRMS taxon details: AphiaID " .. id | ||
| − | local url = WoRMS. | + | local url = data.WoRMS.customArgs['baseURL'] .. data.WoRMS.customArgs['searchStr'] .. id |
return title, url | return title, url | ||
| Line 475: | Line 477: | ||
--====================== Fossilworks ======================================= | --====================== Fossilworks ======================================= | ||
| − | + | data.fossilworks = { | |
| − | + | citationArgs = { | |
website="[[Fossilworks]]", | website="[[Fossilworks]]", | ||
--publisher="Paleobiology Database", | --publisher="Paleobiology Database", | ||
| Line 483: | Line 485: | ||
--via="''fossilworks.org''" -- an alternative format to using |website= | --via="''fossilworks.org''" -- an alternative format to using |website= | ||
}, | }, | ||
| − | + | customArgs = { exclude = "id,date,1", | |
baseURL = "http://fossilworks.org/cgi-bin/", | baseURL = "http://fossilworks.org/cgi-bin/", | ||
searchStr ="bridge.pl?a=taxonInfo&taxon_no=", | searchStr ="bridge.pl?a=taxonInfo&taxon_no=", | ||
| Line 490: | Line 492: | ||
--id = function(id) return p.genericIdCitation (frame, title, url) | --id = function(id) return p.genericIdCitation (frame, title, url) | ||
} | } | ||
| − | fossilworks.id = function(id) | + | data.fossilworks.id = function(id) |
--[[ http://fossilworks.org/cgi-bin/bridge.pl?a=taxonInfo&taxon_no=83087 | --[[ http://fossilworks.org/cgi-bin/bridge.pl?a=taxonInfo&taxon_no=83087 | ||
if not templateArgs['id'] then return "no id parameter detected" end | if not templateArgs['id'] then return "no id parameter detected" end | ||
| Line 497: | Line 499: | ||
]] | ]] | ||
local title = "PaleoDB taxon number: " .. id | local title = "PaleoDB taxon number: " .. id | ||
| − | local url = fossilworks. | + | local url = data.fossilworks.customArgs['baseURL'] .. data.fossilworks.customArgs['searchStr'] .. id |
return title, url | return title, url | ||
end | end | ||
| − | fossilworks.error = function() | + | data.fossilworks.error = function() |
return "Requires id and title parameters" | return "Requires id and title parameters" | ||
end | end | ||
| Line 526: | Line 528: | ||
target=sourceDB | target=sourceDB | ||
| − | templateArgs = | + | templateArgs = sourceDB.citationArgs -- get custom arguments for target (fishbase, cof etc |
| − | + | ||
getArgs(frame, templateArgs) -- get template arguments from parent frame and frane | getArgs(frame, templateArgs) -- get template arguments from parent frame and frane | ||
| − | local url = target. | + | local url = target.customArgs['baseURL'] .. (target.customArgs['defaultSuffix'] or "") |
| − | local title = target. | + | local title = target.customArgs['defaultTitle'] or "" |
return title, url | return title, url | ||
end | end | ||
| Line 543: | Line 545: | ||
local excludeTable = {} | local excludeTable = {} | ||
| − | if target. | + | if target.customArgs['exclude'] then |
| − | excludeTable = mw.text.split (target. | + | excludeTable = mw.text.split (target.customArgs['exclude'] , "%s*,%s*"); |
for k,v in pairs(excludeTable) do | for k,v in pairs(excludeTable) do | ||
if tonumber (v) then | if tonumber (v) then | ||
| Line 622: | Line 624: | ||
-- common function for genus and species | -- common function for genus and species | ||
| − | local function getGenusSpecies( | + | local function getGenusSpecies() |
--TODO standardise genus species handling | --TODO standardise genus species handling | ||
local genus, species, subspecies | local genus, species, subspecies | ||
| Line 718: | Line 720: | ||
--======= Mammals | --======= Mammals | ||
p.asm = function(frame) return p._main(frame, asm) end | p.asm = function(frame) return p._main(frame, asm) end | ||
| + | -- MSW3 has custom handling (see above) | ||
--=========== Other | --=========== Other | ||
p.fossilworks = function(frame) return p._main(frame, fossilworks) end | p.fossilworks = function(frame) return p._main(frame, fossilworks) end | ||
| Line 723: | Line 726: | ||
p.WoRMS = function(frame) return p._main(frame, WoRMS) end | p.WoRMS = function(frame) return p._main(frame, WoRMS) end | ||
| + | --fallback = function() return "hello" end | ||
--######################################################### | --######################################################### | ||
p.main = function(frame) | p.main = function(frame) | ||
| − | local source = frame.args[1] | + | local source = mw.text.trim(frame.args[1]) |
| − | return p._main(frame, source) | + | |
| + | if source == "MSW3" then return p.MSW3(frame) end | ||
| + | if source == "Reference" then return p.Reference(frame) end | ||
| + | |||
| + | if source == "HBWa" then source = "HBWalive" end -- aliases | ||
| + | --return p[source]['test'] | ||
| + | if source == "fishbase" | ||
| + | or source == "cof" | ||
| + | or source == "fotw5" or source == "Fotw5" | ||
| + | or source == "reptileDB" | ||
| + | or source == "amphibiaweb" | ||
| + | or source == "ASW6" | ||
| + | or source == "asm" | ||
| + | or source == "HBWalive" or source == "HBWa" | ||
| + | or source == "fossilworks" | ||
| + | or source == "WoRMS" or source == "worms" | ||
| + | -- and so on | ||
| + | then return p._main(frame,data[source]) | ||
| + | else | ||
| + | -- | ||
| + | -- is there a point in the default if it needs the named object/table? | ||
| + | return p._main(frame,data[source]) | ||
| + | end | ||
end | end | ||
p._main = function(frame, source) | p._main = function(frame, source) | ||
| Line 737: | Line 763: | ||
--taxon related parameters | --taxon related parameters | ||
| − | local genus, species, subspecies = getGenusSpecies( | + | local genus, species, subspecies = getGenusSpecies() |
local family = templateArgs['family'] | local family = templateArgs['family'] | ||
local order = templateArgs['order'] | local order = templateArgs['order'] | ||
| Line 778: | Line 804: | ||
end | end | ||
| − | if source. | + | if source.citeTemplate == "Cite book" then |
return p.citeBook(frame, title, url, chapterParams) | return p.citeBook(frame, title, url, chapterParams) | ||
end | end | ||
Revision as of 15:54, 27 October 2019
Documentation for this module may be created at Module:FishRef/sandbox/doc
require('Module:No globals')
local p = {}
local data = {}
local templateArgs = {} -- contains arguments passed to cite web
local target = {} -- short cut to target table, e.g. fishbase, cof, etc
local function firstToUpper(str)
return (str:gsub("^%l", string.upper))
end
-- define citation template and custom parameters for various sources
--####################### FISH #####################################
--======================== Fishbase =================================
data.fishbase = {
citationArgs = {
['editor1-last']="Froese", ['editor1-first']="Rainer", ['editor1-link']="Rainer Froese",
['editor2-last']="Pauly", ['editor2-first']="Daniel",
--['last-author-amp'] ="yes",
['website'] = "[[Fishbase]]",
--['publisher'] = ""
},
customArgs = { exclude= "order, family,genus, species, subspecies, 1, 2, 3, 4",
baseURL = "http://www.fishbase.org/",
defaultTitle = "Search FishBase"
},
}
data.fishbase.species = function(genus, species, subspecies)
local title = genus .. " " .. species
local url = data.fishbase.customArgs['baseURL']
.. "summary/SpeciesSummary.php?genusname=" .. genus .. "&speciesname=" .. species
if subspecies then
url = url .. "+" .. subspecies
title = title .. " " .. subspecies
end
title = "''" .. title .. "''"
return title, url
end
data.fishbase.genus = function(genus)
local title = "Species in genus ''" .. firstToUpper(genus) .. "''"
local url = data.fishbase.customArgs['baseURL'] .. "identification/SpeciesList.php?genus=" .. genus
return title, url
end
data.fishbase.order = function(order)
local title = "Order " .. firstToUpper(order)
local url = data.fishbase.customArgs['baseURL'] .. "Summary/OrdersSummary.php?order=" .. order
return title, url
end
data.fishbase.family = function(family)
local title = "Family " .. firstToUpper(family)
local url = data.fishbase.customArgs['baseURL'] .. "Summary/FamilySummary.php?family=" .. family
return title, url
end
data.fishbase.error = function()
return "No recognised taxon options: order, family, genus, species, subspecies."
end
data.fishbase.custom = function()
--TODO decide what to do with default date
local version = "April 2006 version" -- Should we have a default (probably not)
if templateArgs['month'] then version = templateArgs['month'] end
if templateArgs['year'] then version = templateArgs['year'] .. " version" end
if templateArgs['month'] then version = templateArgs['month'] .. " " .. version end
templateArgs['version'] = version
end
--================================ Catalog of Fishes ================================================
data.cof = {
citationArgs = {
--baseURL = "http://researcharchive.calacademy.org/research/ichthyology/catalog/fishcatget.asp?",
['editor1-last']="Eschmeyer", ['editor1-first']="William N.", ['editor1-link']="William N. Eschmeyer",
['editor2-last']="Fricke", ['editor2-first']="Ron",
['editor3-last']="van der Laan", ['editor3-first']="Richard",
['last-author-amp'] ="yes",
['website'] = "[[Catalog of Fishes]]",
['publisher'] = "[[California Academy of Sciences]]"
},
customArgs = { exclude= "family,genus,species,genid,spid,id,list,1,2,3",
baseURL = "http://researcharchive.calacademy.org/research/ichthyology/catalog/fishcatget.asp?",
defaultTitle = "CAS - Eschmeyer's Catalog of Fishes"
}
}
data.cof.species = function(genus, species, subspecies)
local taxon = genus .. " " .. species
local url = data.cof.customArgs['baseURL'] .. 'tbl=species&genus=' .. genus .. '&species=' .. species
local title = "Species related to " .. "''" .. firstToUpper(taxon) .. "''" -- .. "" species synonyms"
return title, url
end
data.cof.genus = function(genus)
local url = data.cof.customArgs['baseURL'] .. 'tbl=species&genus=' .. genus
local title = 'Species in the genus ' .. firstToUpper(genus)
return title, url
end
-- note the family works with subfamilies using &family=SUBFAMILY
data.cof.family = function(family)
local list = templateArgs['list'] or "genus"
local url = data.cof.customArgs['baseURL'] .. 'tbl=' .. list .. '&family=' .. family
local title = "Species"
if list == "genus" then title = "Genera" end
title = title .. ' in the family ' .. firstToUpper(family)
return title, url
end
data.cof.genid = function(genid)
local searchStr = "genid" .. '=' .. genid
local title = searchStr
local url = data.cof.customArgs['baseURL'] .. searchStr
return title, url
end
data.cof.spid = function(spid)
local searchStr = "spid" .. '=' .. spid
local title = searchStr
local url = data.cof.customArgs['baseURL'] .. searchStr
return title, url
end
data.cof.error = function()
return "Error. No recognised option set by template (need one of family, genus, species (also requires genus), spid, or genid"
end
--======================Fishes of the World 5===============================
data.fotw5 = {
citeTemplate = "Cite book",
citationArgs = {
--['website'] = "[[]]",
first1 = "Joseph S.", last1 = "Nelson",
first2="Terry C.", last2="Grande",
first3="Mark V. H.", last3="Wilson",
--work = "Fishes of the World (work)",
title = "Fishes of the World", edition="5th", year = 2016,
publisher ="John Wiley and Sons", location="Hoboken",
isbn = "978-1-118-34233-6", doi="10.1002/9781119174844" ,
},
customArgs = {exclude="q,dq,1",
baseURL = "https://sites.google.com/site/fotw5th/",
defaultTitle = "Fishes of the World",
},
GoogleBooks = { baseURL = "https://books.google.co.uk/books?id=",
id = "E-MLDAAAQBAJ",
defaultPage = "&pg=PP1"
}
}
data.fotw5.default2 = function(targs)
local title = data.fotw5.citationArgs['work']
local url = data.fotw5.customArgs['baseURL']
local chapterParams = { title = title,
['chapter-url']= data.fotw5.customArgs['googleBooks']
}
--return title, url, chapterParams
end
--====================TODO FishWisePro==================================================
data.fishwisepro = {
citationArgs = {
['website'] = "[[FishWisePro]]",
},
customArgs = {exclude="family,genus,species,1",
baseURL = ""
}
}
-- #################### AMPHIBIA and REPTILES ###############################
-- ================= Amphibian Species of the World (ASW6)
--[[Recommended citation: Frost, Darrel R. 2019. Amphibian Species of the World: an Online Reference. Version 6.0 (Date of access). Electronic Database accessible at http://research.amnh.org/herpetology/amphibia/index.html. American Museum of Natural History, New York, USA.
URL for family page: http://research.amnh.org/vz/herpetology/amphibia/Amphibia/Anura/Allophrynidae
baseURL = http://research.amnh.org/vz/herpetology/amphibia/
suffix = Amphibia/Anura/Allophrynidae
note: needs the whole hierarchy (except the superfamily which is optional)
Template for main taxonomic listing: {{BioRef|ASW6 |title=Amphibia |year=2019 |url=http://research.amnh.org/herpetology/amphibia/index.html |access-date=27 September 2019}}
SEARCH http://research.amnh.org/vz/herpetology/amphibia/amphib/basic_search?basic_query=Atelopus&stree=&stree_id=
searchSuffix = amphib/basic_search?basic_query=Atelopus&stree=&stree_id=
SEARCH http://research.amnh.org/vz/herpetology/amphibia/content/search?taxon=Allophryn*&subtree=&subtree_id=&english_name=&author=&year=&country=
searchSuffix = /content/search?taxon=Allophryn*&subtree=&subtree_id=&english_name=&author=&year=&country=
minimul = /content/search?taxon=Allophryn*&subtree
]]
data.ASW6 ={
citationArgs = {
website ="Amphibian Species of the World, an Online Reference.",
version = "Version 6.0",
publisher = "American Museum of Natural History, New York",
['last1']="Frost", ['first1']="Darrel R.", ['author1-link']="Darrel R. Frost",
},
customArgs = { exclude = "taxon,species,genus,family, superfamily,1,2,3",
baseURL = "http://research.amnh.org/herpetology/amphibia/",
defaultSuffix = "index.html",
defaultTitle = "ASW Home"
}
}
data.ASW6.species = function(genus, species, subspecies)
-- search for genus+species ()
local title = "Search for taxon: " .. "''" .. genus .. " " .. species .. "''"
--local search = ""?action=names&taxon="" -- old version (pre ASW6)
--local search = "amphib/basic_search?basic_query=" -- basic search
local search = "content/search?taxon=" -- guided search for taxon name
local url = data.ASW6.customArgs['baseURL'] .. search -- .. genus .. '+AND+' .. species
.. '"' .. genus .. '+' .. species .. '"'
return title, url
end
data.ASW6.genus = function(genus)
return data.ASW6.taxon(genus) -- use genus as alias of taxon
end
data.ASW6.taxon = function(taxon)
local title = "Search for Taxon: " .. taxon
local url= data.ASW6.customArgs['baseURL'] .. "content/search?taxon=" .. taxon
return title, url
end
data.ASW6.family = function(family)
local order = data.ASW6.checkOrder(family)
local url= data.ASW6.customArgs['baseURL'] .. "Amphibia/" .. order .. "/" .. firstToUpper(family)
local title = firstToUpper(family)
return title, url
end
data.ASW6.checkOrder = function(family)
local gymnophiona={ "Caeciliidae", "Chikilidae", "Dermophiidae", "Herpelidae", "Ichthyophiidae", "Indotyphlidae", "Rhinatrematidae", "Scolecomorphidae", "Siphonopidae", "Typhlonectidae" }
local caudata = { "Ambystomatidae", "Amphiumidae", "Cryptobranchidae", "Hynobiidae", "Plethodontidae", "Proteidae", "Rhyacotritonidae", "Salamandridae", "Sirenidae" }
for k,v in pairs(caudata) do
if v == family then return "Caudata" end
end
for k,v in pairs(gymnophiona) do
if v == family then return "Gymnophiona" end
end
return "Anura"
end
--============================= AmphibiaWeb ===================================
--[[ Citation: AmphibiaWeb. 2019. <https://amphibiaweb.org> University of California, Berkeley, CA, USA. Accessed 27 Sep 2019.
Code: {{BioRef|amphibiaweb |title=Amphibia |year=2019 |url=https://amphibiaweb.org/taxonomy/AW_FamilyPhylogeny.html |access-date=27 September 2019}}
--]]
data.amphibiaweb = {
citationArgs = {
website = "AmphibiaWeb",
publisher = "University of California, Berkeley",
--['editor1-last']="", ['editor1-first']="", ['editor1-link']="",
},
customArgs = { exclude = "taxon,species,genus,family,1,2,3",
baseURL = "https://amphibiaweb.org/",
defaultSuffix = "taxonomy/AW_FamilyPhylogeny.html",
defaultTitle = "AmphibiaWeb Family Taxonomy"
}
}
data.amphibiaweb.species = function (genus, species, subspecies)
local title = "''" .. genus .. " " .. species .. "''"
--https://amphibiaweb.org/cgi/amphib_query?where-genus=Altiphrynoides&where-species=malcolmi
local url = data.amphibiaweb.customArgs['baseURL'] .. "cgi/amphib_query?rel-genus=equals&where-genus="
.. genus .. "&rel-species=equals&where-species=" .. species
return title, url
end
data.amphibiaweb.genus = function (genus)
local title = "''" .. genus .. "''"
--https://amphibiaweb.org/cgi/amphib_query?where-genus=Altiphrynoides&where-species=malcolmi
local url = data.amphibiaweb.customArgs['baseURL'] .. "cgi/amphib_query?rel-genus=equals&where-genus="
.. genus .. "&include_synonymies=Yes&show_photos=Yes"
return title, url
end
data.amphibiaweb.family = function (family) -- if family use standardised url
local url = data.amphibiaweb.customArgs['baseURL'] .. "lists/" .. firstToUpper(templateArgs['family']) .. ".shtml"
local title = templateArgs['family']
return title, url
end
--=========================== The Reptile Database
data.reptileDB = {
-- http://reptile-database.reptarium.cz/species?genus=Epacrophis&species=boulengeri
-- recommended citation: Uetz, P., Freed, P. & Hošek, J. (eds.) (2019) The Reptile Database, http://www.reptile-database.org, accessed [insert date here]
citationArgs = {
--website="reptile-database.org",
website="[[The Reptile Database]]",
['editor1-last']="Uetz", ['editor1-first']="P.", --['editor1-link']="Peter Uetz",
['editor2-last']="Freed", ['editor2-first']="P.",
['editor3-last']="Hošek", ['editor3-first']="J.",
--year=2019
},
customArgs = { exclude = "taxon,species,genus,family,1,2,3",
baseURL = "http://reptile-database.reptarium.cz/"
}
}
data.reptileDB.species = function(genus, species)
local title = "''" .. genus .. " " .. species .. "''"
--http://reptile-database.reptarium.cz/species?genus=Loxocemus&species=bicolor
local url = data.reptileDB.customArgs['baseURL'] .. "species?genus=" .. genus .. "&species=" .. species
return title, url
end
data.reptileDB.genus = function(genus)
local title = "''" .. genus .. "''"
--http://reptile-database.reptarium.cz/advanced_search?genus=Malayopython&submit=Search
local url = data.reptileDB.customArgs['baseURL'] .. "advanced_search?genus=" .. genus .. "&exact%5B0%5D=taxon&submit=search"
return title, url
end
data.reptileDB.taxon = function(taxon)
local title = templateArgs['taxon']
--http://reptile-database.reptarium.cz/advanced_search?taxon=Viperidae&exact%5B0%5D=taxon&submit=Search
local url = data.reptileDB.customArgs['baseURL'] .. "advanced_search?taxon=" .. templateArgs['taxon'] .. "&exact%5B0%5D=taxon&submit=search"
return title, url
end
--################################### BIRDS ########################################
--====================Handbook of the Birds of the World Alive (HBW Alive)==============
data.HBWalive = {
citationArgs = {
website="[[Handbook of the Birds of the World|Handbook of the Birds of the World Alive]]",
publisher="Lynx Edicions"
},
customArgs = { exclude="order,family,genus,species,taxon,id,1",
baseURL = "https://www.hbw.com/",
defaultSuffix = "family/home",
defaultTitle = "Family | HBW Alive"
}
}
--############################## HBW ALIVE #########################################
-- family and species entries have mix of common name and taxon name so cannot be prempted;
-- must use title + url (which uses default functions in this module)
data.HBWalive.order = function(order)
local title = "Order " .. firstToUpper(order)
--https://www.hbw.com/order/struthioniformes
local url = target.customArgs['baseURL'] .. "order/" .. order
return title, url
end
--======================IOC World Bird List==========================
-- Gill, F & D Donsker (Eds). 2019. IOC World Bird List (v9.2). doi : 10.14344/IOC.ML.9.2.
data.IOC = {
citationArgs = {
website="[[IOC World Bird List]]",
version="Version 9.2",
['editor1-last']="Gill", ['editor1-first']="F.", --['editor1-link']="",
['editor2-last']="Donsker", ['editor2-first']="D.",
doi = "10.14344/IOC.ML.9.2",
publisher="International Ornithological Congress"
},
customArgs = { exclude="order,family,genus,species,taxon,id,1",
baseURL = "https://www.worldbirdnames.org/",
defaultSuffix = "",
defaultTitle = "IOC World Bird List"
},
}
data.IOC.order = function(order)
local IOCorders = {Struthioniformes='ratites',Rheiformes='ratites',Apterygiformes='ratites',Casuariiformes='ratites',Tinamiformes='ratites',Galliformes='megapodes',Anseriformes='waterfowl',Caprimulgiformes='nightjars',Apodiformes='swifts',Musophagiformes='turacos',Otidiformes='turacos',Cuculiformes='turacos',Mesitornithiformes='turacos',Pterocliformes='turacos',Columbiformes='pigeons',Gruiformes='flufftails',Podicipediformes='grebes',Phoenicopteriformes='grebes',Charadriiformes='sandpipers',Eurypygiformes='loons',Phaethontiformes='loons',Gaviiformes='loons',Sphenisciformes='loons',Procellariiformes='loons',Ciconiiformes='storks',Suliformes='storks',Pelecaniformes='pelicans',Opisthocomiformes='raptors',Accipitriformes='raptors',Strigiformes='owls',Coliiformes='mousebirds',Leptosomiformes='mousebirds',Trogoniformes='mousebirds',Bucerotiformes='mousebirds',Coraciiformes='rollers',Piciformes='woodpeckers',Cariamiformes='falcons',Falconiformes='falcons',Psittaciformes='parrots',
Passeriformes='nz_wrens'} -- passeriformes link not very useful
local title = "Order " .. firstToUpper(order)
local url = data.IOC.customArgs['baseURL'] .. "/bow/" .. IOCorders[order]
return title, url
end
data.IOC.family = function(family)
local title = "Family " .. firstToUpper(family)
--https://www.worldbirdnames.org/Family/Struthionidae
local url = data.IOC.customArgs['baseURL'] .. "Family/" .. family
return title, url
end
-- ============================= ASM Mammal Diversity Database ========================
data.asm = {
citationArgs = {
website="ASM Mammal Diversity Database",
publisher="[[American Society of Mammalogists]]"
},
customArgs = { exclude="family,genus,species,taxon,id,1",
baseURL = "https://mammaldiversity.org/",
defaultTitle="ASM Mammal Diversity Database"
}
}
data.asm.species = function(genus, species)
local title = "''" .. genus .. " " .. species .. "''"
--https://mammaldiversity.org/species-account.php?genus=ursus&species=arctos
local url = data.asm.customArgs['baseURL'] .. "species-account.php?genus=" .. genus .. "&species=" .. species
return title, url
end
data.asm.id = function(id)
local url = data.asm.customArgs['baseURL'] .. "species-account/species-id=" .. templateArgs['id']
local title = "Species-id=" .. id
return title, url
end
data.asm.genus = function(genus) return data.asm.taxon(genus, "TITLE_ITALICS") end
data.asm.family = function(family) return data.asm.taxon(family) end
data.asm.order = function(order) return data.asm.taxon(order) end
data.asm.taxon = function(taxon, titleItalics)
--https://mammaldiversity.org/#ZmVsaWRhZSZnbG9iYWxfc2VhcmNoPXRydWUmbG9vc2U9dHJ1ZQ
-- Base64.encode(felidae&global_search=true&loose=true)
local title = firstToUpper(taxon)
if titleItalics then title = "''" .. title .. "''" end
local url = data.asm.customArgs['baseURL']
.. '#' .. data.asm.Base64.encode(taxon.."&global_search=true&loose=false")
return title, url
end
--############################## Base64 encode and decode (used for ASM#####################
local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
-- encoding
data.asm.Base64 = {}
data.asm.Base64.encode = function(data)
return ((data:gsub('.', function(x)
local r,b='',x:byte()
for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end
return r;
end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
if (#x < 6) then return '' end
local c=0
for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end
return b:sub(c+1,c+1)
end)..({ '', '==', '=' })[#data%3+1])
end
-- decoding
data.asm.Base64.decode=function(data)
data = string.gsub(data, '[^'..b..'=]', '')
return (data:gsub('.', function(x)
if (x == '=') then return '' end
local r,f='',(b:find(x)-1)
for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end
return r;
end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x)
if (#x ~= 8) then return '' end
local c=0
for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end
return string.char(c)
end))
end
--######################## Misc ##################################
--[[ 3 approaches to handling DB:
1) use DB as website and use via to append WoRMS
2) use DB as website and use postscript to append WoRMS
3) use WoRMSa as website and designate DB as author (recommended by WoRMS) CURRENT
]]
data.WoRMS = {
citationArgs = {
author = "WoRMS",
website = "[[World Register of Marine Species]]",
--['via'] = "[[World Register of Marine Species]]",
--postscript = ' from the [[World Register of Marine Species]].'
},
customArgs = {exclude="id,db,1",
baseURL = "http://www.marinespecies.org/aphia.php?",
searchStr = "p=taxdetails&id=",
defaultTitle="World Register of Marine Species"
}
}
data.WoRMS.id = function(id)
--[[ Two styles
1. http://www.marinespecies.org/aphia.php?p=taxdetails&id=14712
> WoRMS (2018). Heterobranchia. Accessed at: http://marinespecies.org/aphia.php?p=taxdetails&id=14712 on 2018-11-28
2. http://www.marinespecies.org/aphia.php?p=taxdetails&id=1057249
> MolluscaBase (2018). Ringipleura. Accessed through: World Register of Marine Species at: http://www.marinespecies.org/aphia.php?p=taxdetails&id=1057249 on 2018-11-28
]]
if not templateArgs['id'] then return "no id parameter detected" end
local searchStr = "p=taxdetails&id=" .. templateArgs['id']
if templateArgs['db'] then -- if database hosted by WoRMS
templateArgs['author'] = templateArgs['db'] -- this is recommended by WoRMS
--templateArgs['website'] = templateArgs['db'] -- alternative (and use |postscript)
--templateArgs['publisher'] = templateArgs['via']
--[[else -- WoRMS is primary source
templateArgs['via'] = nil
templateArgs['postscript'] = nil]]
end
--page <title>WoRMS - World Register of Marine Species - Heterobranchia</title>
local title = "WoRMS taxon details: AphiaID " .. id
local url = data.WoRMS.customArgs['baseURL'] .. data.WoRMS.customArgs['searchStr'] .. id
return title, url
end
--====================== Fossilworks =======================================
data.fossilworks = {
citationArgs = {
website="[[Fossilworks]]",
--publisher="Paleobiology Database",
--postscript = 'none',
postscript = " from the [[Paleobiology Database]].",
--via="''fossilworks.org''" -- an alternative format to using |website=
},
customArgs = { exclude = "id,date,1",
baseURL = "http://fossilworks.org/cgi-bin/",
searchStr ="bridge.pl?a=taxonInfo&taxon_no=",
defaultTitle = "Fossilworks: Gateway to the Paleobiology Database"
}
--id = function(id) return p.genericIdCitation (frame, title, url)
}
data.fossilworks.id = function(id)
--[[ http://fossilworks.org/cgi-bin/bridge.pl?a=taxonInfo&taxon_no=83087
if not templateArgs['id'] then return "no id parameter detected" end
local searchStr = "bridge.pl?a=taxonInfo&taxon_no=" .. templateArgs['id']
templateArgs['url']= target.CustomArgs['baseURL'] .. searchStr
]]
local title = "PaleoDB taxon number: " .. id
local url = data.fossilworks.customArgs['baseURL'] .. data.fossilworks.customArgs['searchStr'] .. id
return title, url
end
data.fossilworks.error = function()
return "Requires id and title parameters"
end
--############################## General Functions ########################################
local function getArgs (frame, args)
local parents = mw.getCurrentFrame():getParent()
for k,v in pairs(parents.args) do
--check content
if v and v ~= "" then
args[k]=v --parents.args[k]
end
end
for k,v in pairs(frame.args) do
--check content
if v and v ~= "" then
args[k]=v
end
end
end
local function initialise(frame, sourceDB)
target=sourceDB
templateArgs = sourceDB.citationArgs -- get custom arguments for target (fishbase, cof etc
getArgs(frame, templateArgs) -- get template arguments from parent frame and frane
local url = target.customArgs['baseURL'] .. (target.customArgs['defaultSuffix'] or "")
local title = target.customArgs['defaultTitle'] or ""
return title, url
end
-- moved up top for scope
local function firstToUpper2(str)
return (str:gsub("^%l", string.upper))
end
-- clear template arguments that won't be recognised by {{cite web}}
local function clearCustomArgs()
local excludeTable = {}
if target.customArgs['exclude'] then
excludeTable = mw.text.split (target.customArgs['exclude'] , "%s*,%s*");
for k,v in pairs(excludeTable) do
if tonumber (v) then
v = tonumber (v) --convert positional parameters (numbers as string) to a number
end
templateArgs[v]=nil --clear content
end
end
end
-- function handling the cite web template
p.citeWeb = function(frame, title, url)
-- set url and title if not provided (template parameters override above)
if not templateArgs['url'] and url then
templateArgs['url']= url
end
if not templateArgs['title'] and title then
templateArgs['title'] = title
end
clearCustomArgs()--blank template parameters not for cite web
local citeTemplate = 'cite web' -- use Template:Cite web unless specified
--if target.citeTemplate then citeTemplate = target.citeTemplate end
return frame:expandTemplate{ title = citeTemplate, args = templateArgs }
end
-- p.CiteBook
-- for reasons of consisitency within BioRef/FishRef the title parameter is the section-title of {{cite book}}
p.citeBook = function(frame, title, url, chapterParams) -- very much a msw3 function
--if (1==1) then return templateArgs['title'] end
-- set url and title if not provided (template parameters override above)
if not templateArgs['url'] and url then
templateArgs['url']= url
if target.GoogleBooks then
templateArgs['url'] = target.GoogleBooks['baseURL'] .. target.GoogleBooks['id']
.. (target.GoogleBooks['defaultPage'] or "&pg=PP1")
end
end
if not templateArgs['title'] and title then
-- templateArgs['title'] = title
end
if templateArgs['title'] ~= title or templateArgs['taxon-title'] then -- do we have a section title provided
templateArgs['section'] = templateArgs['title'] -- chapter/section title passed as title parameter
templateArgs['title'] = title -- the work is the book title given in the source data
if target.GoogleBooks then
templateArgs['section-url'] = target.GoogleBooks['baseURL'] .. target.GoogleBooks['id']
local pageSuffix = target.GoogleBooks['defaultPage'] or ""
if templateArgs['page'] then
pageSuffix = "&pg=PT" .. templateArgs['page']
end
local searchStr = ""
-- quoted search {{#if:{{{text|{{{dq|}}}}}}|&dq={{urlencode:{{{text|{{{dq|}}}}}}}}}}
if templateArgs['q'] then searchStr = "&q=" .. mw.text.encode( templateArgs['q'] ) end
-- search #if:{{{keywords|{{{q|}}}}}}|&q={{urlencode:{{{keywords|{{{q|}}}}}}}}}}
if templateArgs['dq'] then searchStr = "&dq=" .. mw.text.encode( templateArgs['dq'] ) end
templateArgs['section-url'] = templateArgs['section-url'] .. pageSuffix .. searchStr
end
end
clearCustomArgs()--blank template parameters not for cite web
local citeTemplate = 'cite book' -- use Template:Cite web unless specified
--if target.citeTemplate then citeTemplate = target.citeTemplate end
return frame:expandTemplate{ title = citeTemplate, args = templateArgs }
end
-- common function for genus and species
local function getGenusSpecies()
--TODO standardise genus species handling
local genus, species, subspecies
if (templateArgs['genus'] or templateArgs[2] ) then
genus = templateArgs['genus'] or templateArgs[2]
genus = firstToUpper(mw.text.trim(genus))
end
if (templateArgs['species'] or templateArgs[3] ) then
species = templateArgs['species'] or templateArgs[3]
species = mw.text.trim(species)
end
if (templateArgs['subspecies'] or templateArgs[4] ) then
subspecies = templateArgs['subspecies'] or templateArgs[4]
subspecies = mw.text.trim(subspecies)
end
return genus, species, subspecies
end
--#################### MSW3 -- uses cite book
p.MSW3 = function(frame)
local msw = require('Module:FishRef/MSW')
initialise(frame, msw.MSW3)
return msw.MSW3.main(frame,templateArgs)
end
p.MSW3merged = function(frame)
local data = require('Module:FishRef/MSW')
return p._main(frame, data.MSW3)
end
p.MSW3_standalone = function(frame)
local data = require('Module:FishRef/MSW')
initialise(frame, data.MSW3)
local url = target.CustomArgs['baseURL']
if templateArgs['title'] and templateArgs['id'] then
templateArgs['chapter-url']= url .. target.CustomArgs['searchStr'] .. templateArgs['id']
templateArgs['chapter'] = templateArgs['title']
templateArgs['title'] = target.CustomArgs['bookTitle']
if templateArgs['page'] then
templateArgs['url'] = target.CustomArgs['googleBooksURL'] .. templateArgs['page']
else
--return "Page number for google books required"
end
elseif templateArgs['order'] then
templateArgs['chapter'] = "Order " .. templateArgs['order']
local chapter = target.chapters[templateArgs['order']]
for k,v in pairs(chapter) do -- add chapter specific parameters
templateArgs[k] = v
end
templateArgs['chapter-url']= url .. target.CustomArgs['searchStr'] .. templateArgs['id']
templateArgs['url']= target.CustomArgs['googleBooksURL'] .. templateArgs['page']
if templateArgs['pages'] and templateArgs['page'] then templateArgs['page'] = nil end
else -- default output
templateArgs['url']= target.CustomArgs['googleBooksURL'] .. "1" -- default to book
templateArgs['url']= url
end
-- using cite book
clearCustomArgs()--blank template parameters not for cite web
return frame:expandTemplate{ title = 'cite book', args = templateArgs }
end
--########################### handling for ID only (unused?) ##################################
p.genericIdCitation = function(frame, title, url)
if not templateArgs['id'] then return "no id parameter detected" end
templateArgs['url']= target.CustomArgs['baseURL'] .. target.CustomArgs['searchStr'] .. templateArgs['id']
return p.citeWeb(frame, title, url)
end
--########################### Functions for access ##############################################
--================ Fishbase, Catalog of Fishes (cof) ================
p.fishbase = function(frame) return p._main(frame, fishbase) end
p.cof = function(frame) return p._main(frame, cof) end
p.fotw5 = function(frame) return p._main(frame, fotw5) end
--=================== ASW6, AmphibiaWeb, ReptileDB
p.reptileDB = function(frame) return p._main(frame, reptileDB) end
p.ASW6 = function(frame) return p._main(frame, ASW6) end
p.amphibiaweb = function(frame) return p._main(frame, amphibiaweb) end
--=========== Birds
p.HBWa = function(frame) return p._main(frame, HBWalive) end
p.HBWalive = function(frame) return p._main(frame, HBWalive) end
p.IOC = function(frame) return p._main(frame, IOC) end
--======= Mammals
p.asm = function(frame) return p._main(frame, asm) end
-- MSW3 has custom handling (see above)
--=========== Other
p.fossilworks = function(frame) return p._main(frame, fossilworks) end
p.worms = function(frame) return p._main(frame, WoRMS) end
p.WoRMS = function(frame) return p._main(frame, WoRMS) end
--fallback = function() return "hello" end
--#########################################################
p.main = function(frame)
local source = mw.text.trim(frame.args[1])
if source == "MSW3" then return p.MSW3(frame) end
if source == "Reference" then return p.Reference(frame) end
if source == "HBWa" then source = "HBWalive" end -- aliases
--return p[source]['test']
if source == "fishbase"
or source == "cof"
or source == "fotw5" or source == "Fotw5"
or source == "reptileDB"
or source == "amphibiaweb"
or source == "ASW6"
or source == "asm"
or source == "HBWalive" or source == "HBWa"
or source == "fossilworks"
or source == "WoRMS" or source == "worms"
-- and so on
then return p._main(frame,data[source])
else
--
-- is there a point in the default if it needs the named object/table?
return p._main(frame,data[source])
end
end
p._main = function(frame, source)
--TODO in modular version source will be provided in frame arguments
--local source = mw.getCurrentFrame():getParent().args[1]
local chapterParams = {} -- used for cite book (only MSW3 at moment)
local title, url = initialise(frame, source)
--taxon related parameters
local genus, species, subspecies = getGenusSpecies()
local family = templateArgs['family']
local order = templateArgs['order']
local taxon = templateArgs['taxon']
local id = templateArgs['id'] --id related parameters
local spid = templateArgs['spid']
local genid = templateArgs['genid']
local mode, value
-- the functions
if genus and species and source.species then
title, url = source.species(genus,species,subspecies)
else -- functions with just their own name as parameter
if genus then mode = "genus"; value = genus
elseif family then mode = "family"; value = family
elseif order then mode = "order"; value = order
elseif taxon then mode = "taxon"; value = taxon
elseif id then mode = "id"; value = id
elseif spid then mode = "spid"; value = spid
elseif genid then mode = "genid"; value = genid
else
-- no suitable parameter (use default page)
if source.default then
title, url, chapterParams = source.default(templateArgs)
end
end
end
if mode then
if source[mode] then
title, url, chapterParams = source[mode](value)
else
if source.error then return source.error() end
return "Error: parameter not supported for this source"
end
else -- use default if error message commented out
-- return "Error: unrecognised parameter"
end
if source.citeTemplate == "Cite book" then
return p.citeBook(frame, title, url, chapterParams)
end
return p.citeWeb(frame, title, url)
end -- End the function.
local refs ={}
refs['Frost-2006']= '{{cite journal | last1 = Frost | first1 = Darrel R. | title = The Amphibian Tree of Life | hdl = 2246/5781 | journal = Bulletin of the American Museum of Natural History | volume = 297 | pages = 1–291 | year = 2006 | last2 = Grant | first2 = Taran | last3 = Faivovich | first3 = Julián | last4 = Bain | first4 = Raoul H. | last5 = Haas | first5 = Alexander | last6 = Haddad |first6 = Célio F.B. | last7 = De Sá | first7 = Rafael O. | last8 = Channing | first8 = Alan | last9 = Wilkinson | first9 = Mark | last10 = Donnellan | first10 = Stephen C. | last11 = Raxworthy | first11 = Christopher J. | last12 = Campbell | first12 = Jonathan A. | last13 = Blotto | first13 = Boris L. | last14 = Moler | first14 = Paul | last15 = Drewes | first15 = Robert C. | last16 = Nussbaum |first16 = Ronald A. | last17 = Lynch | first17 = John D. | last18 = Green | first18 = David M. | last19 = Wheeler | first19 = Ward C. | doi = 10.1206/0003-0090(2006)297[0001:TATOL]2.0.CO;2 | url = https://www.researchgate.net/publication/213771051 }}'
refs['Nelson-2016'] = '{{cite book| last = Nelson| first = Joseph S.|first2=Terry C. |last2=Grande |first3=Mark V. H. |last3=Wilson | title = Fishes of the World |edition=5th|year = 2016| publisher =John Wiley and Sons |location=Hoboken |isbn = 978-1-118-34233-6 |doi=10.1002/9781119174844 |url=https://sites.google.com/site/fotw5th/}}'
p.Reference = function(frame)
getArgs(frame, templateArgs)
if templateArgs[2] then
local reference = mw.text.trim(templateArgs[2])
if reference ~= "" and refs[reference] then
if templateArgs['pages'] then refs[reference] = refs[reference]:gsub("}}", "|pages="..templateArgs['pages'].."}}") end
if templateArgs['expand'] and templateArgs['expand']=='no' then
return refs[reference]
else
return frame:preprocess(refs[reference])
end
else
return 'Reference not found: "' .. templateArgs[2] .. '"'
end
end
return "Reference parameter missing."
end -- End the function.
-- All modules end by returning the variable containing its functions to Wikipedia.
return p