모듈:Message box 편집하기

귀하는 로그인되어 있지 않습니다. 이대로 편집하면 귀하의 IP 주소가 편집 기록에 남게 됩니다.

편집을 취소할 수 있습니다. 이 편집을 되돌리려면 아래의 바뀐 내용을 확인한 후 게시해주세요.

최신판 당신의 편집
13번째 줄: 13번째 줄:
local CONFIG_MODULE = 'Module:Message box/configuration'
local CONFIG_MODULE = 'Module:Message box/configuration'
local DEMOSPACES = {talk = 'tmbox', image = 'imbox', file = 'imbox', category = 'cmbox', article = 'ambox', main = 'ambox'}
local DEMOSPACES = {talk = 'tmbox', image = 'imbox', file = 'imbox', category = 'cmbox', article = 'ambox', main = 'ambox'}
local TEMPLATE_STYLES = 'Module:Message box/%s.css'


--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
67번째 줄: 66번째 줄:
args = args or {}
args = args or {}
local obj = {}
local obj = {}
obj.boxType = boxType


-- Set the title object and the namespace.
-- Set the title object and the namespace.
84번째 줄: 81번째 줄:
-- use template from DEMOSPACES
-- use template from DEMOSPACES
obj.cfg = cfg[DEMOSPACES[demospace]]
obj.cfg = cfg[DEMOSPACES[demospace]]
obj.boxType = DEMOSPACES[demospace]
elseif string.find( demospace, 'talk' ) then
elseif string.find( demospace, 'talk' ) then
-- demo as a talk page
-- demo as a talk page
obj.cfg = cfg.tmbox
obj.cfg = cfg.tmbox
obj.boxType = 'tmbox'
else
else
-- default to ombox
-- default to ombox
obj.cfg = cfg.ombox
obj.cfg = cfg.ombox
obj.boxType = 'ombox'
end
end
elseif ns == 0 then
elseif ns == 0 then
obj.cfg = cfg.ambox -- main namespace
obj.cfg = cfg.ambox -- main namespace
obj.boxType = 'ambox'
elseif ns == 6 then
elseif ns == 6 then
obj.cfg = cfg.imbox -- file namespace
obj.cfg = cfg.imbox -- file namespace
obj.boxType = 'imbox'
elseif ns == 14 then
elseif ns == 14 then
obj.cfg = cfg.cmbox -- category namespace
obj.cfg = cfg.cmbox -- category namespace
obj.boxType = 'cmbox'
else
else
local nsTable = mw.site.namespaces[ns]
local nsTable = mw.site.namespaces[ns]
if nsTable and nsTable.isTalk then
if nsTable and nsTable.isTalk then
obj.cfg = cfg.tmbox -- any talk namespace
obj.cfg = cfg.tmbox -- any talk namespace
obj.boxType = 'tmbox'
else
else
obj.cfg = cfg.ombox -- other namespaces or invalid input
obj.cfg = cfg.ombox -- other namespaces or invalid input
obj.boxType = 'ombox'
end
end
end
end
279번째 줄: 268번째 줄:
end
end
if talkTitle and talkTitle.exists then
if talkTitle and talkTitle.exists then
local talkText = 'Relevant discussion may be found on'
                local talkText
if talkArgIsTalkPage then
                if self.isSmall then
talkText = string.format(
                    local talkLink = talkArgIsTalkPage and talk or (talkTitle.prefixedText .. '#' .. talk)
'%s [[%s|%s]].',
                    talkText = string.format('([[%s|talk]])', talkLink)
talkText,
                else
talk,
                    talkText = 'Relevant discussion may be found on'
talkTitle.prefixedText
                    if talkArgIsTalkPage then
)
                        talkText = string.format(
else
                            '%s [[%s|%s]].',
talkText = string.format(
                            talkText,
'%s the [[%s#%s|talk page]].',
                            talk,
talkText,
                            talkTitle.prefixedText
talkTitle.prefixedText,
                        )
talk
                    else
)
                        talkText = string.format(
end
                            '%s the [[%s#%s|talk page]].',
                            talkText,
                            talkTitle.prefixedText,
                            talk
                        )
                    end
                end
self.talk = talkText
self.talk = talkText
end
end
308번째 줄: 303번째 줄:
end
end
if date then
if date then
self.date = string.format(" <small class='date-container'>''(<span class='date'>%s</span>)''</small>", date)
self.date = string.format(" <span class='date-container'>''(<span class='date'>%s</span>)''</span>", date)
end
end
self.info = args.info
self.info = args.info
331번째 줄: 326번째 줄:
self.imageEmptyCell = cfg.imageEmptyCell
self.imageEmptyCell = cfg.imageEmptyCell
if cfg.imageEmptyCellStyle then
if cfg.imageEmptyCellStyle then
self.imageEmptyCellStyle = 'border:none;padding:0px;width:1px'
self.imageEmptyCellStyle = 'border:none;padding:0;width:1px'
end
end


488번째 줄: 483번째 줄:
))
))
end
end
-- Add TemplateStyles
root:wikitext(mw.getCurrentFrame():extensionTag{
name = 'templatestyles',
args = { src = TEMPLATE_STYLES:format(self.boxType) },
})


-- Create the box table.
-- Create the box table.
local boxTable
local boxTable = root:tag('table')
-- Check for fmbox because not all interface messages have mw-parser-output
-- which is necessary for TemplateStyles. Add the wrapper class if it is and
-- then start the actual mbox, else start the mbox.
if self.boxType == 'fmbox' then
boxTable = root:tag('div')
:addClass('mw-parser-output')
:tag('table')
else
boxTable = root:tag('table')
end
 
boxTable:attr('id', self.id or nil)
boxTable:attr('id', self.id or nil)
for i, class in ipairs(self.classes or {}) do
for i, class in ipairs(self.classes or {}) do
552번째 줄: 530번째 줄:
:addClass('mbox-text-span')
:addClass('mbox-text-span')
:wikitext(self.issue or nil)
:wikitext(self.issue or nil)
if (self.talk or self.fix) and not self.isSmall then
if (self.talk or self.fix) then
textCellDiv:tag('span')
textCellDiv:tag('span')
:addClass('hide-when-compact')
:addClass('hide-when-compact')
566번째 줄: 544번째 줄:
end
end
if self.removalNotice then
if self.removalNotice then
textCellDiv:tag('small')
textCellDiv:tag('span')
:addClass('hide-when-compact')
:addClass('hide-when-compact')
:tag('i')
:tag('i')
가온 위키에서의 모든 기여는 크리에이티브 커먼즈 저작자표시-동일조건변경허락 라이선스로 배포된다는 점을 유의해 주세요(자세한 내용에 대해서는 가온 위키:저작권 문서를 읽어주세요). 만약 여기에 동의하지 않는다면 문서를 저장하지 말아 주세요.
또한, 직접 작성했거나 퍼블릭 도메인과 같은 자유 문서에서 가져왔다는 것을 보증해야 합니다. 저작권이 있는 내용을 허가 없이 저장하지 마세요!
취소 편집 도움말 (새 창에서 열림)