Difference between revisions of "Module:UserLinks/extra"

From blackwiki
Jump to navigation Jump to search
blackwiki>Mr. Stradivarius
m (Protected Module:UserLinks/extra: High-risk Lua module: 6000 transclusions ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite)))
blackwiki>Mr. Stradivarius
(add four new link functions)
Line 22: Line 22:
  
 
local linkFunctions = {}
 
local linkFunctions = {}
 +
 +
function linkFunctions.coibot(snippets)
 +
-- COIBot report
 +
return makeWikilink(
 +
nil,
 +
4,
 +
'WikiProject Spam/UserReports/' .. snippets.username,
 +
'COIBot'
 +
)
 +
end
  
 
function linkFunctions.ggl(snippets)
 
function linkFunctions.ggl(snippets)
Line 56: Line 66:
 
snippets.username .. '/sandbox',
 
snippets.username .. '/sandbox',
 
'sandbox'
 
'sandbox'
 +
)
 +
end
 +
 +
function linkFunctions.sfs(snippets)
 +
-- StopForumSpam
 +
return makeUrlLink(
 +
{
 +
protocol = 'http',
 +
host = 'www.stopforumspam.com',
 +
path = '/search/' .. snippets.username,
 +
},
 +
'StopForumSpam'
 +
)
 +
end
 +
 +
function linkFunctions.sul2(snippets)
 +
-- Global contribs, Luxo's tool
 +
return makeUrlLink(
 +
{
 +
host = 'tools.wmflabs.org',
 +
path = '/guc/index.php',
 +
query = {
 +
user = snippets.username,
 +
lang = toolLang
 +
}
 +
},
 +
'global contribs'
 
)
 
)
 
end
 
end
Line 66: Line 103:
 
'Log/newusers/' .. snippets.username,
 
'Log/newusers/' .. snippets.username,
 
'user creation'
 
'user creation'
 +
)
 +
end
 +
 +
function linkFunctions.wlh(snippets)
 +
-- Links to user page (what links here)
 +
return makeWikilink(
 +
snippets.interwiki,
 +
-1,
 +
'WhatLinksHere/'
 +
.. mw.site.namespaces[2].name
 +
.. ':'
 +
.. snippets.username,
 +
'links to user page'
 
)
 
)
 
end
 
end
  
 
return {linkFunctions = linkFunctions}
 
return {linkFunctions = linkFunctions}

Revision as of 16:05, 9 April 2014

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

--------------------------------------------------------------------------------
-- This module holds extra link functions for use with [[Module:UserLinks]].
--
-- It is intended for experimenting with new link functions that will eventually
-- be added to the main module code.
--
-- Since this module is transcluded in only a small number of pages, changes
-- should cause little server overhead and should propagate quickly.
--
-- Link functions using the same link code as a function in the main module will
-- be ignored; please give your function a unique code.
--------------------------------------------------------------------------------

-- Load shared helper functions
local mShared = require('Module:UserLinks/shared')
local raiseError = mShared.raiseError
local makeWikitextError = mShared.makeWikitextError
local makeWikilink = mShared.makeWikilink
local makeUrlLink = mShared.makeUrlLink
local makeFullUrlLink = mShared.makeFullUrlLink
local message = mShared.message

local linkFunctions = {}

function linkFunctions.coibot(snippets)
	-- COIBot report
	return makeWikilink(
		nil,
		4,
		'WikiProject Spam/UserReports/' .. snippets.username,
		'COIBot'
	)
end

function linkFunctions.ggl(snippets)
	-- Google search for the username.
	return makeUrlLink(
		{
			host = 'www.google.com',
			path = '/search',
			query = {q = snippets.username},
		},
		'Google'
	)
end

function linkFunctions.msg(snippets)
	-- New message on user talk page
	return makeFullUrlLink(
		snippets.interwiki,
		3,
		snippets.username,
		{
			action = 'edit',
			section = 'new',
		},
		'message'
	)
end

function linkFunctions.sbx(snippets)
	-- User sandbox
	return makeWikilink(
		snippets.interwiki,
		2,
		snippets.username .. '/sandbox',
		'sandbox'
	)
end

function linkFunctions.sfs(snippets)
	-- StopForumSpam
	return makeUrlLink(
		{
			protocol = 'http',
			host = 'www.stopforumspam.com',
			path = '/search/' .. snippets.username,
		},
		'StopForumSpam'
	)
end

function linkFunctions.sul2(snippets)
	-- Global contribs, Luxo's tool
	return makeUrlLink(
		{
			host = 'tools.wmflabs.org',
			path = '/guc/index.php',
			query = {
				user = snippets.username,
				lang = toolLang
			}
		},
		'global contribs'
	)
end

function linkFunctions.uc(snippets)
	-- User creation
	return makeWikilink(
		snippets.interwiki,
		-1,
		'Log/newusers/' .. snippets.username,
		'user creation'
	)
end

function linkFunctions.wlh(snippets)
	-- Links to user page (what links here)
	return makeWikilink(
		snippets.interwiki,
		-1,
		'WhatLinksHere/'
			.. mw.site.namespaces[2].name
			.. ':'
			.. snippets.username,
		'links to user page'
	)
end

return {linkFunctions = linkFunctions}