Module:Subject page header
Appearance
| This Lua module is used in system messages. Changes to it can cause immediate changes to the Wikipedia user interface. To avoid major disruption, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Please discuss changes on the talk page before implementing them. |
| This module depends on the following other modules: |
This module is used from the interface message MediaWiki:Subjectpageheader-json and MediaWiki:Subjectpageheader-SecurePoll, shown at the top of pages with relevant content models.
The interface message is parsed on every page view. There is no caching (although for logged-out users Varnish caches the entire HTML before it even reaches MediaWiki). So, please ensure this module runs as fast as possible. Some tips:
- Avoid unconditional imports of other modules. Instead, import them inside conditional blocks where they are needed.
- Avoid unconditionally performing expensive lookups.
Usage
{{#invoke:Subject page header|main}}
local p = {}
-- Invoked from [[MediaWiki:Subjectpageheader-json]]
p.json = function(frame)
local title = mw.title.getCurrentTitle()
local pageName = title.fullText
local isJsonPage = pageName:len() > 5 and pageName:sub(-5) == ".json"
if isJsonPage then
local docPageName = pageName:sub(0, -6)
local docTitle = mw.title.new(docPageName)
local content = ''
if docTitle.exists then
local Hatnote = require('Module:Hatnote')
content =
'<hr>' ..
Hatnote._hatnote(
'The following documentation is located at [['..docPageName..']].<span class="mw-editsection-like plainlinks">[[Special:EditPage/'..docPageName..'|edit]][[Special:PageHistory/'..docPageName..'|history]]</span>'
) ..
frame:preprocess(docTitle.content)
end
return '<div class="mw-parser-output">' .. content .. '</div>'
end
return ''
end
-- Invoked from [[MediaWiki:Subjectpageheader-SecurePoll]]
p.SecurePoll = function()
local Hatnote = require('Module:Hatnote')
return '<div class="mw-parser-output">'..Hatnote._hatnote('This page contains the configuration for a [[m:SecurePoll|SecurePoll]] election. It cannot be directly edited. Any changes must be done via [[Special:SecurePoll]].')..'</div>'
end
return p