From Wikipedia, the free encyclopedia


-- This module implements {{drvlinks}}



local lang = mw.language.getContentLanguage()

local mToolbar = require('Module:Toolbar')



local p = {}



local function para(k, v)

	return string.format('|%s=%s', k, v or '')

end



local function makeWikilink(page, display)

	if display then

		return string.format('[[%s|%s]]', page, display)

	else

		return string.format('[[%s]]', page)

	end

end



local function makeExternalLink(url, display)

	-- The URL can be a URL string or a mw.uri object.

	url = tostring(url)

	return string.format('[%s %s]', url, display)

end



function p._main(args, frame)

	frame = frame or mw.getCurrentFrame()



	-- Get the page name

	local page = args.pg

	if not page then

		error('no page name specified; please use ' .. para('pg', "''pagename''"), 2)

	end



	-- Get the namespace table from mw.site.namespaces

	local ns = args.ns

	if type(ns) == 'string' then

		ns = ns:lower()

		ns = lang:ucfirst(ns)

	end

	ns = tonumber(ns) or ns

	if not ns or ns == 'Article' then

		ns = 0

	end

	ns = mw.site.namespacesns

	if not ns or ns.id < 0 then -- Invalid parameter or a special namespace

		error(string.format(

			'Invalid %s, please use "Article" or a namespace name listed ' ..

				'at [[Wikipedia:Namespaces]] (excluding special namespaces)',

			para('ns')

		), 2)

	end



	-- Get the page links

	local pageLinks

	do

		local templateTitle

		if ns.id == 0 then

			templateTitle = 'la'

		elseif ns.id == 1 then

			templateTitle = 'lat'

		elseif ns.isTalk then

			templateTitle = 'lnt'

		else

			templateTitle = 'ln'

		end



		local targs = {}

		if templateTitle == 'ln' then

			targs1 = ns.name

			targs2 = page

		elseif templateTitle == 'lnt' then

			targs1 = ns.subject.name

			targs2 = page

		else

			targs1 = page

		end



		pageLinks = frame:expandTemplate{title = templateTitle, args = targs}

	end



	-- Get the tool links

	local toolLinks

	do

		local tlargs = {}

		local fullPageName

		if ns.id == 0 then

			fullPageName = page

		else

			fullPageName = ns.name .. ':' .. lang:ucfirst(page)

		end



		-- Restore link

		tlargs#tlargs + 1 = makeWikilink(

			'Special:Undelete/' .. fullPageName,

			'restore'

		)



		-- Google cache link

		local pageUrl = mw.uri.fullUrl(fullPageName)

		pageUrl = tostring(pageUrl)

		tlargs#tlargs + 1 = makeExternalLink(

			'https://www.google.com/search?q=cache:' .. pageUrl,

			'cache'

		)



		-- XfD link

		if ns.id ~= 6 and ns.id ~= 10 and ns.id ~= 14 then

			-- No XfD links for files, templates or categories.

			local xfdPage, display

			if ns.id == 0 then

				xfdPage = 'Wikipedia:Articles for deletion/' .. fullPageName

				display = 'AfD'

			else

				xfdPage = 'Wikipedia:Miscellany for deletion/' .. fullPageName

				display = 'MfD'

			end

			tlargs#tlargs + 1 = makeWikilink(xfdPage, display)

		end



		toolLinks = mToolbar._main(tlargs)

	end



	return pageLinks .. ' ' .. toolLinks

end



function p.main(frame)

	local args = require('Module:Arguments').getArgs(frame, {

		wrappers = 'Template:Drvlinks'

	})

	return p._main(args, frame)

end



return p
From Wikipedia, the free encyclopedia


-- This module implements {{drvlinks}}



local lang = mw.language.getContentLanguage()

local mToolbar = require('Module:Toolbar')



local p = {}



local function para(k, v)

	return string.format('|%s=%s', k, v or '')

end



local function makeWikilink(page, display)

	if display then

		return string.format('[[%s|%s]]', page, display)

	else

		return string.format('[[%s]]', page)

	end

end



local function makeExternalLink(url, display)

	-- The URL can be a URL string or a mw.uri object.

	url = tostring(url)

	return string.format('[%s %s]', url, display)

end



function p._main(args, frame)

	frame = frame or mw.getCurrentFrame()



	-- Get the page name

	local page = args.pg

	if not page then

		error('no page name specified; please use ' .. para('pg', "''pagename''"), 2)

	end



	-- Get the namespace table from mw.site.namespaces

	local ns = args.ns

	if type(ns) == 'string' then

		ns = ns:lower()

		ns = lang:ucfirst(ns)

	end

	ns = tonumber(ns) or ns

	if not ns or ns == 'Article' then

		ns = 0

	end

	ns = mw.site.namespacesns

	if not ns or ns.id < 0 then -- Invalid parameter or a special namespace

		error(string.format(

			'Invalid %s, please use "Article" or a namespace name listed ' ..

				'at [[Wikipedia:Namespaces]] (excluding special namespaces)',

			para('ns')

		), 2)

	end



	-- Get the page links

	local pageLinks

	do

		local templateTitle

		if ns.id == 0 then

			templateTitle = 'la'

		elseif ns.id == 1 then

			templateTitle = 'lat'

		elseif ns.isTalk then

			templateTitle = 'lnt'

		else

			templateTitle = 'ln'

		end



		local targs = {}

		if templateTitle == 'ln' then

			targs1 = ns.name

			targs2 = page

		elseif templateTitle == 'lnt' then

			targs1 = ns.subject.name

			targs2 = page

		else

			targs1 = page

		end



		pageLinks = frame:expandTemplate{title = templateTitle, args = targs}

	end



	-- Get the tool links

	local toolLinks

	do

		local tlargs = {}

		local fullPageName

		if ns.id == 0 then

			fullPageName = page

		else

			fullPageName = ns.name .. ':' .. lang:ucfirst(page)

		end



		-- Restore link

		tlargs#tlargs + 1 = makeWikilink(

			'Special:Undelete/' .. fullPageName,

			'restore'

		)



		-- Google cache link

		local pageUrl = mw.uri.fullUrl(fullPageName)

		pageUrl = tostring(pageUrl)

		tlargs#tlargs + 1 = makeExternalLink(

			'https://www.google.com/search?q=cache:' .. pageUrl,

			'cache'

		)



		-- XfD link

		if ns.id ~= 6 and ns.id ~= 10 and ns.id ~= 14 then

			-- No XfD links for files, templates or categories.

			local xfdPage, display

			if ns.id == 0 then

				xfdPage = 'Wikipedia:Articles for deletion/' .. fullPageName

				display = 'AfD'

			else

				xfdPage = 'Wikipedia:Miscellany for deletion/' .. fullPageName

				display = 'MfD'

			end

			tlargs#tlargs + 1 = makeWikilink(xfdPage, display)

		end



		toolLinks = mToolbar._main(tlargs)

	end



	return pageLinks .. ' ' .. toolLinks

end



function p.main(frame)

	local args = require('Module:Arguments').getArgs(frame, {

		wrappers = 'Template:Drvlinks'

	})

	return p._main(args, frame)

end



return p

Videos

Youtube | Vimeo | Bing

Websites

Google | Yahoo | Bing

Encyclopedia

Google | Yahoo | Bing

Facebook