local p = {}
local yesno = require('Module:Yesno')
local getArgs = require "Module:Arguments".getArgs
function p._fullurl(args)
local args = mw.clone(args)
local onlyurl = yesno(args.onlyurl)
args.onlyurl = nil
local title = args['title'] or args[1] or tostring(mw.title.getCurrentTitle())
if title == '' then
-- 不能讓title變空值,否則url會返回nil
title = tostring(mw.title.getCurrentTitle())
end
local url, text
if args[3] then
url = tostring(mw.uri.fullUrl(title, args[2]))
text = args[3]
else
text = args['text'] or args[2] or args[1] or title
args.title = nil
args.text = nil
args[1] = nil
args[2] = nil
url = tostring(mw.uri.fullUrl(title, args))
end
local plainlink = '<span class="plainlinks">[' .. url .. ' ' .. text .. ']</span>'
if onlyurl then
return url
else
return plainlink
end
end
function p.fullurl(frame)
local args = getArgs(frame)
return p._fullurl(args)
end
function p._fullurl2(title, paid, text)
return '<span class="plainlinks">[' .. tostring(mw.uri.fullUrl(title,paid)) .. ' ' .. text .. ']</span>'
end
return p