模組: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:別名重定向 ( 110,882 )
- Category:單型分類單元重定向 ( 36 )
- Category:指向單型分類單元的重定向 ( 4 )
- Category:學名重定向 ( 75,430 )
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 ( 19 )
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