Module:Documentation: Difference between revisions

only generate the URL for the compare link in the env table - the rest is now done elsewhere so that the display can be different in different places
m>Mr. Stradivarius
(fix subjectSpace var in makeSubpagesBlurb)
m>Mr. Stradivarius
(only generate the URL for the compare link in the env table - the rest is now done elsewhere so that the display can be different in different places)
Line 174: Line 174:
-- env.docSpace - the number of the namespace the title puts its documentation in.
-- env.docSpace - the number of the namespace the title puts its documentation in.
-- env.docpageRoot - the text of the base page of the /doc, /sandbox and /testcases pages, with namespace.
-- env.docpageRoot - the text of the base page of the /doc, /sandbox and /testcases pages, with namespace.
-- env.compareLink - a URL link of the Special:ComparePages page comparing the sandbox with the template.
-- env.compareUrl - URL of the Special:ComparePages page comparing the sandbox with the template.
--  
--  
-- All table lookups are passed through pcall so that errors are caught. If an error occurs, the value
-- All table lookups are passed through pcall so that errors are caught. If an error occurs, the value
Line 280: Line 280:
end
end
function envFuncs.compareLink()
function envFuncs.compareUrl()
-- Diff link between the sandbox and the main template using [[Special:ComparePages]].
-- Diff link between the sandbox and the main template using [[Special:ComparePages]].
local templateTitle = env.templateTitle
local templateTitle = env.templateTitle
Line 288: Line 288:
{page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText}
{page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText}
)
)
compareUrl = tostring(compareUrl)
return tostring(compareUrl)
local compareDisplay = message('compareLinkDisplay', 'string')
return makeUrlLink(compareUrl, compareDisplay)
end
end


Line 316: Line 314:
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 templateLink = makeWikilink(templateTitle.prefixedText)
local templateLink = makeWikilink(templateTitle.prefixedText)
if isPreviewing then
local compareUrl = env.compareUrl
if isPreviewing or not compareUrl then
-- 'This is the [[Wikipedia:Template test cases|template sandbox]] page for $1.'
-- 'This is the [[Wikipedia:Template test cases|template sandbox]] page for $1.'
text = text .. message('sandboxNoticeBlurb', 'string', {templateLink})
text = text .. message('sandboxNoticeBlurb', 'string', {templateLink})
else
else
-- 'This is the [[Wikipedia:Template test cases|template sandbox]] page for $1 ($2).'
-- 'This is the [[Wikipedia:Template test cases|template sandbox]] page for $1 ($2).'
text = text .. message('sandboxNoticeDiffBlurb', 'string', {templateLink, env.compareLink})
local comparedisplay = message('sandboxnoticecomparelinkdisplay', 'string')
local comparelink = makeurllink(compareurl, comparedisplay)
text = text .. message('sandboxNoticeDiffBlurb', 'string', {templateLink, compareLink})
end
end
-- Get the test cases page blurb if the page exists.
-- Get the test cases page blurb if the page exists.
Line 710: Line 711:
local sandboxEditDisplay = message('sandboxEditLinkDisplay', 'string')
local sandboxEditDisplay = message('sandboxEditLinkDisplay', 'string')
local sandboxEditLink = makeUrlLink(sandboxEditUrl, sandboxEditDisplay)
local sandboxEditLink = makeUrlLink(sandboxEditUrl, sandboxEditDisplay)
local compareLink = env.compareLink
local compareUrl = env.compareUrl
local compareLink
if compareUrl then
local compareDisplay = message('compareLinkDisplay', 'string')
compareLink = makeUrlLink(compareUrl, compareDisplay)
end
sandboxLinks = sandboxLink .. ' ' .. makeToolbar(sandboxEditLink, compareLink)
sandboxLinks = sandboxLink .. ' ' .. makeToolbar(sandboxEditLink, compareLink)
else
else
Anonymous user