Changes

Module:Documentation

1,469 bytes added, 23:56, 14 January 2014
add a templateTitle object to the env functions, and reformat the experimentBlurb function to make it fit on the page
return mw.site.namespaces[env.title.namespace].subject.id
end
function envFuncs.docspace()
-- The name of the documentation namespace.
end
end
function envFuncs.templatePage()
-- The template page with no namespace or interwiki prefixes.
return title.text
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
local templatePage = env.templatePage
-- Get title objects.
local templateSuccess, templateTitle = env:grab('templateTitle')
if not templateSuccess then
return err(templateTitle)
end
local sandboxSuccess, sandboxTitle = env:grab('sandboxTitle')
if not sandboxSuccess then
local sandboxLinks, testcasesLinks
if sandboxTitle.exists then
local sandboxLink sandboxPage = makeWikilink(sandboxTitle.prefixedText, local sandboxDisplay = message('sandboxLinkDisplay', 'string') local sandboxLink = makeWikilink(sandboxPage, sandboxDisplay) local sandboxEditLink sandboxEditUrl = makeUrlLink(sandboxTitle:fullUrl{action = 'edit'}, local sandboxEditDisplay = message('sandboxEditLinkDisplay', 'string')) local compareLink sandboxEditLink = makeUrlLink(sandboxEditUrl, sandboxEditDisplay) local compareUrl = mw.titleuri.newfullUrl('Special:ComparePages'):fullUrl, {page1 = templatePagetemplateTitle.prefixedText, page2 = sandboxsandboxPage}, ) compareUrl = tostring(compareUrl) local compareDisplay = message('compareLinkDisplay', 'string') local compareLink = makeUrlLink(compareUrl, compareDisplay)
sandboxLinks = sandboxLink .. ' ' .. makeToolbar(sandboxEditLink, compareLink)
else
local sandboxPreload = if subjectSpace == 828 and then sandboxPreload = message('moduleSandboxPreload', 'string') or else sandboxPreload = message('templateSandboxPreload', 'string') end local sandboxCreateLink sandboxCreateUrl = makeUrlLink(sandboxTitle:fullUrl{action = 'edit', preload = sandboxPreload}, local sandboxCreateDisplay = message('sandboxCreateLinkDisplay', 'string') local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay)
local mirrorSummary = message('mirrorEditSummary', 'string', {makeWikilink(templatePage)})
local mirrorLink mirrorUrl = makeUrlLink(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)
end
if testcasesTitle.exists then
local testcasesLink testcasesPage = makeWikilink(testcasesTitle.prefixedText, local testcasesDisplay = message('testcasesLinkDisplay', 'string') local testcasesLink = makeWikilink(testcasesPage, testcasesDisplay) local testcasesEditLink testcasesEditUrl = makeUrlLink(testcasesTitle:fullUrl{action = 'edit'}, local testcasesEditDisplay = message('testcasesEditLinkDisplay', 'string') local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay)
testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink)
else
local testcasesPreload = if subjectSpace == 828 and then testcasesPreload = message('moduleTestcasesPreload', 'string') or else testcasesPreload = message('templateTestcasesPreload', 'string') end local testcasesCreateLink testcasesCreateUrl = makeUrlLink(testcasesTitle:fullUrl{action = 'edit', preload = testcasesPreload}, local testcasesCreateDisplay = message('testcasesCreateLinkDisplay', 'string') local testcasesCreateLink = makeUrlLink(testcasesCreateUrl, testcasesCreateDisplay)
testcasesLinks = message('testcasesLinkDisplay', 'string') .. ' ' .. makeToolbar(testcasesCreateLink)
end
return message(local messageName if subjectSpace == 828 and then messageName = 'experimentBlurbModule' or else messageName = 'experimentBlurbTemplate' end return message(messageName, 'string', {sandboxLinks, testcasesLinks})
end
Anonymous user