Difference between revisions of "Module:Documentation"

Jump to navigation Jump to search
m
Lua error
en>Tomybrz
m (7 revisions imported from w:en:Module:Documentation)
en>Tomybrz
m (Lua error)
Line 136: Line 136:
:attr('id', message('main-div-id'))
:attr('id', message('main-div-id'))
:addClass(message('main-div-classes'))
:addClass(message('main-div-classes'))
:css('padding', '12px')
:newline()
:newline()
:wikitext(p._startBox(args, env))
:wikitext(p._startBox(args, env))
Line 355: Line 356:
-- "This is the template sandbox for [[Template:Foo]] (diff)."
-- "This is the template sandbox for [[Template:Foo]] (diff)."
local text = ''
local text = ''
local frame = mw.getCurrentFrame()
local isPreviewing = frame:preprocess('{{REVISIONID}}') == '' -- True if the page is being previewed.
local pagetype
local pagetype
if subjectSpace == 10 then
if subjectSpace == 10 then
Line 365: Line 368:
local templateLink = makeWikilink(templateTitle.prefixedText)
local templateLink = makeWikilink(templateTitle.prefixedText)
local compareUrl = env.compareUrl
local compareUrl = env.compareUrl
if compareUrl then
if isPreviewing or not compareUrl then
text = text .. message('sandbox-notice-blurb', {pagetype, templateLink})
else
local compareDisplay = message('sandbox-notice-compare-link-display')
local compareDisplay = message('sandbox-notice-compare-link-display')
local compareLink = makeUrlLink(compareUrl, compareDisplay)
local compareLink = makeUrlLink(compareUrl, compareDisplay)
text = text .. message('sandbox-notice-diff-blurb', {pagetype, templateLink, compareLink})
text = text .. message('sandbox-notice-diff-blurb', {pagetype, templateLink, compareLink})
else
text = text .. message('sandbox-notice-blurb', {pagetype, templateLink})
end
end
-- Get the test cases page blurb if the page exists. This is something like
-- Get the test cases page blurb if the page exists. This is something like
Line 376: Line 379:
local testcasesTitle = env.testcasesTitle
local testcasesTitle = env.testcasesTitle
if testcasesTitle and testcasesTitle.exists then
if testcasesTitle and testcasesTitle.exists then
if testcasesTitle.contentModel == "Scribunto" then
if testcasesTitle.namespace == mw.site.namespaces.Module.id then
local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display')
local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display')
Line 402: Line 405:
-- 'protection-template' --> 'pp-template'
-- 'protection-template' --> 'pp-template'
-- 'protection-template-args' --> {docusage = 'yes'}
-- 'protection-template-args' --> {docusage = 'yes'}
local protectionLevels, mProtectionBanner
local title = env.title
local title = env.title
local protectionLevels
local protectionTemplate = message('protection-template')
local namespace = title.namespace
if not (protectionTemplate and (namespace == 10 or namespace == 828)) then
-- Don't display the protection template if we are not in the template or module namespaces.
return nil
end
protectionLevels = env.protectionLevels
protectionLevels = env.protectionLevels
if not protectionLevels then
if not protectionLevels then
return nil
return nil
end
end
local editProt = protectionLevels.edit and protectionLevels.edit[1]
local editLevels = protectionLevels.edit
local moveProt = protectionLevels.move and protectionLevels.move[1]
local moveLevels = protectionLevels.move
if editProt then
if moveLevels and moveLevels[1] == 'sysop' or editLevels and editLevels[1] then
-- The page is edit-protected.
-- The page is full-move protected, or full, template, or semi-protected.
mProtectionBanner = require('Module:Protection banner')
local frame = mw.getCurrentFrame()
local reason = message('protection-reason-edit')
return frame:expandTemplate{title = protectionTemplate, args = message('protection-template-args', nil, 'table')}
return mProtectionBanner._main{reason, small = true}
elseif moveProt and moveProt ~= 'autoconfirmed' then
-- The page is move-protected but not edit-protected. Exclude move
-- protection with the level "autoconfirmed", as this is equivalent to
-- no move protection at all.
mProtectionBanner = require('Module:Protection banner')
return mProtectionBanner._main{action = 'move', small = true}
else
else
return nil
return nil
Line 483: Line 485:
if not title or not docTitle then
if not title or not docTitle then
return nil
return nil
end
if docTitle.isRedirect then
docTitle = docTitle.redirectTarget
end
end


Line 553: Line 552:
--
--
-- Messages:
-- Messages:
-- 'documentation-icon-wikitext' --> '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]]'
-- 'documentation-icon-wikitext' --> '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=Documentation icon]]'
-- 'template-namespace-heading' --> 'Template documentation'
-- 'template-namespace-heading' --> 'Template documentation'
-- 'module-namespace-heading' --> 'Module documentation'
-- 'module-namespace-heading' --> 'Module documentation'
Line 858: Line 857:
local mirrorPreload = message('mirror-link-preload')
local mirrorPreload = message('mirror-link-preload')
local mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary}
local mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary}
if subjectSpace == 828 then
mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = templateTitle.prefixedText, summary = mirrorSummary}
end
local mirrorDisplay = message('mirror-link-display')
local mirrorDisplay = message('mirror-link-display')
local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay)
local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay)
Line 872: Line 868:
local testcasesEditDisplay = message('testcases-edit-link-display')
local testcasesEditDisplay = message('testcases-edit-link-display')
local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay)
local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay)
-- for Modules, add testcases run link if exists
testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink)
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
else
local testcasesPreload
local testcasesPreload
Anonymous user

Navigation menu