Module:Effective protection level: Difference between revisions

From NvWiki
Jump to navigation Jump to search
Handle gadget page
 
Line 1: Line 1:
local p = {}
== Pending changes ==
-- Returns the permission required to perform a given action on a given title.
{{ping|Jackmcbarn}} As part of my work on a {{tl|pp-meta}} replacement I need a function to detect the pending change level of a page. And I thought that this module would be as good a place to put that function as any. I've had a go at adapting the module in the [[Module:Effective protection level/sandbox|sandbox]] - let me know what you think. '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr. Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪ talk ♪]]</sup> 00:51, 26 March 2014 (UTC)
-- If no title is specified, the title of the page being displayed is used.
:{{ping|Mr. Stradivarius}} I've made some adjustments to it. How is it now? [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 21:19, 27 March 2014 (UTC)
function p._main(action, pagename)
::Looks good, thanks for making the changes. Putting pending changes detection in the main function does seem easier. Also, I didn't know pending changes could be activated on a page but not be limited to reviewing by autoconfirmed or reviewer users. You learn something new every day. :) '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr. Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪ talk ♪]]</sup> 02:47, 28 March 2014 (UTC)
local title
:::Well technically, that's one of those things that the software can do but isn't set up to work here on enwp. Anyway, I'm adding it to the live version then. [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 01:06, 30 March 2014 (UTC)
if type(pagename) == 'table' and pagename.prefixedText then
title = pagename
elseif pagename then
title = mw.title.new(pagename)
else
title = mw.title.getCurrentTitle()
end
pagename = title.prefixedText
if action == 'autoreview' then
local level = mw.ext.FlaggedRevs.getStabilitySettings(title)
level = level and level.autoreview
if level == 'review' then
return 'reviewer'
elseif level ~= '' then
return level
else
return nil -- not '*'. a page not being PC-protected is distinct from it being PC-protected with anyone able to review. also not '', as that would mean PC-protected but nobody can review
end
elseif action ~= 'edit' and action ~= 'move' and action ~= 'create' and action ~= 'upload' and action ~= 'undelete' then
error( 'First parameter must be one of edit, move, create, upload, undelete, autoreview', 2 )
end
if title.namespace == 8 then -- MediaWiki namespace
if title.text:sub(-3) == '.js' or title.text:sub(-4) == '.css' or title.contentModel == 'javascript' or title.contentModel == 'css' then -- site JS or CSS page
return 'interfaceadmin'
elseif title.baseText == "Gadgets-definition" then
return 'interfaceadmin'
else -- any non-JS/CSS MediaWiki page
return 'sysop'
end
elseif title.namespace == 2 and title.isSubpage then
if title.contentModel == 'javascript' or title.contentModel == 'css' then -- user JS or CSS page
return 'interfaceadmin'
elseif title.contentModel == 'json' then -- user JSON page
return 'sysop'
end
end
if action == 'undelete' then
return 'sysop'
end
local level = title.protectionLevels[action] and title.protectionLevels[action][1]
if level == 'sysop' or level == 'editprotected' then
return 'sysop'
elseif title.cascadingProtection.restrictions[action] and title.cascadingProtection.restrictions[action][1] then -- used by a cascading-protected page
return 'sysop'
elseif level == 'templateeditor' then
return 'templateeditor'
elseif action == 'move' then
local blacklistentry = mw.ext.TitleBlacklist.test('edit', pagename) -- Testing action edit is correct, since this is for the source page. The target page name gets tested with action move.
if blacklistentry and not blacklistentry.params.autoconfirmed then
return 'templateeditor'
elseif title.namespace == 6 then
return 'filemover'
elseif level == 'extendedconfirmed' then
return 'extendedconfirmed'
else
return 'autoconfirmed'
end
end
local blacklistentry = mw.ext.TitleBlacklist.test(action, pagename)
if blacklistentry then
if not blacklistentry.params.autoconfirmed then
return 'templateeditor'
elseif level == 'extendedconfirmed' then
return 'extendedconfirmed'
else
return 'autoconfirmed'
end
elseif level == 'editsemiprotected' then -- create-semiprotected pages return this for some reason
return 'autoconfirmed'
elseif level then
return level
elseif action == 'upload' then
return 'autoconfirmed'
elseif action == 'create' and title.namespace % 2 == 0 and title.namespace ~= 118 then -- You need to be registered, but not autoconfirmed, to create non-talk pages other than drafts
if title.namespace == 0 then
return 'autoconfirmed' -- Per [[WP:ACPERM]], you need to be autoconfirmed to create pages in mainspace
end
return 'user'
else
return '*'
end
end


setmetatable(p, { __index = function(t, k)
== JSON ==
return function(frame)
return t._main(k, frame.args[1])
end
end })


return p
{{ping|Jackmcbarn}} It looks like we need to add .json user pages to this module judging from [[Special:PermaLink/833861777#Tech News: 2018-14|this week's tech news]]. The protection doesn't appear to be in force yet, though. I think [https://en.wikipedia.org/w/index.php?title=Special%3AComparePages&page1=Module%3AEffective+protection+level&page2=Module%3AEffective+protection+level%2Fsandbox this edit] should do the trick - do you see any issues with it? Best — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr.&nbsp;Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪&nbsp;talk&nbsp;♪]]</sup> 11:35, 3 April 2018 (UTC)
:I went ahead and made the edit. — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr.&nbsp;Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪&nbsp;talk&nbsp;♪]]</sup> 11:55, 6 April 2018 (UTC)
 
== Protected edit request on 11 September 2025 ==
 
{{edit fully-protected|Module:Effective protection level|answered=yes}}
Set [[MediaWiki:Gadgets-definition]] <s>and subpages</s> returns <code>interfaceadmin</code>. [[User:Dabao qian|Dabao qian]] ([[User talk:Dabao qian|talk]]) 18:35, 11 September 2025 (UTC)
 
:My edit request in zhwiki changes Line 29 to <syntaxhighlight lang="lua">if title.text:sub(-3) == '.js' or title.text:sub(-4) == '.css' or title.text == 'Gadgets-definition' or title.contentModel == 'javascript' or title.contentModel == 'css' then -- site JS or CSS page</syntaxhighlight> [[User:Srapoj|Srapoj]] ([[User talk:Srapoj|talk]]) 19:44, 11 September 2025 (UTC)
:: {{done}} [[User:Pppery|* Pppery *]] [[User talk:Pppery|<sub style="color:#800000">it has begun...</sub>]] 02:37, 25 September 2025 (UTC)

Revision as of 02:37, 25 September 2025

Pending changes

Template:Ping As part of my work on a {{pp-meta}} replacement I need a function to detect the pending change level of a page. And I thought that this module would be as good a place to put that function as any. I've had a go at adapting the module in the sandbox - let me know what you think. — Mr. Stradivarius ♪ talk ♪ 00:51, 26 March 2014 (UTC)

Template:Ping I've made some adjustments to it. How is it now? Jackmcbarn (talk) 21:19, 27 March 2014 (UTC)
Looks good, thanks for making the changes. Putting pending changes detection in the main function does seem easier. Also, I didn't know pending changes could be activated on a page but not be limited to reviewing by autoconfirmed or reviewer users. You learn something new every day. :) — Mr. Stradivarius ♪ talk ♪ 02:47, 28 March 2014 (UTC)
Well technically, that's one of those things that the software can do but isn't set up to work here on enwp. Anyway, I'm adding it to the live version then. Jackmcbarn (talk) 01:06, 30 March 2014 (UTC)

JSON

Template:Ping It looks like we need to add .json user pages to this module judging from this week's tech news. The protection doesn't appear to be in force yet, though. I think this edit should do the trick - do you see any issues with it? Best — Mr. Stradivarius ♪ talk ♪ 11:35, 3 April 2018 (UTC)

I went ahead and made the edit. — Mr. Stradivarius ♪ talk ♪ 11:55, 6 April 2018 (UTC)

Protected edit request on 11 September 2025

Template:Edit fully-protected Set MediaWiki:Gadgets-definition and subpages returns interfaceadmin. Dabao qian (talk) 18:35, 11 September 2025 (UTC)

My edit request in zhwiki changes Line 29 to
if title.text:sub(-3) == '.js' or title.text:sub(-4) == '.css' or title.text == 'Gadgets-definition' or title.contentModel == 'javascript' or title.contentModel == 'css' then -- site JS or CSS page
Srapoj (talk) 19:44, 11 September 2025 (UTC)
Template:Done * Pppery * it has begun... 02:37, 25 September 2025 (UTC)