Edit the documentation or categories for this module.
local lang = mw.getLanguage('en')
local util_time = require('Module:TimeUtil')
local p = {}
local h = {}
function p.makeBday(y,m,d)
if not (m and d) then
return {}
end
local m = tostring(util_time.monthNameToNumber[m])
if #m == 1 then
m = '0' .. m
end
if #d == 1 then
d = '0' .. d
end
local full = y and m and d
if not full then
y = 2014 -- we won't print this, just a random year so that the formatting works
end
local str = ('%s-%s-%s'):format(y,m,d)
local tbl = {
full = full,
age = full and util_time.age(str),
display = full and lang:formatDate('F j, Y',str) or lang:formatDate('F j',str),
store = full and str or ''
}
tbl.displayandage = tbl.display .. (full and (' (age %s)'):format(tbl.age) or '')
return tbl
end
function p.getFile(arg, default)
local title = arg and mw.title.makeTitle('Media',arg or '')
return title and title.exists and arg or default
end
function p.statDisplays(tbl)
local ret = {}
for _, v in ipairs(tbl) do
ret[v] = Stat(v):flair('medium')
end
return ret
end
------------------------------------------------------------------------------------
function p.getAndMergeRedirects(cargo, processed, tableType)
local redirectsPruned = h.getUniqueCaseRedirects(processed.redirects, processed.pagename)
cargo[#cargo+1] = {
_table = ('%sRedirects'):format(tableType),
AllName = processed.pagename,
}
for k, v in ipairs(redirectsPruned) do
if v and v ~= '' then
cargo[#cargo+1] = h.getRedirectCargo(v, k, processed.pagename, tableType)
end
end
end
function h.getRedirects(pagename, tableType)
end
function h.getUniqueCaseRedirects(redirects, pagename)
local hash = { [mw.ustring.lower(pagename)] = true }
local ret = {}
for _, v in ipairs(redirects) do
local lc = mw.ustring.lower(v)
if not hash[lc] then
ret[#ret+1] = lc
end
hash[lc] = true
end
return ret
end
function h.getRedirectCargo(name, i, title, tableType)
-- there's a cargo bug responsible for the commented code here
-- cargo ignores special characters unless you use BINARY so when i deleted the BINARY conditions, the special characters became a liability
-- lua can't check special-character-agnostic string equality natively
-- so i'll rely on cargo's storing bug where it only stores an equivalent-up-to-case-and-special-character-substitution set of rows one time
-- so here we guarantee it's unable to tell the difference between actually-different rows
-- by removing OtherName field and UniqueLine field
-- probably we don't need those fields anyway, but we absolutely cannot have them until this cargo issue is fixed
return {
_table = tableType .. 'Redirects',
AllName = name,
-- OtherName = name,
-- UniqueLine = ('%s_%s'):format(title, i + 1)
}
end
return p