Module:Bongolium500/main page modules: Difference between revisions

From Tardis Wiki, the free Doctor Who reference
no edit summary
No edit summary
No edit summary
 
(38 intermediate revisions by the same user not shown)
Line 5: Line 5:
local h = {}
local h = {}
local MONTHS = {"January", "Feburary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}
local MONTHS = {"January", "Feburary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}
function p.recentReleases(frame)
local args = frame.args
if not args["max"] or args["max"] == "" or not type(tonumber(args["max"])) == "number" then
args["max"] = 8
end
local outputText = "<div class=\"mainpage-box-recent\">\n"
local done = false
local i = 1
local side = "left"
while not done do
outputText = outputText .. "<div class=\"recent-release-box\">" .. frame:preprocess(args[i]:gsub("{!%-%-" .. side .. "%-.-%-align%-%-}", ""):gsub("{!%-%-left%-", ""):gsub("{!%-%-right%-", ""):gsub("%-align%-%-}", "")) .. "</div>\n"
if side == "left" then side = "right" else side = "left" end
i = i + 1
if i > tonumber(args["max"]) then
done = true
elseif args[i] == null or args[i] == "" then
done = true
end
end
outputText = outputText .. "</table></div>"
return outputText
end


function p.releaseModule(frame)
function p.releaseModule(frame)
local PREFIX = "MAINPAGERELEASE-"
local PREFIX = "MAINPAGERELEASE-"
local currentDate = os.date("%F")
local currentDate = frame.args[1]
local outputWidget = cache.get(PREFIX .. currentDate) or ""
local outputWidget = cache.get(PREFIX .. currentDate) or ""
Line 20: Line 44:
local numToReturn = 0
local numToReturn = 0
if #releases < 3 then numToReturn = #releases else numToReturn = 3 end
if #releases < 5 then numToReturn = #releases else numToReturn = 5 end
local usedNumbers = {}
local usedNumbers = {}
for count=1, numToReturn do
for count=1, numToReturn do
local ranNum = math.random(1, #releases)
local ranNum = math.random(1, #releases)
while not usedNumbers[ranNum] do
while usedNumbers[ranNum] do
ranNum = math.random(1, #releases)
ranNum = math.random(1, #releases)
end  
end  
Line 31: Line 55:
local temp = textUtil.split(randomRelease, " %- ")
local temp = textUtil.split(randomRelease, " %- ")
local year = temp[1]
local year = temp[1]
local text = temp[2]
if not string.find(year, "%[%[") then
outputWidget = outputWidget .. "... \n<h3>" .. year .."</h3> \n<span>" .. text .. "</span>"
year = "[[" .. year .. " (releases)|" .. year .. "]]"
end
local text = temp[2] or ""    --:gsub([['"`UNIQ--nowiki-00000001-QINU`"']], "\'")
outputWidget = outputWidget .. "\n<h3>..." .. year .."</h3>\n<span>" .. text .. "</span>"
end
end
outputWidget = outputWidget .. "</div>"
outputWidget = outputWidget .. "</div>"
--cache.set(PREFIX .. currentDate, outputWidget)
cache.set(PREFIX .. currentDate, outputWidget)--]]
end
end
return outputWidget
return outputWidget
Line 43: Line 70:
function p.birthdayModule(frame)
function p.birthdayModule(frame)
local PREFIX = "MAINPAGEBIRTHDAY-"
local PREFIX = "MAINPAGEBIRTHDAY-"
local currentDate = os.date("%F")
local currentDate = frame.args[1]
local outputWidget = cache.get(PREFIX .. currentDate) or ""
local outputWidget = cache.get(PREFIX .. currentDate) or ""
Cookies help us deliver our services. By using our services, you agree to our use of cookies.