Módulo:Lua banner
Ir para navegação
Ir para pesquisar
40x40px | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
Descrição
Este Módulo implementa a predefinição {{Lua}}
. Por favor consulte a predefinição para mais instruções.
Uso
Outra documentação:
-- This module implements the {{lua}} template. local yesno = require('Módulo:Yesno') local mList = require('Módulo:Lista') local mTableTools = require('Módulo:TableTools') local mMessageBox = require('Módulo: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">Erro: nenhum módulo especificado</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 = (mw.title.getCurrentTitle():inNamespaces(828,829) and 'Este módulo' or 'Esta predefinição') .. ' usa [[Wikipédia:Lua|Lua]]:\n' .. moduleList end boxArgs.type = 'notice' boxArgs.small = true boxArgs.image = '[[Ficheiro:Lua-logo-nolabel.svg|30px|alt=|link=]]' 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] = '!Predefinições com base em Lua com erros' end -- Lua templates category titleObj = titleObj or mw.title.getCurrentTitle() local subpageBlacklist = { doc = true, Testes = true, Testes2 = true, Exemplos_para_testes = true } if titleObj.namespace == 10 and not subpageBlacklist[titleObj.subpageText] then local category = args.category if not category then local categories = { ['Módulo:String'] = '!Predefinições de manipulação de cadeias baseadas em Lua', ['Módulo:Math'] = '!Predefinições com base no módulo Lua Math', ['Módulo:BaseConvert'] = '!Predefinições com base no módulo BaseConvert', ['Módulo:Citação'] = '!Predefinições de citação com base em Lua' } categories['Módulo:Citação/CS1'] = categories['Módulo:Citação'] category = modules[1] and categories[modules[1]] category = category or '!Predefinições com base em Lua' end cats[#cats + 1] = category local protLevels = { autoconfirmed = 1, autoreviewer = 2, sysop = 3 } local currentProt = titleObj.protectionLevels["edit"][1] if currentProt == nil then currentProt = 0 else currentProt = protLevels[currentProt] end for i, module in ipairs(modules) do local moduleProt = mw.title.new(module).protectionLevels["edit"][1] if moduleProt == nil then moduleProt = 0 else moduleProt = protLevels[moduleProt] end if moduleProt < currentProt then cats[#cats + 1] = "!Predefinições que usam módulos de Lua subprotegidos" break end end end for i, cat in ipairs(cats) do cats[i] = string.format('[[Categoria:%s]]', cat) end return table.concat(cats) end return p