模块文档[创建]
您可能想要创建本Scribunto模块的文档。 编者可以在本模板的沙盒 (创建 | 镜像)和测试样例 (创建)页面进行实验。 请在/doc子页面中添加分类。本模块的子页面。 |
local p = {}
local yesno = require('Module:Yesno')
local mError = require('Module:Error').error
function p._fullurl(args)
local paid = ''
local title = args['title'] or args[1] or args['1'] or tostring(mw.title.getCurrentTitle())
if title == '' then
--不能让title变空值,否则url会返回nil
title = tostring(mw.title.getCurrentTitle())
end
local text = args['text'] or args[2] or args['1'] or title
for k, v in pairs( args ) do
if ((k == 'title') or (k == 1) or (k == '1') or (k == 'text') or (k == 2) or (k == '2') or (k == 'onlyurl') or (k == 'paid')) then
if (k == 'paid') then
if paid == '' then
paid = mw.text.trim(v)
else
paid = paid .. '&' .. mw.text.trim(v)
end
end
else
if paid == '' then
paid = k .. '=' .. mw.text.trim(v)
else
paid = paid .. '&' .. k .. '=' .. mw.text.trim(v)
end
end
end
local url = tostring(mw.uri.fullUrl(title,paid))
local plainlink = '<span class="plainlinks">[' .. url .. ' ' .. text .. ']</span>'
if (args['action'] == 'submit') then
return plainlink .. mError{'[[Module:Fullur]]错误:<code>|action=submin</code>不是有效的值,请使用<code>|action=edit</code>。'}
else
if yesno(args['onlyurl']) then
return url
else
return plainlink
end
end
end
function p.fullurl(frame)
local args = {}
for k, v in pairs( frame.args ) do
args[k] = v
end
for k, v in pairs( frame:getParent().args ) do
args[k] = v
end
return p._fullurl(args)
end
function p._fullurl2(title ,paid, text)
return '<span class="plainlinks">[' .. tostring(mw.uri.fullUrl(title,paid)) .. ' ' .. text .. ']</span>'
end
--[=[
function p.hosturl ()
return "//zh.wikipedia.org"
end
function p.scripturl ()
return p.hosturl () .. "/w"
end
function p.index ()
return p.scripturl () .. "/index.php"
end
function p.articlepath ()
return p () .. "/wiki"
end
p["index.php"] = function ()
return p.index ()
end
p["api.php"] = function ()
return p.scripturl () .. "/api.php"
end
p["rest.php"] = function (frame)
return p.scripturl () .. "/rest.php"
end
]=]--
return p