Module:Documentation: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
m
1 revision imported from wikipedia:Module:Documentation
m (13 revisions imported from metawikimedia:Module:Documentation)
m (1 revision imported from wikipedia:Module:Documentation)
 
(2 intermediate revisions by 2 users not shown)
Line 11:
-- Often-used functions.
local ugsub = mw.ustring.gsub
local format = mw.ustring.format
 
----------------------------------------------------------------------------
Line 50 ⟶ 51:
local function makeWikilink(page, display)
if display then
return mw.ustring.format('[[%s|%s]]', page, display)
else
return mw.ustring.format('[[%s]]', page)
end
end
Line 66 ⟶ 67:
 
local function makeUrlLink(url, display)
return mw.ustring.format('[%s %s]', url, display)
end
 
Line 81 ⟶ 82:
end
-- 'documentation-toolbar'
return dataformat(
return '<span class="' .. message('toolbar-class') .. '">('
..'<span table.concatclass="%s">(ret, ' &#124; ') .. '%s)</span>',
message('toolbar-class'),
table.concat(ret, ' &#124; ')
)
end
 
Line 313 ⟶ 317:
local sandboxTitle = env.sandboxTitle
if templateTitle.exists and sandboxTitle.exists then
local compareUrl = mw.uri.fullUrlcanonicalUrl(
'Special:ComparePages',
{ page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText}
Line 349 ⟶ 353:
--
-- Messages:
-- 'sandbox-notice-image' --> '[[ImageFile:Sandbox.svg|50px|alt=|link=]]'
-- 'sandbox-notice-blurb' --> 'This is the $1 for $2.'
-- 'sandbox-notice-diff-blurb' --> 'This is the $1 for $2 ($3).'
Line 505 ⟶ 509:
end
 
local data = {}
data.title = title
data.docTitle = docTitle
-- View, display, edit, and purge links if /doc exists.
data.viewLinkDisplay = message('view-link-display')
data.editLinkDisplay = message('edit-link-display')
data.historyLinkDisplay = message('history-link-display')
data.purgeLinkDisplay = message('purge-link-display')
-- Create link if /doc doesn't exist.
local preload = args.preload
Line 522 ⟶ 518:
end
end
data.preload = preload
return s{
data.createLinkDisplay = message('create-link-display')
data. title = title,
return data
data. docTitle = docTitle,
-- View, display, edit, and purge links if /doc exists.
data. viewLinkDisplay = message('view-link-display'),
data. editLinkDisplay = message('edit-link-display'),
data. historyLinkDisplay = message('history-link-display'),
data. purgeLinkDisplay = message('purge-link-display'),
data. preload = preload,
data. createLinkDisplay = message('create-link-display')
}
end
 
Line 532 ⟶ 537:
-- @data - a table of data generated by p.makeStartBoxLinksData
--]]
local docTitle = data.docTitle
-- yes, we do intend to purge the template page on which the documentation appears
local purgeLink = makeUrlLinkmakeWikilink(title"Special:fullUrl{actionPurge/" =.. 'purge'}data.title.prefixedText, data.purgeLinkDisplay)
local function escapeBrackets(s)
-- Escapes square brackets with HTML entities.
s = s:gsub('%[', '&#91;') -- Replace square brackets with HTML entities.
s = s:gsub('%]', '&#93;')
return s
end
 
local ret
local docTitle = data.docTitle
local title = data.title
local purgeLink = makeUrlLink(title:fullUrl{action = 'purge'}, data.purgeLinkDisplay)
if docTitle.exists then
local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay)
local editLink = makeUrlLinkmakeWikilink(docTitle"Special:fullUrl{actionEditPage/" =.. 'edit'}docTitle.prefixedText, data.editLinkDisplay)
local historyLink = makeUrlLinkmakeWikilink(docTitle"Special:fullUrl{actionPageHistory/" =.. 'history'}docTitle.prefixedText, data.historyLinkDisplay)
return "&#91;" .. viewLink .. "&#93; &#91;" .. editLink .. "&#93; &#91;" .. historyLink .. "&#93; &#91;" .. purgeLink .. "&#93;"
ret = '[%s] [%s] [%s] [%s]'
ret = escapeBrackets(ret)
ret = mw.ustring.format(ret, viewLink, editLink, historyLink, purgeLink)
else
local createLink = makeUrlLink(docTitle:fullUrlcanonicalUrl{action = 'edit', preload = data.preload}, data.createLinkDisplay)
return "&#91;" .. createLink .. "&#93; &#91;" .. purgeLink .. "&#93;"
ret = '[%s] [%s]'
ret = escapeBrackets(ret)
ret = mw.ustring.format(ret, createLink, purgeLink)
end
return ret
Line 771 ⟶ 764:
-- /doc exists; link to it.
local docLink = makeWikilink(docTitle.prefixedText)
local editUrl = docTitle:fullUrl{action = 'edit'}
local editDisplay = message('edit-link-display')
local editLink = makeUrlLinkmakeWikilink(editUrl"Special:EditPage/" .. docTitle.prefixedText, editDisplay)
local historyUrl = docTitle:fullUrl{action = 'history'}
local historyDisplay = message('history-link-display')
local historyLink = makeUrlLinkmakeWikilink(historyUrl"Special:PageHistory/" .. docTitle.prefixedText, historyDisplay)
ret = message('transcluded-from-blurb', {docLink})
.. ' '
Line 783 ⟶ 774:
elseif env.subjectSpace == 828 then
-- /doc does not exist; ask to create it.
local createUrl = docTitle:fullUrlcanonicalUrl{action = 'edit', preload = message('module-preload')}
local createDisplay = message('create-link-display')
local createLink = makeUrlLink(createUrl, createDisplay)
Line 834 ⟶ 825:
local sandboxDisplay = message('sandbox-link-display')
local sandboxLink = makeWikilink(sandboxPage, sandboxDisplay)
local sandboxEditUrl = sandboxTitle:fullUrl{action = 'edit'}
local sandboxEditDisplay = message('sandbox-edit-link-display')
local sandboxEditLink = makeUrlLinkmakeWikilink(sandboxEditUrl"Special:EditPage/" .. sandboxPage, sandboxEditDisplay)
local compareUrl = env.compareUrl
local compareLink
Line 851 ⟶ 841:
sandboxPreload = message('template-sandbox-preload')
end
local sandboxCreateUrl = sandboxTitle:fullUrlcanonicalUrl{action = 'edit', preload = sandboxPreload}
local sandboxCreateDisplay = message('sandbox-create-link-display')
local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay)
local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)})
local mirrorPreload = message('mirror-link-preload')
local mirrorUrl = sandboxTitle:fullUrlcanonicalUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary}
if subjectSpace == 828 then
mirrorUrl = sandboxTitle:fullUrlcanonicalUrl{action = 'edit', preload = templateTitle.prefixedText, summary = mirrorSummary}
end
local mirrorDisplay = message('mirror-link-display')
Line 868 ⟶ 858:
local testcasesDisplay = message('testcases-link-display')
local testcasesLink = makeWikilink(testcasesPage, testcasesDisplay)
local testcasesEditUrl = testcasesTitle:fullUrlcanonicalUrl{action = 'edit'}
local testcasesEditDisplay = message('testcases-edit-link-display')
local testcasesEditLink = makeUrlLinkmakeWikilink(testcasesEditUrl"Special:EditPage/" .. testcasesPage, testcasesEditDisplay)
-- for Modules, add testcases run link if exists
if testcasesTitle.contentModel == "Scribunto" and testcasesTitle.talkPageTitle and testcasesTitle.talkPageTitle.exists then
Line 886 ⟶ 876:
testcasesPreload = message('template-testcases-preload')
end
local testcasesCreateUrl = testcasesTitle:fullUrlcanonicalUrl{action = 'edit', preload = testcasesPreload}
local testcasesCreateDisplay = message('testcases-create-link-display')
local testcasesCreateLink = makeUrlLink(testcasesCreateUrl, testcasesCreateDisplay)
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu