Module:Asbox: Difference between revisions
Jump to navigation
Jump to search
per request
m (1 revision imported) |
(per request) |
||
Line 12: | Line 12: | ||
--]] | --]] | ||
local WRAPPER_TEMPLATE, args = 'Template:Asbox' | local WRAPPER_TEMPLATE, args = 'Template:Asbox' | ||
local templatestyles = 'Asbox/styles.css' | |||
local p, Buffer, stubCats = { | local p, Buffer, stubCats = { | ||
--Prevents dupli-cats... get it? Maybe not? | --Prevents dupli-cats... get it? Maybe not? | ||
Line 77: | Line 78: | ||
local function catStub(page, pageDoc) | local function catStub(page, pageDoc) | ||
stubCats = {missing = {}, v = {}} | stubCats = {missing = {}, v = {}} | ||
disallowedUnicodeChars = '[^%w%p%s]' -- for i18n we make this a separate string | |||
local code | local code | ||
for k, _ in pairs(args) do | for k, _ in pairs(args) do | ||
Line 85: | Line 87: | ||
for k, v in ipairs(stubCats) do | for k, v in ipairs(stubCats) do | ||
--Get category names and, if called by p.templatepage, the optional sort key | --Get category names and, if called by p.templatepage, the optional sort key | ||
local tsort, cat = args['tempsort' .. v], mw.ustring.gsub(args['category' .. v], | local tsort, cat = args['tempsort' .. v], mw.ustring.gsub(args['category' .. v], disallowedUnicodeChars, '')--remove all hidden unicode chars | ||
--Do not place template in main category if |tempsort = 'no'. However, DO place articles of that template in the main category. | --Do not place template in main category if |tempsort = 'no'. However, DO place articles of that template in the main category. | ||
table.insert(stubCats.v, | table.insert(stubCats.v, | ||
Line 214: | Line 216: | ||
function p.main(frame, page) | function p.main(frame, page) | ||
args, page = p:init(frame, page) | args, page = p:init(frame, page) | ||
local output = mw.html.create' | local output = mw.html.create'div' | ||
:addClass'metadata plainlinks stub' | :attr{role = 'note'} | ||
: | :addClass'metadata plainlinks asbox stub' | ||
:tag'table' | |||
:attr{role = 'presentation'} | |||
:tag'tr' | |||
:addClass'noresize' | |||
:node((args.icon or args.image) and | |||
mw.html.create'td' | |||
:wikitext(args.icon or ('[[File:%s|%spx|alt=%s]]'):format( | |||
args.image or '', | |||
args.pix or '40x30', | |||
args.imagealt or 'Stub icon' | |||
)) | |||
) | |||
:tag'td' | |||
:tag'p' | |||
:addClass'asbox-body' | |||
:wikitext( | |||
Buffer'This':_(args.subject):_(args.article or 'article'):_(args.qualifier)' ',--space | |||
' is a [[Wikipedia:stub|stub]]. You can help Wikipedia by [', | |||
page:fullUrl('action=edit', 'relative'), | |||
' expanding it].' | |||
) | |||
:done() | |||
:node(args.note and | |||
mw.html.create() | |||
:tag'p' | |||
:addClass'asbox-note' | |||
:wikitext(args.note) | |||
:done() | |||
) | ) | ||
:allDone() | :allDone() | ||
:node(args.name and | |||
require'Module:Navbar'._navbar{ | |||
args.name, | |||
mini = 'yes', | |||
} | |||
) | |||
--[[ | --[[ | ||
Stub categories for templates include a sort key; this ensures that all stub tags appear at the beginning of their respective categories. | Stub categories for templates include a sort key; this ensures that all stub tags appear at the beginning of their respective categories. | ||
Line 282: | Line 285: | ||
end | end | ||
end | end | ||
return output:wikitext(not p.demo and category{done = true} or nil) | return frame:extensionTag{ name = 'templatestyles', args = { src = templatestyles} } .. tostring(output:wikitext(not p.demo and category{done = true} or nil)) | ||
end | end | ||
return p | return p |