Modulis:YBC
Moduļa dokumentācija[skatīt] [labot] [hronoloģija] [pārlādēt]
Palīgs {{Year by category}} pievienošanai. Obligāti jālieto substitūcija!
Piemēri[labot pirmkodu]
Kategorijā 2015. gads sportā
{{subst:#invoke:YBC|main|cat=sportā|sortkey=Sports|parent=Sporta notikumi pēc gada}}
Kategorijā 2015. gada albumi
{{subst:#invoke:YBC|main|cat=albumi|year=gada|sortkey=Albumi|parent=Albumi pēc gada|subcat_postfix=. gads mūzikā}}
Kategorijā 2016. gadā mirušie
{{subst:#invoke:YBC|mir}}
Kategorijā 1950. gadā dzimušie
{{subst:#invoke:YBC|dz}}
Dokumentācija iekļauta no Modulis:YBC/doc (labot | hronoloģija) Vari eksperimentēt šī moduļa smilšu kastes (izveidot | spoguļversija) un testu (izveidot) lapā Moduļa apakšlapas. |
local p = {}
local entity = mw.wikibase.getEntityObject()
local title = mw.title.getCurrentTitle()
local pagename = title.text
function p.dz(frame)
local out = {}
local commonsT = {}
local m,c,d,y
local _,_,y1,y2,y3,y4 = string.find(pagename,"(%d)(%d)(%d)(%d)")
out[#out+1] = '|' .. y1 .. y2 .. y3 .. '|' .. y4
if entity and entity.claims["P373"] then
if entity.sitelinks.commonswiki then
commons = entity.sitelinks.commonswiki.title
end
end
if commons then
commons = string.gsub(commons,"Category:","")
commonsT[#commonsT+1] = frame:preprocess('{{Commons category|' .. commons .. '|' .. pagename .. '}}\n')
end
parameters = table.concat(out)
result = frame:preprocess('{{dzimgads' .. parameters .. '}}')
commonsres = table.concat(commonsT)
return (commonsres or '') .. result
end
function p.dz3(frame)
local out = {}
local commonsT = {}
local m,c,d,y
local _,_,y1,y2,y3 = string.find(pagename,"(%d)(%d)(%d)")
out[#out+1] = '|' .. y1 .. y2 .. '|' .. y3
if entity and entity.claims["P373"] then
if entity.sitelinks.commonswiki then
commons = entity.sitelinks.commonswiki.title
end
end
if commons then
commons = string.gsub(commons,"Category:","")
commonsT[#commonsT+1] = frame:preprocess('{{Commons category|' .. commons .. '|' .. pagename .. '}}\n')
end
parameters = table.concat(out)
result = frame:preprocess('{{dzimgads' .. parameters .. '}}')
commonsres = table.concat(commonsT)
return (commonsres or '') .. result
end
function p.mir(frame)
local out = {}
local commonsT = {}
local m,c,d,y
local _,_,y1,y2,y3,y4 = string.find(pagename,"(%d)(%d)(%d)(%d)")
out[#out+1] = '|' .. y1 .. y2 .. y3 .. '|' .. y4
if entity and entity.claims["P373"] then
if entity.sitelinks.commonswiki then
commons = entity.sitelinks.commonswiki.title
end
end
if commons then
commons = string.gsub(commons,"Category:","")
commonsT[#commonsT+1] = frame:preprocess('{{Commons category|' .. commons .. '|' .. pagename .. '}}\n')
end
parameters = table.concat(out)
result = frame:preprocess('{{mirgads' .. parameters .. '}}')
commonsres = table.concat(commonsT)
return (commonsres or '') .. result
end
function p.mir3(frame)
local out = {}
local commonsT = {}
local m,c,d,y
local _,_,y1,y2,y3 = string.find(pagename,"(%d)(%d)(%d)")
out[#out+1] = '|' .. y1 .. y2 .. '|' .. y3
if entity and entity.claims["P373"] then
if entity.sitelinks.commonswiki then
commons = entity.sitelinks.commonswiki.title
end
end
if commons then
commons = string.gsub(commons,"Category:","")
commonsT[#commonsT+1] = frame:preprocess('{{Commons category|' .. commons .. '|' .. pagename .. '}}\n')
end
parameters = table.concat(out)
result = frame:preprocess('{{mirgads' .. parameters .. '}}')
commonsres = table.concat(commonsT)
return (commonsres or '') .. result
end
function p.main(frame)
local out = {}
local commonsT = {}
local cat = frame.args.cat
local parent = frame.args.parent
local year = frame.args.year
local subcat = frame.args.subcat
local sortkey = frame.args.sortkey
local subcat_postfix = frame.args.subcat_postfix
local m,c,d,y
local _,_,y1,y2,y3,y4 = string.find(pagename,"(%d)(%d)(%d)(%d)")
out[#out+1] = '\n|m = ' .. y1 .. ' |c = ' .. y2 .. ' |d = ' .. y3 .. ' |y = ' .. y4
if cat then out[#out+1] = '|cat = ' .. cat end
if year then out[#out+1] = '|year = ' .. year end
if sortkey then out[#out+1] = '|sortkey = ' .. sortkey end
if parent then out[#out+1] = '|parent = ' .. parent end
if subcat then
out[#out+1] = '|subcat = ' .. subcat
elseif subcat_postfix then
out[#out+1] = '|subcat = ' .. y1 .. y2 .. y3 .. y4 .. subcat_postfix
else
out[#out+1] = '|subcat = ' .. y1 .. y2 .. y3 .. y4 .. '. gads'
end
if entity and entity.claims["P373"] then
if entity.sitelinks.commonswiki then
commons = entity.sitelinks.commonswiki.title
end
end
if commons then
commons = string.gsub(commons,"Category:","")
commonsT[#commonsT+1] = frame:preprocess('{{Commons category|' .. commons .. '|' .. pagename .. '}}\n')
end
parameters = table.concat(out,'\n')
result = frame:preprocess('{{year by category' .. parameters .. '\n}}')
commonsres = table.concat(commonsT)
return (commonsres or '') .. result
end
return p