"ഘടകം:Asbox" എന്ന താളിന്റെ പതിപ്പുകൾ തമ്മിലുള്ള വ്യത്യാസം

Content deleted Content added
imported>Codehydro
(ചെ.) minor copyedit of comments; code should now be in a mature form
imported>Codehydro
moved share initialization for p.main and p.templatepage to p.init; other minor changes
വരി 1:
local p = {
cats = {inv = {}}
local WRAPPER_TEMPLATE = 'Template:Asbox'
local args, stubCats
local p = {
cats = {inv = {}},
--initializes variables required by both p.main and p.templatepage
init = function(self, frame, page)
args = args or require('Module:Arguments').getArgs(frame, {
wrappers = WRAPPER_TEMPLATE
})
page = page or mw.title.getCurrentTitle()
--Ensures demo parameter will never affect article spacecategory() output. Necessaryfor because demo now affects category()articles
p self.demo = pself.demo or page.namespace ~= 0 and args.demo or nil
return args, page
end
 
--[[
Line 15 ⟶ 25:
[1] = full category name; defaults to local attention if blank
k = Category sort key. Prefix before v.t
t = page.text or args.tempsort#; appended after k (or in its place if omitted;). t is requiredRequired if v is not a string
Basically the same as v = (v[1] or attention) .. ' | ' .. (v.k or '') .. v.t
]] link = string.format(
Line 122 ⟶ 132:
--Includes standard stub documention and flags stub templates with bad parameter values.
function p.templatepage(frame, page)
args, page = args or require('Modulep:Arguments').getArgsinit(frame, {page)
wrappers = WRAPPER_TEMPLATE
})
page = page or mw.title.getCurrentTitle()
p.demo = p.demo or page.namespace ~= 0 and args.demo or nil
local tStubDoc = mw.title.new'Template:Stub documentation'
local pageDoc = mw.title.new(page.fullText .. '/doc')
--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 ombox{--Show ombox warnings for missing args. Ombox for args with non-existing categories is in catStub()
ifNot = args.category,
'The <code>|category</code> parameter is not set. Please add an appropriate stub category.',
Line 141 ⟶ 147:
{k = 'D', t = page.text}
}
--catStub() may 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',
Line 197 ⟶ 204:
 
function p.main(frame, page)
args, page = args or require('Modulep:Arguments').getArgsinit(frame, {page)
wrappers = WRAPPER_TEMPLATE
})
page = page or mw.title.getCurrentTitle()
--Ensures demo parameter will never affect article space output. Necessary because demo now affects category()
p.demo = p.demo or page.namespace ~= 0 and args.demo or nil
local output = mw.html.create()
:tag'table'
Line 208 ⟶ 210:
:css('background', 'transparent')
:attr('role', 'presentation')
:tag'tr'
:node((args.icon or args.image) and
mw.html.create'td'
:wikitext(args.icon or string.format(
'[[File:%s|%spx|alt=%s]]',
args.image,
args.pix or '40x30',
args.imagealt or 'Stub icon'
))
)
:node(tag'td'
mw.html.create'td'
:tag'i'
:wikitext(string.format(
Line 227 ⟶ 229:
page:fullUrl('action=edit', 'relative')
))
:done()
:wikitext(args.name and
require('Module:Navbar')._navbar{
Line 243 ⟶ 245:
:css('font-size', 'smaller')
:wikitext(args.note)
:done()
)
:allDone()
:done()
--[[
Stub categories for templates include a sort key (Otherwise all will be indexed under the letter 'T' for 'Template:[] stubs')
"https://ml.wikipedia.org/wiki/ഘടകം:Asbox" എന്ന താളിൽനിന്ന് ശേഖരിച്ചത്