Module:Documentation: Difference between revisions
From Roses, Tulips, & Liberty
Content deleted Content added
use docTitle.prefixedText instead of docpage |
split out experiment blurb code |
||
Line 229: | Line 229: | ||
function envFuncs.docTitle() |
function envFuncs.docTitle() |
||
local title = env.title |
local title = env.title |
||
local docname = args[1] -- |
local docname = args[1] -- User-specified doc page. |
||
⚫ | |||
⚫ | |||
local docpage |
local docpage |
||
if docname then |
if docname then |
||
docpage = docname |
docpage = docname |
||
else |
else |
||
⚫ | |||
local namespace = docspace or title.nsText |
|||
local pagename = templatePage or title.text |
|||
⚫ | |||
end |
end |
||
return mw.title.new(docpage) |
return mw.title.new(docpage) |
||
end |
end |
||
function envFuncs.docpageRoot() |
|||
⚫ | |||
return (env.docspace or title.nsText) .. ':' .. (env.templatePage or title.text) |
|||
⚫ | |||
function envFuncs.sandboxTitle() |
|||
local titleArg = env.docpageRoot .. '/' .. message('sandboxSubpage', 'string') |
|||
⚫ | |||
if not title then |
|||
error(message('titleArgError', 'string', {titleArg})) |
|||
⚫ | |||
return title |
|||
end |
|||
function envFuncs.testcasesTitle() |
|||
local titleArg = env.docpageRoot .. '/' .. message('testcasesSubpage', 'string') |
|||
⚫ | |||
if not title then |
|||
error(message('titleArgError', 'string', {titleArg})) |
|||
end |
|||
return title |
|||
end |
|||
function env:grab(key) |
function env:grab(key) |
||
local success, val = pcall(function() return self[key] end) |
local success, val = pcall(function() return self[key] end) |
||
Line 363: | Line 382: | ||
local title = data.title |
local title = data.title |
||
if docTitle.exists then |
if docTitle.exists then |
||
local viewLink = makeWikilink( |
local viewLink = makeWikilink(docpage, 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) |
||
Line 536: | Line 555: | ||
if subjectSpace == 2 or subjectSpace == 828 or subjectSpace == 10 then |
if subjectSpace == 2 or subjectSpace == 828 or subjectSpace == 10 then |
||
-- We are in the user, module or template namespaces. |
-- We are in the user, module or template namespaces. |
||
text = text .. p.makeEndBoxExperimentBlurb(args, env) |
|||
⚫ | |||
text = text .. '<br />' |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
local testcasesPreload = subjectSpace == 828 and message('moduleTestcasesPreload', 'string') or message('templateTestcasesPreload', 'string') |
|||
⚫ | |||
⚫ | |||
⚫ | |||
text = text .. message('experimentBlurb', 'string', {pagePossessive, sandboxLinks, testcasesLinks}) .. '<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 |
||
Line 593: | Line 588: | ||
-- Return the fmbox output. |
-- Return the fmbox output. |
||
return messageBox.main('fmbox', fmargs) |
return messageBox.main('fmbox', fmargs) |
||
end |
|||
function p.makeEndBoxExperimentBlurb(args, env) |
|||
-- Renders the text "Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages." |
|||
local subjectSpace = env.subjectSpace |
|||
⚫ | |||
-- Get title objects. |
|||
local sandboxSuccess, sandboxTitle = env:grab('sandboxTitle') |
|||
if not sandboxSuccess then |
|||
return err(sandboxTitle) |
|||
end |
|||
local testcasesSuccess, testcasesTitle = env:grab('testcasesTitle') |
|||
if not testcasesSuccess then |
|||
return err(testcasesTitle) |
|||
end |
|||
-- Make links. |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end |
|||
return message(subjectSpace == 828 and 'experimentBlurbModule' or 'experimentBlurbTemplate', 'string', {sandboxLinks, testcasesLinks}) |
|||
end |
end |
||