Module:Subject page header
File:Test Template Info-Icon - Version (2).svg Module documentation[view] [edit] [history] [purge]
| Error creating thumbnail: File missing | This Lua module is used in system messages. Changes to it can cause immediate changes to the MyWiki 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 is used from the interface message MediaWiki:Subjectpageheader, shown at the top of all non-talk pages.
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 Hatnote = require('Module:Hatnote')
local docPageName = pageName .. '/doc'
local docTitle = mw.title.new(docPageName)
local content = ''
if docTitle.exists then
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)
else
content = Hatnote._hatnote('Documentation for this JSON page can be created at the [['..docPageName..'|/doc]] subpage.')
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