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:04, 1 March 2015 (create data module for Module:Signpost). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

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

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

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

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

return main()