Module:ILLArchiveList

--Outputs a list of ILL request archive pages, for use in Template:PILL header/archives --Lua originally by Bryght, rewritten by AttemptToCallNil --DPL by Sophie with help from SuperDragon local p = {}

function p.main(frame) local numberOfRows = 2 local dpl = frame:callParserFunction{ name = '#dpl', args = { '', titleregexp = 'Interlanguage link requests/Archive [0-9]+$', namespace = 'Project', ordermethod = 'title', format = ',%TITLE%\\n,', replaceintitle = '/Interlanguage link requests\\/Archive /,' } }   local pages = mw.text.split(mw.text.trim(dpl), '\n') local total = #pages -- In case the number of archives isn't exactly divisible by the number of rows, -- add one extra archive for `archives % rows` initial rows local baseItemsPerRow = math.floor(total / numberOfRows) local rowsWithExtraItems = total % numberOfRows local lastEndIndex = 0 local row_data = {} for i = 1, numberOfRows do   	local startIndex = lastEndIndex + 1 local endIndex = startIndex + baseItemsPerRow if i > rowsWithExtraItems then endIndex = endIndex - 1 end row_data[i] = table.concat(pages, ', ', startIndex, endIndex) lastEndIndex = endIndex end return table.concat(row_data, ', ') end

return p