మాడ్యూల్:Protection banner: కూర్పుల మధ్య తేడాలు

Content deleted Content added
చి Changed protection level of Module:Protection banner: High-risk Lua module: request at my talk page ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite))
bring changes from sandbox live
పంక్తి 20:
 
local function makeCategoryLink(cat, sort)
elseifif cat then
local nsText = mw.site.namespaces[14].name
if cat and sort then
return string.format(
'[[%s:%s|%s]]',
local nsText = mw.site.namespaces[14].name,
nsText,
cat,
sort
)
elseif cat then
return string.format(
'[[%s:%s]]',
nsText,
cat
)
else
return ''
end
end
Line 41 ⟶ 32:
-- Validation function for the expiry and the protection date
local function validateDate(dateString, dateType)
langif =not lang orthen
lang = mw.language.getContentLanguage()
end
local success, result = pcall(lang.formatDate, lang, 'U', dateString)
if success then
Line 50 ⟶ 43:
end
error(string.format(
'invalid %s: ("%s")',
dateType,
tostring(dateString)
Line 64 ⟶ 57:
end
 
-- Given a directed graph formatted as node -> table of direct successors,
local function toTableEnd(t, pos)
-- get a table of all nodes reachable from a given node (though always
-- Sends the value at position pos to the end of array t, and shifts the
-- including the given node).
-- other items down accordingly.
local function toTableEndgetReachableNodes(tgraph, posstart)
return table.insert(t, table.remove(t, pos))
end
 
local function walkHierarchy(hierarchy, start)
local toWalk, retval = {[start] = true}, {}
while true do
-- Can't use pairs() since we're adding and removing things as we're iterating
local k = next(toWalk) -- This always gets the "first" key
if k == nil then break end
return ''retval
end
toWalk[k] = nil
retval[k] = true
for _,v in ipairs(hierarchygraph[k]) do
if not retval[v] then
toWalk[v] = true
Line 84 ⟶ 76:
end
end
return retval
end
 
Line 122 ⟶ 113:
else
error(string.format(
'invalid action: ("%s")',
tostring(args.action)
), 3)
Line 214 ⟶ 205:
 
-- Get the namespace key fragment.
local namespaceFragment = cfg.categoryNamespaceKeys[title.namespace]
if not namespaceFragment and title.namespace % 2 == 1 then
do
namespaceFragment = cfg.categoryNamespaceKeys[title.namespace]'talk'
if not namespaceFragment and title.namespace % 2 == 1 then
namespaceFragment = 'talk'
end
end
Line 244 ⟶ 232:
-- instead.
--]]
iftable.insert(order, table.remove(order, self.reason and cfg.reasonsWithNamespacePriority[self.reason] thenand 2 or 3))
-- table.insert(order, 3, table.remove(order, 2))
toTableEnd(order, 2)
else
toTableEnd(order, 3)
end
--[[
Line 495 ⟶ 478:
if level == 'autoconfirmed' then
requestType = 'semi'
elseif level == 'extendedconfirmed' then
requestType = 'extended'
elseif level == 'templateeditor' then
requestType = 'template'
Line 761 ⟶ 746:
end
return setmetatable(obj, BannerTemplate)
end
 
function BannerTemplate:setImageWidth(width)
self._imageWidth = width
end
 
function BannerTemplate:setImageTooltip(tooltip)
self._imageCaption = tooltip
end
 
Line 777 ⟶ 754:
return makeFileLink{
file = filename,
size = (self._imageWidthimageWidth or 20) .. 'px',
alt = self._imageAlt,
link = self._imageLink,
caption = self._imageCaptionimageCaption
}
end
Line 793 ⟶ 770:
function Banner.new(protectionObj, blurbObj, cfg)
local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn't need the blurb.
obj:setImageWidth(.imageWidth = 40)
obj:setImageTooltip(.imageCaption = blurbObj:makeBannerText('alt')) -- Large banners use the alt text for the tooltip.
obj._reasonText = blurbObj:makeBannerText('text')
obj._explanationText = blurbObj:makeBannerText('explanation')
Line 828 ⟶ 805:
function Padlock.new(protectionObj, blurbObj, cfg)
local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn't need the blurb.
obj:setImageWidth(.imageWidth = 20)
obj:setImageTooltip(.imageCaption = blurbObj:makeBannerText('tooltip'))
obj._imageAlt = blurbObj:makeBannerText('alt')
obj._imageLink = blurbObj:makeBannerText('link')
Line 841 ⟶ 818:
local frame = mw.getCurrentFrame()
-- The nowiki tag helps prevent whitespace at the top of articles.
local nowiki =return frame:extensionTag{name = 'nowiki'} .. frame:extensionTag{
local indicator = frame:extensionTag{
name = 'indicator',
args = {name = self._indicatorName},
content = self:renderImage()
}
return nowiki .. indicator
end
 
Line 880 ⟶ 855:
if protectionObj.action == 'edit' or
args.demolevel or
not walkHierarchygetReachableNodes(
cfg.hierarchy,
protectionObj.level
"https://te.wikipedia.org/wiki/మాడ్యూల్:Protection_banner" నుండి వెలికితీశారు