模块:Science redirect
外观
此模块使用Lua语言: |
本模块为{{R from scientific name}}
、{{R to monotypic taxon}}
和{{R from monotypic taxon}}
模板的后端。
模板的参数和分类在Module:Science redirect/conf中设置。
使用
[编辑]{{#invoke:Science redirect|R|template name excluding 'R'}}
例如,对于{{R from scientific name}},可以使用{{#invoke:Science redirect|R|from scientific name}}
来生成:
添加或修改支持模板
[编辑]模板的参数和分类在Module:Science redirect/conf中设置。
调试模板时,可添加参数|debug=true
,例如{{#invoke:Science redirect|R|from scientific name|debug=true}}
会生成:
{{Redirect template
| info = 它引导出学名标题至遵循命名常规的合适名称,能够协助编者写作。除非为了更新重定向页,一般不应该用管道链接取代重定向链接。
| name = 学名重定向
| from = 生物分类的学名
| id = R_from_scientific_name
| all category = 学名重定向
| printworthy = yes
| to = 该分类的俗名
}}
分类索引
[编辑]Science redirects ( 0 )
[编辑]- Category:Redirects from scientific names ( 0 )
- Category:Redirects to monotypic taxa ( 0 )
- Category:Redirects from monotypic taxa ( 0 )
Category:重定向 ( 56 )
- Category:别名重定向 ( 97,076 )
- Category:单型分类单元重定向 ( 26 )
- Category:指向单型分类单元的重定向 ( 4 )
- Category:学名重定向 ( 75,285 )
Category:昆虫重定向 ( 0 )
- Category:昆虫别名重定向 ( 0 )
- Category:昆虫单型分类单元重定向 ( 0 )
- Category:指向昆虫单型分类单元的重定向 ( 0 )
- Category:昆虫学名重定向 ( 0 )
Category:爬行动物重定向 ( 0 )
- Category:爬行动物别名重定向 ( 0 )
- Category:爬行动物单型分类单元重定向 ( 0 )
- Category:指向爬行动物单型分类单元的重定向 ( 0 )
- Category:爬行动物学名重定向 ( 0 )
Category:节肢动物重定向 ( 0 )
- Category:节肢动物别名重定向 ( 0 )
- Category:节肢动物单型分类单元重定向 ( 0 )
- Category:指向节肢动物单型分类单元的重定向 ( 0 )
- Category:节肢动物学名重定向 ( 0 )
Category:两栖动物重定向 ( 0 )
- Category:两栖动物别名重定向 ( 0 )
- Category:两栖动物单型分类单元重定向 ( 0 )
- Category:指向两栖动物单型分类单元的重定向 ( 0 )
- Category:两栖动物学名重定向 ( 0 )
Category:哺乳动物重定向 ( 0 )
- Category:哺乳动物别名重定向 ( 0 )
- Category:哺乳动物单型分类单元重定向 ( 0 )
- Category:指向哺乳动物单型分类单元的重定向 ( 0 )
- Category:哺乳动物学名重定向 ( 0 )
Category:植物重定向 ( 0 )
- Category:植物别名重定向 ( 0 )
- Category:植物单型分类单元重定向 ( 0 )
- Category:指向植物单型分类单元的重定向 ( 0 )
- Category:植物学名重定向 ( 0 )
Category:鸟类重定向 ( 0 )
- Category:鸟类别名重定向 ( 0 )
- Category:鸟类单型分类单元重定向 ( 0 )
- Category:指向鸟类单型分类单元的重定向 ( 0 )
- Category:鸟类学名重定向 ( 0 )
Category:病毒重定向 ( 0 )
- Category:病毒别名重定向 ( 0 )
- Category:病毒单型分类单元重定向 ( 0 )
- Category:指向病毒单型分类单元的重定向 ( 0 )
- Category:病毒学名重定向 ( 0 )
Category:微生物重定向 ( 0 )
- Category:微生物别名重定向 ( 0 )
- Category:微生物单型分类单元重定向 ( 0 )
- Category:指向微生物单型分类单元的重定向 ( 0 )
- Category:微生物学名重定向 ( 0 )
Category:甲壳动物重定向 ( 0 )
- Category:甲壳动物别名重定向 ( 0 )
- Category:甲壳动物单型分类单元重定向 ( 0 )
- Category:指向甲壳动物单型分类单元的重定向 ( 0 )
- Category:甲壳动物学名重定向 ( 0 )
Category:蜘蛛重定向 ( 0 )
- Category:蜘蛛别名重定向 ( 0 )
- Category:蜘蛛单型分类单元重定向 ( 0 )
- Category:指向蜘蛛单型分类单元的重定向 ( 0 )
- Category:蜘蛛学名重定向 ( 0 )
Category:动物重定向 ( 0 )
- Category:动物别名重定向 ( 0 )
- Category:动物单型分类单元重定向 ( 0 )
- Category:指向动物单型分类单元的重定向 ( 0 )
- Category:动物学名重定向 ( 0 )
Category:藻类重定向 ( 0 )
- Category:藻类别名重定向 ( 0 )
- Category:藻类单型分类单元重定向 ( 0 )
- Category:指向藻类单型分类单元的重定向 ( 0 )
- Category:藻类学名重定向 ( 0 )
Category:真菌重定向 ( 0 )
- Category:真菌别名重定向 ( 0 )
- Category:真菌单型分类单元重定向 ( 0 )
- Category:指向真菌单型分类单元的重定向 ( 0 )
- Category:真菌学名重定向 ( 0 )
Category:软体动物重定向 ( 0 )
- Category:软体动物别名重定向 ( 0 )
- Category:软体动物单型分类单元重定向 ( 0 )
- Category:指向软体动物单型分类单元的重定向 ( 0 )
- Category:软体动物学名重定向 ( 0 )
Category:鱼类重定向 ( 0 )
- Category:鱼类别名重定向 ( 0 )
- Category:鱼类单型分类单元重定向 ( 0 )
- Category:指向鱼类单型分类单元的重定向 ( 0 )
- Category:鱼类学名重定向 ( 0 )
无效参数
[编辑]- Category:使用学名重定向未知参数1 ( 18 )
local conf = require( "Module:Science redirect/conf" )
local p = {}
function p.R(frame)
local template = mw.ustring.gsub(frame.args[1], ' ', '_')
if conf.templates[template] then
return p._main(frame, 'R_' .. template, conf.templates[template].name, conf.templates[template].from, conf.templates[template].to, conf.templates[template].category, conf.templates[template].info)
elseif template then
return '<span class="error">'..template..'模板不可用。</span>\n'
else
return '<span class="error">未指明任何模板。</span>\n'
end
end
function p.list(frame)
local outstr = ""
local ocats={}
for _, v in pairs(conf.cats) do ocats[v] = true end
for k, _ in pairs(ocats) do
outstr = outstr .. "\n=== " .. frame:expandTemplate{ title = 'cl', args = { (k .. "重定向"), count = "yes" } } .. " ===\n"
for kk, vv in pairs (conf.templates) do
outstr = outstr .. "*" .. frame:expandTemplate{ title = 'cl', args = { (mw.ustring.gsub(vv.category, '$1', k) .. "重定向"), count = "yes" } } .. "\n"
end
end
return outstr
end
function p._main(frame, id, name, from, to, category, info)
--initialize variables
local args = frame:getParent().args
local chineseNoun = ''
local outStr = ''
--Check for known parameter 1
local cat = mw.ustring.match(mw.ustring.lower(args[1] or 'none'), '^(.-)s?$')
if conf.cats[cat] then chineseNoun = conf.cats[cat] else
chineseNoun = ''
outStr = '[[Category:使用学名重定向未知参数1]]'
end
--support alternative indications for printworthy
if args[2] == 'unprintworthy' or args['unprintworthy'] == 'true' then args['printworthy'] = 'no' end
--build template arguments
local outArgs = {
id = id,
name = mw.ustring.gsub(name..'重定向', '$1', chineseNoun),
from = mw.ustring.gsub(from, '$1', chineseNoun),
to = mw.ustring.gsub(to, '$1', chineseNoun),
['all category'] = mw.ustring.gsub(category..'重定向', '$1', chineseNoun),
printworthy = (args['printworthy'] or 'yes'),
info = info,
}
--build output string
if frame.args['debug'] == 'true' then
local debugStr = '{{Redirect template<br />\n'
for k,v in pairs( outArgs ) do
debugStr = debugStr..'| '..k..' = '..v..'<br />\n'
end
outStr = debugStr..'}}'..frame:extensionTag{ name = 'nowiki', content = outStr}
else
outStr = frame:expandTemplate{ title = 'Redirect template', args = outArgs }..outStr
end
return outStr
end
return p