Module:Archive list: Difference between revisions
From Test Wiki
Content deleted Content added
m>MarcoAurelio m Protected "Module:Archive list": High-risk Lua module ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only administrators] (indefinite)) |
Created page with "-- This module implements {{archive list}} in Lua, and adds a few -- new features. -- Process a numeric argument to make sure it is a positive -- integer. local function processNumArg( num ) if num then num = tonumber( num ) if type( num ) == 'number' then num = math.floor( num ) if num >= 0 then return num end end end return nil end -- Checks whether a page exists, going through pc..." |
||
| Line 160: | Line 160: | ||
return 1 |
return 1 |
||
end |
end |
||
end |
|||
-- Get whether to leave a blank cell in the first row and column |
|||
-- If links start at 1, and lineNum is a round number, this aligns the first |
|||
-- column to start on a multiple of lineNum, which may be a nice round number |
|||
local function getLeaveFirstCellBlank( leaveFirstCellBlank ) |
|||
return leaveFirstCellBlank == 'yes' |
|||
or leaveFirstCellBlank == 'y' |
|||
or leaveFirstCellBlank == 1 |
|||
end |
end |
||
| Line 222: | Line 231: | ||
table.insert(ret, "<table style=\"width: 100%; padding: 0px; text-align: center; background-color: transparent;\"><tr><td>") |
table.insert(ret, "<table style=\"width: 100%; padding: 0px; text-align: center; background-color: transparent;\"><tr><td>") |
||
end |
end |
||
if glargs.leaveFirstCellBlank then |
|||
-- An empty first cell aligns the first column on multiples of lineNum |
|||
table.insert(ret, sep) |
|||
lineCounter = lineCounter + 1 |
|||
end |
|||
for archiveNum = start, glargs.max do |
for archiveNum = start, glargs.max do |
||
local link = mw.ustring.format( |
local link = mw.ustring.format( |
||
| Line 267: | Line 281: | ||
local sep = getSeparator( args.sep ) |
local sep = getSeparator( args.sep ) |
||
local lineSep = getSeparator( args.linesep ) |
local lineSep = getSeparator( args.linesep ) |
||
local leaveFirstCellBlank = getLeaveFirstCellBlank( args.leavefirstcellblank ) |
|||
local glargs = { |
local glargs = { |
||
start = start, |
start = start, |
||
| Line 275: | Line 290: | ||
sep = sep, |
sep = sep, |
||
lineNum = lineNum, |
lineNum = lineNum, |
||
lineSep = lineSep |
lineSep = lineSep, |
||
leaveFirstCellBlank = leaveFirstCellBlank |
|||
} |
} |
||
return generateLinks( glargs ) |
return generateLinks( glargs ) |
||