Module:Documentation: Difference between revisions
make [create] links look like [view] [edit] etc. links
m>Mr. Stradivarius (use the module preload in the start box create link if we're in the module namespace) |
m>Mr. Stradivarius (make [create] links look like [view] [edit] etc. links) |
||
Line 503: | Line 503: | ||
-- @data - a table of data generated by p.makeStartBoxLinksData | -- @data - a table of data generated by p.makeStartBoxLinksData | ||
--]] | --]] | ||
local function escapeBrackets(s) | |||
-- Escapes square brackets with HTML entities. | |||
s = s:gsub('%[', '[') -- Replace square brackets with HTML entities. | |||
s = s:gsub('%]', ']') | |||
return s | |||
end | |||
local ret | local ret | ||
local docTitle = data.docTitle | local docTitle = data.docTitle | ||
Line 512: | Line 520: | ||
local purgeLink = makeUrlLink(title:fullUrl{action = 'purge'}, data.purgeLinkDisplay) | local purgeLink = makeUrlLink(title:fullUrl{action = 'purge'}, data.purgeLinkDisplay) | ||
ret = '[%s] [%s] [%s] [%s]' | ret = '[%s] [%s] [%s] [%s]' | ||
ret = | ret = escapeBrackets(ret) | ||
ret = mw.ustring.format(ret, viewLink, editLink, historyLink, purgeLink) | ret = mw.ustring.format(ret, viewLink, editLink, historyLink, purgeLink) | ||
else | else | ||
local createLink = makeUrlLink(docTitle:fullUrl{action = 'edit', preload = data.preload}, data.createLinkDisplay) | |||
ret = '[%s]' | |||
ret = escapeBrackets(ret) | |||
ret = mw.ustring.format(ret, createLink) | |||
end | end | ||
return ret | return ret | ||
Line 534: | Line 544: | ||
-- 'file-namespace-heading' --> 'Summary' | -- 'file-namespace-heading' --> 'Summary' | ||
-- 'other-namespaces-heading' --> 'Documentation' | -- 'other-namespaces-heading' --> 'Documentation' | ||
-- 'start-box-linkclasses' --> 'mw-editsection plainlinks' | -- 'start-box-linkclasses' --> 'mw-editsection-like plainlinks' | ||
-- 'start-box-link-id' --> 'doc_editlinks' | -- 'start-box-link-id' --> 'doc_editlinks' | ||
-- 'testcases-create-link-display' --> 'create' | -- 'testcases-create-link-display' --> 'create' |