Module:Documentation:修订间差异
删除的内容 添加的内容
移植 Module:Documentation(enwiki 骨架 + zhwiki 改进 + -{}- 变体支持) |
去掉 message() 中多余的 preprocess 调用(config 已无 -{}-) |
||
| (未显示同一用户的10个中间版本) | |||
第20行:
--[[
-- Gets a message from the cfg table and formats it if appropriate.
--
--]]
local msg = cfg[cfgKey]
第79行:
end
for i = 1, lim do
if v then
ret[#ret + 1] = v
end
end
if #ret == 0 then return nil end
return format(
'<span class="%s">(%s)</span>',
第254行 ⟶ 第258行:
function envFuncs.testcasesTitle()
return mw.title.new(env.docpageBase .. '/' .. message('testcases-subpage'))
end
function envFuncs.printTitle()
local templateTitle = env.templateTitle
if templateTitle then
return templateTitle:subPageTitle(message('print-subpage'))
end
return nil
end
第333行 ⟶ 第345行:
omargs.image = message('sandbox-notice-image')
local text = '__EXPECTUNUSEDTEMPLATE__'
local pagetype, pagetypee, sandboxCat
if subjectSpace == 10 then
第351行 ⟶ 第363行:
local templateLink = makeWikilink(templateTitle.prefixedText)
local compareUrl = env.compareUrl
-- mworg 预览检测:预览时不显示 diff 链接
if compareUrl then▼
local isPreviewing = mw.getCurrentFrame():preprocess('{{REVISIONID}}') == ''
▲ if isPreviewing or not compareUrl then
text = text .. message('sandbox-notice-blurb', {pagetype, templateLink})▼
else▼
local compareDisplay = message('sandbox-notice-compare-link-display')
local compareLink = makeUrlLink(compareUrl, compareDisplay)
text = text .. message('sandbox-notice-diff-blurb', {pagetype, templateLink, compareLink})
▲ else
▲ text = text .. message('sandbox-notice-blurb', {pagetype, templateLink})
end
第366行 ⟶ 第380行:
local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)
local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)
text = text .. '<br /><small>' .. message('sandbox-notice-testcases-run-blurb', {pagetypee, testcasesLink, testcasesRunLink}) .. '</small>'
else
local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)
text = text .. '<br /><small>' .. message('sandbox-notice-testcases-blurb', {pagetypee, testcasesLink}) .. '</small>'
end
end
第419行 ⟶ 第433行:
if subjectSpace == 828 then
preload = message('module-preload')
elseif subjectSpace == 6 then
preload = message('file-docpage-preload')
else
preload = message('docpage-preload')
第437行 ⟶ 第453行:
function p.renderStartBoxLinks(data)
local docTitle = data.docTitle
local purgeLink = makeWikilink("Special:Purge/" .. data.title.prefixedText, data.purgeLinkDisplay)
if docTitle.exists then
local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay)
local editLink = makeWikilink("Special:EditPage/" .. docTitle.prefixedText, data.editLinkDisplay)
local historyLink = makeWikilink("Special:PageHistory/" .. docTitle.prefixedText, data.historyLinkDisplay)
return format('[%s] [%s] [%s] [%s]',
else
local createLink = makeUrlLink(docTitle:canonicalUrl{action = 'edit', preload = data.preload}, data.createLinkDisplay)
return
end
end
第484行 ⟶ 第499行:
if links then
data.linksClass = message('start-box-link-classes')
data.linksId = message('start-box-link-id')
data.links = links
end
第574行 ⟶ 第590行:
end
text = text .. '' .. (p.makeSubpagesBlurb(args, env) or '')
-- Print 版本提示(位于 end box 末尾)
local printBlurb = p.makePrintBlurb(args, env)
if printBlurb then
text = text .. '<br />' .. printBlurb
end
end
end
第720行 ⟶ 第741行:
)
return message('subpages-blurb', {subpagesLink})
end
----------------------------------------------------------------------------
-- Print version
----------------------------------------------------------------------------
function p.makePrintBlurb(args, env)
--[=[
-- Generates the blurb displayed when there is a print version of the template available.
-- @args - a table of arguments passed by the user
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
--
-- Config keys:
-- 'print-subpage' --> 'Print'
-- 'print-link-display' --> '/Print'
-- 'print-blurb' --> '此模板有$1打印版本...'
-- 'display-print-category' --> false
-- 'print-category' --> '有打印版本的模板'
--]=]
local subjectSpace = env.subjectSpace
local printTitle = env.printTitle
if subjectSpace ~= 10 or not printTitle or not printTitle.exists then
return nil
end
local printLink = makeWikilink(printTitle.prefixedText, message('print-link-display'))
local text = message('print-blurb', {printLink})
if message('display-print-category', nil, 'boolean') then
text = text .. makeCategoryLink(message('print-category'))
end
return text
end
| |||