| 第108行: |
第108行: |
| | }) | | }) |
| | return p[funcName](args) | | return p[funcName](args) |
| | + | end |
| | + | end |
| | + | |
| | + | ---------------------------------------------------------------------------- |
| | + | -- Entry points |
| | + | ---------------------------------------------------------------------------- |
| | + | |
| | + | function p.nonexistent(frame) |
| | + | if mw.title.getCurrentTitle().subpageText == 'testcases' then |
| | + | return frame:expandTemplate{title = 'module test cases notice'} |
| | + | else |
| | + | return p.main(frame) |
| | end | | end |
| | end | | end |
| 第129行: |
第141行: |
| | local root = mw.html.create() | | local root = mw.html.create() |
| | root | | root |
| | + | :wikitext(p._getModuleWikitext(args, env)) |
| | :wikitext(p.protectionTemplate(env)) | | :wikitext(p.protectionTemplate(env)) |
| | :wikitext(p.sandboxNotice(args, env)) | | :wikitext(p.sandboxNotice(args, env)) |
| 第323行: |
第336行: |
| | -- Auxiliary templates | | -- Auxiliary templates |
| | ---------------------------------------------------------------------------- | | ---------------------------------------------------------------------------- |
| | + | p.getModuleWikitext = makeInvokeFunc('_getModuleWikitext') |
| | + | |
| | + | function p._getModuleWikitext(args, env) |
| | + | local currentTitle = mw.title.getCurrentTitle() |
| | + | if currentTitle.contentModel ~= 'Scribunto' then return end |
| | + | pcall(require, currentTitle.prefixedText) -- if it fails, we don't care |
| | + | local moduleWikitext = package.loaded["Module:Module wikitext"] |
| | + | if moduleWikitext then |
| | + | return moduleWikitext.main() |
| | + | end |
| | + | return '' |
| | + | end |
| | + | |
| | | | |
| | function p.sandboxNotice(args, env) | | function p.sandboxNotice(args, env) |
| 第355行: |
第381行: |
| | -- "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 |
| 第364行: |
第388行: |
| | else | | else |
| | pagetype = message('sandbox-notice-pagetype-other') | | pagetype = message('sandbox-notice-pagetype-other') |
| | + | end |
| | + | local pagetypee |
| | + | if subjectSpace == 10 then |
| | + | pagetypee = message('template-pagetype') |
| | + | elseif subjectSpace == 828 then |
| | + | pagetypee = message('module-pagetype') |
| | + | else |
| | + | pagetypee = message('default-pagetype')--message 'other-pagetype' 不存在 |
| | end | | end |
| | 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 |
| 第383行: |
第415行: |
| | 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-testcases-run-blurb', {testcasesLink, testcasesRunLink}) | + | text = text .. '<br /><small>' .. message('sandbox-notice-testcases-run-blurb', {pagetypee, testcasesLink, testcasesRunLink}) .. '</small>' |
| | 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-testcases-blurb', {testcasesLink}) | + | text = text .. '<br /><small>' .. message('sandbox-notice-testcases-blurb', {pagetypee, testcasesLink}) .. '</small>' |
| | end | | end |
| | end | | end |
| 第406行: |
第438行: |
| | 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 |
| 第556行: |
第584行: |
| | -- | | -- |
| | -- 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' |
| 第738行: |
第766行: |
| | text = text .. (p.makeCategoriesBlurb(args, env) or '') | | text = text .. (p.makeCategoriesBlurb(args, env) or '') |
| | end | | end |
| − | text = text .. ' ' .. (p.makeSubpagesBlurb(args, env) or '') --"Subpages of this template" | + | text = text .. (p.makeSubpagesBlurb(args, env) or '') --"Subpages of this template" |
| | local printBlurb = p.makePrintBlurb(args, env) -- Two-line blurb about print versions of templates. | | local printBlurb = p.makePrintBlurb(args, env) -- Two-line blurb about print versions of templates. |
| | if printBlurb then | | if printBlurb then |
| 第811行: |
第839行: |
| | -- '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' |
| 第859行: |
第887行: |
| | 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) |
| 第871行: |
第903行: |
| | 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 subjectSpace == 828 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 |