"ഘടകം:Asbox" എന്ന താളിന്റെ പതിപ്പുകൾ തമ്മിലുള്ള വ്യത്യാസം
Content deleted Content added
imported>Codehydro actually, I think what was missing was the space in front |
imported>Codehydro simplify concatenation using Module:Buffer (Asbox is the first to use); more comments; fix minor bug when both icon and image params were omitted |
||
വരി 2:
local args, stubCats
local p = {}
local buffer = require('Module:Buffer')
--initializes variables required by both p.main and p.templatepage
function p:init(frame, page)
Line 11 ⟶ 12:
self.demo = self.demo or page.namespace ~= 0 and args.demo or nil
return args, page
end▼
return self▼
end
Line 41 ⟶ 36:
Basically the same as v = (v[1] or attention) .. ' | ' .. (v.k or '') .. v.t
]]
if v and v ~= true then--reject v = nil, false, or true
link = ('[[%sCategory:%s]]'
p.demo and ':' or '',
type(v) == type'' and
or (p.demo and '%s|Category:%s|%s' or '%s|%s%s'
v[1] or attention,
p.demo and (v[1] or attention) or v.k or '', p.demo and ((v.k or '') .. v.t) or v.t
)
p.cats[link] = true▼
)▼
▲ end
▲ p.cats[link] = true
end
return cat.done and table.concat(p.cats, p.demo and ' | ' or nil) or ''
Line 62 ⟶ 59:
]]
local function ombox(v)
if v.ifNot then return end
p.ombox = p.ombox or require('Module:Message box').ombox
category{v[2]}
Line 79 ⟶ 74:
local function catStub(page, pageDoc)
stubCats = {missing = {}, v = {}}
local code
for k, _ in pairs(args) do
--Find category parameters and store the number (main cat = '')
Line 89 ⟶ 85:
--Do not place in main category if |tempsort = 'no'; For example, if stub template merely
--adds |qualifier= to a meta stub and |category#= to a sub-category of meta's main category
if tonumber(v
--p.templatepage passes page; p.main does not, i.e. articles are categorized without sort keys.
table.insert(stubCats.v, page and
(tsort and {cat, k = ' ', t = tsort} or {cat, k = ' *', t = page.text})--space
or cat
)
Line 99 ⟶ 95:
if page then
if not mw.title.new('Category:' .. cat).exists then
code = code or mw.html.create'code':wikitext'|category'
table.insert(stubCats.missing,
end
--[[
Line 107 ⟶ 104:
(presumably, this doc would have an explanation as to why the main stub cat is non-conforming).
]]
table.insert(stubCats.v, v == '' and not p.demo and pageDoc.exists and
▲ 'Stub message templates with documentation subpages'
▲ or not string.match(cat, ' stubs$') and {k = 'S', t = page.text}
)
end
Line 135 ⟶ 130:
end
for _, v in ipairs(stubCats) do
table.insert(wikitext,
v and args['category' .. v] or '{{{category}}}',
v and mw.site.stats.pagesInCategory(args['category' .. v], 'all') or 0
Line 151 ⟶ 145:
--Reorganization note: Original Asbox alternates between outputting categories and checking on params |category#=.
--Rather than checking multiple times and switching tasks, all stub category param operations have been rolled into catStub()
category'Stub message templates using icon parameter'▼
elseif args.image then▼
if not mw.title.new('Media:' .. mw.text.split(args.image, '|')[1]).exists then▼
category{k = 'B', t = page.text}▼
category'Stub message templates without images'▼
▲ :_(ombox{--Show ombox warnings for missing args.
ifNot = args.category,
'The <code>|category</code> parameter is not set. Please add an appropriate stub category.',
Line 171 ⟶ 156:
{k = 'D', t = page.text}
})
:_(catStub(page, pageDoc))--catStub() may also return an ombox if there are non-existing categories
:_(category{
done = p.demo ~= 'doc',--Outputs categories if not doc demo
'Stub message templates',
'Exclude in print',
args.
▲
▲ )
args.imagealt and {k = 'I', t = page.text},
})
:_((not p.demo or p.demo == 'doc') and--Add standard stub template documentation
require('Module:Documentation').main{
▲ :_(page.text ~= 'Stub' and--This comparison performed in {{Asbox/stubtree}} before it invokes Module:Asbox stubtree
require('Module:Asbox stubtree').subtree{args = {pagename = page.text}}
)
:
:_'. It uses {{[[Template:Asbox|asbox]]}}, which is a meta-template designed to ease the process of creating and maintaining stub templates.\n=== Usage ===\nTyping
:_(mw.html.create'
:
▲ :_'. It uses {{[[Template:Asbox|asbox]]}}, which is a meta-template designed to ease the process of creating and maintaining stub templates.\n=== Usage ===\nTyping <code>{{'
'stub'▼
)
:_'
:_(#stubCats > 1 and 'ies' or 'y')
:_':\n'
Line 203 ⟶ 189:
:_'\n== General information ==\n'
:_(frame:expandTemplate{title = tStubDoc.text})
:_'\n\n'(),
['link box'] = buffer'This documentation is automatically generated by [[Module:Asbox]].'
:_in'The general information is transcluded from [[Template:Stub documentation]]. '
:_(
:cssText'
tStubDoc:fullUrl('action=
▲ ))
:_(page.protectionLevels.edit[1] == 'sysop' and
▲ " <br/>This template is [[WP:PROTECT|fully protected]] and any [[WP:CAT|categories]] should be added to the template's [",
▲ pageDoc:fullUrl('action=edit&preload=Template:Category_interwiki/preload', 'relative'),
▲ '| /doc] subpage, which is not protected.'
▲ )
}
)()
end
Line 228 ⟶ 213:
local output = mw.html.create()
:tag'table'
:addClass
:css
:attr
:tag'tr'
:node((args.icon or args.image) and
mw.html.create'td'
:wikitext(args.icon or
args.image or '
args.pix or '40x30',
args.imagealt or 'Stub icon'
Line 243 ⟶ 227:
:tag'td'
:tag'i'
:wikitext
buffer'This':_(args.subject):_(args.article or 'article'):_(args.qualifier)' ',--space
'
▲ page:fullUrl('action=edit', 'relative')
▲ ))
:done()
:
require
args.name,
mini = 'yes',
style = 'position: absolute; right: 15px; display: none;'
}
)
:node(args.note and
mw.html.create
:tag'br':done()
:
▲ :css('font-style', 'normal')
▲ :done()
)
:allDone()
|