Gaan na inhoud

Module:Lua banner

in Wikipedia, die vrye ensiklopedie

Dokumentasie vir hierdie module kan geskep word by: Module:Lua banner/doc

-- This module implements the {{lua}} template.

local yesno = require('Module:Yesno')
local mList = require('Module:List')
local mTableTools = require('Module:TableTools')
local mMessageBox = require('Module:Message box')

local p = {}

function p.main(frame)
	local origArgs = frame:getParent().args
	local args = {}
	for k, v in pairs(origArgs) do
		v = v:match('^%s*(.-)%s*$')
		if v ~= '' then
			args[k] = v
		end
	end
	return p._main(args)
end

function p._main(args)
	local modules = mTableTools.compressSparseArray(args)
	local box = p.renderBox(modules)
	local trackingCategories = p.renderTrackingCategories(args, modules)
	return box .. trackingCategories
end

function p.renderBox(modules)
	local boxArgs = {}
	if #modules < 1 then
		boxArgs.text = '<strong class="error">Fout: geen modules gespesifiseer nie</strong>'
	else
		local moduleLinks = {}
		for i, module in ipairs(modules) do
			moduleLinks[i] = string.format('[[:%s]]', module)
		end
		local moduleList = mList.makeList('bulleted', moduleLinks)
		boxArgs.text = 'Gebruik [[Wikipedia:Lua|Lua]]:\n' .. moduleList
	end
	boxArgs.type = 'notice'
	boxArgs.small = true
	boxArgs.style = 'margin: 4px 10%; border-collapse: collapse; border: 1px solid #aaa; background: #f9f9f9; clear: right; float: right; margin: 4px 0 4px 1em; width: 238px; font-size: 88%; line-height: 1.25em;'
	boxArgs.image = '[[File:Lua-logo-nolabel.svg|30px|alt=Lua logo|link=Wikipedia:Lua]]'
	return mMessageBox.main('mbox', boxArgs)
end

function p.renderTrackingCategories(args, modules, titleObj)
	if yesno(args.nocat) then
		return ''
	end
	
	local cats = {}
	
	-- Error category
	if #modules < 1 then
		cats[#cats + 1] = 'Lua-sjablone met foute'
	end
	
	-- Lua templates category
	titleObj = titleObj or mw.title.getCurrentTitle()
	local subpageBlacklist = {
		doc = true,
		sandbox = true,
		sandbox2 = true,
		testcases = true
	}
	if titleObj.namespace == 10 
		and not subpageBlacklist[titleObj.subpageText]
	then
		local category = args.category
		if not category then
			local categories = {
				['Module:String'] = 'String-gebaseerde Lua-Sjablone',
				['Module:Math'] = 'Sjablone gebasseer op die Math-Lua-module',
				['Module:BaseConvert'] = 'Sjablone gebasseer op die BaseConvert-Lua-module',
				['Module:Citation'] = 'Lua-gebasseerde aanhalingsjablones'
			}
			categories['Module:Citation/CS1'] = categories['Module:Citation']
			category = modules[1] and categories[modules[1]]
			category = category or 'Lua-gebaseerde sjablone'
		end
		cats[#cats + 1] = category
	end
	
	for i, cat in ipairs(cats) do
		cats[i] = string.format('[[Category:%s]]', cat)
	end
	return table.concat(cats)
end

return p
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy