Open main menu

Changes

Module:Documentation

199 bytes added, 17:51, 21 October 2015
m
1 revision imported: The current Wikipedia Template:Infobox.
-- Get required modules.
local getArgs = require('Module:Arguments').getArgs
local htmlBuilder = require('Module:HtmlBuilder')
local messageBox = require('Module:Message box')
--]]
local env = p.getEnvironment(args)
local root = htmlBuildermw.html.create()
root
.:wikitext(p.protectionTemplate(env)) .:wikitext(p.sandboxNotice(args, env))
-- This div tag is from {{documentation/start box}}, but moving it here
-- so that we don't have to worry about unclosed tags.
.: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)) .:wikitext(p.addTrackingCategories(env))
return tostring(root)
end
-- 'protection-template' --> 'pp-template'
-- 'protection-template-args' --> {docusage = 'yes'}
local protectionLevels, mProtectionBanner
local title = env.title
local protectionLevels local protectionTemplate = message('protection-template') local namespace = if title.namespace if not (protectionTemplate and (namespace =~= 10 or and title.namespace =~= 828)) then
-- Don't display the protection template if we are not in the template or module namespaces.
return nil
return nil
end
local editLevels editProt = protectionLevels.editand protectionLevels.edit[1] local moveLevels moveProt = protectionLevels.move if moveLevels and moveLevelsprotectionLevels.move[1] if editProt then -- The page is edit-protected. mProtectionBanner =require('Module:Protection banner') local reason = message('sysopprotection-reason-edit' or editLevels ) return mProtectionBanner._main{reason, small = true} elseif moveProt and editLevels[1] moveProt ~= 'autoconfirmed' then -- The page is fullmove-protected but not edit-protected. Exclude move protected -- protection with the level "autoconfirmed", or full, template, or semias this is equivalent to --protectedno move protection at all. local frame mProtectionBanner = mw.getCurrentFramerequire('Module:Protection banner') return frame:expandTemplatemProtectionBanner._main{title action = protectionTemplate, args = message('protection-template-argsmove', nil, 'table')small = true}
else
return nil
-- Renders the start box html.
-- @data - a table of data generated by p.makeStartBoxData.
local sbox = htmlBuildermw.html.create('div')
sbox
.: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 links = data.links
if links then
sbox.:tag('span') .:addClass(data.linksClass) .:attr('id', data.linksId) .:wikitext(links)
end
return tostring(sbox)
-- 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'
-- 'module-testcases-preload' --> 'Template:Documentation/preload-module-testcases'
-- '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 = templatePagemirrorPreload, summary = mirrorSummary}
local mirrorDisplay = message('mirror-link-display')
local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay)