Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Signpost/index
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-- This module processes data from [[Module:Signpost/index]], to be loaded from -- [[Module:Signpost]] with mw.loadData. local PAGE_FORMAT = 'Wikipedia:Wikipedia Signpost/%s/%s' local INDEX_START_YEAR = 2005 local INDEX_BASE = 'Module:Signpost/index/' local ALIASES_MODULE = 'Module:Signpost/aliases' local insert = table.insert local format = string.format local function makePageName(date, subpage) return format(PAGE_FORMAT, date, subpage) end local function addSubtable(tIn, tOut, key) tOut[key] = tOut[key] or {} insert(tOut[key], tIn) end local function maybeRequire(page) local success, module = pcall(require, page) if success then return module end end local function getYearIndexes() local ret = {} for i = INDEX_START_YEAR, os.date('*t').year + 1 do local module = maybeRequire(INDEX_BASE .. tostring(i)) insert(ret, module) end return ret end local function makeAliases() local aliasData = require(ALIASES_MODULE) local ret = {} for key, aliases in pairs(aliasData) do for i, alias in ipairs(aliases) do ret[alias] = key end end return ret end local function addArticleToIndex(index, article, sortKey) article.sortKey = sortKey index.list[sortKey] = article local date = article.date addSubtable(article, index.dates, date) local page = makePageName(date, article.subpage) article.page = page index.pages[page] = article article.tags = article.tags or {} for l, tag in ipairs(article.tags) do addSubtable(article, index.tags, tag) end article.authors = article.authors or {} for l, author in ipairs(article.authors) do addSubtable(article, index.authors, author) end end local function main() local index = { aliases = makeAliases(), authors = {}, dates = {}, list = {}, pages = {}, tags = {}, } local sortKey = 0 for j, yearIndex in ipairs(getYearIndexes()) do for k, article in ipairs(yearIndex) do sortKey = sortKey + 1 addArticleToIndex(index, article, sortKey) end end return index end return main()
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Signpost/index/doc
(
edit
)