Modul:Fullurl
Utseende
Dokumentationen för denna modul kan skapas på Modul:Fullurl/dok
local p = {}
local yesno = require('Module:Yesno')
local mError = require('Module:Error').error
function p._fullurl(args, frame)
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
paid = mw.text.trim(v)
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]]error: unknow args-action <code>submin</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, frame)
end
return p