Difference between pages "Template:Merge from" and "Module:UserLinks/extra"

(Difference between pages)
Jump to navigation Jump to search
(Created page with "<includeonly><div style="background:#EFF;border-collapse:collapse;border:1px dashed #aaa;padding:1em;margin:3px 10%;">This article has been merged from [[{{{1}}}]]. The histor...")
 
m (1 revision imported)
 
Line 1: Line 1:
  +
--------------------------------------------------------------------------------
<includeonly><div style="background:#EFF;border-collapse:collapse;border:1px dashed #aaa;padding:1em;margin:3px 10%;">This article has been merged from [[{{{1}}}]]. The history of that page serves as the attribution history for the contents of this article. Please specify pagename and date when using this template. {{#if:{{{diff|}}}|&nbsp;on [{{{diff}}} {{{date}}}]|&nbsp;on {{{date|<span class="error"> date of merge missing</span>}}}}}.</div>[[Category:Merge]]
 
  +
-- This module holds extra link functions for use with [[Module:UserLinks]].
</includeonly><noinclude><!-- start of doc -->
 
  +
--
{{DEFAULTSORT:{{PAGENAME}}}}
 
  +
-- It is intended for experimenting with new link functions that will eventually
When moving material from one wiki article to another, put this template on the talk page of the destination article, to indicate that its page history containing the [http://en.wikipedia.org/wiki/GNU_Free_Documentation_License GFDL] attribution to the contributors is elsewhere. Notes also need to be put in edit summaries of both articles.
 
  +
-- 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
Usage:<code><nowiki>
 
  +
local mShared = require('Module:UserLinks/shared')
{{Merge from|page=[[source]]|date=dd Month yyyy}}
 
  +
local raiseError = mShared.raiseError
</nowiki></code>
 
  +
local makeWikitextError = mShared.makeWikitextError
  +
local makeWikilink = mShared.makeWikilink
  +
local makeUrlLink = mShared.makeUrlLink
  +
local makeFullUrlLink = mShared.makeFullUrlLink
  +
local message = mShared.message
   
  +
local linkFunctions = {}
See [[Help:Splitting and merging]].
 
  +
[[Category:Templates]]
 
  +
function linkFunctions.coibot(snippets)
<!-- end of doc --></noinclude>
 
  +
-- 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.http(snippets)
  +
-- To see if an IP is serving a web page
  +
return makeUrlLink(
  +
{
  +
protocol = 'http',
  +
host = snippets.username
  +
},
  +
'http'
  +
)
  +
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.rbl(snippets)
  +
-- Realtime blacklists
  +
return makeUrlLink(
  +
{
  +
protocol = 'https',
  +
host = 'www.robtex.com',
  +
path = '/rbls/' .. snippets.username .. '.html',
  +
},
  +
'RBLs'
  +
)
  +
end
  +
  +
function linkFunctions.rdns(snippets)
  +
-- Reverse DNS lookup
  +
return makeUrlLink(
  +
{
  +
protocol = 'http',
  +
host = 'www.dnswatch.info',
  +
path = '/dns/dnslookup',
  +
query = {
  +
la = 'en',
  +
host = snippets.username,
  +
submit = 'Resolve'
  +
}
  +
},
  +
'RDNS'
  +
)
  +
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 = snippets.toolLang
  +
}
  +
},
  +
'global contribs'
  +
)
  +
end
  +
  +
function linkFunctions.uc(snippets)
  +
-- User creation
  +
return makeWikilink(
  +
snippets.interwiki,
  +
-1,
  +
'Log/newusers/' .. snippets.username,
  +
'user creation'
  +
)
  +
end
  +
  +
function linkFunctions.whois(snippets)
  +
-- WHOIS information for IPs
  +
return makeUrlLink(
  +
{
  +
protocol = 'https',
  +
host = 'tools.wmflabs.org',
  +
path = '/whois/gateway.py',
  +
query = {
  +
lookup = 'true',
  +
ip = snippets.username,
  +
},
  +
},
  +
'WHOIS'
  +
)
  +
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
  +
  +
function linkFunctions.cr(snippets)
  +
-- Change rights
  +
return makeWikilink(
  +
snippets.interwiki,
  +
-1,
  +
'UserRights/' .. snippets.username,
  +
'change rights'
  +
)
  +
end
  +
  +
return {linkFunctions = linkFunctions}

Latest revision as of 10:45, 22 June 2018

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.http(snippets)
	-- To see if an IP is serving a web page
	return makeUrlLink(
		{
			protocol = 'http',
			host = snippets.username
		},
		'http'
	)
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.rbl(snippets)
	-- Realtime blacklists
	return makeUrlLink(
		{
			protocol = 'https',
			host = 'www.robtex.com',
			path = '/rbls/' .. snippets.username .. '.html',
		},
		'RBLs'
	)
end

function linkFunctions.rdns(snippets)
	-- Reverse DNS lookup
	return makeUrlLink(
		{
			protocol = 'http',
			host = 'www.dnswatch.info',
			path = '/dns/dnslookup',
			query = {
				la = 'en',
				host = snippets.username,
				submit = 'Resolve'
			}
		},
		'RDNS'
	)
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 = snippets.toolLang
			}
		},
		'global contribs'
	)
end

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

function linkFunctions.whois(snippets)
	-- WHOIS information for IPs
	return makeUrlLink(
		{
			protocol = 'https',
			host = 'tools.wmflabs.org',
			path = '/whois/gateway.py',
			query = {
				lookup = 'true',
				ip = snippets.username,
			},
		},
		'WHOIS'
	)
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

function linkFunctions.cr(snippets)
	-- Change rights
	return makeWikilink(
		snippets.interwiki,
		-1,
		'UserRights/' .. snippets.username,
		'change rights'
	)
end

return {linkFunctions = linkFunctions}