Module:Documentation: Difference between revisions
From Video Credit Archive
Content deleted Content added
wikpedia>Mr. Stradivarius put argument names into a config file for easy porting to other wikis |
wikpedia>Mr. Stradivarius more il8n work |
||
Line 21: | Line 21: | ||
cfg.contentArg = 'content' -- Passes documentation content directly from the {{documentation}} invocation. |
cfg.contentArg = 'content' -- Passes documentation content directly from the {{documentation}} invocation. |
||
cfg.linkBoxArg = 'link box' -- Specifies a custom link box (end box) or prevents it from being generated. |
cfg.linkBoxArg = 'link box' -- Specifies a custom link box (end box) or prevents it from being generated. |
||
-- Software settings |
|||
-- The following are software settings that may change from wiki to wiki. For example, the classes |
|||
-- defined in commons.css or the names of templates. |
|||
cfg.mainDivId = 'template-documentation' -- The "id" attribute of the main HTML "div" tag. |
|||
cfg.mainDivClasses = 'template-documentation iezoomfix' -- The CSS classes added to the main HTML "div" tag. |
|||
cfg.sandboxSubpage = 'sandbox' -- The name of the template subpage typically used for sandboxes. |
|||
-- Display settings |
|||
-- The following settings configure the values displayed by the module. |
|||
cfg.sandboxLinkDisplay = 'sandbox' |
|||
---------------------------------------------------------------------------- |
---------------------------------------------------------------------------- |
||
Line 104: | Line 117: | ||
-- so that we don't have to worry about unclosed tags. |
-- so that we don't have to worry about unclosed tags. |
||
.tag('div') |
.tag('div') |
||
.attr('id', |
.attr('id', cfg.mainDivId) |
||
.addClass( |
.addClass(cfg.mainDivClasses) |
||
.wikitext(p._startBox(args)) |
.wikitext(p._startBox(args)) |
||
.wikitext(p._content(args)) |
.wikitext(p._content(args)) |
||
Line 118: | Line 131: | ||
function p.sandboxNotice(args) |
function p.sandboxNotice(args) |
||
if currentTitle.subpageText == |
if currentTitle.subpageText == cfg.sandboxSubpage then |
||
local frame = mw.getCurrentFrame() |
local frame = mw.getCurrentFrame() |
||
local root = htmlBuilder.create() |
local root = htmlBuilder.create() |
||
Line 293: | Line 306: | ||
local docExist = docTitle.exists |
local docExist = docTitle.exists |
||
local docnameFed = args[1] and true |
local docnameFed = args[1] and true |
||
local sandbox = docpageRoot .. '/ |
local sandbox = docpageRoot .. '/' .. cfg.sandboxSubpage |
||
local testcases = docpageRoot .. '/testcases' |
local testcases = docpageRoot .. '/testcases' |
||
templatePage = currentTitle.nsText .. ':' .. templatePage |
templatePage = currentTitle.nsText .. ':' .. templatePage |
||
Line 337: | Line 350: | ||
local sandboxTitle = mw.title.new(sandbox) |
local sandboxTitle = mw.title.new(sandbox) |
||
if sandboxTitle.exists then |
if sandboxTitle.exists then |
||
local sandboxLink = makeWikilink(sandbox, |
local sandboxLink = makeWikilink(sandbox, cfg.sandboxLinkDisplay) |
||
local sandboxEditLink = makeUrlLink(sandboxTitle:fullUrl{action = 'edit'}, 'edit') |
local sandboxEditLink = makeUrlLink(sandboxTitle:fullUrl{action = 'edit'}, 'edit') |
||
local compareLink = makeUrlLink(mw.title.new('Special:ComparePages'):fullUrl{page1 = templatePage, page2 = sandbox}, 'diff') |
local compareLink = makeUrlLink(mw.title.new('Special:ComparePages'):fullUrl{page1 = templatePage, page2 = sandbox}, 'diff') |
||
Line 346: | Line 359: | ||
local mirrorSummary = 'Create sandbox version of ' .. makeWikilink(templatePage) |
local mirrorSummary = 'Create sandbox version of ' .. makeWikilink(templatePage) |
||
local mirrorLink = makeUrlLink(sandboxTitle:fullUrl{action = 'edit', preload = templatePage, summary = mirrorSummary}, 'mirror') |
local mirrorLink = makeUrlLink(sandboxTitle:fullUrl{action = 'edit', preload = templatePage, summary = mirrorSummary}, 'mirror') |
||
text = text .. ' |
text = text .. cfg.sandboxLinkDisplay .. ' ' .. makeToolbar(sandboxCreateLink, mirrorLink) |
||
end |
end |
||
text = text .. ' and ' |
text = text .. ' and ' |
||
Line 417: | Line 430: | ||
-- Determines the template page. No namespace or interwiki prefixes are included. |
-- Determines the template page. No namespace or interwiki prefixes are included. |
||
local subpage = currentTitle.subpageText |
local subpage = currentTitle.subpageText |
||
if subpage == |
if subpage == cfg.sandboxSubpage or subpage == 'testcases' then |
||
return currentTitle.baseText |
return currentTitle.baseText |
||
else |
else |