Module:Documentation: Difference between revisions
Content deleted Content added
m 1 revision imported |
m 1 revision imported |
||
(21 intermediate revisions by 11 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
else
return
end
end
Line 66 ⟶ 67:
local function makeUrlLink(url, display)
return
end
Line 81 ⟶ 82:
end
-- 'documentation-toolbar'
return format(
message('toolbar-class'),
table.concat(ret, ' | ')
)
end
Line 139 ⟶ 143:
-- 'documentation-container'
:addClass(message('container'))
:attr('role', 'complementary')
:attr('aria-labelledby', args.heading ~= '' and 'documentation-heading' or nil)
:attr('aria-label', args.heading == '' and 'Documentation' or nil)
:newline()
:tag('div')
Line 177 ⟶ 184:
-- env.sandboxTitle - the /sandbox subpage.
-- env.testcasesTitle - the /testcases subpage.
--
-- Data includes:
Line 271 ⟶ 277:
--]]
return mw.title.new(env.docpageBase .. '/' .. message('testcases-subpage'))
end
Line 320 ⟶ 317:
local sandboxTitle = env.sandboxTitle
if templateTitle.exists and sandboxTitle.exists then
local compareUrl = mw.uri.
'Special:ComparePages',
{ page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText}
Line 356 ⟶ 353:
--
-- Messages:
-- 'sandbox-notice-image' --> '[[
-- 'sandbox-notice-blurb' --> 'This is the $1 for $2.'
-- 'sandbox-notice-diff-blurb' --> 'This is the $1 for $2 ($3).'
Line 366 ⟶ 363:
-- 'sandbox-notice-testcases-link-display' --> 'test cases'
-- 'sandbox-category' --> 'Template sandboxes'
-- 'module-sandbox-category' --> 'Module sandboxes'
-- 'other-sandbox-category' --> 'Sandboxes outside of template or module namespace'
--]=]
local title = env.title
Line 381 ⟶ 380:
-- "This is the template sandbox for [[Template:Foo]] (diff)."
local text = ''
local pagetype, sandboxCat
if subjectSpace == 10 then
pagetype = message('sandbox-notice-pagetype-template')
sandboxCat = message('sandbox-category')
elseif subjectSpace == 828 then
pagetype = message('sandbox-notice-pagetype-module')
sandboxCat = message('module-sandbox-category')
else
pagetype = message('sandbox-notice-pagetype-other')
sandboxCat = message('other-sandbox-category')
end
local templateLink = makeWikilink(templateTitle.prefixedText)
Line 414 ⟶ 416:
end
end
-- Add the sandbox to the sandbox category.
omargs.text = text .. makeCategoryLink(
-- 'documentation-clear'
Line 498 ⟶ 501:
-- 'history-link-display' --> 'history'
-- 'purge-link-display' --> 'purge'
-- 'module-preload' --> 'Template:Documentation/preload-module-doc'
-- 'docpage-preload' --> 'Template:Documentation/preload'
Line 513 ⟶ 515:
end
-- Create link if /doc doesn't exist.
local preload = args.preload
if not preload then
if subjectSpace ==
preload = message('module-preload')
else
Line 532 ⟶ 524:
end
end
return {
title = title,
docTitle = docTitle,
-- View, display, edit, and purge links if /doc exists.
viewLinkDisplay = message('view-link-display'),
editLinkDisplay = message('edit-link-display'),
historyLinkDisplay = message('history-link-display'),
purgeLinkDisplay = message('purge-link-display'),
preload = preload,
createLinkDisplay = message('create-link-display')
}
end
function p.renderStartBoxLinks(data)
--[[
-- Generates the [view][edit][history][purge] or [create][purge] links from the data table.
-- @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 = makeWikilink("Special:Purge/" .. data.title.prefixedText, data.purgeLinkDisplay)
if docTitle.exists then
local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay)
local editLink =
local historyLink =
return "[" .. viewLink .. "] [" .. editLink .. "] [" .. historyLink .. "] [" .. purgeLink .. "]"
else
local createLink = makeUrlLink(docTitle:
return "[" .. createLink .. "] [" .. purgeLink .. "]"
end
return ret
Line 640 ⟶ 629:
:tag('span')
:addClass(data.headingClass)
:attr('id', 'documentation-heading')
:cssText(data.headingStyleText)
:wikitext(data.heading)
Line 740 ⟶ 730:
end
text = text .. ' ' .. (p.makeSubpagesBlurb(args, env) or '') --"Subpages of this template"
end
end
Line 749 ⟶ 735:
local box = mw.html.create('div')
-- 'documentation-metadata'
box:
:addClass(message('end-box-class'))
-- 'plainlinks'
:addClass(message('end-box-plainlinks'))
Line 779 ⟶ 766:
return nil
end
if docTitle.exists then
-- /doc exists; link to it.
local docLink = makeWikilink(docTitle.prefixedText)
local editDisplay = message('edit-link-display')
local editLink =
local historyDisplay = message('history-link-display')
local historyLink =
.. ' '
.. makeToolbar(editLink, historyLink)
Line 795 ⟶ 779:
elseif env.subjectSpace == 828 then
-- /doc does not exist; ask to create it.
local createUrl = docTitle:
local createDisplay = message('create-link-display')
local createLink = makeUrlLink(createUrl, createDisplay)
.. '<br />'
end
end
Line 846 ⟶ 829:
local sandboxDisplay = message('sandbox-link-display')
local sandboxLink = makeWikilink(sandboxPage, sandboxDisplay)
local sandboxEditDisplay = message('sandbox-edit-link-display')
local sandboxEditLink =
local compareUrl = env.compareUrl
local compareLink
Line 863 ⟶ 845:
sandboxPreload = message('template-sandbox-preload')
end
local sandboxCreateUrl = sandboxTitle:
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:
if subjectSpace == 828 then
mirrorUrl = sandboxTitle:
end
local mirrorDisplay = message('mirror-link-display')
Line 880 ⟶ 862:
local testcasesDisplay = message('testcases-link-display')
local testcasesLink = makeWikilink(testcasesPage, testcasesDisplay)
local testcasesEditUrl = testcasesTitle:
local testcasesEditDisplay = message('testcases-edit-link-display')
local testcasesEditLink =
-- for Modules, add testcases run link if exists
if testcasesTitle.contentModel == "Scribunto" and testcasesTitle.talkPageTitle and testcasesTitle.talkPageTitle.exists then
Line 898 ⟶ 880:
testcasesPreload = message('template-testcases-preload')
end
local testcasesCreateUrl = testcasesTitle:
local testcasesCreateDisplay = message('testcases-create-link-display')
local testcasesCreateLink = makeUrlLink(testcasesCreateUrl, testcasesCreateDisplay)
Line 959 ⟶ 941:
)
return message('subpages-blurb', {subpagesLink})
end
Line 1,015 ⟶ 967:
end
local subpage = title.subpageText
if message('display-strange-usage-category', nil, 'boolean')
and (
Line 1,022 ⟶ 973:
)
then
end
return
end
|