Jump to content

Module:Signpost/index

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Mr. Stradivarius (talk | contribs) at 15:18, 1 March 2015 (deal with tags properly). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

-- This module processes data from [[Module:Signpost/index]], to be loaded from
-- [[Module:Signpost]] with mw.loadData.

local insert = table.insert
local index = require('Module:Signpost/index')

local function addSubtable(tIn, tOut, key)
	tOut[key] = tOut[key] or {}
	insert(tOut[key], tIn)
end

local function main()
	local ret, dates, tags, pages = {}, {}, {}, {}
	for i, t in ipairs(index) do
		addSubtable(t, dates, t.date)
		for i, tag in ipairs(t.tags) do
			addSubtable(t, tags, tag)
		end
		pages[t.page] = t
	end
	return {
		dates = dates,
		tags = tags,
		pages = pages
	}
end

return main()