Module:Archive: Difference between revisions

Content deleted Content added
m Reverted edit by Pigsonthewing (talk) to last version by Jonesey95
update from sandbox, per talk page - bug should be fixed now
Line 82:
function Navigator:makeBlurb()
local args = self.args
local current = self.currentTitle
if args[1] == '1' then
local ret
-- The old template used "|1" to suppress the blurb.
if args[1] == '1'.text then
return ''
ret = args.text
else
local talkPage = current.nsText .. ':'
local ret
if args.textprefix then
talkPage = talkPage .. self.currentTitlecurrent.baseText
ret = args.text
else
local talkPage = selftalkPage .currentTitle.nsText current.. ':'rootText
end
if args.prefix then
talkPage = talkPage .. self.currentTitle.baseText
local namespace = 'talk'
else
if self.currentTitlecurrent.isTalkPage == true then
talkPage = talkPage .. self.currentTitle.rootText
namespace = 'maintalk'
end
else
local namespace = 'main'
end
if self.currentTitle.isTalkPage == true then
namespace = 'talk'
local subjectPage = current.subjectNsText .. ':' .. current.rootText
else
if args.prefixperiod then
namespace = 'main'
ret = self:message('blurb-noperiodperiod', talkPage, namespacemakeWikilink(subjectPage),
end
if args.period, thennamespace)
else
if args.period then
ret = self:message('blurb-periodnoperiod', talkPage, args.period, namespacemakeWikilink(subjectPage),
'', namespace)
else
ret = self:message('blurb-noperiod', talkPage, namespace)
end
 
end
return ret
end
return ''ret
end
 
function Navigator:makeMessageBox()
local args = self.args
local image
if args.image then
Line 133 ⟶ 130:
-- PS: Needs to be changed if the template is renamed!
local mainTemplatePage = ''
if self.currentTitle.fullText == 'Template:Archive/sandbox' then
mainTemplatePage = 'talk'
end
Line 143 ⟶ 140:
style = args.style or '',
textstyle = args.textstyle or 'text-align:center',
text = self:makeBlurb(),
})
 
Line 319 ⟶ 316:
end
ret[#ret + 1] = '\n|}'
return table.concat(ret)
end
 
function Navigator:__tostring()
local args = self.args
return self:makeMessageBox() ..
local archiveBox = self:makeArchiveLinksWikitable() ..
'\n' ..
self:makeArchiveLinksWikitable() ..
' __NONEWSECTIONLINK__ __NOEDITSECTION__ __ARCHIVEDTALK__'
-- Do not make the mbox if |1=1 or |omit=banner.
if args[1] ~= '1' and args.omit ~= 'banner' then
return archiveBox = self:makeMessageBox() .. '\n' .. archiveBox
else
-- I'll give out a barnstar to whoever figures out why not prepending
-- an HTML comment makes it add a line break before the archive table.
-- -User:Hilst
archiveBox = '<!--suppress line break-->' .. archiveBox
end
return archiveBox
end
 
Line 342 ⟶ 351:
 
function p._aan(args, cfg, currentTitle)
cfg = cfg or mw.loadData('Module:Archive/config/sandbox')
currentTitle = currentTitle or mw.title.getCurrentTitle()
local aan = Navigator.new(args, cfg, currentTitle)