"ഘടകം: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
function p:insert(v)
if v then
table.insert(self, v)
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 = string.format(
link = ('[[%sCategory:%s]]',):format(
p.demo and ':' or '',
type(v) == type'' and v or string.format(
)v
or (p.demo and '%s|Category:%s|%s' or '%s|%s%s',):format(
v[1] or attention,
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
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 ~= '') or tsort ~= 'no' then
--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, '<tostring(mw.clone(code>category' .. ):wikitext(v .. '</code>')))
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'
v == '' and not p.demo and pageDoc.exists and
or not string.match(cat, ' stubs$') and {k = 'S', t = page.text}
'Stub message templates with documentation subpages'
or not string.match(cat, ' stubs$') and {k = 'S', t = page.text}
or nil
)
end
Line 135 ⟶ 130:
end
for _, v in ipairs(stubCats) do
table.insert(wikitext, string.base:format(
base,
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()
return selfbuffer(
if args.icon then
:_(ombox{--Show ombox warnings for missing args.
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}
end
else
category'Stub message templates without images'
end
return table.concat(({_ = p.insert})
:_(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
:_(catStub(page, pageDoc))
:_(category{
done = p.demo ~= 'doc',--Outputs categories if not doc demo
'Stub message templates',
'Exclude in print',
args.imagealticon and {k = 'I', t = page.text} or nil
category 'Stub message templates using icon parameter'
elseif or args.image thenand (
if not mw.title.new('Media:' .. mw.text.split(args.image, '|')[1]).exists--do nothing if exists. category() will reject thentrue
category or {k = 'B', t = page.text}
)
category or 'Stub message templates without images',
args.imagealt and {k = 'I', t = page.text},
})
:_((not p.demo or p.demo == 'doc') and--Add standard stub template documentation; demo calls will not call Module:Documentation unless p.demo = 'doc'
require('Module:Documentation').main{
:_content = buffer(page.text ~= 'Stub' and--This comparison performed in {{Asbox/stubtree}} before it invokes Module:Asbox stubtree
content = table.concat(({_ = p.insert})
:_(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}}
)
:__in'\n== About this template ==\nThis template is used to identify a':_(args.subject):_'stub':_(args.qualifier):_out' '--space
:_'. 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>{{'
:_(args.subject)
:_(mw.html.create' stubcode'
:_wikitext(args'{{', page.qualifiertext and== 'Stub' and 'stub' ..or argspage.qualifiertext, '}}')
:_'. 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>{{'
:_(page.text == 'Stub' and
'stub'
or page.text
)
:_'}}</code> produces the message shown at the beginning, and adds the article to the following categor'
:_(#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]]. '
['link box'] = table.concat(({_ = p.insert})
:_(stringmw.format(html.create'span'
:cssText'This documentation is automatically generated by [[Template:Asbox/templatepage]].<br>The general information is transcluded from [[Template:Stub documentation]]. <span style="font-size:smaller;font-style:normal;line-height:130%%">([%s edit] | [%s history])</span>',
tStubDoc :fullUrlnode(('action=([%s edit',] 'relative| [%s history])'),:format(
tStubDoc:fullUrl('action=historyedit', 'relative'),
page tStubDoc:fullUrl('action=edithistory', 'relative')
))
'stub' ))
))
:done_out()
:_(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 [",
table.concat{
.. pageDoc:fullUrl('action=edit&preload=Template:Category_interwiki/preload', 'relative'),
" <br/>This template is [[WP:PROTECT|fully protected]] and any [[WP:CAT|categories]] should be added to the template's [",
.. '| /doc] subpage, which is not protected.'
pageDoc:fullUrl('action=edit&preload=Template:Category_interwiki/preload', 'relative'),
or)' nil<br/>'
'| /doc] subpage, which is not protected.'
}
)
)
}
)()
)
end
 
Line 228 ⟶ 213:
local output = mw.html.create()
:tag'table'
:addClass('metadata plainlinks stub')
:css('{background', = 'transparent')}
:attr('{role', = 'presentation')}
:tag'tr'
:node((args.icon or args.image) and
mw.html.create'td'
:wikitext(args.icon or string.('[[File:%s|%spx|alt=%s]]'):format(
args.image or '[[File:%s|%spx|alt=%s]]',
args.image,
args.pix or '40x30',
args.imagealt or 'Stub icon'
Line 243 ⟶ 227:
:tag'td'
:tag'i'
:wikitext(string.format(
buffer'This':_(args.subject):_(args.article or 'article'):_(args.qualifier)' ',--space
'This %s %s %s is a [[Wikipedia:stub|stub]]. You can help Wikipedia by [%s expanding it].',
args.subject or '',
args.article orpage:fullUrl('action=edit', 'articlerelative'),
args.qualifier' orexpanding it].'',
})
page:fullUrl('action=edit', 'relative')
))
:done()
:wikitextnode(args.name and
require('Module:Navbar')._navbar{
args.name,
mini = 'yes',
style = 'position: absolute; right: 15px; display: none;'
}
or nil
)
:node(args.note and
mw.html.create()'span'
:css({['font-style',] = 'normal'), ['font-size'] = 'smaller'}
:tag'br':done()
:tag'span'wikitext(args.note)
:css('font-style', 'normal')
:css('font-size', 'smaller')
:wikitext(args.note)
:done()
)
:allDone()
"https://ml.wikipedia.org/wiki/ഘടകം:Asbox" എന്ന താളിൽനിന്ന് ശേഖരിച്ചത്