「モジュール:Documentation」の版間の差分

en:Module:Documentation 16:34, 28 August 2015‎(UTC)より
編集の要約なし
template>K-iczn
(en:Module:Documentation 16:34, 28 August 2015‎(UTC)より)
1行目: 1行目:
-- This モジュール implements {{documentation}}.
-- This module implements {{documentation}}.


-- Get required modules.
-- Get required modules.
local getArgs = require('モジュール:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs
local htmlBuilder = require('モジュール:HtmlBuilder')
local messageBox = require('Module:Message box')
local messageBox = require('モジュール:Message box')


-- Get the config table.
-- Get the config table.
local cfg = mw.loadData('モジュール:Documentation/config')
local cfg = mw.loadData('Module:Documentation/config')


local p = {}
local p = {}
34行目: 33行目:
expectType = expectType or 'string'
expectType = expectType or 'string'
if type(msg) ~= expectType then
if type(msg) ~= expectType then
error('message: type error in message cfg.' .. cfgKey .. ' (' .. expectType .. ' expected, got ' .. type(msg) .. ')', 2)
error('メッセージ: メッセージCFGの入力エラー。' .. cfgKey .. ' (' .. expectType .. ' expected, got ' .. type(msg) .. ')', 2)
end
end
if not valArray then
if not valArray then
42行目: 41行目:
local function getMessageVal(match)
local function getMessageVal(match)
match = tonumber(match)
match = tonumber(match)
return valArray[match] or error('message: no value found for key $' .. match .. ' in message cfg.' .. cfgKey, 4)
return valArray[match] or error('メッセージ: メッセージCFGにおいて$' .. match .. 'キーへの値の入力が必要です。' .. cfgKey, 4)
end
end


128行目: 127行目:
--]]
--]]
local env = p.getEnvironment(args)
local env = p.getEnvironment(args)
local root = htmlBuilder.create()
local root = mw.html.create()
root
root
.wikitext(p.protectionTemplate(env))
:wikitext(p.protectionTemplate(env))
.wikitext(p.sandboxNotice(args, env))
:wikitext(p.sandboxNotice(args, env))
-- This div tag is from {{documentation/start box}}, but moving it here
-- This div tag is from {{documentation/start box}}, but moving it here
-- 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', message('main-div-id'))
:attr('id', message('main-div-id'))
.addClass(message('main-div-classes'))
:addClass(message('main-div-classes'))
                        .css('background-color', '#ecfcf4')
:newline()
                        .css('border', '1px solid #aaa')
:wikitext(p._startBox(args, env))
                        .css('padding', '12px')
:wikitext(p._content(args, env))
.newline()
:tag('div')
.wikitext(p._startBox(args, env))
:css('clear', 'both') -- So right or left floating items don't stick out of the doc box.
.wikitext(p._content(args, env))
:newline()
.tag('div')
:done()
.css('clear', 'both') -- So right or left floating items don't stick out of the doc box.
:done()
.newline()
:wikitext(p._endBox(args, env))
.done()
:wikitext(p.addTrackingCategories(env))
.done()
.wikitext(p._endBox(args, env))
.newline()
.wikitext(p.addTrackingCategories(env))
return tostring(root)
return tostring(root)
end
end
409行目: 404行目:
-- 'protection-template' --> 'pp-template'
-- 'protection-template' --> 'pp-template'
-- 'protection-template-args' --> {docusage = 'yes'}
-- 'protection-template-args' --> {docusage = 'yes'}
local protectionLevels, mProtectionBanner
local title = env.title
local title = env.title
local protectionLevels
if title.namespace ~= 10 and title.namespace ~= 828 then
local protectionTemplate = message('protection-template')
local namespace = title.namespace
if not (protectionTemplate and (namespace == 10 or namespace == 828)) then
-- Don't display the protection template if we are not in the template or module namespaces.
-- Don't display the protection template if we are not in the template or module namespaces.
return nil
return nil
421行目: 414行目:
return nil
return nil
end
end
local editLevels = protectionLevels.edit
local editProt = protectionLevels.edit and protectionLevels.edit[1]
local moveLevels = protectionLevels.move
local moveProt = protectionLevels.move and protectionLevels.move[1]
if moveLevels and moveLevels[1] == 'sysop' or editLevels and editLevels[1] then
if editProt then
-- The page is full-move protected, or full, template, or semi-protected.
-- The page is edit-protected.
local frame = mw.getCurrentFrame()
mProtectionBanner = require('Module:Protection banner')
return frame:expandTemplate{title = protectionTemplate, args = message('protection-template-args', nil, 'table')}
local reason = message('protection-reason-edit')
return mProtectionBanner._main{reason, small = true}
elseif moveProt and moveProt ~= 'autoconfirmed' then
-- The page is move-protected but not edit-protected. Exclude move
-- protection with the level "autoconfirmed", as this is equivalent to
-- no move protection at all.
mProtectionBanner = require('Module:Protection banner')
return mProtectionBanner._main{action = 'move', small = true}
else
else
return nil
return nil
616行目: 616行目:
-- Renders the start box html.
-- Renders the start box html.
-- @data - a table of data generated by p.makeStartBoxData.
-- @data - a table of data generated by p.makeStartBoxData.
local sbox = htmlBuilder.create('div')
local sbox = mw.html.create('div')
sbox
sbox
.css('padding-bottom', '3px')
:css('padding-bottom', '3px')
.css('border-bottom', '1px solid #aaa')
:css('border-bottom', '1px solid #aaa')
.css('margin-bottom', '1ex')
:css('margin-bottom', '1ex')
.newline()
:newline()
.tag('span')
:tag('span')
.cssText(data.headingStyleText)
:cssText(data.headingStyleText)
.css('font-weight', data.headingFontWeight)
:css('font-weight', data.headingFontWeight)
.css('font-size', data.headingFontSize)
:css('font-size', data.headingFontSize)
.wikitext(data.heading)
:wikitext(data.heading)
local links = data.links
local links = data.links
if links then
if links then
sbox.tag('span')
sbox:tag('span')
.addClass(data.linksClass)
:addClass(data.linksClass)
.attr('id', data.linksId)
:attr('id', data.linksId)
.wikitext(links)
:wikitext(links)
end
end
return tostring(sbox)
return tostring(sbox)
730行目: 730行目:
-- Add sandbox and testcases links.
-- Add sandbox and testcases links.
-- "Editors can experiment in this template's sandbox and testcases pages."
-- "Editors can experiment in this template's sandbox and testcases pages."
text = text .. p.makeExperimentBlurb(args, env)
text = text .. (p.makeExperimentBlurb(args, env) or '')
text = text .. '<br />'
text = text .. '<br />'
if not args.content and not args[1] then
if not args.content and not args[1] then
811行目: 811行目:
-- 'mirror-edit-summary' --> 'Create sandbox version of $1'
-- 'mirror-edit-summary' --> 'Create sandbox version of $1'
-- 'mirror-link-display' --> 'mirror'
-- 'mirror-link-display' --> 'mirror'
-- 'mirror-link-preload' --> 'Template:Documentation/mirror'
-- 'sandbox-link-display' --> 'sandbox'
-- 'sandbox-link-display' --> 'sandbox'
-- 'testcases-link-display' --> 'testcases'
-- 'testcases-link-display' --> 'testcases'
-- 'testcases-edit-link-display'--> 'edit'
-- 'testcases-edit-link-display'--> 'edit'
-- 'module-testcases-preload' --> 'Template:Documentation/preload-module-testcases'
-- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox'
-- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox'
-- 'testcases-create-link-display' --> 'create'
-- 'testcases-create-link-display' --> 'create'
859行目: 859行目:
local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay)
local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay)
local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)})
local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)})
local mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = templatePage, summary = mirrorSummary}
local mirrorPreload = message('mirror-link-preload')
local mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary}
local mirrorDisplay = message('mirror-link-display')
local mirrorDisplay = message('mirror-link-display')
local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay)
local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay)
匿名利用者