[dismiss]
The wiki is currently a work in progress. If you'd like to help out, please check the Community Portal and our getting started guide. Also, check out our sister project on poewiki.net.
Module:New content
The above documentation is transcluded from Module:New content/doc.
Editors can experiment in this module's sandbox and testcases pages.
Subpages of this module.
Editors can experiment in this module's sandbox and testcases pages.
Subpages of this module.
local getArgs = require('Module:Arguments').getArgs
local util = require('Module:Util')
local messageBox = require('Module:Message box')
local cargo = mw.ext.cargo
local gFrame
local m = {}
local p = {}
----------------------------------------------------------------------------
-- Message box pseudo-class
----------------------------------------------------------------------------
function m:new(version, released, part, space, talk)
self.version = version
self.released = released or false
self.part = part
self.space = space
self.talk = talk
local text = mw.html.create()
:node(self:getMainBlurb())
:node(self:getEditBlurb())
:node(self:getTalkBlurb())
local mbox = messageBox.main('mbox', {
type = 'content',
image = self:getImage(),
text = tostring(text),
})
local cats = self:getCategories()
local html = mw.html.create()
:wikitext(mbox)
:wikitext(cats)
return tostring(html)
end
function m:getMainBlurb()
local node = mw.html.create()
local text
if self.released then -- Newly released content
if self.part then
if self.part == 'section' then
text = string.format('This section describes new Path of Exile content released in [[version %s]].', self.version)
else
text = string.format('Parts of this %s related to %s describe new Path of Exile content released in [[version %s]].', self.space, self.part, self.version)
end
else
text = string.format('This %s describes new Path of Exile content released in [[version %s]].', self.space, self.version)
end
else -- Upcoming content
if self.part then
if self.part == 'section' then
text = string.format('This section describes new Path of Exile content coming in [[version %s]].', self.version)
else
text = string.format('Parts of this %s related to %s describe new Path of Exile content coming in [[version %s]].', self.space, self.part, self.version)
end
else
text = string.format('This %s describes new Path of Exile content coming in [[version %s]].', self.space, self.version)
end
end
node
:tag('b')
:node(text)
:done()
:wikitext(' ')
:wikitext('Information may be missing or incorrect.')
:tag('br')
:done()
:newline()
return node
end
function m:getEditBlurb()
local node = mw.html.create()
local title = mw.title.getCurrentTitle()
local link = string.format('[%s %s]', title:fullUrl{action = 'edit'}, 'expand this ' .. self.space)
node
:wikitext(string.format('Please %s so that it provides complete and accurate information.', link))
:wikitext(' ')
return node
end
function m:getTalkBlurb()
local node = mw.html.create()
local title = mw.title.getCurrentTitle()
if title.canTalk and title.talkPageTitle.exists then
local text, link
local url = title.talkPageTitle:fullUrl()
if self.talk then
text = 'This is discussed in greater detail on the %s.'
link = string.format('[%s#%s %s]', url, self.talk, 'talk page')
else
text = 'Relevant discussion may be found on the %s.'
link = string.format('[%s %s]', url, 'talk page')
end
node
:wikitext(string.format(text, link))
:wikitext(' ')
end
return node
end
function m:getImage()
local image
if self.released then
image = '[[File:Albino Rhoa Feather inventory icon.png|48px|alt=|link=]]'
else
image = '[[File:Divination card inventory icon.png|48px|alt=|link=]]'
end
return image
end
function m:getCategories()
local cat
if self.released then
cat = util.misc.add_category('Newly released content')
else
cat = util.misc.add_category('Upcoming content')
end
return cat
end
----------------------------------------------------------------------------
-- main() - Implements Template:New content
----------------------------------------------------------------------------
function p.main(frame)
local args = getArgs(frame, {
parentFirst = true
})
gFrame = frame
return p._main(args)
end
function p._main(args)
local frame = util.misc.get_frame(gFrame)
args = args or {}
args.version = args.version or args[1]
if type(args.version) ~= 'string' then -- Version is required
error(string.format('Argument "%s" is required', 'version'))
end
args.part = args.part or args[2]
args.space = args.space or frame:expandTemplate{title = 'SUBJECTSPACE formatted'}
local now = os.date('!%F %T') -- Current UTC timestamp in Y-m-d H:i:s format
local version = cargo.query( -- Query specified version with release date before current date
'versions',
'_pageName',
{
where = string.format('version = "%s" AND release_date < "%s"', util.cast.version(args.version, {return_type = 'string'}), now),
limit = 1,
groupBy = '_pageID',
}
)
return m:new(args.version, #version > 0, args.part, args.space, args.talk)
end
return p