Moduł:Czywiesz: Różnice pomiędzy wersjami
Z Nonsensopedii, polskiej encyklopedii humoru
Ostrzyciel (dyskusja • edycje) M (lua pierze skarpety w garnku) |
Ostrzyciel (dyskusja • edycje) M (eep) |
||
Linia 4: | Linia 4: | ||
function p.czywiesz(frame) |
function p.czywiesz(frame) |
||
local text = frame.args[1] or '' |
local text = frame.args[1] or '' |
||
p. |
p._czywiesz(text) |
||
end |
end |
||
function p. |
function p._czywiesz(text) |
||
local articles = {} |
local articles = {} |
||
for link, t in pairs(linki.wLink(text)) do |
for link, t in pairs(linki.wLink(text)) do |
Aktualna wersja na dzień 11:42, 13 maj 2021
Ogarnia szablon {{czyw}}
.
local linki = require('Moduł:Linki')
local p = {}
function p.czywiesz(frame)
local text = frame.args[1] or ''
p._czywiesz(text)
end
function p._czywiesz(text)
local articles = {}
for link, t in pairs(linki.wLink(text)) do
table.insert(articles, link)
end
if #articles == 0 then return end
-- What year is it?
local title = mw.title.getCurrentTitle()
local year = 0
local mainpage = 'false'
if title.fullText == 'Szablon:Czy wiesz' then
year = os.date('*t').year
mainpage = 'true'
elseif mw.ustring.match(title.fullText, '^Nonsensopedia:Czy wiesz, że.../') then
year = title.subpageText
else
return
end
-- Set the SMW props
mw.smw.subobject( {
['Jest czywieszem strony'] = articles,
['Ma treść'] = text,
['Jest z roku'] = year,
['Jest na stronie głównej'] = mainpage,
} )
end
return p