Module:Archive: Difference between revisions

Content deleted Content added
this should fix it for all namespaces, see talk page
various fixes tested in sandbox, see Template talk:Archive for details
Line 4:
-- This module produces a talk archive banner, together with an automatically-
-- generated list of navigation links to other archives of the talk page in
-- question. It implements {{Automatic archive navigatorArchive}} and.
-- {{Talk archive navigation}}.
-------------------------------------------------------------------------------
 
Line 27 ⟶ 26:
return s
end
 
local function makeTable(width)
local archiveTable = mw.html.create('table')
archiveTable
:css({
['max-width'] = width,
['margin:'] = '0 auto 0.5em;text-align:center"',
['margin:0 auto 0.5em;text-align:'] = 'center"'
})
-- Set width so that the table doesn't spill out on narrower skins
-- or when zooming in. It has to be defined multiple times because
-- "stretch" is experimental.
:cssText('width:100%;width:-moz-available;width:-webkit-fill-available;width:stretch')
return archiveTable
end
 
 
-------------------------------------------------------------------------------
Line 94 ⟶ 109:
end
local namespace = 'main'
if current.isTalkPage == true then
namespace = 'talk'
else
namespace = 'main'
end
local subjectPage = current.subjectNsText .. ':' .. current.rootText
-- Prepend colon for non-mainspace pages.
if current.subjectNsText ~= '' then
subjectPage = ':' .. subjectPage -- Prepend colon for non-mainspace pages
end
if args.period then
ret = self:message('blurb-period', talkPage, makeWikilink(subjectPage),
Line 236 ⟶ 251:
if args.next then archives[#archives + 1] = mw.title.new(args.next) end
local linkstable = {makeTable('30em')
'{| style="width:30em;' ..
'margin:0 auto 0.5em;text-align:center"'
}
for i, title in ipairs(archives) do
links[#links + 1] = '\n| '
if tostring(title) == self.currentTitle.prefixedText then
links[#links + 1] = table:tag("td"):wikitext(string.format(
'<span style="font-size:115%%;">%s</span>',
makeWikilink(title.fullText, title.subpageText)
))
else
table:tag("td"):wikitext(
links[#links + 1] = makeWikilink(title.fullText, title.subpageText)
)
end
end
return table.concattostring(linkstable)
links[#links + 1] = '\n|}'
return table.concat(links)
end
if noLinks < 1 then
Line 297 ⟶ 309:
 
-- Output the wikitable.
local ret = {}
local width
if noLinks <= 3 then
Line 304 ⟶ 315:
width = string.format('%dem', (noLinks + 3) * 5)
else
width = '50em37em'
end
local table = makeTable(width)
ret[#ret + 1] = string.format(
'{| style="width:%s;' ..
'margin:0 auto 0.5em;text-align:center"',
width
)
for i, s in ipairs(links) do
table:tag("td"):wikitext(s)
if i % 20 == 1 then
ret[#ret + 1] = '\n|-'
end
ret[#ret + 1] = '\n| '
ret[#ret + 1] = s
end
ret[#ret + 1] = '\n|}'
return table.concattostring(rettable)
end
 
function Navigator:__tostring()
local args = self.args
local boxComponents
local archiveBox = self:makeArchiveLinksWikitable() ..
)
' __NONEWSECTIONLINK__ __NOEDITSECTION__ __ARCHIVEDTALK__'
-- Is |omit filled? If not, make the whole box.
if i % 20args.omit == 1nil then
-- Do not make the mbox if |1=1 or |omit=banner.
archiveBoxboxComponents = self:makeMessageBox() .. '\n' .. archiveBoxself:makeArchiveLinksWikitable()
if args[1] ~= '1' and args.omit ~= 'banner' then
-- We're omitting the banner, so we should only make the links table.
archiveBox = self:makeMessageBox() .. '\n' .. archiveBox
if args[1] ~= '1' andelseif args.omit ~== 'banner' then
else
local archiveBox boxComponents = self:makeArchiveLinksWikitable() ..
-- I'll give out a barnstar to whoever figures out why not prepending
-- We're omitting the archives, so we should only make the banner.
-- an HTML comment makes it add a line break before the archive table.
elseif args.omit == 'archives' then
-- -User:Hilst
boxComponents = self:makeMessageBox()
archiveBox = '<!--suppress line break-->' .. archiveBox
end
boxComponents = boxComponents .. ' __NONEWSECTIONLINK__ __NOEDITSECTION__ __ARCHIVEDTALK__'
return archiveBox
return boxComponents
end