Module:Statcount

From Wikidata
Jump to navigation Jump to search
Lua
CodeDiscussionLinksLink count SubpagesDocumentationTestsResultsSandboxLive code All modules

Documentation for this module may be created at Module:Statcount/doc

Code

local p = {}

function p.main(frame)
	local p=frame:getParent().args[1]
	local content=mw.title.makeTitle( 4, 'Statistics/count/' .. frame:getParent().args[1] ):getContent()
	redir_title = content and require('Module:Redirect').getTargetFromText(content)
	if redir_title then
		content=mw.title.makeTitle( 0, redir_title ):getContent()
	end
	if content then
		if  mw.ustring.find(content, "| statcount = ", 1, true) then
			content=mw.ustring.sub( content,mw.ustring.find(content, "| statcount = ", 1, true)+13)
			return mw.ustring.sub( content,1,mw.ustring.find(content, "}}", 1, true)-1)
		else
			return 'fail to parse [[Wikidata:Statistics/count/' .. frame:getParent().args[1] .. ']]'
		end
	else
		return 'create [[Wikidata:Statistics/count/' .. frame:getParent().args[1] .. ']]'
	end
end
 
return p