跳转到内容

模組:Main/main

维基百科,自由的百科全书

这是本页的一个历史版本,由Cwek留言 | 贡献2015年10月7日 (三) 04:31编辑。这可能和当前版本存在着巨大的差异。

--这是给T:Main,T:See also等类似模板使用改进mainLua模组的类型定义文件
--这是给t:main部分代码来源于m:main中

local t={}

function t.build(pframe,pages)
	-- Get the list of pages. If no first page was specified we use the current
	-- page name.
	local currentTitle = mw.title.getCurrentTitle()
	local firstPageTable = pages[1]
	local firstPage
	if firstPageTable then
		firstPage = firstPageTable[1]
	else
		firstPage = currentTitle.text
		firstPageTable = {firstPage}
		pages[1] = firstPageTable
	end

	-- Find the pagetype.
	local firstPageNs = mHatnote.findNamespaceId(firstPage)
	local pagetype = firstPageNs == 0 and '条目' or '页面'
	
	-- Build the text.
	local currentNs = currentTitle.namespace
	local isCategoryNamespace = currentNs - currentNs % 2 == 14
	local stringToFormat
	if isCategoryNamespace then
		stringToFormat = '此[[Wikipedia:頁面分類|分类]]的主%s是%s'
	else
		stringToFormat = '主%s:%s'
	end
	local text = string.format(stringToFormat, pagetype, links)
end

function t.limit()
	--限制数,无限请设为-1
	return 10
end

function t.limitWarnString(pframe)
	--超过限制时返回的警告语句
	return  "<span class=\"error\">(在模板"+pframe:expandTemplate{title="tl",args={"main"}}+"中使用了太多的参数)</span>"
end

function t.extraclasses()
	--rellink的extraclasses
	return 'noprint relarticle mainarticle'
end

return t