Jump to content

Module:Documentation: Difference between revisions

use better messages for the sandbox notice when in the module namespace, and only show the diff link when both pages exist
m>Mr. Stradivarius
m (Protected Module:Documentation: High-risk Lua module ([Edit=Allow only template editors and admins] (indefinite) [Move=Allow only template editors and admins] (indefinite)))
m>Mr. Stradivarius
(use better messages for the sandbox notice when in the module namespace, and only show the diff link when both pages exist)
Line 302: Line 302:
local templateTitle = env.templateTitle
local templateTitle = env.templateTitle
local sandboxTitle = env.sandboxTitle
local sandboxTitle = env.sandboxTitle
local compareUrl = mw.uri.fullUrl(
if templateTitle.exists and sandboxTitle.exists then
'Special:ComparePages',
local compareUrl = mw.uri.fullUrl(
{page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText}
'Special:ComparePages',
)
{page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText}
return tostring(compareUrl)
)
return tostring(compareUrl)
else
return nil
end
end
end


Line 324: Line 328:
-- Messages:
-- Messages:
-- 'sandbox-notice-image' --> '[[Image:Sandbox.png|50px|alt=|link=]]'
-- 'sandbox-notice-image' --> '[[Image:Sandbox.png|50px|alt=|link=]]'
-- 'sandbox-notice-blurb' --> 'This is the [[Wikipedia:Template test cases|template sandbox]] page for $1.'
-- 'sandbox-notice-blurb' --> 'This is the $1 for $2.'
-- 'sandbox-notice-diff-blurb' --> 'This is the [[Wikipedia:Template test cases|template sandbox]] page for $1 ($2).'
-- 'sandbox-notice-diff-blurb' --> 'This is the $1 for $2 ($3).'
-- 'sandbox-notice-pagetype-template' --> '[[Wikipedia:Template test cases|template sandbox]] page'
-- 'sandbox-notice-pagetype-module' --> '[[Wikipedia:Template test cases|module sandbox]] page'
-- 'sandbox-notice-pagetype-other' --> 'sandbox page'
-- 'sandbox-notice-compare-link-display' --> 'diff'
-- 'sandbox-notice-compare-link-display' --> 'diff'
-- 'sandbox-notice-testcases-blurb' --> 'See also the companion subpage for $1.'
-- 'sandbox-notice-testcases-blurb' --> 'See also the companion subpage for $1.'
Line 334: Line 341:
local sandboxTitle = env.sandboxTitle
local sandboxTitle = env.sandboxTitle
local templateTitle = env.templateTitle
local templateTitle = env.templateTitle
if not (title and sandboxTitle and templateTitle and mw.title.equals(title, sandboxTitle)) then
local subjectSpace = env.subjectSpace
if not (subjectSpace and title and sandboxTitle and templateTitle and mw.title.equals(title, sandboxTitle)) then
return nil
return nil
end
end
Line 345: Line 353:
local frame = mw.getCurrentFrame()
local frame = mw.getCurrentFrame()
local isPreviewing = frame:preprocess('{{REVISIONID}}') == '' -- True if the page is being previewed.
local isPreviewing = frame:preprocess('{{REVISIONID}}') == '' -- True if the page is being previewed.
local pagetype
if subjectSpace == 10 then
pagetype = message('sandbox-notice-pagetype-template')
elseif subjectSpace == 828 then
pagetype = message('sandbox-notice-pagetype-module')
else
pagetype = message('sandbox-notice-pagetype-other')
end
local templateLink = makeWikilink(templateTitle.prefixedText)
local templateLink = makeWikilink(templateTitle.prefixedText)
local compareUrl = env.compareUrl
local compareUrl = env.compareUrl
if isPreviewing or not compareUrl then
if isPreviewing or not compareUrl then
text = text .. message('sandbox-notice-blurb', {templateLink})
text = text .. message('sandbox-notice-blurb', {pagetype, templateLink})
else
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', {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
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.