Module:Documentation: Difference between revisions
Jump to navigation
Jump to search
m>Mr. Stradivarius simplify the content function |
m>Mr. Stradivarius finish moving end box code into sub-functions |
||
Line 528: | Line 528: | ||
function p._endBox(args, env) | function p._endBox(args, env) | ||
-- This function generates the end box (also known as the link box). | |||
-- Get environment data. | |||
local subjectSpace = env.subjectSpace | local subjectSpace = env.subjectSpace | ||
local success, docTitle = env:grab('docTitle') | |||
if not success then | |||
return docTitle -- Error message | |||
local | |||
if | |||
end | end | ||
-- Check whether we should output the end box at all. Add the end | |||
-- box by default if the documentation exists or if we are in the | |||
-- user, module or template namespaces. | |||
if linkBox == 'off' | |||
or not ( | |||
docTitle.exists | |||
-- | or subjectSpace == 2 | ||
or subjectSpace == 828 | |||
or subjectSpace == 10 | |||
) | |||
if linkBox == 'off' or not ( | then | ||
return nil | return nil | ||
end | end | ||
Line 580: | Line 570: | ||
text = text .. p.makeEndBoxExperimentBlurb(args, env) | text = text .. p.makeEndBoxExperimentBlurb(args, env) | ||
text = text .. '<br />' | text = text .. '<br />' | ||
-- Show the categories text, but not if "content" fed or "docname fed" since then it is unclear where to add the categories. | -- Show the categories text, but not if "content" fed or "docname fed" | ||
-- since then it is unclear where to add the categories. | |||
if not content and not docnameFed then | if not content and not docnameFed then | ||
text = text .. (p.makeCategoriesBlurb(args, env) or '') | |||
text = text .. | |||
end | end | ||
-- Show the "subpages" link. | -- Show the "subpages" link. | ||
if subjectSpace ~= 6 then -- Don't show the link in file space. | if subjectSpace ~= 6 then -- Don't show the link in file space. | ||
text = text .. ' ' .. (p.makeSubpagesBlurb(args, env) or '') | |||
text = text .. ' ' .. | |||
end | end | ||
-- Show the "print" link if it exists. | -- Show the "print" link if it exists. | ||
local | local printBlurb = p.makePrintBlurb(args, env) | ||
if printBlurb then | |||
if | text = text .. '<br />' .. printBlurb | ||
text = text .. '<br />' .. | |||
end | end | ||
end | end | ||
Line 611: | Line 590: | ||
-- Return the fmbox output. | -- Return the fmbox output. | ||
return messageBox.main('fmbox', fmargs) | return messageBox.main('fmbox', fmargs) | ||
end | |||
function p.makePrintBlurb(args, env) | |||
-- Get the /Print title object | |||
local success, printTitle = env:grab('printTitle') | |||
if not success then | |||
return printTitle -- Error message | |||
end | |||
-- Make the print blurb. | |||
local ret | |||
if printTitle.exists then | |||
local printLink = makeWikilink(printTitle.prefixedText, message('printLinkDisplay', 'string')) | |||
ret = message('printBlurb', 'string', {printLink}) | |||
local displayPrintCategory = message('displayPrintCategory', 'boolean') | |||
if displayPrintCategory then | |||
ret = ret .. makeCategoryLink(message('printCategory', 'string')) | |||
end | |||
end | |||
return ret | |||
end | |||
function p.makeSubpagesBlurb(args, env) | |||
-- Get the template title object | |||
local success, templateTitle = env:grab('templateTitle') | |||
if not success then | |||
return templateTitle -- Error message. | |||
end | |||
-- Make the subpages blurb. | |||
local pagetype | |||
if subjectSpace == 10 then | |||
pagetype = message('templatePagetype', 'string') | |||
elseif subjectSpace == 828 then | |||
pagetype = message('modulePagetype', 'string') | |||
else | |||
pagetype = message('defaultPagetype', 'string') | |||
end | |||
return makeWikilink( | |||
'Special:PrefixIndex/' .. templateTitle.prefixedText .. '/', | |||
message('subpagesLinkDisplay', 'string', {pagetype}) | |||
) | |||
end | end | ||