کاربر ناشناس
پودمان:Message box: تفاوت میان نسخهها
support templatestyles
جز (۱ نسخه واردشده) |
(support templatestyles) |
||
خط ۸۱: | خط ۸۱: | ||
-- use template from DEMOSPACES | -- use template from DEMOSPACES | ||
obj.cfg = cfg[DEMOSPACES[demospace]] | obj.cfg = cfg[DEMOSPACES[demospace]] | ||
elseif string.find( demospace, ' | elseif string.find( demospace, 'talk' ) then | ||
-- demo as a talk page | -- demo as a talk page | ||
obj.cfg = cfg.tmbox | obj.cfg = cfg.tmbox | ||
خط ۱۳۳: | خط ۱۳۳: | ||
end | end | ||
if sort then | if sort then | ||
cat = string.format('[[ | cat = string.format('[[Category:%s|%s]]', cat, sort) | ||
else | else | ||
cat = string.format('[[ | cat = string.format('[[Category:%s]]', cat) | ||
end | end | ||
self.hasCategories = true | self.hasCategories = true | ||
خط ۲۰۶: | خط ۲۰۶: | ||
local templateName = mw.ustring.match( | local templateName = mw.ustring.match( | ||
self.name, | self.name, | ||
'^ | '^[tT][eE][mM][pP][lL][aA][tT][eE][%s_]*:[%s_]*(.*)$' | ||
) or self.name | ) or self.name | ||
templateName = ' | templateName = 'Template:' .. templateName | ||
self.templateTitle = getTitleObject(templateName) | self.templateTitle = getTitleObject(templateName) | ||
end | end | ||
خط ۲۲۴: | خط ۲۲۴: | ||
local sect | local sect | ||
if args.sect == '' then | if args.sect == '' then | ||
sect = ' | sect = 'This ' .. (cfg.sectionDefault or 'page') | ||
elseif type(args.sect) == 'string' then | elseif type(args.sect) == 'string' then | ||
sect = ' | sect = 'This ' .. args.sect | ||
end | end | ||
local issue = args.issue | local issue = args.issue | ||
خط ۲۷۳: | خط ۲۷۳: | ||
talkText = string.format('([[%s|talk]])', talkLink) | talkText = string.format('([[%s|talk]])', talkLink) | ||
else | else | ||
talkText = ' | talkText = 'Relevant discussion may be found on' | ||
if talkArgIsTalkPage then | if talkArgIsTalkPage then | ||
talkText = string.format( | talkText = string.format( | ||
'%s [[%s|%s]] | '%s [[%s|%s]].', | ||
talkText, | talkText, | ||
talk, | talk, | ||
talkTitle.prefixedText | talkTitle.prefixedText | ||
) | ) | ||
else | else | ||
talkText = string.format( | talkText = string.format( | ||
'%s [[%s#%s| | '%s the [[%s#%s|talk page]].', | ||
talkText, | talkText, | ||
talkTitle.prefixedText, | talkTitle.prefixedText, | ||
talk | talk | ||
) | ) | ||
end | end | ||
خط ۳۰۲: | خط ۳۰۰: | ||
date = args.date | date = args.date | ||
elseif args.date == '' and self.isTemplatePage then | elseif args.date == '' and self.isTemplatePage then | ||
date = lang:formatDate(' | date = lang:formatDate('F Y') | ||
end | end | ||
if date then | if date then | ||
self.date = string.format(" < | 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 | ||
خط ۳۲۸: | خط ۳۲۶: | ||
self.imageEmptyCell = cfg.imageEmptyCell | self.imageEmptyCell = cfg.imageEmptyCell | ||
if cfg.imageEmptyCellStyle then | if cfg.imageEmptyCellStyle then | ||
self.imageEmptyCellStyle = 'border:none;padding: | self.imageEmptyCellStyle = 'border:none;padding:0;width:1px' | ||
end | end | ||
خط ۳۴۱: | خط ۳۳۹: | ||
and (cfg.imageSmallSize or '30x30px') | and (cfg.imageSmallSize or '30x30px') | ||
or '40x40px' | or '40x40px' | ||
self.imageLeft = string.format('[[ | self.imageLeft = string.format('[[File:%s|%s|link=|alt=]]', self.typeImage | ||
or 'Imbox notice.png', imageSize) | or 'Imbox notice.png', imageSize) | ||
end | end | ||
خط ۳۵۱: | خط ۳۴۹: | ||
self.imageRight = imageRight | self.imageRight = imageRight | ||
end | end | ||
-- set templatestyles | |||
self.templatestyles = args.templatestyles | |||
end | end | ||
خط ۳۷۰: | خط ۳۷۱: | ||
local date = args.date | local date = args.date | ||
date = type(date) == 'string' and date | date = type(date) == 'string' and date | ||
local preposition = ' | local preposition = 'from' | ||
for _, num in ipairs(nums) do | for _, num in ipairs(nums) do | ||
local mainCat = args['cat' .. tostring(num)] | local mainCat = args['cat' .. tostring(num)] | ||
خط ۳۸۰: | خط ۳۸۱: | ||
local catTitle = string.format('%s %s %s', mainCat, preposition, date) | local catTitle = string.format('%s %s %s', mainCat, preposition, date) | ||
self:addCat(0, catTitle) | self:addCat(0, catTitle) | ||
catTitle = getTitleObject(' | catTitle = getTitleObject('Category:' .. catTitle) | ||
if not catTitle or not catTitle.exists then | if not catTitle or not catTitle.exists then | ||
self:addCat(0, ' | self:addCat(0, 'Articles with invalid date parameter in template') | ||
end | end | ||
elseif mainCat and (not date or date == '') then | elseif mainCat and (not date or date == '') then | ||
خط ۴۲۸: | خط ۴۲۹: | ||
if self.categoryNums and #self.categoryNums > 0 then | if self.categoryNums and #self.categoryNums > 0 then | ||
templateCat = templateErrorCategory | templateCat = templateErrorCategory | ||
templateSort = ' | templateSort = 'C' | ||
end | end | ||
end | end | ||
خط ۴۳۹: | خط ۴۴۰: | ||
if self.invalidTypeError then | if self.invalidTypeError then | ||
local allSort = (self.title.namespace == 0 and 'Main:' or '') .. self.title.prefixedText | local allSort = (self.title.namespace == 0 and 'Main:' or '') .. self.title.prefixedText | ||
self:addCat('all', ' | self:addCat('all', 'Wikipedia message box parameter needs fixing', allSort) | ||
end | end | ||
if self.isSubstituted then | if self.isSubstituted then | ||
self:addCat('all', ' | self:addCat('all', 'Pages with incorrectly substituted templates') | ||
end | end | ||
end | end | ||
خط ۴۸۱: | خط ۴۸۲: | ||
:addClass('error') | :addClass('error') | ||
:wikitext(string.format( | :wikitext(string.format( | ||
' | 'Template <code>%s[[Template:%s|%s]]%s</code> has been incorrectly substituted.', | ||
mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}') | mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}') | ||
)) | )) | ||
end | |||
-- Add support for a single custom templatestyles sheet. Undocumented as | |||
-- need should be limited and many templates using mbox are substed; we | |||
-- don't want to spread templatestyles sheets around to arbitrary places | |||
-- TODO: Add each template's stylesheet, waiting on [[MediaWiki talk:Common.css/to do]] | |||
local frame = mw.getCurrentFrame() -- we'll need this unconditionally for the TODO | |||
if self.templatestyles then | |||
root:wikitext(frame:extensionTag{ | |||
name = 'templatestyles', | |||
args = { src = self.templatestyles }, | |||
}) | |||
end | end | ||
خط ۵۴۶: | خط ۵۵۹: | ||
end | end | ||
if self.removalNotice then | if self.removalNotice then | ||
textCellDiv:tag(' | textCellDiv:tag('span') | ||
:addClass('hide-when-compact') | :addClass('hide-when-compact') | ||
:tag('i') | :tag('i') | ||
خط ۵۸۵: | خط ۵۹۸: | ||
:css('text-align', 'center') | :css('text-align', 'center') | ||
:wikitext(string.format( | :wikitext(string.format( | ||
' | 'This message box is using an invalid "type=%s" parameter and needs fixing.', | ||
self.type or '' | self.type or '' | ||
)) | )) |