Module:Documentation: Difference between revisions
Content added Content deleted
(allow for nil values of makeDocPageBlurb) |
(add a templateTitle object to the env functions, and reformat the experimentBlurb function to make it fit on the page) |
||
Line 203: | Line 203: | ||
return mw.site.namespaces[env.title.namespace].subject.id |
return mw.site.namespaces[env.title.namespace].subject.id |
||
end |
end |
||
function envFuncs.docspace() |
function envFuncs.docspace() |
||
-- The name of the documentation namespace. |
-- The name of the documentation namespace. |
||
Line 215: | Line 215: | ||
end |
end |
||
end |
end |
||
function envFuncs.templatePage() |
function envFuncs.templatePage() |
||
-- The template page with no namespace or interwiki prefixes. |
-- The template page with no namespace or interwiki prefixes. |
||
Line 225: | Line 225: | ||
return title.text |
return title.text |
||
end |
end |
||
end |
|||
function envFuncs.templateTitle() |
|||
-- The template (or module, etc.) title object. |
|||
local title = env.title |
|||
local subpage = title.subpageText |
|||
local ret |
|||
if subpage == message('sandboxSubpage', 'string') or subpage == message('testcasesSubpage', 'string') then |
|||
ret = title.basePageTitle |
|||
else |
|||
ret = title |
|||
end |
|||
if not ret then |
|||
error(message('titleArgError', 'string', {titleArg})) |
|||
end |
|||
return ret |
|||
end |
end |
||
Line 633: | Line 649: | ||
local templatePage = env.templatePage |
local templatePage = env.templatePage |
||
-- Get title objects. |
-- Get title objects. |
||
local templateSuccess, templateTitle = env:grab('templateTitle') |
|||
if not templateSuccess then |
|||
return err(templateTitle) |
|||
end |
|||
local sandboxSuccess, sandboxTitle = env:grab('sandboxTitle') |
local sandboxSuccess, sandboxTitle = env:grab('sandboxTitle') |
||
if not sandboxSuccess then |
if not sandboxSuccess then |
||
Line 644: | Line 664: | ||
local sandboxLinks, testcasesLinks |
local sandboxLinks, testcasesLinks |
||
if sandboxTitle.exists then |
if sandboxTitle.exists then |
||
local |
local sandboxPage = sandboxTitle.prefixedText |
||
local |
local sandboxDisplay = message('sandboxLinkDisplay', 'string') |
||
local sandboxLink = makeWikilink(sandboxPage, sandboxDisplay) |
|||
local compareLink = makeUrlLink(mw.title.new('Special:ComparePages'):fullUrl{page1 = templatePage, page2 = sandbox}, message('compareLinkDisplay', 'string')) |
|||
local sandboxEditUrl = sandboxTitle:fullUrl{action = 'edit'} |
|||
local sandboxEditDisplay = message('sandboxEditLinkDisplay', 'string') |
|||
local sandboxEditLink = makeUrlLink(sandboxEditUrl, sandboxEditDisplay) |
|||
local compareUrl = mw.uri.fullUrl('Special:ComparePages', {page1 = templateTitle.prefixedText, page2 = sandboxPage}) |
|||
compareUrl = tostring(compareUrl) |
|||
local compareDisplay = message('compareLinkDisplay', 'string') |
|||
local compareLink = makeUrlLink(compareUrl, compareDisplay) |
|||
sandboxLinks = sandboxLink .. ' ' .. makeToolbar(sandboxEditLink, compareLink) |
sandboxLinks = sandboxLink .. ' ' .. makeToolbar(sandboxEditLink, compareLink) |
||
else |
else |
||
local sandboxPreload |
|||
⚫ | |||
if subjectSpace == 828 then |
|||
⚫ | |||
sandboxPreload = message('moduleSandboxPreload', 'string') |
|||
else |
|||
⚫ | |||
end |
|||
⚫ | |||
local sandboxCreateDisplay = message('sandboxCreateLinkDisplay', 'string') |
|||
local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay) |
|||
local mirrorSummary = message('mirrorEditSummary', 'string', {makeWikilink(templatePage)}) |
local mirrorSummary = message('mirrorEditSummary', 'string', {makeWikilink(templatePage)}) |
||
local |
local mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = templatePage, summary = mirrorSummary} |
||
local mirrorDisplay = message('mirrorLinkDisplay', 'string') |
|||
local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay) |
|||
sandboxLinks = message('sandboxLinkDisplay', 'string') .. ' ' .. makeToolbar(sandboxCreateLink, mirrorLink) |
sandboxLinks = message('sandboxLinkDisplay', 'string') .. ' ' .. makeToolbar(sandboxCreateLink, mirrorLink) |
||
end |
end |
||
if testcasesTitle.exists then |
if testcasesTitle.exists then |
||
local |
local testcasesPage = testcasesTitle.prefixedText |
||
local |
local testcasesDisplay = message('testcasesLinkDisplay', 'string') |
||
local testcasesLink = makeWikilink(testcasesPage, testcasesDisplay) |
|||
local testcasesEditUrl = testcasesTitle:fullUrl{action = 'edit'} |
|||
local testcasesEditDisplay = message('testcasesEditLinkDisplay', 'string') |
|||
local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay) |
|||
testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink) |
testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink) |
||
else |
else |
||
local testcasesPreload |
|||
⚫ | |||
if subjectSpace == 828 then |
|||
⚫ | |||
testcasesPreload = message('moduleTestcasesPreload', 'string') |
|||
else |
|||
⚫ | |||
end |
|||
⚫ | |||
local testcasesCreateDisplay = message('testcasesCreateLinkDisplay', 'string') |
|||
local testcasesCreateLink = makeUrlLink(testcasesCreateUrl, testcasesCreateDisplay) |
|||
testcasesLinks = message('testcasesLinkDisplay', 'string') .. ' ' .. makeToolbar(testcasesCreateLink) |
testcasesLinks = message('testcasesLinkDisplay', 'string') .. ' ' .. makeToolbar(testcasesCreateLink) |
||
end |
end |
||
local messageName |
|||
⚫ | |||
if subjectSpace == 828 then |
|||
messageName = 'experimentBlurbModule' |
|||
else |
|||
messageName = 'experimentBlurbTemplate' |
|||
end |
|||
⚫ | |||
end |
end |
||