Module:User Wikimedia project

require('strict')

local p = {} --p stands for package

local getArgs = require('Module:Arguments').getArgs local language_name = require('Module:ISO 639').language_name

local userbox = require('Module:Userbox').userbox

local project_data = { ['b'] =				{['name'] = 'Wikibooks'}, ['commons'] =		{['name'] = 'Wikimedia Commons', ['namespace'] = 'Commons'}, ['d'] =				{['name'] = 'Wikidata'}, ['m'] =				{['name'] = 'Meta'}, ['MW'] =			{['name'] = 'MediaWiki'}, ['n'] =				{['name'] = 'Wikinews'}, ['q'] =				{['name'] = 'Wikiquote'}, ['s'] =				{['name'] = 'Wikisource'}, ['v'] =				{['name'] = 'Wikiversity'}, ['w'] =				{['name'] = 'Wikipedia'}, ['wikispecies'] =	{['name'] = 'Wikispecies'}, ['wikt'] =			{['name'] = 'Wiktionary'} }

local function link_data(project, lang_code) local link_prefix local project_link if not project then return nil end if lang_code then link_prefix = project .. ':' .. lang_code project_link =  .. language_name(lang_code, 'Unrecognized Language') .. ' ' .. project_data[project]['name'] ..  else link_prefix = project project_link =  .. project_data[project]['name'] ..  end return {['link_prefix'] = link_prefix, ['project_link'] = project_link} end

function p._user(box_args) local args = box_args or {} -- Info local username = args[1] or args.username or mw.title.getCurrentTitle.rootText args[1] = nil local pagetext = args[2] or 'a page' args[2] = nil local lang_code = args.lang_code local project = args.project or 's'	local link_prefix = link_data(project, lang_code).link_prefix local project_link = link_data(project, lang_code).project_link local user_link =  .. pagetext ..  args.info = 'This user has ' .. user_link .. ' on ' .. project_link .. '.'	-- Style args['id-c'] = args['id-c'] or '#ffffff' args['info-c'] = args['info-c'] or '#f6f6f6' args['border-c'] = args['border-c'] or '#bbbbbb' -- Id	args.id = '' -- Userbox return userbox(args) end

function p.user(frame) return p._user(getArgs(frame)) end

function p._user_admin(box_args) local args = box_args or {} -- Info local username = args[1] or args.username or mw.title.getCurrentTitle.rootText args[1] = nil local lang_code = args.lang_code local project = args.project or 's'	local project_namespace = project_data[project]['namespace'] or project_data[project]['name'] local cat = '' local testing = mw.title.getCurrentTitle.subpageText == 'sandbox' or mw.title.getCurrentTitle.subpageText == 'testcases' if mw.title.getCurrentTitle.nsText == 'User' or testing then cat = '' end local link_prefix = link_data(project, lang_code).link_prefix local project_link = link_data(project, lang_code).project_link local user_link = 'This user' local admin_link = "administrator" local verify_link = '[' .. tostring(mw.uri.fullUrl(link_prefix .. ':Special:ListUsers', 'limit=1&username=' .. mw.uri.encode(username, 'WIKI'))) .. ' verify]' args.info = user_link .. ' is an ' .. admin_link .. ' on ' .. project_link .. '. ( ' .. verify_link .. ' )' .. cat -- Style args['id-c'] = args['id-c'] or '#ffffff' args['info-c'] = args['info-c'] or '#eaf3ff' args['border-c'] = args['border-c'] or '#3366cc' -- Id	args.id = '' -- Userbox return userbox(args) end

function p.user_admin(frame) return p._user_admin(getArgs(frame)) end

return p