10,178
edits
Changes
m
local htmlBuilder = require('Module:HtmlBuilder')
.:wikitext(p.protectionTemplate(env)) .:wikitext(p.sandboxNotice(args, env))
.:tag('div') .:attr('id', message('main-div-id')) .:addClass(message('main-div-classes')) .:newline() .:wikitext(p._startBox(args, env)) .:wikitext(p._content(args, env)) .:tag('div') .:css('clear', 'both') -- So right or left floating items don't stick out of the doc box. .:newline() .:done() .:done() .:wikitext(p._endBox(args, env)) .newline() .:wikitext(p.addTrackingCategories(env))
local frame = mw.getCurrentFrame()
local isPreviewing = frame:preprocess('{{REVISIONID}}') == '' -- True if the page is being previewed.
return local ret = '<div style="clear: both;"></div>' ret = ret .. messageBox.main('ombox', omargs) return ret
local protectionTemplate protectionLevels = message('protection-template') local namespace = titleenv.namespaceprotectionLevels if not (protectionTemplate and (namespace == 10 or namespace == 828)) protectionLevels then -- Don't display the protection template if we are not in the template or module namespaces.
local prefixedTitle = title.prefixedText
if getProtectionLevel('move', prefixedTitle) == 'sysop' or getProtectionLevel('edit', prefixedTitle) then
-- The page is full-move protected, or full, template, or semi-protected.
return frame:expandTemplate{title = protectionTemplate, args = message('protection-template-args', nil, 'table')}
end
return nil
.:css('padding-bottom', '3px') .:css('border-bottom', '1px solid #aaa') .:css('margin-bottom', '1ex') .:newline() .:tag('span') .:cssText(data.headingStyleText) .:css('font-weight', data.headingFontWeight) .:css('font-size', data.headingFontSize) .:wikitext(data.heading)
local frame content = args._content or mw.getCurrentFrame() content = frame:expandTemplate{title = docTitle.prefixedText}
-- 'module-testcases-preload' --> 'Template:Documentation/preload-module-testcases'
1 revision imported
-- Get required modules.
local getArgs = require('Module:Arguments').getArgs
local messageBox = require('Module:Message box')
--]]
local env = p.getEnvironment(args)
local root = htmlBuildermw.html.create()
root
-- This div tag is from {{documentation/start box}}, but moving it here
-- so that we don't have to worry about unclosed tags.
return tostring(root)
end
--
-- Data includes:
-- env.protectionLevels - the protection levels table of the title object.
-- env.subjectSpace - the number of the title's subject namespace.
-- env.docSpace - the number of the namespace the title puts its documentation in.
--]]
return env.templateTitle:subPageTitle(message('print-subpage'))
end
function envFuncs.protectionLevels()
-- The protection levels table of the title object.
return env.title.protectionLevels
end
--
-- Messages:
-- 'sandbox-notice-image' --> '[[Image:Sandbox.pngsvg|50px|alt=|link=]]'
-- 'sandbox-notice-blurb' --> 'This is the $1 for $2.'
-- 'sandbox-notice-diff-blurb' --> 'This is the $1 for $2 ($3).'
-- "This is the template sandbox for [[Template:Foo]] (diff)."
local text = ''
local pagetype
if subjectSpace == 10 then
local templateLink = makeWikilink(templateTitle.prefixedText)
local compareUrl = env.compareUrl
if isPreviewing or not compareUrl then text = text .. message('sandbox-notice-blurb', {pagetype, templateLink}) else
local compareDisplay = message('sandbox-notice-compare-link-display')
local compareLink = makeUrlLink(compareUrl, compareDisplay)
text = text .. message('sandbox-notice-diff-blurb', {pagetype, templateLink, compareLink})
else
text = text .. message('sandbox-notice-blurb', {pagetype, templateLink})
end
-- Get the test cases page blurb if the page exists. This is something like
local testcasesTitle = env.testcasesTitle
if testcasesTitle and testcasesTitle.exists then
if testcasesTitle.contentModel == "Scribunto" then local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display') local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display') local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay) local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay) text = text .. '<br />' .. message('sandbox-notice-testcases-run-blurb', {testcasesLink, testcasesRunLink}) else local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display') local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay) text = text .. '<br />' .. message('sandbox-notice-testcases-blurb', {testcasesLink}) end
end
-- Add the sandbox to the sandbox category.
text = text .. makeCategoryLink(message('sandbox-category'))
omargs.text = text
end
-- 'protection-template' --> 'pp-template'
-- 'protection-template-args' --> {docusage = 'yes'}
local protectionLevels, mProtectionBanner
local title = env.title
return nil
end
local frame editProt = mwprotectionLevels.getCurrentFrame()edit and protectionLevels.edit[1] local function getProtectionLevel(protectionType, page)moveProt = protectionLevels.move and protectionLevels.move[1] if editProt then -- Gets the protection level for page, or for the current page if The page is not specifiededit-protected. mProtectionBanner = require('Module:Protection banner') local level reason = frame:callParserFunctionmessage('PROTECTIONLEVELprotection-reason-edit', protectionType, page) if level return mProtectionBanner._main{reason, small = true} elseif moveProt and moveProt ~= 'autoconfirmed' then return level -- The page is move-protected but not edit-protected. Exclude move else return nil -- The parser function returns protection with the blank string if there level "autoconfirmed", as this is equivalent to -- no matchmove protection at all. mProtectionBanner = require('Module:Protection banner') return mProtectionBanner._main{action = 'move', small = true} else endreturn nil
end
end
local links
local content = args.content
if not content or args[1] then
-- No need to include the links if the documentation is on the template page itself.
local linksData = p.makeStartBoxLinksData(args, env)
if not title or not docTitle then
return nil
end
if docTitle.isRedirect then
docTitle = docTitle.redirectTarget
end
--
-- Messages:
-- 'documentation-icon-wikitext' --> '[[File:Test TemplateInfo-infoIcon - Version (2).pngsvg|50px|link=|alt=Documentation icon]]'
-- 'template-namespace-heading' --> 'Template documentation'
-- 'module-namespace-heading' --> 'Module documentation'
-- Renders the start box html.
-- @data - a table of data generated by p.makeStartBoxData.
local sbox = htmlBuildermw.html.create('div')
sbox
local links = data.links
if links then
sbox.:tag('span') .:addClass(data.linksClass) .:attr('id', data.linksId) .:wikitext(links)
end
return tostring(sbox)
local content = args.content
if not content and docTitle and docTitle.exists then
end
-- The line breaks below are necessary so that "=== Headings ===" at the start and end
-- of docs are interpreted correctly.
return '\n' .. (content or '') .. '\n'
end
p.contentTitle = makeInvokeFunc('_contentTitle')
function p._contentTitle(args, env)
env = env or p.getEnvironment(args)
local docTitle = env.docTitle
if not args.content and docTitle and docTitle.exists then
return docTitle.prefixedText
else
return ''
end
end
-- Add sandbox and testcases links.
-- "Editors can experiment in this template's sandbox and testcases pages."
text = text .. (p.makeExperimentBlurb(args, env) or '')
text = text .. '<br />'
if not args.content and not args[1] then
-- 'mirror-edit-summary' --> 'Create sandbox version of $1'
-- 'mirror-link-display' --> 'mirror'
-- 'mirror-link-preload' --> 'Template:Documentation/mirror'
-- 'sandbox-link-display' --> 'sandbox'
-- 'testcases-link-display' --> 'testcases'
-- 'testcases-edit-link-display'--> 'edit'
-- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox'
-- 'testcases-create-link-display' --> 'create'
local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay)
local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)})
local mirrorPreload = message('mirror-link-preload') local mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary} if subjectSpace == 828 then mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = templatePagetemplateTitle.prefixedText, summary = mirrorSummary} end
local mirrorDisplay = message('mirror-link-display')
local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay)
local testcasesEditDisplay = message('testcases-edit-link-display')
local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay)
-- for Modules, add testcases run link if exists if testcasesTitle.contentModel == "Scribunto" and testcasesTitle.talkPageTitle and testcasesTitle.talkPageTitle.exists then local testcasesRunLinkDisplay = message('testcases-run-link-display') local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay) testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink, testcasesRunLink) else testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink) end
else
local testcasesPreload