Module:Protection banner/config: Difference between revisions

    From Nonbinary Wiki
    (rename category to Wikipedia fully-protected files, see Wikipedia:Categories_for_discussion/Log/2016_March_9#Category:Protected_images)
    (rename categories per WP:CFDS)
    Line 736: Line 736:
    ['all|all|reset|all|all']                = 'Wikipedia Office-protected pages',
    ['all|all|reset|all|all']                = 'Wikipedia Office-protected pages',
    ['all|all|dmca|all|all']                = 'Wikipedia Office-protected pages',
    ['all|all|dmca|all|all']                = 'Wikipedia Office-protected pages',
    ['all|all|mainpage|all|all']            = 'Protected main page images',
    ['all|all|mainpage|all|all']            = 'Wikipedia fully-protected main page images',
    ['all|template|all|all|edit']            = 'Wikipedia fully-protected templates',
    ['all|template|all|all|edit']            = 'Wikipedia fully-protected templates',
    ['all|all|all|autoconfirmed|edit']      = 'Wikipedia semi-protected pages',
    ['all|all|all|autoconfirmed|edit']      = 'Wikipedia semi-protected pages',
    Line 746: Line 746:
    ['all|all|vandalism|autoconfirmed|edit'] = 'Wikipedia pages semi-protected against vandalism',
    ['all|all|vandalism|autoconfirmed|edit'] = 'Wikipedia pages semi-protected against vandalism',
    ['all|category|all|autoconfirmed|edit']  = 'Wikipedia semi-protected categories',
    ['all|category|all|autoconfirmed|edit']  = 'Wikipedia semi-protected categories',
    ['all|file|all|autoconfirmed|edit']      = 'Semi-protected images',
    ['all|file|all|autoconfirmed|edit']      = 'Wikipedia semi-protected images',
    ['all|portal|all|autoconfirmed|edit']    = 'Semi-protected portals',
    ['all|portal|all|autoconfirmed|edit']    = 'Wikipedia semi-protected portals',
    ['all|project|all|autoconfirmed|edit']  = 'Semi-protected project pages',
    ['all|project|all|autoconfirmed|edit']  = 'Wikipedia semi-protected project pages',
    ['all|talk|all|autoconfirmed|edit']      = 'Semi-protected talk pages',
    ['all|talk|all|autoconfirmed|edit']      = 'Wikipedia semi-protected talk pages',
    ['all|template|all|autoconfirmed|edit']  = 'Wikipedia semi-protected templates',
    ['all|template|all|autoconfirmed|edit']  = 'Wikipedia semi-protected templates',
    ['all|user|all|autoconfirmed|edit']      = 'Wikipedia semi-protected user and user talk pages',
    ['all|user|all|autoconfirmed|edit']      = 'Wikipedia semi-protected user and user talk pages',
    Line 760: Line 760:
    ['all|category|all|sysop|edit']          = 'Wikipedia protected categories',
    ['all|category|all|sysop|edit']          = 'Wikipedia protected categories',
    ['all|file|all|sysop|edit']              = 'Wikipedia fully-protected files',
    ['all|file|all|sysop|edit']              = 'Wikipedia fully-protected files',
    ['all|project|all|sysop|edit']          = 'Protected project pages',
    ['all|project|all|sysop|edit']          = 'Wikipedia fully-protected project pages',
    ['all|talk|all|sysop|edit']              = 'Protected talk pages',
    ['all|talk|all|sysop|edit']              = 'Wikipedia fully-protected talk pages',
    ['all|template|all|sysop|edit']          = 'Wikipedia fully-protected templates',
    ['all|template|all|sysop|edit']          = 'Wikipedia fully-protected templates',
    ['all|user|all|sysop|edit']              = 'Wikipedia protected user and user talk pages',
    ['all|user|all|sysop|edit']              = 'Wikipedia protected user and user talk pages',

    Revision as of 20:18, 2 May 2016

    Documentation for this module may be created at Module:Protection banner/config/doc

    -- This module provides configuration data for [[Module:Protection banner]].
    
    return {
    
    --------------------------------------------------------------------------------
    --
    --                                BANNER DATA
    --
    --------------------------------------------------------------------------------
    
    --[[
    -- Banner data consists of six fields:
    -- * text - the main protection text that appears at the top of protection
    --   banners.
    -- * explanation - the text that appears below the main protection text, used
    --   to explain the details of the protection.
    -- * tooltip - the tooltip text you see when you move the mouse over a small
    --   padlock icon.
    -- * link - the page that the small padlock icon links to.
    -- * alt - the alt text for the small padlock icon. This is also used as tooltip
    --   text for the large protection banners.
    -- * image - the padlock image used in both protection banners and small padlock
    --   icons.
    --
    -- The module checks in three separate tables to find a value for each field.
    -- First it checks the banners table, which has values specific to the reason
    -- for the page being protected. Then the module checks the defaultBanners
    -- table, which has values specific to each protection level. Finally, the
    -- module checks the masterBanner table, which holds data for protection
    -- templates to use if no data has been found in the previous two tables.
    --
    -- The values in the banner data can take parameters. These are specified
    -- using ${TEXTLIKETHIS} (a dollar sign preceding a parameter name
    -- enclosed in curly braces).
    --
    --                          Available parameters:
    --
    -- ${CURRENTVERSION} - a link to the page history or the move log, with the
    -- display message "current-version-edit-display" or
    -- "current-version-move-display".
    --
    -- ${EDITREQUEST} - a link to create an edit request for the current page.
    --
    -- ${EXPIRY} - the protection expiry date in the format DD Month YYYY. If
    -- protection is indefinite or is not set, this is the blank string.
    --
    -- ${EXPLANATIONBLURB} - an explanation blurb, e.g. "Please discuss any changes
    -- on the talk page; you may submit a request to ask an administrator to make
    -- an edit if it is minor or supported by consensus."
    --
    -- ${IMAGELINK} - a link to set the image to, depending on the protection
    -- action and protection level.
    --
    -- ${INTROBLURB} - the PROTECTIONBLURB parameter, plus the expiry if an expiry
    -- is set. E.g. "Editing of this page by new or unregistered users is currently 
    -- disabled until dd Month YYYY."
    --
    -- ${INTROFRAGMENT} - the same as ${INTROBLURB}, but without final punctuation
    -- so that it can be used in run-on sentences.
    --
    -- ${PAGETYPE} - the type of the page, e.g. "article" or "template".
    -- Defined in the cfg.pagetypes table.
    --
    -- ${PROTECTIONBLURB} - a blurb explaining the protection level of the page, e.g.
    -- "Editing of this page by new or unregistered users is currently disabled"
    --
    -- ${PROTECTIONDATE} - the protection date, if it has been supplied to the
    -- template.
    --
    -- ${PROTECTIONLEVEL} - the protection level, e.g. "fully protected" or
    -- "semi-protected".
    --
    -- ${PROTECTIONLOG} - a link to the protection log or the pending changes log,
    -- depending on the protection action.
    --
    -- ${TALKPAGE} - a link to the talk page. If a section is specified, links
    -- straight to that talk page section.
    --
    -- ${TOOLTIPBLURB} - uses the PAGETYPE, PROTECTIONTYPE and EXPIRY parameters to
    -- create a blurb like "This template is semi-protected", or "This article is
    -- move-protected until DD Month YYYY".
    --
    -- ${VANDAL} - links for the specified username (or the root page name)
    -- using Module:Vandal-m.
    --
    --                                 Functions
    --
    -- For advanced users, it is possible to use Lua functions instead of strings
    -- in the banner config tables. Using functions gives flexibility that is not
    -- possible just by using parameters. Functions take two arguments, the
    -- protection object and the template arguments, and they must output a string.
    --
    -- For example:
    --
    -- text = function (protectionObj, args)
    --     if protectionObj.level == 'autoconfirmed' then
    --         return 'foo'
    --     else
    --         return 'bar'
    --     end
    -- end
    --
    -- Some protection object properties and methods that may be useful:
    -- protectionObj.action - the protection action
    -- protectionObj.level - the protection level
    -- protectionObj.reason - the protection reason
    -- protectionObj.expiry - the expiry. Nil if unset, the string "indef" if set
    --     to indefinite, and the protection time in unix time if temporary.
    -- protectionObj.protectionDate - the protection date in unix time, or nil if
    --     unspecified.
    -- protectionObj.bannerConfig - the banner config found by the module. Beware
    --     of editing the config field used by the function, as it could create an
    --     infinite loop.
    -- protectionObj:isProtected - returns a boolean showing whether the page is
    --     protected.
    -- protectionObj:isTemporary - returns a boolean showing whether the expiry is
    --     temporary.
    -- protectionObj:isIncorrect - returns a boolean showing whether the protection
    --     template is incorrect.
    --]]
    
    -- The master banner data, used if no values have been found in banners or
    -- defaultBanners.
    masterBanner = {
    	text = '${INTROBLURB}',
    	explanation = '${EXPLANATIONBLURB}',
    	tooltip = '${TOOLTIPBLURB}',
    	link = '${IMAGELINK}',
    	alt = 'Page ${PROTECTIONLEVEL}'
    },
    
    -- The default banner data. This holds banner data for different protection
    -- levels.
    -- *required* - this table needs edit, move, autoreview and upload subtables.
    defaultBanners = {
    	edit = {},
    	move = {},
    	autoreview = {
    		autoconfirmed = {
    			alt = 'Page protected with pending changes level 1',
    			tooltip = 'All edits by unregistered and new users are subject to review',
    			image = 'Padlock-silver-light.svg'
    		},
    		default = {
    			alt = 'Page protected with pending changes level 2',
    			tooltip = 'All edits by users who are not reviewers or administrators are'
    				.. ' subject to review',
    		}
    	},
    	upload = {}
    },
    
    -- The banner data. This holds banner data for different protection reasons.
    -- In fact, the reasons specified in this table control which reasons are
    -- valid inputs to the first positional parameter.
    --
    -- There is also a non-standard "description" field that can be used for items
    -- in this table. This is a description of the protection reason for use in the
    -- module documentation.
    --
    -- *required* - this table needs edit, move, autoreview and upload subtables.
    banners = {
    	edit = {
    		blp = {
    			description = 'For pages protected to promote compliance with the'
    				.. ' [[Wikipedia:Biographies of living persons'
    				.. '|biographies of living persons]] policy.',
    			text = '${INTROFRAGMENT} to promote compliance with'
    				.. ' [[Wikipedia:Biographies of living persons'
    				.. "|Wikipedia's policy on the biographies"
    				.. ' of living people]].',
    			tooltip = '${TOOLTIPFRAGMENT} to promote compliance with the policy on'
    				.. ' biographies of living people',
    		},
    		dmca = {
    			description = 'For pages protected by the Wikimedia Foundation'
    				.. ' due to Digital Millennium Copyright Act takedown requests.',
    			explanation = function (protectionObj, args)
    				local ret = 'Pursuant to a rights owner notice under the Digital'
    					.. ' Millennium Copyright Act (DMCA) regarding some content'
    					.. ' in this article, the Wikimedia Foundation acted under'
    					.. ' applicable law and took down and restricted the content'
    					.. ' in question.'
    				if args.notice then
    					ret = ret .. ' A copy of the received notice can be found here: '
    						.. args.notice .. '.'
    				end
    				ret = ret .. ' For more information, including websites discussing'
    					.. ' how to file a counter-notice, please see'
    					.. " [[Wikipedia:Office actions]] and the article's ${TALKPAGE}."
    					.. "'''Do not remove this template from the article until the"
    					.. " restrictions are withdrawn'''."
    				return ret
    			end,
    			image = 'Padlock-black.svg',
    		},
    		dispute = {
    			description = 'For pages protected due to editing disputes.',
    			text = function (protectionObj, args)
    				-- Find the value of "disputes".
    				local display = 'disputes'
    				local disputes
    				if args.section then
    					disputes = string.format(
    						'[[%s:%s#%s|%s]]',
    						mw.site.namespaces[protectionObj.title.namespace].talk.name,
    						protectionObj.title.text,
    						args.section,
    						display
    					)
    				else
    					disputes = display
    				end
    
    				-- Make the blurb, depending on the expiry.
    				local msg
    				if type(protectionObj.expiry) == 'number' then
    					msg = '${INTROFRAGMENT} or until editing %s have been resolved.'
    				else
    					msg = '${INTROFRAGMENT} until editing %s have been resolved.'
    				end
    				return string.format(msg, disputes)
    			end,
    			explanation = "This protection is '''not''' an endorsement of the"
    				.. ' ${CURRENTVERSION}. ${EXPLANATIONBLURB}',
    			tooltip = '${TOOLTIPFRAGMENT} due to editing disputes',
    		},
    		mainpage = {
    			description = 'For pages protected for being displayed on the [[Main Page]].',
    			text = 'This file is currently'
    				.. ' [[Wikipedia:This page is protected|protected]] from'
    				.. ' editing because it is currently or will soon be displayed'
    				.. ' on the [[Main Page]].',
    			explanation = 'Images on the Main Page are protected due to their high'
    				.. ' visibility. Please discuss any necessary changes on the ${TALKPAGE}.'
    				.. '<br /><span sty