Module:Main: Difference between revisions

Content added Content deleted
(unpack the table used for formatPageTables)
(update after changes to Module:Hatnote)
Line 27: Line 27:
end
end
pages = mTableTools.compressSparseArray(pages)
pages = mTableTools.compressSparseArray(pages)
local options = {
return p._main(unpack(pages))
selfref = args.selfref
}
return p._main(options, unpack(pages))
end
end


function p._main(...)
function p._main(options, ...)
-- Get the list of pages. If no first page was specified we use the current
-- Get the list of pages. If no first page was specified we use the current
-- page name.
-- page name.
Line 46: Line 49:


-- Find the pagetype.
-- Find the pagetype.
local firstPageNs = mHatnote._findNamespaceId(firstPage)
local firstPageNs = mHatnote.findNamespaceId(firstPage)
local pagetype = firstPageNs == 0 and 'article' or 'page'
local pagetype = firstPageNs == 0 and 'article' or 'page'


-- Make the formatted link text
-- Make the formatted link text
local links = mHatnote._formatPageTables(unpack(pages))
local links = mHatnote.formatPageTables(unpack(pages))
links = mw.text.listToText(links)
links = mw.text.listToText(links)


Line 75: Line 78:
local text = string.format(stringToFormat, pagetype, links)
local text = string.format(stringToFormat, pagetype, links)


-- Pass the text to the _rellink function in [[Module:Hatnote]].
-- Process the options and pass the text to the _rellink function in
-- [[Module:Hatnote]].
local extraclasses = 'relarticle mainarticle'
options = options or {}
return mHatnote._rellink(text, extraclasses)
local hnOptions = {
extraclasses = 'relarticle mainarticle',
selfref = options.selfref
}
return mHatnote._hatnote(text, hnOptions)
end
end