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

Content deleted Content added
imported>Codehydro
(ചെ.) irrelevant class name from template:param
imported>Codehydro
comments and some code simplification
വരി 9:
end
 
--Formats category links. Stores them until called with cat.done=true
--Takes multiple or single categories in the form of 'cat' or {'cat1', 'cat2', {'cat3', 'sort3'}}
--If it finds a category name of length 1, assumes it is a sort key.
--Such keys must always be paired in a table {{'cat', 'sort'}}
local attention = 'Stub message templates needing attention'
function category(cat)--{{'cat', 'sort'}, 'cat2'} or 'cat'
for _, v in ipairs(type(cat) == type'' and {cat} or cat) do
p.key = string.format(
'[[%sCategory:%s]]',
demo(':', ''),
--All user-inputed cats are always paired with a sort key
--Since all non-user cat are longer than 2 chars, we can
--compare length instead of checking type
#v > 2 and v or string.format(
demo('%s|Category:%s|%s', '%s|%s%s'),
Line 30 ⟶ 37:
end
 
--Makes an ombox warning; will return an empty string instead
--if optional v.ifNot is true
function ombox(v)--{text, {subcat, page}}
if v.ifNot then
Line 41 ⟶ 50:
}
end
 
 
function catStub(page, pageDoc)--p.templatepage passes page; p.main does not
Line 48 ⟶ 58:
v = {}
}
--Find category parameters and store the number (main cat = '')
for k, _ in pairs(args) do
table.insert(stubCats, string.match(k, '^category(%d*)$'))
Line 54 ⟶ 65:
local cat, tsort
for k, v in ipairs(stubCats) do
--Get category names and, if called by p.templatepage, the optional sort key
cat = args['category' .. v]
tsort = args['tempsort' .. v]
--Does not place in main category if |tempsort = 'no'
--For example, if stub template simply adds |qualifier= to a meta stub
--and includes a |category#= to a sub-category of the main category
if v ~= '' or tsort ~= 'no' then
table.insert(stubCats.v, {cat, page and (tsort or ('*' .. page.text))})
end
if page then
--Check category existance
--This check is only performed on the template page
--since it uses an expensive parser function
if not mw.title.new('Category:' .. cat).exists then
table.insert(stubCats.missing, '<code>category' .. v .. '</code>')
end
table.insert(stubCats.v,
--Only check for docs if main |category= is set and flags if present.
--Main categories with no docs and all numbered categories
--are checked for proper naming and flagged if not
v == '' and pageDoc.exists and
'Stub message templates with documentation subpages'
Line 71 ⟶ 92:
end
end
--Add category names after loop is completed
if #stubCats.missing > 0 then
stubCats.missed = {}
for k, meowFeedMe in ipairs(stubCats.missing) do
table.insert(stubCats.missed, '<code>|' .. meowFeedMe .. '</code>')
end
end
category(stubCats.v)
--Out params set to non-categories with <code> tags to ombox
return stubCats.missed and ombox{
ifreturn #stubCats.missing >and 0 thenombox{
--Changed, original msg: One or more of the stub categories defined in this template do not seem to exist! Please double-check the parameters {{para|category}}, {{para|category1}} and {{para|category2}}.
'The following parameter' .. (#stubCats.missing == 1 and ' defines a stub category that does' or 's define stub categories that do') .. ' not exist: ' .. mw.text.listToText(stubCats.missedmissing),
{'N', page.text}
} or ''
end
 
--Shows population of categories found by catStub()
--Outputs demo values if there are none
function population()
local wikitext, base = '', '* [[:Category:%s]] (population: (%s)\n'
Line 96 ⟶ 115:
end
 
function p.templatepage(frame, page)--flagsFlags bad stub templates and creates standard doc page
function p.templatepage(frame, page)
local tStubDoc = mw.title.new('Template:Stub documentation')
local pageDoc = mw.title.new(page.fullText .. '/doc')
Line 103 ⟶ 123:
wrappers = WRAPPER_TEMPLATE
})
return category{
'Stub message templates',
'Exclude in print',
Line 120 ⟶ 140:
args.imagealt and {'I', page.text} or nil
}
--Show ombox warnings and check for bat stub categories
.. ombox{
return stubCats.missed and ombox{
ifNot = args.category,
'The <code>|category</code> parameter is not set. Please add an appropriate stub category.',
Line 131 ⟶ 152:
}
.. catStub(page, pageDoc)
--Add standard stub template documentation
.. ((args.demo and args.demo ~= 'doc' and '') or (require('Module:Documentation').main{
content =
Line 166 ⟶ 188:
)
}
--Output categories when done.
.. (args.demo ~= 'doc' and category{done = true} or '')))
end
 
--The template as it appears on articles.
function p.main(frame, page)
page = page or mw.title.getCurrentTitle()
Line 215 ⟶ 239:
--Preview categories; not in original template, but shouldn't hurt
p.templatepage(frame, page)
table.sort(p.cats)
output:wikitext(string.format('<small>Demo categories: %s</small>', category{done = true}))
else
"https://ml.wikipedia.org/wiki/ഘടകം:Asbox" എന്ന താളിൽനിന്ന് ശേഖരിച്ചത്