Module:Bogga Hore
Appearance
Documentation for this module may be created at Module:Bogga Hore/doc
--Module tusmooyinka bogga hore
local fgetFAlist = require('Module:Bogga Hore/Xul').getFAlist
local fgetGAlist = require('Module:Bogga Hore/Wacan').getGAlist
local fgetFPlist = require('Module:Bogga Hore/Portal').getFPlist
local fgetFPiclist = require('Module:Bogga Hore/Sawirro').getFPiclist
local fgetFWordlist = require('Module:Bogga Hore/Oraah').getFWordlist
local a = {}
function a.rnumber( frame )
d = {}
if(frame.args[1] =='ga' or frame.args[1] =='Wacan' ) then
d = fgetGAlist()
return #d
elseif (frame.args[1] =='fa' or frame.args[1] =='Xul' ) then
d = fgetFAlist()
return #d
elseif (frame.args[1] =='fp' or frame.args[1] =='Portal' ) then
d = fgetFPlist()
local nb =0
for t,s in pairs(d) do
nb = nb+1
end
return nb
elseif (frame.args[1] =='fpic' or frame.args[1] =='Sawirro' ) then
d = fgetFPiclist()
local nb =0
for t,s in pairs(d) do
nb = nb+1
end
return nb
end
end
function a.rlist( frame )
d = {}
if(frame.args[1] =='ga' or frame.args[1] =='Wacan' ) then
d = fgetGAlist()
elseif (frame.args[1] =='fa' or frame.args[1] =='Xul' ) then
d = fgetFAlist()
end
math.randomseed( os.time() )
x = math.random(1,#d)
repeat
x1 = math.random(1,#d)
until x1 ~= x
repeat
x2 = math.random(1,#d)
until (x2 ~= x and x2 ~= x1)
return "[["..d[x1].."]] – [["..d[x].."]] – [["..d[x2].."]]"
end
function a.plist(frame)
local c = ''
local d = {}
if(frame.args[1] =='ga' or frame.args[1] =='Xul' ) then
d = fgetGAlist()
for _,s in ipairs(d) do
c = c .. "\n# [[" .. s .. "]]"
end
elseif (frame.args[1] =='fa' or frame.args[1] =='Xul' ) then
d = fgetFAlist()
for _,s in ipairs(d) do
c = c .. "\n# [[" .. s .. "]]"
end
elseif (frame.args[1] =='fp' or frame.args[1] =='Portal' ) then
d = fgetFPlist()
for t,s in pairs(d) do
c = c .. "\n# [[" ..t.."|".. s[3] .. "]]"
end
end
return c
end
----
----Doorasho horleh/iskuraran qayb ka mid ah maqaalada wacan/ee loo xushay si loogu soo bandhigo bogga hore
----
---- _RandOne : Natiijada waa magac iskuraran maqaal kaliyaee xul/Wacan
local function _getOnepDay( frame )
d = {}
math.randomseed( os.time() )
if (frame.args[1] =='dyk' or frame.args[1] =='Ogtahay' ) then
local nbf = mw.site.stats.pagesInCategory( 'Liiska mashruuca ma ogtahay', 'pages' )
if(type(nbf) ~= "number") then return '' end
---- x = math.random(1,nbf)
x = (math.floor(os.time()/(24*3600)) % nbf ) +1
return frame:expandTemplate{ title = 'Ma Ogtahay/Hadda', args = { x } }
elseif (frame.args[1] =='fpic' or frame.args[1] =='Sawirro' ) then
d = fgetFPiclist()
local nbf=0
for t,s in pairs(d) do
nbf = nbf + 1
end
---- x = math.random(1,nbf)
x = math.floor(os.time()/(24*3600)) % nbf
local nb=0
for t,s in pairs(d) do
nb = nb + 1
if(nb == x) then
return frame:expandTemplate{ title = 'Sawirro bogga hore', args = { t, s[1], s[2] } }
end
end
elseif (frame.args[1] =='fw' or frame.args[1] =='Oraah' ) then
d = fgetFWordlist()
local nbf=0
for title,items in pairs(d) do
nbf = nbf + 1
end
x = math.floor(os.time()/(24*3600)) % nbf
local nb=0
for t,s in pairs(d) do
nb = nb + 1
if(nb == x) then
return frame:expandTemplate{ title = 'Oraahda maanta', args = { s[1], s[2] } }
end
end
elseif (frame.args[1] =='fp' or frame.args[1] =='Portal' ) then
d = fgetFPlist()
local nbf=0
for title,items in pairs(d) do
nbf = nbf + 1
end
--- x = math.random(1,nbf)
x = math.floor(os.time()/(24*3600)) % nbf
local nb=0
for t,s in pairs(d) do
nb = nb + 1
if(nb == x) then
return frame:expandTemplate{ title = 'Portalka maanta xulka ah/Template', args = { s[1], s[2], t , s[3] } }
end
end
elseif(frame.args[1] =='ga' or frame.args[1] =='Wacan' ) then
d = fgetGAlist()
elseif (frame.args[1] =='fa' or frame.args[1] =='Xul' ) then
d = fgetFAlist()
end
---x = math.random(1,#d)
x = math.floor(os.time()/(24*3600)) % #d
return x --d[x]
end
local function _LCount( items )
local nb = 0
for _, item in ipairs(items) do
nb = nb +1
end
return nb
end
local function _OneDay( frame )
local dayList = {}
local monthList = {}
local articles = {}
local nbarts = 0
math.randomseed( os.time() )
if(frame.args[1] =='Xul' or frame.args[1] =='Wacan' ) then
---- Waa hubaalأin uusan jirin maqaal loogu talogalay maalinkaan isga ah
dayList = mw.loadData('Module:Bogga Hore/'.. frame.args[1]..'/Taariikh')
for date1, articles in pairs(dayList) do
if( date1 == mw.getContentLanguage():formatDate('Y-n-d') ) then
nbarts = _LCount(articles)
if(nbarts == 1) then
return articles[1]
elseif nbarts > 1 then
return articles[math.random(1,nbarts) ]
end
end
end
--- Baarista xun sanadeed
monthList = mw.loadData('Module:Bogga Hore/'.. frame.args[1]..'/Bil/'..mw.getContentLanguage():formatDate('n'))
articles = monthList[mw.getContentLanguage():formatDate('d')]
if(type(articles) ~= 'table') then
return ''
end
nbarts = _LCount(articles)
if(nbarts == 0) then
return ''
elseif nbarts == 1 then
return articles[1]
else
return articles[math.random(1,nbarts) ]
end
end
return ''
end
function a.selectArt(frame)
local title = _OneDay( frame )
if(title ~= '') then
return title
else
return _getOnepDay( frame )
end
end
----
----
return a