![]() | This Lua module is used on approximately 2,370,000 pages, or roughly 4% of all pages. To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them. |
![]() | This module is rated as ready for general use. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing. |
![]() | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
![]() | This module is rated as ready for general use. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing. |
![]() | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
![]() | This module depends on the following other modules: |
![]() | This module uses TemplateStyles: |
Usage
This module implements the {{Asbox}} template. Please see the template page for usage instructions.
Acknowledgements
In addition to the contributors listed in the contribution histories of Template:Asbox and Module:Asbox, this module also implements ideas from the deleted Template:Asbox/templatepage, which primary author is User:MSGJ and included code contributions from User:WOSlinker, and User:Od_Mishehu.
Tracking category
local WRAPPER_TEMPLATE = 'Template:Asbox'
local p = {}
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame, {
wrappers = WRAPPER_TEMPLATE
})
local output = mw.html.create('table')
local page = mw.title.getCurrentTitle()
output
:addClass('metadata plainlinks stub')
:css('background','transparent')
:attr('role','presentation')
if args.icon or args.image then
output
:tag('td'):wikitext(args.icon or string.format(
'[[File:%s|%spx|alt=%s]]',
args.image,
args.pix or '40x30',
args.imagealt or 'Stub icon'
))
end
local buffer = output:tag('td')
buffer
:tag('i')
:wikitext(string.format(
'This %s %s %s is a [[Wikipedia:stub|stub]]. You can help Wikipedia by [%s expanding it].',
args.subject or '',
args.article or 'article',
args.qualifier or '',
page:fullUrl('action=edit', 'relative')
))
if args.name then
buffer
:wikitext(require('Module:Navbar')._navbar{
args.name,
mini = 'yes',
style = 'position: absolute; right: 15px; display: none;'
})
end
if args.note then
buffer:tag('br')
buffer
:tag('span')
:css('font-style', 'normal')
:css('font-size', 'smaller')
:wikitext(args.note)
end
output = tostring(output)
if page.namespace == 0 then -- Main namespace
output = output .. '[[Category:All stub articles]]'
for k,v in pairs(args) do
if string.match(k, '^category%d*$') then
output = output .. string.format('[[Category:%s]]', v)
end
end
end
-- Instead of the title check you do here, see if the parent frame's title is the same as the current page's title.
if not args.demo and page.basePageTitle ~= WRAPPER_TEMPLATE then
--mw.title.new('') is always nil. This is intentional and matches the results of original {{FULLPAGENAME:{{{name|}}}}}
if mw.title.new(args.name or '') == page then
-- You should probably convert Template:Asbox/templatepage to Lua too.
-- Do it in this module, in a function called templatepage.
output = output .. frame:expandTemplate{
title = 'Asbox/templatepage',
args = args
}
elseif not page.isSubpage and page.namespace == 10 then -- Template namespace and not a subpage
output = output .. string.format(
'[[Category:Stub message templates needing attention|%s]]',
(args.name and 'E' or 'W') .. page.text
)
end
end
return output
end
return p