跳转到内容

模組:Fullurl

本页使用了标题或全文手工转换
被永久保护的模块
维基百科,自由的百科全书

这是本页的一个历史版本,由SunAfterRain留言 | 贡献2019年11月27日 (三) 13:56编辑。这可能和当前版本存在着巨大的差异。

local fullurl = {}
local yesno = require('Module:Yesno')
local mError = require('Module:Error').error

function fullurl._fullurl(args, frame)
	local paid = ''
	local title = args['title'] or args[1] or args['1'] or tostring(mw.title.getCurrentTitle())
	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 = v
			end
		else
			paid = paid .. '&' .. k .. '=' .. v
		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 fullurl.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 fullurl._fullurl(args, frame)
end

function fullurl.hosturl ()
    return "//zh.wikipedia.org/"
end

function fullurl.scripturl ()
    return hosturl () .. "/w"
end

fullurl["index.php"] = function ()
    return fullurl.scripturl () .. "/index.php"
end

fullurl["api.php"] = function ()
    return fullurl.scripturl () .. "/api.php"
end

fullurl["rest.php"] = function (frame)
    return fullurl.scripturl () .. "/rest.php"
end

function fullurl.articlepath ()
    return hosturl () .. "/wiki"
end

return fullurl