Module:Biota infobox/core
Appearance
From Wikipedia, the free encyclopedia
This module is rated as alpha. It is ready for limited use and third-party feedback. It may be used on a small number of pages, but should be monitored closely. Suggestions for new features or adjustments to input and output are welcome.
Page semi-protected Editing of this module by new or unregistered users is currently disabled.
See the protection policy and protection log for more details. If you cannot edit this module and you wish to make a change, you can submit an edit request , discuss changes on the talk page, request unprotection, log in, or create an account.
See the protection policy and protection log for more details. If you cannot edit this module and you wish to make a change, you can submit an edit request , discuss changes on the talk page, request unprotection, log in, or create an account.
This module started out as a quick module for template {{paraphyletic group }}, but has morphed into a module to emulate the {{taxobox/core }}. Handling for templates that call the core has been added for {{taxobox }}, {{Automatic taxobox }} and {{Speciesbox }}, but is incomplete.
Data subpages
Examples:
- User:Jts1882/taxobox/manual (manual taxobox version)
- User:Jts1882/taxobox/auto (automatic taxobox version)
- User:Jts1882/taxobox/species (speciesbox version)
- User:Jts1882/taxobox/infra (subspeciesbox and infraspeciesbox versions)
- User:Jts1882/taxobox/para (paraphyletic group versions)
- User:Jts1882/taxobox/Wikidata (wikidata versions)
Sandbox version at Module:Sandbox/Jts1882/Biota infobox.
Usage
{{#invoke:Biota infobox|function_name}}
The above documentation is transcluded from Module:Biota infobox/core/doc. (edit | history)
Editors can experiment in this module's sandbox (create | mirror) and testcases (create) pages.
Subpages of this module.
Editors can experiment in this module's sandbox (create | mirror) and testcases (create) pages.
Subpages of this module.
require('strict') localp={} localtemplateArgs={} localinfo={} localparamData=require('Module:Biota infobox/data')-- contains the taxon ranks in order localautotaxa=require("Module:Autotaxobox") localparameters=require('Module:Biota infobox/param') --[[ ##################### CORE FUNCTIONS ################################### this core function emulates Template:Taxobox/core it is followed by functions handling the different type of entry ]] p.main=function(frame) -- this function emulates Template:Taxobox/core when called from taxobox feeder templates -- i.e. Taxobox, Automatic taxobox, Speciesbox, etc parameters.getArgs(frame) templateArgs['image_upright']=templateArgs['upright']or1 templateArgs['image2_upright']=templateArgs['upright2']or1 info.headerColor=templateArgs['colour'] returnp._core --TODO check it works end -- this is the core function, called either from main() or auto() p.core=function(frame,args,localinfo) templateArgs=args info=localinfo returnp._core(frame) end p._core=function(frame) -- TODO use mw.title.getCurrentTitle().basePageTitle info.name=templateArgs['name']ortostring(mw.title.getCurrentTitle())--.rootPageTitle ) ifnotinfo.headerColorthen info.headerColor=p.getTaxoboxColor(frame)-- so only transverse taxobox heirarchy once end --[[ create table (two versions) 1. use mwhtml library to build table in taxoboxTable 2. use wikitest to build table in wikitextTable ]] localtaxoboxTable=mw.html.create('table'):addClass('infobox'):addClass('biota') :addClass('biota-infobox') localwikitextTable='\n{| class="infobox biota biota-infobox" ' info.subheader='' iftemplateArgs['subheader']andtemplateArgs['subheader']~=''then info.subheader='<div style="font-weight:normal;font-size:smaller;">'..templateArgs['subheader']..'</div>' end --TODO do we need additional handling to check {{geological range}} template -- or handle oldest_fossil and youngest_fossil (these don't seem to be used now) -- Note: taxobox/core uses temporal_range localtemporalRange='' iftemplateArgs['temporal_range']then temporalRange='<div><small>Temporal range: '..templateArgs['temporal_range']..'</small></div>'-- use <div> rather than <br/> end localrowHeader=taxoboxTable:tag('tr'):tag('th'):attr('colspan','2'):addClass('section-header') :cssText('background:'..info.headerColor..';') :wikitext(info.name..info.subheader..temporalRange) wikitextTable=wikitextTable..'\n|-\n! colspan="2" class="section-header" style="background:'..info.headerColor..';" ' ..'|'..info.name..info.subheader..temporalRange -- add images wikitextTable=wikitextTable..p.addImageSection(frame,taxoboxTable,'image') ..p.addImageSection(frame,taxoboxTable,'image2') --add conservation status wikitextTable=wikitextTable..p.addStatusSection(frame,taxoboxTable,'status') ..p.addStatusSection(frame,taxoboxTable,'status2') ..p.addStatusSection(frame,taxoboxTable,'status3') -- add taxonomy table (uses entered parameters or automatic taxonomy system) wikitextTable=wikitextTable..p.addTaxonomySection(frame,taxoboxTable) -- add sections with binomial, trinomial, type species/genus (with authorities) wikitextTable=wikitextTable ..p.addTaxonSection(frame,taxoboxTable,'binomial','Binomial name') ..p.addTaxonSection(frame,taxoboxTable,'trinomial','Trionomial name') ..p.addTaxonSection(frame,taxoboxTable,'type_genus','Type genus') --TODO type_ichnogenus, type_oogenus ..p.addTaxonSection(frame,taxoboxTable,'type_species','Type species') --TODO type_ichnospecies, type_oospecies ..p.addTaxonSection(frame,taxoboxTable,'type_strain','Type strain') -- add sections showing subdivisions (i.e. child taxa) wikitextTable=wikitextTable ..p.addListSection(frame,taxoboxTable,'subdivision',templateArgs['subdivision_ranks']or'Subdivisions') ..p.addListSection(frame,taxoboxTable,'possible_subdivision',templateArgs['possible_subdivision_ranks']or'Possible subdivisions') -- diversity section (TODO consider how best to handle) wikitextTable=wikitextTable..p.addTaxonSection(frame,taxoboxTable,'diversity','Diversity') -- show included groups (accepts 'included' or 'includes') [used for paraphyletic taxa] wikitextTable=wikitextTable..p.addListSection(frame,taxoboxTable,'includes','Groups included') --p.addListSection(frame, taxoboxTable, 'included', 'Groups included') -- use alias --add range map (should this be below binomial/trinomial?) wikitextTable=wikitextTable..p.addImageSection(frame,taxoboxTable,'range_map') -- show excluded groups (accepts 'excluded' or 'excludes') [used for paraphyletic taxa] localexcludedHeaderText='[[Cladistics|Cladistically]] included but traditionally excluded taxa' wikitextTable=wikitextTable..p.addListSection(frame,taxoboxTable,'excludes',excludedHeaderText) -- add addition binomials, trinomial and range maps wikitextTable=wikitextTable ..p.addTaxonSection(frame,taxoboxTable,'binomial2','Binomial name (2)') --p.addTaxonSection(frame, taxoboxTable, 'trinomial2', 'Trionomial name (2)') ..p.addImageSection(frame,taxoboxTable,'range_map2') ..p.addTaxonSection(frame,taxoboxTable,'binomial3','Binomial name (3)') --p.addTaxonSection(frame, taxoboxTable, 'trinomial3', 'Trionomial name (3)') ..p.addImageSection(frame,taxoboxTable,'range_map3') ..p.addTaxonSection(frame,taxoboxTable,'binomial4','Binomial name (4)') --p.addTaxonSection(frame, taxoboxTable, 'trinomial4', 'Trionomial name (4)') ..p.addImageSection(frame,taxoboxTable,'range_map4') -- add synonyms section wikitextTable=wikitextTable..p.addListSection(frame,taxoboxTable,'synonyms','[[Synonym (taxonomy)|Synonyms]]') -- add debug/tracking info section ifinfo.debugthen wikitextTable=wikitextTable..p.addListSection(frame,taxoboxTable,'debug','Debug/tracking info') end ------------------add templateSyles and return taxobox table--------------------------- localsrc="Template:Biota infobox/styles.css"-- TemplateStyles file wikitextTable=wikitextTable..'\n|}' localoutput=wikitextTable-- output the wikitext table --local output = tostring(taxoboxTable) -- output the mw.html table returnoutput..p.templateStyle(frame,src)..info.parameterCategory --return '<div style="float:right;">' .. output .. p.templateStyle( frame, src ) .. info.parameterCategory .. '</div>' end-- End the main function. --[[ ==================================================================================== function to add conservation sections uses template {{taxobox/species|{{{status_system|}}}|{{{status|}}}|{{{status_ref|}}}|extinct={{{extinct|}}} }} }} --]] functionp.addStatusSection(frame,taxoboxTable,status) -- must use table container to handle template output -- don't use header or content cells; the 'taxobox/species' template handles it -- just need to add background colour on the row localwikiText="" iftemplateArgs[status]andtemplateArgs[status]~=""then localstatusText=frame:expandTemplate{title='taxobox/species', args={templateArgs[status..'_system']or'', templateArgs[status]or'', templateArgs[status..'_ref']or'', ['extinction_date']=templateArgs['extinct']or'', ['colour']=templateArgs['colour']or'' } } localrow=taxoboxTable:tag('tr') --:cssText('background:' .. p.getTaxoboxColor(frame) .. ';') localcell=row:tag('td'):attr('colspan','2') :wikitext('\n{|\n|- style="background:'..info.headerColor..';"') :wikitext('\n'..tostring(statusText)) :wikitext('\n|}') -- mw.addWarning ('taxobox/species returns:' .. '<pre>' .. statusText .. '</pre>') ifstatus=="status2"orstatus=="status3"then wikiText='\n|-'..tostring(statusText)-- Horrible fudge to prevent header on second conservation status -- mimicks taxobox in not having newline after \- so header doesn't show else wikiText='\n|- colspan="2" style="background:'..info.headerColor..';" ' ..'\n'..tostring(statusText) end end returnwikiText end --[[ ============================================================================== function to add sections for taxonomic information with authorities ('_authority' suffix) e.g. binomial, trinomial, type_species, type_genus; diversity also handled here --]] functionp.addTaxonSection(frame,taxoboxTable,target,headerText) localwikiText="" -- return if we don't have value ifnottemplateArgs[target]ortemplateArgs[target]==''thenreturn""end localbold=""-- variable for bolding binomial and trinomial (type genus/species etc are not bolded) localshowHeader=true locallistHeader=(templateArgs[target..'_text']orheaderText) -- custom processing section --if target == 'binomial' or target == 'binomial2' or target == 'binomial3' or target == 'binomial4' then iftarget=='binomial'then headerText='[[Binomial nomenclature|'..listHeader..']]' bold="'''" --elseif target == 'trinomial' or target == 'trinomial2' or target == 'trinomial3' or target == 'trinomial4' then elseiftarget=='trinomial'then localtrinomenLink="Trinomen"-- for zoological or default ifinfo.auto=="infraspeciesbox"thentrinomenLink="Infraspecific name (botany)"end-- regnum contains plant/fung/Archaeplastida" headerText='[['..trinomenLink..'|'..headerText..']]' bold="'''" elseiftarget=='binomial2'ortarget=='binomial3'ortarget=='binomial4' ortarget=='trinomial2'ortarget=='trinomial3'ortarget=='trinomial4'then showHeader=false bold="'''" elseiftarget=='diversity'then headerText='[[Biodiversity|'..headerText..']]' else --TODO is any handling needed for other option headerText='[['..headerText..']]' end iftemplateArgs[target..'_ref']then headerText=headerText..templateArgs[target..'_ref']..'\n' end localcontentString=''-- content for the content cell iftarget=='diversity'andtemplateArgs['diversity']~=""then iftemplateArgs[target..'_link']andtemplateArgs[target..'_link']~=""then contentString='\n[['..templateArgs[target..'_link']..'|'..templateArgs[target]..']]\n' else contentString='\n'..templateArgs[target]..'\n' end else -- taxon name and authority (binomial, type species, etc) localauthorityString='' iftemplateArgs[target..'_authority']then authorityString='<br/><div style="text-align:center"><small>'..templateArgs[target..'_authority']..'</small></div>'-- \n' end contentString=bold..templateArgs[target]..bold..authorityString contentString='<div style="padding-left:1em;text-indent:-1em">'..contentString..'</div>'..'\n' --contentString = '\n' .. bold .. templateArgs[target] .. bold .. authorityString .. '\n' -- extra <p> inserted end -- add table rows iftemplateArgs[target]andtemplateArgs[target]~=''then ifshowHeaderthen localrowHeader=taxoboxTable:tag('tr') rowHeader:tag('th') :attr('colspan','2') :addClass('section-header') :cssText('background:'..info.headerColor..';') :wikitext(headerText) wikiText=wikiText..'\n|- \n! colspan="2" class="section-header" style="background:'..info.headerColor..';" ' ..'|'..headerText end localrowList=taxoboxTable:tag('tr') rowList:tag('td') :attr('colspan','2') --:addClass('section-content') :addClass('taxon-section') --:cssText('text-align:center;') --font-weight:bold;') :wikitext(contentString) wikiText=wikiText..'\n|- \n| colspan="2" class="taxon-section" |'..contentString end returnwikiText end --[[ ==================================================================================== function to produce sections for included taxa (subdivisions), synonyms, etc - each consists of two rows containing a header and the content - for paraphyletic groups it has include(d|s) and exclude(d|s) groups - for general taxobox it has subdivision and possible subdivision (disabled here) - any can be modified for other purposes (e.g. sisters) by changing the header taxt with a -text parameter ]] functionp.addListSection(frame,taxoboxTable,target,headerText) ifnottemplateArgs[target]ortemplateArgs[target]==""thenreturn""end-- redundant for now localwikiText="" localrefString='' iftemplateArgs[target..'_ref']then --add '_ref' option for 'synonym_ref' (the rest get it as a bonus) TODO check example refString=templateArgs[target..'_ref']--.. '\n' end locallistHeader=(templateArgs[target..'_text']orheaderText)..refString -- add table rows iftemplateArgs[target]andtemplateArgs[target]~=''then localrowHeader=taxoboxTable:tag('tr') rowHeader:tag('th') :attr('colspan','2') :addClass('section-header') :cssText('background:'..info.headerColor..';') :wikitext(listHeader) wikiText=wikiText..'\n|- \n! colspan="2" class="section-header" style="background:'..info.headerColor..';" ' ..'|'..listHeader localrowList=taxoboxTable:tag('tr') rowList:tag('td') :attr('colspan','2') :addClass('section-content') :wikitext('\n'..templateArgs[target]..'\n') wikiText=wikiText..'\n|- \n| colspan="2" class="section-content" ' ..'|'..'\n'..templateArgs[target]..'\n' end returnwikiText end ----------------------------------------------------------------------------------------------- --[[ ============================================================================ function to add image sections - used for illustrative images at top and for range maps --]] functionp.addImageSection(frame,taxoboxTable,target) localwikiText="" iftemplateArgs[target]andtemplateArgs[target]~=''then localimageWidth='' localimageCaptionString='' iftemplateArgs[target..'_caption']then --imageCaptionString = '<br /><small><div style="text-align:center">' .. templateArgs[target .. '_caption'] .. '</div></small>' --imageCaptionString = '<br /><div>' .. templateArgs[target .. '_caption'] .. '</div>' imageCaptionString=templateArgs[target..'_caption'] end localimageAltString='' iftemplateArgs[target..'_alt']then imageAltString=templateArgs[target..'_alt'] elseiftemplateArgs[target..'_caption']then imageAltString=templateArgs[target..'_caption']-- use caption for alt text if none provided end localupright=templateArgs['image_upright']or1 localInfoboxImage=require('Module:InfoboxImage')--, parent.args[target] ) localparams={args={image=templateArgs[target], size=templateArgs[target..'_width'], sizedefault='frameless', alt=imageAltString, upright=templateArgs[target..'_upright']orupright } } localimage=InfoboxImage.InfoboxImage(params) --local rowImage = taxoboxTable:tag('tr') localrowImage=mw.html.create('tr') rowImage:tag('td') :attr('colspan','2') :addClass("image-section") :wikitext(image) --:wikitext(imageCaptionString) taxoboxTable:node(rowImage) wikiText=wikiText..'\n|- \n|colspan="2" class="image-section" |'..image ifimageCaptionString~=""then-- only insert row if caption string localrowImageCaption=mw.html.create('tr') rowImageCaption:tag('td') :attr('colspan','2') :addClass("image-section") --:wikitext(image) :wikitext(imageCaptionString) taxoboxTable:node(rowImageCaption) wikiText=wikiText..'\n|- \n|colspan="2" class="image-section" |'..imageCaptionString end end -- TODO handle upright returnwikiText end --[[ ============================ TAXONOMY SECTION ======================================= adds a table showing the taxonomy - uses either manual parameters or the automatic taxonomy system - currently adds a table inside a cell (like paraphyletic group) rather than just adding rows (core taxobox system) --]] functionp.addTaxonomySection(frame,taxoboxTable) localwikiText="" localtaxonomyHeader="[[Taxonomy_(biology)|Scientific classification]]" iftemplateArgs['virus_group']then taxonomyHeader="[[Virus classification]]" elseiftemplateArgs['ichnos']then taxonomyHeader="[[Trace fossil classification]]" elseiftemplateArgs['veterovata']then taxonomyHeader="[[Veterovata|Eggshell classification]]" else -- TODO add other options (DONE but not verified ichnos or veterovata) -- ! colspan=2 style="min-width:15em; text-align: center{{#if:{{{colour|}}}|{{;}} background-color{{COLON}} {{{colour}}} }}" | -- {{#if:{{{virus_group|{{{virus|}}}}}}|[[Virus classification]] -- |{{#if:{{{ichnos|}}}|[[Trace fossil classification]] -- |{{#if:{{{veterovata|}}}|[[Veterovata|Eggshell classification]] -- |[[Taxonomy (biology)|Scientific classification]]}} }} }} -- {{#if:{{{edit link|}}}|{{edit taxonomy|{{{parent|}}} | {{{edit link}}} }} -- {{#if: {{{classification_status|}}} | <br>({{{classification_status}}}) | }} }} -- handle |classification_status=disputed (add ref) end -- add symbol and link to taxonomy editor localeditLink='' ifinfo.autothen localtooltip=templateArgs['edit link']or"Edit this classification" localstyle='font-size:smaller; float:right; padding-right:0.4em; margin-left:-3em;' locallink='Template:Taxonomy/'..templateArgs['parent'] ifinfo.db=="wikidata"then localmessage='Select%20preview%20to%20see%20Wikidata%20hierarchy' localurl='https://en.wikipedia.org/w/index.php?action=edit§ion=new&preloadtitle='..message ..'&title=Template:Biota_infobox/Wikidata/preview&preload=User:Jts1882/Taxonomy/preload2&preloadparams%5b%5d=' link=url..string.gsub(templateArgs['parent']," ","_") end editLink='<span class="plainlinks" style="'..style..'">' ..'[[File:OOjs UI icon edit-ltr.svg|15px|link='..link..'|'..tooltip..']]</span>' --.. '[[File:Red Pencil Icon.png|link=' .. link .. '|' .. tooltip .. ']]</span>' end localstatus="" iftemplateArgs['classification_status']then status='<div style="font-weight:normal;" >('..templateArgs['classification_status']..')' iftemplateArgs['classification_ref']thenstatus=status..templateArgs['classification_ref']end status=status..'</div>' end localrowTaxonomyHeader=taxoboxTable:tag('tr') rowTaxonomyHeader:tag('th') :attr('colspan','2') :addClass('section-header') :cssText('background:'..info.headerColor..';') :wikitext(taxonomyHeader) :wikitext(editLink) :wikitext(status) wikiText=wikiText..'\n|- \n! colspan="2" class="section-header" style="min-width:15em;text-align:center;background:'..info.headerColor..';" ' ..'|'..taxonomyHeader..editLink..status --[[ get taxonomy list, either using automatic taxobox system or manual system manual: get ranks and taxa from template parameter auto (default): get ranks and taxa from taxonomy template parameters module: get ranks and taxa from dataa submodules wikidata: get ranks and taxa from wikidata ]] -- shows ranks of genus or above for all auto modes ifinfo.db=="module"then localwdModule=require('Module:Biota infobox/Wikidata') wikiText=wikiText..wdModule.addModuleTaxonomy(frame,taxoboxTable,templateArgs)-- use module copy of template data elseifinfo.db=="wikidata"then --wikiText = wikiText ..'\n|-|\n|' .. p.addWikidataTaxonomy(frame, taxoboxTable) -- use wikidata localwdModule=require('Module:Biota infobox/Wikidata') wikiText=wikiText..wdModule.addWikidataTaxonomy(frame,taxoboxTable,templateArgs)-- use wikidata -- TODO need to handle colour -- the default is class="section-header" colspan="2" style="background:rgb(250,240,230);" -- wikiText = wikiText:gsub('style="background:rgb%(250,240,230%);"', 'style="background:red;"') -- gsub must be applied to wikitextTable -- use more generally to avoid traversing the hierarchy twice) elseifinfo.autothen --[[ get automatic taxonomy hierarchy (three different variants) 1) direct call to taxoboxList() - preferred if issues with setting frame arguments can be resolved (used in live version) 2) experimental version of taxoboxList() 3) [ET] using Template:Taxobox/taxonomy ]] wikiText=wikiText..'\n|-|\n|'..p.addAutomaticTaxonomy(frame,taxoboxTable)-- use #invoke of module end ifinfo.autothen -- use manual taxobox for subgeneric ranks: subgenus,species, subspecies, variety (also for informal group) -- ranks below genys using manual taxobox code localtaxonRanks={'subgenus','species','hybrid','subspecies','population','variety','infraspecies_rank1','infraspecies_rank2','informal'} wikiText=wikiText..p.addManualTaxonomy(frame,taxoboxTable,taxonRanks) else wikiText=wikiText..p.addManualTaxonomy(frame,taxoboxTable,paramData.taxonRanks)-- just add rows manually end returnwikiText end -------------------------------------------------AUTOMATIC TAXONOMY (using invoke of module function) ----------- functionp.addAutomaticTaxonomy(frame,taxoboxTable)-- use invoke of module function --emulate template: {{taxobox/taxonomy}} --which uses {{#invoke:Autotaxobox|taxoboxList --local autotaxa = require("Module:Autotaxobox") -- also needed for colours so global now localbold_first='bold' iftemplateArgs['species']ortemplateArgs['hybrid']thenbold_first='link'end iftemplateArgs['link_parent']thenbold_first='link'end localargs={templateArgs['parent'],-- or tostring( mw.title.getCurrentTitle() ), display_taxa=templateArgs['display_taxa']or1, offset=templateArgs['offset']or0, authority=templateArgs['authority'], parent_authority=templateArgs['parent_authority'], gparent_authority=templateArgs['grandparent_authority'], ggparent_authority=templateArgs['greatgrandparent_authority'], gggparent_authority=templateArgs['greatgreatgrandparent_authority'], virus=templateArgs['virus'], bold_first=bold_first } frame.args=args -- templateArgs['debug'] = mw.dumpObject(frame) localautoTaxonomy=autotaxa.taxoboxList(frame) if(1==1)thenreturnautoTaxonomyend localrow=taxoboxTable:tag('tr')-- incompatible with the templates called :wikitext('\n|rank ||taxon name ') :wikitext('\n'..autoTaxonomy)-- autoTaxonomy ends with a new row (|-)at end :wikitext('\n|x ||y ')-- so add blank cells to complete extra row -- this and affects spacing in taxonomy rows --:wikitext('\n') -- spacing fine, newline for table wikitext --[[ note: the output of {{taxobox/showtaxon}} [used by invoke:Autotaxobox|taxoboxList] ends with a newline token this and affects spacing in taxonomy rows leaving the empty row results in spurious paragraphs above the table ]] return end ----------------------------------------MANUAL TAXONOMY-------------------------------- functionp.addManualTaxonomy(frame,taxoboxTable,taxonRanks) --local parent = mw.getCurrentFrame():getParent() --local taxonRanks = data.taxonRanks -- following {{Paraphyletic group, a table is add to the cell in the classification row --local taxonomyTable = mw.html.create('table'):addClass('taxonomy') -- an alternative is to dispense with the extra table and just add the rows (like taxobox/core), -- which would need colspan=2 on other rows (DONE) localtaxonomyTable=taxoboxTable localwikiText="" fork,vinpairs(taxonRanks)do iftemplateArgs[v]then localtaxonName=templateArgs[v] localtaxonRank=frame:expandTemplate{title="anglicise rank",args={taxonRanks[k]}} ifv=='infraspecies_rank1'andtemplateArgs['infraspecies_rank1_name']then taxonRank=templateArgs['infraspecies_rank1_name'] elseifv=='infraspecies_rank2'andtemplateArgs['infraspecies_rank2_name']then taxonRank=templateArgs['infraspecies_rank2_name'] elseifv=='population'andtemplateArgs['population_rank_name']then taxonRank=templateArgs['population_rank_name'] end iftaxonRanks[k]=="virus_group"then taxonName=frame:expandTemplate{title="Virus group",args={templateArgs[v]}} -- taxonRank = "Group" -- handled by anglicise rank template end localauthorityString='' iftemplateArgs[taxonRanks[k]..'_authority']then authorityString='<br /><small>'..templateArgs[taxonRanks[k]..'_authority']..'</small>' end localtaxonString='<span style="padding-left:1em;text-indent:-1em;display:inline-block" class="'.. taxonRanks[k]..'">'..taxonName..'</span>'..authorityString localrow=taxonomyTable:tag('tr') row:tag('td'):wikitext(taxonRank..':') row:tag('td'):wikitext(taxonString) --:wikitext('<br /><small>'..parent.args[taxonRanks[k]..'_authority']..'</small>') wikiText=wikiText..'\n|- \n|'..taxonRank..': \n|'..taxonString end end-- end for loop --return tostring(taxonomyTable) returnwikiText end --[[ ########################### UTILITY FUNCTIONS ############################################### -----------------------------------------TAXOBOX COLOUR-------------------------------------- -- gets colour for headers using manual or automatic taxobox schemes ]] functionp.getTaxoboxColor(frame) localcolorAs=templateArgs['color_as']ornil ifinfo.autoandnottemplateArgs['virus_group']then --[[(1) if color_as|colour_as|color as|colour as set, use template {{Taxobox colour|color_as}} (2) else use the auto taxonnomy tree to find colour: {{#invoke:Autotaxobox|taxoboxColour| }} {{#invoke:Autotaxobox|taxoboxColour|{{{parent|{{{genus|{{first word|{{{taxon|{{PAGENAME}} }} --]] --[[if (templateArgs['color_as'] and templateArgs['color_as'] ~= "") or (templateArgs['colour_as'] and templateArgs['colour_as'] ~= "") or (templateArgs['color as'] and templateArgs['color as'] ~= "") or (templateArgs['colour as'] and templateArgs['colour as'] ~= "") then local colorAs = "" if templateArgs['color_as'] then colorAs = templateArgs['color_as'] end if templateArgs['colour_as'] then colorAs = templateArgs['colour_as'] end if templateArgs['color as'] then colorAs = templateArgs['color as'] end if templateArgs['colour as'] then colorAs = templateArgs['colour as'] end]] ifcolorAsthen-- templateArgs['color_as'] and templateArgs['color_as'] ~= "" then returnframe:expandTemplate{title='Taxobox colour',args={colorAs}} else -- us #invoke:Autotaxobox|taxoboxColour|{{{parent}}} [parent should be set] frame.args[1]=templateArgs['parent'] returnautotaxa.taxoboxColour(frame) --return "palegreen" end else-- use manual taxobox colours --{{Taxobox colour|{{{regnum|{{{virus_group|{{{unranked_phylum|{{{phylum|''[[Incertae sedis]]''}}}}}}}}}}}}}} ifnotcolorAsthen--templateArgs['color_as'] then localgroup='' iftemplateArgs['regnum']then group=templateArgs['regnum'] elseiftemplateArgs['virus_group']then group=templateArgs['virus_group'] elseiftemplateArgs['unranked_phylum']then group=templateArgs['unranked_phylum'] elseiftemplateArgs['phylum']then group=templateArgs['phylum'] else group="''[[Incertae sedis]]''"-- TODO check if this is what was desired end colorAs=group end returnframe:expandTemplate{title='Taxobox colour',args={colorAs}} end end ------------------------------------------------------------------- functionp.templateStyle(frame,src) returnframe:extensionTag('templatestyles','',{src=src}); end functionp.firstToUpper(str) return(str:gsub("^%l",string.upper)) end functionp.test(frame) returninfo.auto end returnp