Module:Documentation: Difference between revisions
Jump to navigation
Jump to search
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. | -- 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. | 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} | ||
) | ) | ||
return tostring(compareUrl) | |||
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, | 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 | 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 |