Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 About  





2 Usage  





3 See also  














Module:Taxonbar/whitelist






Беларуская (тарашкевіца)

Simple English
 

Edit links
 









Module
Talk
 

















Read
View source
View history
 








Tools
   


Actions  



Read
View source
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 





Permanently protected module

From Wikipedia, the free encyclopedia
 

< Module:Taxonbar

About

This module returns strict, lax, or all acceptable instance of (P31)s as a Lua table for use in a module such as Module:Taxonbar.

For use in documentation, see {{Taxonbar/whitelist}}.

Usage

local whitelists = require( 'Module:Taxonbar/whitelist' ).whitelist
Arg Lua Output
strict
local myWhitelist = whitelists{ args = { 'strict' } }
myWhitelist = {
 'Q16521' = 1,
 'Q310890' = 2,
 'Q47487597' = 3,
 'Q2568288' = 4,
 'Q23038290' = 5,
 'Q59278506' = 6,
 'Q98961713' = 7,
 'Q58051350' = 8,
}
lax
local myWhitelist = whitelists{ args = { 'lax' } }
myWhitelist = {
 'Q42621' = 1,
 'Q235536' = 2,
 'Q713623' = 3,
 'Q848328' = 4,
 'Q857968' = 5,
 'Q17487588' = 6,
 'Q124477390' = 7,
}
all
local myWhitelist = whitelists{ args = { 'all' } }
myWhitelist = {
 'Q16521' = 1,
 'Q310890' = 2,
 'Q47487597' = 3,
 'Q2568288' = 4,
 'Q23038290' = 5,
 'Q59278506' = 6,
 'Q98961713' = 7,
 'Q58051350' = 8,
 'Q42621' = 9,
 'Q235536' = 10,
 'Q713623' = 11,
 'Q848328' = 12,
 'Q857968' = 13,
 'Q17487588' = 14,
 'Q124477390' = 15,
}

See also

local p = {}

--returns any combination of strict/lax/all acceptable instance-of's,
--either as a table for use inside [[Module:Taxonbar]] or another module,
--or as an ordered list for use in documentation.
function p.whitelist( frame )
 local listType = frame.args[1]
 local documentation = frame.args[2]
 local outList = {}
 local acceptableInstanceOf_Strict = { --table order == display order
  'Q16521',  --taxon
  'Q310890',  --monotypic taxon
  'Q47487597', --monotypic fossil taxon
  'Q2568288',  --ichnotaxon
  'Q23038290', --fossil taxon
  'Q59278506', --ootaxon
  'Q98961713', --extinct taxon
  'Q58051350', --paraphyletic group (subclass of taxon)
 }
 local acceptableInstanceOf_Lax = { --table order == display order
  'Q42621',  --hybrid
  'Q235536',  --incertae sedis
  'Q713623',  --clade
  'Q848328',  --serotype
  'Q857968',  --candidatus
  'Q17487588', --unavailable combination
  'Q124477390', --taxon hypothesis
 }
 
 if listType == 'strict'  then outList = acceptableInstanceOf_Strict
 elseif listType == 'lax' then outList = acceptableInstanceOf_Lax
 else --elseif listType == 'all' then --concatenate strict + lax IIF requested
  local acceptableInstanceOf_All = {}
  local i = 0
  for _, v in pairs( acceptableInstanceOf_Strict ) do
   i = i + 1
   acceptableInstanceOf_All[i] = v
  end
  for _, v in pairs( acceptableInstanceOf_Lax ) do
   i = i + 1
   acceptableInstanceOf_All[i] = v
  end
  outList = acceptableInstanceOf_All
 end
 
 if (documentation == nil) or --module only
    (documentation and documentation == '')
 then
  local out = {}
  for k, v in pairs( outList ) do
   out[v] = k --output Q# as keys for easier searching within Module:Taxonbar
  end
  return out
  
 elseif (documentation == 'docdoc') then --self-documentation only
  local selfdocout = 'myWhitelist = {\n'
  for k, q in pairs( outList ) do
   selfdocout = selfdocout..'\t\''..q..'\' = '..k..',\n'
  end
  selfdocout = selfdocout..'}'
  local args = { ['lang'] = 'lua',
        ['code'] = selfdocout }
  out = frame:expandTemplate{ title = 'Syntaxhighlight', args = args }
  return out
  
 else --normal documentation only
  local out = ''
  for _, q in pairs( outList ) do
   local Q = frame:expandTemplate{ title = 'Q', args = { q } }
   out = out..'# '..Q..'\n'
  end
  out = mw.ustring.gsub(out, '%s+$', '')
  return out
 end
 
end

return p

Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:Taxonbar/whitelist&oldid=1206169106"

Hidden category: 
Wikipedia template-protected modules
 



This page was last edited on 11 February 2024, at 10:55 (UTC).

Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Mobile view



Wikimedia Foundation
Powered by MediaWiki