Difference between revisions of "Module:Documentation"
Jump to navigation
Jump to search
m
Lua error
>Tomybrz m (7 revisions imported from w:en:Module:Documentation) |
>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}) | ||
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. | 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 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 | local editLevels = protectionLevels.edit | ||
local | local moveLevels = protectionLevels.move | ||
if moveLevels and moveLevels[1] == 'sysop' or editLevels and editLevels[1] then | |||
-- The page is | -- The page is full-move protected, or full, template, or semi-protected. | ||
local frame = mw.getCurrentFrame() | |||
return frame:expandTemplate{title = protectionTemplate, args = message('protection-template-args', nil, 'table')} | |||
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 | 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} | ||
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) | ||
testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink) | |||
else | else | ||
local testcasesPreload | local testcasesPreload |