Line 355: |
Line 355: |
| -- "This is the template sandbox for [[Template:Foo]] (diff)." | | -- "This is the template sandbox for [[Template:Foo]] (diff)." |
| local text = '' | | local text = '' |
− | local frame = mw.getCurrentFrame()
| |
− | local isPreviewing = frame:preprocess('{{REVISIONID}}') == '' -- True if the page is being previewed.
| |
| local pagetype | | local pagetype |
| if subjectSpace == 10 then | | if subjectSpace == 10 then |
Line 367: |
Line 365: |
| local templateLink = makeWikilink(templateTitle.prefixedText) | | local templateLink = makeWikilink(templateTitle.prefixedText) |
| local compareUrl = env.compareUrl | | local compareUrl = env.compareUrl |
− | if isPreviewing or not compareUrl then | + | if compareUrl then |
− | text = text .. message('sandbox-notice-blurb', {pagetype, templateLink})
| |
− | else
| |
| local compareDisplay = message('sandbox-notice-compare-link-display') | | local compareDisplay = message('sandbox-notice-compare-link-display') |
| local compareLink = makeUrlLink(compareUrl, compareDisplay) | | local compareLink = makeUrlLink(compareUrl, compareDisplay) |
| text = text .. message('sandbox-notice-diff-blurb', {pagetype, templateLink, compareLink}) | | text = text .. message('sandbox-notice-diff-blurb', {pagetype, templateLink, compareLink}) |
| + | else |
| + | text = text .. message('sandbox-notice-blurb', {pagetype, templateLink}) |
| end | | end |
| -- Get the test cases page blurb if the page exists. This is something like | | -- Get the test cases page blurb if the page exists. This is something like |
Line 378: |
Line 376: |
| local testcasesTitle = env.testcasesTitle | | local testcasesTitle = env.testcasesTitle |
| if testcasesTitle and testcasesTitle.exists then | | if testcasesTitle and testcasesTitle.exists then |
− | if testcasesTitle.namespace == mw.site.namespaces.Module.id then | + | if testcasesTitle.contentModel == "Scribunto" then |
| local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display') | | local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display') |
| local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display') | | local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display') |
Line 406: |
Line 404: |
| local protectionLevels, mProtectionBanner | | local protectionLevels, mProtectionBanner |
| local title = env.title | | local title = env.title |
− | if title.namespace ~= 10 and title.namespace ~= 828 then
| |
− | -- Don't display the protection template if we are not in the template or module namespaces.
| |
− | return nil
| |
− | end
| |
| protectionLevels = env.protectionLevels | | protectionLevels = env.protectionLevels |
| if not protectionLevels then | | if not protectionLevels then |
Line 451: |
Line 445: |
| local links | | local links |
| local content = args.content | | local content = args.content |
− | if not content then | + | if not content or args[1] then |
| -- No need to include the links if the documentation is on the template page itself. | | -- No need to include the links if the documentation is on the template page itself. |
| local linksData = p.makeStartBoxLinksData(args, env) | | local linksData = p.makeStartBoxLinksData(args, env) |
Line 489: |
Line 483: |
| if not title or not docTitle then | | if not title or not docTitle then |
| return nil | | return nil |
| + | end |
| + | if docTitle.isRedirect then |
| + | docTitle = docTitle.redirectTarget |
| end | | end |
| | | |
Line 556: |
Line 553: |
| -- | | -- |
| -- Messages: | | -- Messages: |
− | -- 'documentation-icon-wikitext' --> '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=Documentation icon]]' | + | -- 'documentation-icon-wikitext' --> '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]]' |
| -- 'template-namespace-heading' --> 'Template documentation' | | -- 'template-namespace-heading' --> 'Template documentation' |
| -- 'module-namespace-heading' --> 'Module documentation' | | -- 'module-namespace-heading' --> 'Module documentation' |
Line 811: |
Line 808: |
| -- 'mirror-edit-summary' --> 'Create sandbox version of $1' | | -- 'mirror-edit-summary' --> 'Create sandbox version of $1' |
| -- 'mirror-link-display' --> 'mirror' | | -- 'mirror-link-display' --> 'mirror' |
| + | -- 'mirror-link-preload' --> 'Template:Documentation/mirror' |
| -- 'sandbox-link-display' --> 'sandbox' | | -- 'sandbox-link-display' --> 'sandbox' |
| -- 'testcases-link-display' --> 'testcases' | | -- 'testcases-link-display' --> 'testcases' |
| -- 'testcases-edit-link-display'--> 'edit' | | -- 'testcases-edit-link-display'--> 'edit' |
− | -- 'module-testcases-preload' --> 'Template:Documentation/preload-module-testcases'
| |
| -- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox' | | -- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox' |
| -- 'testcases-create-link-display' --> 'create' | | -- 'testcases-create-link-display' --> 'create' |
Line 859: |
Line 856: |
| 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 mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = templatePage, summary = mirrorSummary} | + | local mirrorPreload = message('mirror-link-preload') |
| + | local mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary} |
| + | if subjectSpace == 828 then |
| + | mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = templateTitle.prefixedText, summary = mirrorSummary} |
| + | end |
| local mirrorDisplay = message('mirror-link-display') | | local mirrorDisplay = message('mirror-link-display') |
| local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay) | | local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay) |
Line 871: |
Line 872: |
| local testcasesEditDisplay = message('testcases-edit-link-display') | | local testcasesEditDisplay = message('testcases-edit-link-display') |
| local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay) | | local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay) |
− | testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink) | + | -- for Modules, add testcases run link if exists |
| + | if testcasesTitle.contentModel == "Scribunto" and testcasesTitle.talkPageTitle and testcasesTitle.talkPageTitle.exists then |
| + | local testcasesRunLinkDisplay = message('testcases-run-link-display') |
| + | local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay) |
| + | testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink, testcasesRunLink) |
| + | else |
| + | testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink) |
| + | end |
| else | | else |
| local testcasesPreload | | local testcasesPreload |