Module:Documentation: Difference between revisions

use a makeToolbar function instead of writing out the toolbars by hand
(don't use mw.uri.encode - title:fullUrl already encodes the strings for us)
(use a makeToolbar function instead of writing out the toolbars by hand)
Line 27:
return mw.ustring.format('[%s %s]', url, display)
end
 
local function makeToolbar(...)
local ret = {}
local lim = select('#', ...)
if lim < 1 then
return nil
end
for i = 1, lim do
ret[#ret + 1] = select(i, ...)
end
return '<small style="font-style: normal;">(' .. table.concat(ret, ' &#124; ') .. ')</small>'
end
 
----------------------------------------------------------------------------
Line 271 ⟶ 283:
local editLink = makeUrlLink(docTitle:fullUrl{action = 'edit'}, 'edit')
local historyLink = makeUrlLink(docTitle:fullUrl{action = 'history'}, 'history')
text = text .. 'The above [[Wikipedia:Template documentation|documentation]] is [[Wikipedia:Transclusion|transcluded]] from ' .. docLink .. '. '
.. ' <small style="font-style: normal;">makeToolbar(' .. editLink .. ' &#124; ' .., historyLink) .. ')</small> <br />'
elseif subjectSpace == 828 then
-- /doc does not exist; ask to create it.
Line 288 ⟶ 300:
local sandboxEditLink = makeUrlLink(sandboxTitle:fullUrl{action = 'edit'}, 'edit')
local compareLink = makeUrlLink(mw.title.new('Special:ComparePages'):fullUrl{page1 = templatePage, page2 = sandbox}, 'diff')
text = text .. sandboxLink .. ' <small style="font-style: normal">(' .. makeToolbar(sandboxEditLink .. ' | ' .., compareLink .. ')</small>'
else
local sandboxPreload = 'Template:Documentation/preload-' .. (subjectSpace == 828 and 'module-' or '') .. 'sandbox'
Line 294 ⟶ 306:
local mirrorSummary = 'Create sandbox version of ' .. makeWikilink(templatePage)
local mirrorLink = makeUrlLink(sandboxTitle:fullUrl{action = 'edit', preload = templatePage, summary = mirrorSummary}, 'mirror')
text = text .. 'sandbox <small style="font-style: normal">(' .. makeToolbar(sandboxCreateLink .. ' | ' .., mirrorLink .. ')</small>'
end
text = text .. ' and '
Line 301 ⟶ 313:
local testcasesLink = makeWikilink(testcases, 'testcases')
local testcasesEditLink = makeUrlLink(testcaseTitle:fullUrl{action = 'edit'}, 'edit')
text = text .. testcasesLink .. ' <small style="font-style: normal">(' .. makeToolbar(testcasesEditLink .. ')</small>'
else
local testcasesPreload = 'Template:Documentation/preload-' .. (subjectSpace == 828 and 'module-' or '') .. 'testcases'
local testcasesCreateLink = makeUrlLink(testcaseTitle:fullUrl{action = 'edit', preload = testcasesPreload}, 'create')
text = text .. 'testcases <small style="font-style: normal">(' .. makeToolbar(testcasesCreateLink .. ')</small>'
end
text = text .. ' pages. <br />'