Moduł:Drzewa link: Różnice pomiędzy wersjami
Z Nonsensopedii, polskiej encyklopedii humoru
M |
M |
||
Linia 19: | Linia 19: | ||
'[[:Kategoria:' .. category .. ']]' .. '\'\'\'' |
'[[:Kategoria:' .. category .. ']]' .. '\'\'\'' |
||
table.insert(catlinks, link) end |
table.insert(catlinks, link) end |
||
mw.logObject(table.concat(catlinks, ', ')) |
|||
return {title='Ambox', args={ |
return {title='Ambox', args={ |
||
Linia 37: | Linia 36: | ||
local cats = {} |
local cats = {} |
||
for index, cat in ipairs(args) do |
for index, cat in ipairs(args) do |
||
if cat == nil then return '' end |
if cat == nil then return 'cat - nil' end |
||
namespace = namespaces_[cat:match("(.+) – "):lower()] or 'główna' |
|||
namespace = namespaces_[cat:match("(.+) – "):lower()] |
|||
else namespace = 'główna' end |
|||
table.insert(namespaces, namespace) |
table.insert(namespaces, namespace) |
||
table.insert(cats, cat) |
table.insert(cats, cat) |
Wersja z 12:44, 2 gru 2020
local p = {}
local tools = require('Moduł:Narzędzia')
function p._linkCats(namespaces, categories)
local comms = {['główna'] = 'artykułów', ['grafiki'] = 'grafik',
['nonnews'] = 'NonNewsów', ['słownik'] = 'haseł słownikowych',
['cytaty'] = 'cytatów', ['poradniki'] = 'poradników',
['nonźródła'] = 'nonźródeł'}
if #categories < 2 then
local use_plural = false else local use_plural = true end
if use_plural then
treessuf = 'ie' else treessuf = 'ach' end
local catlinks = {}
for i=1, #namespaces do
local namespace = namespaces[i]
local category = categories[i]
local link = comms[namespace] .. ': \'\'\'' ..
'[[:Kategoria:' .. category .. ']]' .. '\'\'\''
table.insert(catlinks, link) end
return {title='Ambox', args={
grafika='[[Plik:Dwa drzewa kategorii.svg|x40px]]',
tekst='Ta kategoria ma swój odpowiednik w drzew' .. treessuf
.. ' kategorii ' .. table.concat(catlinks, ', ') .. '.'}}
end
function p.linkCats(frame)
local namespaces_ =
{['główna']='główna', ['grafiki']='grafiki', ['nonnews']='nonnews',
['słownik']='słownik', ['cytaty']='cytaty', ['poradniki']='poradniki',
['nonźródła']='nonźródła'}
local args = tools.getArgs(frame)
local namespaces = {}
local cats = {}
for index, cat in ipairs(args) do
if cat == nil then return 'cat - nil' end
namespace = namespaces_[cat:match("(.+) – "):lower()] or 'główna'
table.insert(namespaces, namespace)
table.insert(cats, cat)
end
return table.concat(namespaces, ', ') .. table.concat(cats, ', ')
-- return frame:expandTemplate(p._linkCats(namespaces, cats))
end
return p