Difference between pages "Module:Documentation" and "Module:Documentation/sandbox"
(Difference between pages)
Dinoguy1000 (talk | contribs) (we don't yet have Special:Purge, Special:EditPage, or Special:PageHistory) |
Dinoguy1000 (talk | contribs) m (1 revision imported: mass import/update of Wikipedia stuff) |
||
Line 5: | Line 5: | ||
-- Get the config table. | -- Get the config table. | ||
− | local cfg = mw.loadData('Module:Documentation/config') | + | local cfg = mw.loadData('Module:Documentation/config/sandbox') |
local p = {} | local p = {} | ||
Line 11: | Line 11: | ||
-- Often-used functions. | -- Often-used functions. | ||
local ugsub = mw.ustring.gsub | local ugsub = mw.ustring.gsub | ||
− | |||
---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ||
Line 51: | Line 50: | ||
local function makeWikilink(page, display) | local function makeWikilink(page, display) | ||
if display then | if display then | ||
− | return format('[[%s|%s]]', page, display) | + | return mw.ustring.format('[[%s|%s]]', page, display) |
else | else | ||
− | return format('[[%s]]', page) | + | return mw.ustring.format('[[%s]]', page) |
end | end | ||
end | end | ||
Line 67: | Line 66: | ||
local function makeUrlLink(url, display) | local function makeUrlLink(url, display) | ||
− | return format('[%s %s]', url, display) | + | return mw.ustring.format('[%s %s]', url, display) |
end | end | ||
Line 82: | Line 81: | ||
end | end | ||
-- 'documentation-toolbar' | -- 'documentation-toolbar' | ||
− | return | + | return '<span class="' .. message('toolbar-class') .. '">(' |
− | + | .. table.concat(ret, ' | ') .. ')</span>' | |
− | |||
− | table.concat(ret, ' | ') | ||
− | |||
end | end | ||
Line 317: | Line 313: | ||
local sandboxTitle = env.sandboxTitle | local sandboxTitle = env.sandboxTitle | ||
if templateTitle.exists and sandboxTitle.exists then | if templateTitle.exists and sandboxTitle.exists then | ||
− | local compareUrl = mw.uri. | + | local compareUrl = mw.uri.fullUrl( |
'Special:ComparePages', | 'Special:ComparePages', | ||
{ page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText} | { page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText} | ||
Line 360: | Line 356: | ||
-- 'sandbox-notice-pagetype-other' --> 'sandbox page' | -- 'sandbox-notice-pagetype-other' --> 'sandbox page' | ||
-- 'sandbox-notice-compare-link-display' --> 'diff' | -- 'sandbox-notice-compare-link-display' --> 'diff' | ||
− | -- 'sandbox-notice- | + | -- 'sandbox-notice-warning-blurb' --> 'To avoid major disruption and server load, [...]' |
− | -- 'sandbox-notice-testcases-link-display' --> ' | + | -- 'sandbox-notice-testcases-link-display' --> 'testcases' |
-- 'sandbox-category' --> 'Template sandboxes' | -- 'sandbox-category' --> 'Template sandboxes' | ||
--]=] | --]=] | ||
Line 398: | Line 394: | ||
-- "See also the companion subpage for [[Template:Foo/testcases|test cases]]." | -- "See also the companion subpage for [[Template:Foo/testcases|test cases]]." | ||
local testcasesTitle = env.testcasesTitle | local testcasesTitle = env.testcasesTitle | ||
− | if testcasesTitle and testcasesTitle.exists then | + | if testcasesTitle and testcasesTitle.exists then -- Link to the testcases |
if testcasesTitle.contentModel == "Scribunto" then | if testcasesTitle.contentModel == "Scribunto" then | ||
local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display') | local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display') | ||
Line 404: | Line 400: | ||
local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay) | local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay) | ||
local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay) | local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay) | ||
− | text = text .. '<br />' .. message('sandbox-notice- | + | local testcasesText = testcasesLink .. ' (' .. testcasesRunLink .. ')' |
+ | text = text .. '<br />' .. message('sandbox-notice-warning-blurb', {testcasesText}) | ||
else | else | ||
local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display') | local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display') | ||
local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay) | local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay) | ||
− | text = text .. '<br />' .. message('sandbox-notice- | + | text = text .. '<br />' .. message('sandbox-notice-warning-blurb', {testcasesLink}) |
end | end | ||
+ | else -- Suggest creation of the testcases | ||
+ | local createUrl = testcasesTitle:fullUrl{action = 'edit', preload = message('template-testcases-preload')} | ||
+ | local testcasesText = message('sandbox-notice-testcases-link-display') .. ' <small>(' .. makeUrlLink(createUrl, message('sandbox-create-link-display')) .. ')</small>' | ||
+ | text = text .. '<br />' .. message('sandbox-notice-warning-blurb', {testcasesText}) | ||
end | end | ||
-- Add the sandbox to the sandbox category. | -- Add the sandbox to the sandbox category. | ||
Line 509: | Line 510: | ||
end | 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. | -- Create link if /doc doesn't exist. | ||
local preload = args.preload | local preload = args.preload | ||
Line 518: | Line 527: | ||
end | end | ||
end | end | ||
− | + | data.preload = preload | |
− | + | data.createLinkDisplay = message('create-link-display') | |
− | + | return data | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
end | end | ||
Line 537: | Line 537: | ||
-- @data - a table of data generated by p.makeStartBoxLinksData | -- @data - a table of data generated by p.makeStartBoxLinksData | ||
--]] | --]] | ||
+ | |||
+ | local function escapeBrackets(s) | ||
+ | -- Escapes square brackets with HTML entities. | ||
+ | s = s:gsub('%[', '[') -- Replace square brackets with HTML entities. | ||
+ | s = s:gsub('%]', ']') | ||
+ | return s | ||
+ | end | ||
+ | |||
+ | local ret | ||
local docTitle = data.docTitle | local docTitle = data.docTitle | ||
− | + | local title = data.title | |
− | local purgeLink = makeUrlLink( | + | local purgeLink = makeUrlLink(title:fullUrl{action = 'purge'}, data.purgeLinkDisplay) |
− | |||
if docTitle.exists then | if docTitle.exists then | ||
local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay) | local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay) | ||
local editLink = makeUrlLink(docTitle:fullUrl{action = 'edit'}, data.editLinkDisplay) | local editLink = makeUrlLink(docTitle:fullUrl{action = 'edit'}, data.editLinkDisplay) | ||
local historyLink = makeUrlLink(docTitle:fullUrl{action = 'history'}, data.historyLinkDisplay) | local historyLink = makeUrlLink(docTitle:fullUrl{action = 'history'}, data.historyLinkDisplay) | ||
− | + | ret = '[%s] [%s] [%s] [%s]' | |
+ | ret = escapeBrackets(ret) | ||
+ | ret = mw.ustring.format(ret, viewLink, editLink, historyLink, purgeLink) | ||
else | else | ||
− | local createLink = makeUrlLink(docTitle: | + | local createLink = makeUrlLink(docTitle:fullUrl{action = 'edit', preload = data.preload}, data.createLinkDisplay) |
− | + | ret = '[%s] [%s]' | |
+ | ret = escapeBrackets(ret) | ||
+ | ret = mw.ustring.format(ret, createLink, purgeLink) | ||
end | end | ||
return ret | return ret | ||
Line 764: | Line 776: | ||
-- /doc exists; link to it. | -- /doc exists; link to it. | ||
local docLink = makeWikilink(docTitle.prefixedText) | local docLink = makeWikilink(docTitle.prefixedText) | ||
+ | local editUrl = docTitle:fullUrl{action = 'edit'} | ||
local editDisplay = message('edit-link-display') | local editDisplay = message('edit-link-display') | ||
− | local editLink = makeUrlLink(docTitle:fullUrl{action = ' | + | local editLink = makeUrlLink(editUrl, editDisplay) |
+ | local historyUrl = docTitle:fullUrl{action = 'history'} | ||
local historyDisplay = message('history-link-display') | local historyDisplay = message('history-link-display') | ||
− | local historyLink = makeUrlLink( | + | local historyLink = makeUrlLink(historyUrl, historyDisplay) |
ret = message('transcluded-from-blurb', {docLink}) | ret = message('transcluded-from-blurb', {docLink}) | ||
.. ' ' | .. ' ' | ||
Line 774: | Line 788: | ||
elseif env.subjectSpace == 828 then | elseif env.subjectSpace == 828 then | ||
-- /doc does not exist; ask to create it. | -- /doc does not exist; ask to create it. | ||
− | local createUrl = docTitle: | + | local createUrl = docTitle:fullUrl{action = 'edit', preload = message('module-preload')} |
local createDisplay = message('create-link-display') | local createDisplay = message('create-link-display') | ||
local createLink = makeUrlLink(createUrl, createDisplay) | local createLink = makeUrlLink(createUrl, createDisplay) | ||
Line 825: | Line 839: | ||
local sandboxDisplay = message('sandbox-link-display') | local sandboxDisplay = message('sandbox-link-display') | ||
local sandboxLink = makeWikilink(sandboxPage, sandboxDisplay) | local sandboxLink = makeWikilink(sandboxPage, sandboxDisplay) | ||
+ | local sandboxEditUrl = sandboxTitle:fullUrl{action = 'edit'} | ||
local sandboxEditDisplay = message('sandbox-edit-link-display') | local sandboxEditDisplay = message('sandbox-edit-link-display') | ||
− | local sandboxEditLink = makeUrlLink( | + | local sandboxEditLink = makeUrlLink(sandboxEditUrl, sandboxEditDisplay) |
local compareUrl = env.compareUrl | local compareUrl = env.compareUrl | ||
local compareLink | local compareLink | ||
Line 841: | Line 856: | ||
sandboxPreload = message('template-sandbox-preload') | sandboxPreload = message('template-sandbox-preload') | ||
end | end | ||
− | local sandboxCreateUrl = sandboxTitle: | + | local sandboxCreateUrl = sandboxTitle:fullUrl{action = 'edit', preload = sandboxPreload} |
local sandboxCreateDisplay = message('sandbox-create-link-display') | local sandboxCreateDisplay = message('sandbox-create-link-display') | ||
local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay) | local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay) | ||
local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)}) | local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)}) | ||
local mirrorPreload = message('mirror-link-preload') | local mirrorPreload = message('mirror-link-preload') | ||
− | local mirrorUrl = sandboxTitle: | + | local mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary} |
if subjectSpace == 828 then | if subjectSpace == 828 then | ||
− | mirrorUrl = sandboxTitle: | + | mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = templateTitle.prefixedText, summary = mirrorSummary} |
end | end | ||
local mirrorDisplay = message('mirror-link-display') | local mirrorDisplay = message('mirror-link-display') | ||
Line 858: | Line 873: | ||
local testcasesDisplay = message('testcases-link-display') | local testcasesDisplay = message('testcases-link-display') | ||
local testcasesLink = makeWikilink(testcasesPage, testcasesDisplay) | local testcasesLink = makeWikilink(testcasesPage, testcasesDisplay) | ||
− | local testcasesEditUrl = testcasesTitle: | + | local testcasesEditUrl = testcasesTitle:fullUrl{action = 'edit'} |
local testcasesEditDisplay = message('testcases-edit-link-display') | local testcasesEditDisplay = message('testcases-edit-link-display') | ||
local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay) | local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay) | ||
Line 876: | Line 891: | ||
testcasesPreload = message('template-testcases-preload') | testcasesPreload = message('template-testcases-preload') | ||
end | end | ||
− | local testcasesCreateUrl = testcasesTitle: | + | local testcasesCreateUrl = testcasesTitle:fullUrl{action = 'edit', preload = testcasesPreload} |
local testcasesCreateDisplay = message('testcases-create-link-display') | local testcasesCreateDisplay = message('testcases-create-link-display') | ||
local testcasesCreateLink = makeUrlLink(testcasesCreateUrl, testcasesCreateDisplay) | local testcasesCreateLink = makeUrlLink(testcasesCreateUrl, testcasesCreateDisplay) |