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.
Usage
{{#invoke:Subject page header|main}}
local p = {}
p.main = function(frame)
local title = mw.title.getCurrentTitle()
-- Bail out quickly on main namespace
if title.namespace == 0 then
return ''
end
local pageName = title.fullText
-- Optimization: first check page name suffix before looking up content model
local isJsonPage = pageName:len() > 5 and pageName:sub(-5) == ".json" and title.contentModel == '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>'
elseif title.namespace == 8 and title.contentModel == 'SecurePoll' then
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 ''
end
return p