Difference between revisions 51832 and 51833 on wikimaniawiki-- This module implements {{documentation}}. -- Get required modules. local getArgs = require('Module:Arguments').getArgs local htmlBuilder = require('Module:HtmlBuilder') local messageBox = require('Module:Message box') -- Get the config table. (contracted; show full)---------------------------------------------------------------------------- -- End box ---------------------------------------------------------------------------- p.endBox = makeInvokeFunc('_endBox') function p._endBox(args, env) --[ =[ -- This function generates the end box (also known as the link box). -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'fmbox-id' --> 'documentation-meta-data' -- 'fmbox-style' --> 'background-color: #ecfcf4' -- 'fmbox-textstyle' --> 'font-style: italic' --] ⏎ -- The HTML is generated by the {{fmbox}} template, courtesy of [[Module:Message box]]. --]=] -- Get environment data. local subjectSpace = env.subjectSpace local docTitle = env.docTitle if not subjectSpace or not docTitle then return nil end (contracted; show full) text = text .. '<br />' -- Show the categories text, but not if we have the content on the template page itself, -- or if the documentation page has been specified explicitly, since then it is unclear -- where to add the categories. if not args.content and not args[1] then text = text .. (p.makeCategoriesBlurb(args, env) or '') end -- Show the "subpages" link . if subjectSpace ~= 6 then -- Don't show the link in file space. if we are not in the File namespace. if subjectSpace ~= 6 then text = text .. ' ' .. (p.makeSubpagesBlurb(args, env) or '') end -- Show the "print" link if it exists. local printBlurb = p.makePrintBlurb(args, env) if printBlurb then text = text .. '<br />' .. printBlurb end end end fmargs.text = text -- Return the fmbox output.⏎ return messageBox.main('fmbox', fmargs) end function p.makePrintBlurb(args, env) -- Get the /Print title object local printTitle = env.printTitle if not printTitle then return nil end -- Make the print blurb. local ret if printTitle.exists then local printLink = makeWikilink(printTitle.prefixedText, message('print-link-display')) ret = message('print-blurb', {printLink}) local displayPrintCategory = message('display-print-category', nil, 'boolean') if displayPrintCategory then ret = ret .. makeCategoryLink(message('print-category')) end end return ret end function p.makeSubpagesBlurb(args, env) -- Get the template title object local subjectSpace = env.subjectSpace local templateTitle = env.templateTitle if not subjectSpace or not templateTitle then return nil end -- Make the subpages blurb. local pagetype if subjectSpace == 10 then pagetype = message('template-pagetype') elseif subjectSpace == 828 then pagetype = message('module-pagetype') else pagetype = message('default-pagetype') end return makeWikilink( 'Special:PrefixIndex/' .. templateTitle.prefixedText .. '/', message('subpages-link-display', {pagetype}) ) end function p.makeCategoriesBlurb(args, env) -- Get the title object. local docTitle = env.docTitle if not docTitle then return nil end -- Make the blurb. local docPathLink = makeWikilink(docTitle.prefixedText, message('doc-link-display')) return message('add-categories-blurb', {docPathLink}) end⏎ ⏎ function p.makeDocPageBlurb(args, env) -- Get the title object. local docTitle = env.docTitle if not docTitle then return nil end -- Make the blurb. local ret (contracted; show full) messageName = 'experiment-blurb-module' else messageName = 'experiment-blurb-template' end return message(messageName, {sandboxLinks, testcasesLinks}) end function p.makeCategoriesBlurb(args, env) -- Get the title object. local docTitle = env.docTitle if not docTitle then return nil end -- Make the blurb. local docPathLink = makeWikilink(docTitle.prefixedText, message('doc-link-display')) return message('add-categories-blurb', {docPathLink}) end function p.makeSubpagesBlurb(args, env) -- Get the template title object local subjectSpace = env.subjectSpace local templateTitle = env.templateTitle if not subjectSpace or not templateTitle then return nil end -- Make the subpages blurb. local pagetype if subjectSpace == 10 then pagetype = message('template-pagetype') elseif subjectSpace == 828 then pagetype = message('module-pagetype') else pagetype = message('default-pagetype') end return makeWikilink( 'Special:PrefixIndex/' .. templateTitle.prefixedText .. '/', message('subpages-link-display', {pagetype}) ) end function p.makePrintBlurb(args, env) -- Get the /Print title object local printTitle = env.printTitle if not printTitle then return nil end -- Make the print blurb. local ret if printTitle.exists then local printLink = makeWikilink(printTitle.prefixedText, message('print-link-display')) ret = message('print-blurb', {printLink}) local displayPrintCategory = message('display-print-category', nil, 'boolean') if displayPrintCategory then ret = ret .. makeCategoryLink(message('print-category')) end end return ret end⏎ ⏎ ---------------------------------------------------------------------------- -- Tracking categories ---------------------------------------------------------------------------- function p.addTrackingCategories(env) -- Check if {{documentation}} is transcluded on a /doc or /testcases page. local title = env.title local ret = '' local subpage = title.subpageText if message('display-strange-usage-category', nil, 'boolean') and (subpage == message('doc-subpage') or subpage == message('testcases-subpage')) then local sort = (title.namespace == 0 and message('strange-usage-category-mainspace-sort') or '') .. title.prefixedText -- Sort on namespace. ret = ret .. makeCategoryLink(message('strange-usage-category'), sort) end return ret end return p All content in the above text box is licensed under the Creative Commons Attribution-ShareAlike license Version 4 and was originally sourced from https://wikimania.wikimedia.org/w/index.php?diff=prev&oldid=51833.
![]() ![]() This site is not affiliated with or endorsed in any way by the Wikimedia Foundation or any of its affiliates. In fact, we fucking despise them.
|