Module:Disambiguation/sandbox

require('strict')

local p = {}

local getArgs = require('Module:Arguments').getArgs local yesno = require('Module:Yesno')

function p._disambiguation(argsWithBlanks) local args = {} for k, v in pairs(argsWithBlanks) do		if k == 'categories' or v ~= '' then args[k] = v		end end local current_title = mw.title.getCurrentTitle local namespace = args.namespace or current_title.nsText local title = args.title or current_title.text local shared = yesno(args.shared) args.title = nil args.shared = nil -- info text local infoword1 = 'works' local infoword2 = 'title' if namespace == 'Author' then infoword1 = 'authors' infoword2 = 'name' elseif namespace == 'Portal' then infoword1 = 'portals' infoword2 = 'topic name' end local info = tostring(mw.html.create('p'):css({['font-style'] = 'italic'}):wikitext(table.concat({		'This is a disambiguation page. It lists ',		infoword1,		' that share the same ',		infoword2,		'. If an article link referred you here, please consider editing it to point directly to the intended page.'	}))) if args.notes then args.notes = info .. ' ' .. args.notes .. ' '	else args.notes = info end -- categories local categories = args.category or args.category local cat = namespace .. ' disambiguation pages' args.category = nil args.categories = nil -- header local disambig_text = ' (disambiguation) ' local postheader = tostring(mw.html.create('div'):addClass('subNote'):css({['margin'] = '4px auto 4px auto'}):wikitext( tostring(mw.html.create('span'):attr('id', 'nofooter'):wikitext( args.intro or tostring(mw.html.create('span'):css({['font-weight'] = 'bold', ['font-style'] = 'italic'}):wikitext(title)) .. ' may refer to:' ))	))	args.disambiguation = true local header if namespace == 'Author' then args.firstname = title .. disambig_text args.last_initial = '!NO_INITIALS' args.description = args.notes args.nocat = true header = require('Module:Author')._author(args) elseif namespace == 'Portal' then args.title = title .. disambig_text args.class = 'none' args.nocat = true args.reviewed = 'n/a' header = require('Module:Portal header')._portal_header(args) elseif namespace == '' or namespace == 'Template' then args.pretitle = 'Works' if shared then args.pretitle = 'Works and pages in other namespaces' end args.pretitle = args.pretitle .. ' entitled' args.title = title if shared and not current_title.isSubpage then -- should be redundant as attached to header args.notes = args.notes .. ''		end args.header_class = 'ws-dynlayout-disable' header = require('Module:Header')._header(args) cat = 'Mainspace disambiguation pages' else header = require('Module:Error')['error']({'Module:Disambiguation error: is only for use in the Main, Author and Portal namespaces'}) postheader = '' cat = 'Disambiguation pages in inappropriate namespaces' end return header .. mw.getCurrentFrame:preprocess('__DISAMBIG__') .. postheader .. (categories or '') end

function p.disambiguation(frame) return p._disambiguation(getArgs(frame, {removeBlanks = false})) end

return p