Anonymous
×
Create a new article
Write your page title here:
We currently have 15 articles on TwistedFates Database. Type your article name above or click on one of the titles below and start writing!



TwistedFates Database
15Articles

Module:Navbar and Module:Message box/configuration: Difference between pages

(Difference between pages)
m (1 revision imported)
 
m (1 revision imported)
 
Line 1: Line 1:
local p = {}
--------------------------------------------------------------------------------
local cfg = mw.loadData('Module:Navbar/configuration')
--                          Message box configuration                        --
--                                                                            --
-- This module contains configuration data for [[Module:Message box]].        --
--------------------------------------------------------------------------------


local function get_title_arg(is_collapsible, template)
return {
local title_arg = 1
ambox = {
if is_collapsible then title_arg = 2 end
types = {
if template then title_arg = 'template' end
speedy = {
return title_arg
class = 'ambox-speedy',
end
image = 'Ambox warning pn.svg'
 
},
local function choose_links(template, args)
delete = {
-- The show table indicates the default displayed items.
class = 'ambox-delete',
-- view, talk, edit, hist, move, watch
image = 'Ambox warning pn.svg'
-- TODO: Move to configuration.
},
local show = {true, true, true, false, false, false}
content = {
if template then
class = 'ambox-content',
show[2] = false
image = 'Ambox important.svg'
show[3] = false
},
local index = {t = 2, d = 2, e = 3, h = 4, m = 5, w = 6,
style = {
talk = 2, edit = 3, hist = 4, move = 5, watch = 6}
class = 'ambox-style',
-- TODO: Consider removing TableTools dependency.
image = 'Edit-clear.svg'
for _, v in ipairs(require ('Module:TableTools').compressSparseArray(args)) do
},
local num = index[v]
move = {
if num then show[num] = true end
class = 'ambox-move',
end
image = 'Merge-split-transwiki default.svg'
end
},
 
protection = {
local remove_edit_link = args.noedit
class = 'ambox-protection',
if remove_edit_link then show[3] = false end
image = 'Semi-protection-shackle-keyhole.svg'
},
notice = {
class = 'ambox-notice',
image = 'Information icon4.svg'
}
},
default                    = 'notice',
allowBlankParams            = {'talk', 'sect', 'date', 'issue', 'fix', 'subst', 'hidden'},
allowSmall                  = true,
smallParam                  = 'left',
smallClass                  = 'mbox-small-left',
substCheck                  = true,
classes                    = {'metadata', 'ambox'},
imageEmptyCell              = true,
imageCheckBlank            = true,
imageSmallSize              = '20x20px',
imageCellDiv                = true,
useCollapsibleTextFields    = true,
imageRightNone              = true,
sectionDefault              = 'article',
allowMainspaceCategories    = true,
templateCategory            = 'Article message templates',
        templateCategoryRequireName = true,
templateErrorCategory      = 'Article message templates with missing parameters',
templateErrorParamsToCheck  = {'issue', 'fix', 'subst'},
removalNotice              = '[[Help:Maintenance template removal|Learn how and when to remove this template message]]'
},
cmbox = {
types = {
speedy = {
class = 'cmbox-speedy',
image = 'Ambox warning pn.svg'
},
delete = {
class = 'cmbox-delete',
image = 'Ambox warning pn.svg'
},
content = {
class = 'cmbox-content',
image = 'Ambox important.svg'
},
style = {
class = 'cmbox-style',
image = 'Edit-clear.svg'
},
move = {
class = 'cmbox-move',
image = 'Merge-split-transwiki default.svg'
},
protection = {
class = 'cmbox-protection',
image = 'Semi-protection-shackle-keyhole.svg'
},
notice = {
class = 'cmbox-notice',
image = 'Information icon4.svg'
}
},
default              = 'notice',
showInvalidTypeError = true,
classes              = {'cmbox'},
imageEmptyCell      = true
},
return show
fmbox = {
types = {
warning = {
class = 'fmbox-warning',
image = 'Ambox warning pn.svg'
},
editnotice = {
class = 'fmbox-editnotice',
image = 'Information icon4.svg'
},
system = {
class = 'fmbox-system',
image = 'Information icon4.svg'
}
},
default              = 'system',
showInvalidTypeError = true,
classes              = {'fmbox'},
imageEmptyCell      = false,
imageRightNone      = false
},
end
imbox = {
 
types = {
local function add_link(link_description, ul, is_mini, font_style)
speedy = {
local l
class = 'imbox-speedy',
if link_description.url then
image = 'Ambox warning pn.svg'
l = {'[', '', ']'}
},
else
delete = {
l = {'[[', '|', ']]'}
class = 'imbox-delete',
end
image = 'Ambox warning pn.svg'
ul:tag('li')
},
:addClass('nv-' .. link_description.full)
content = {
:wikitext(l[1] .. link_description.link .. l[2])
class = 'imbox-content',
:tag(is_mini and 'abbr' or 'span')
image = 'Ambox important.svg'
:attr('title', link_description.html_title)
},
:cssText(font_style)
style = {
:wikitext(is_mini and link_description.mini or link_description.full)
class = 'imbox-style',
:done()
image = 'Edit-clear.svg'
:wikitext(l[3])
},
:done()
move = {
end
class = 'imbox-move',
 
image = 'Merge-split-transwiki default.svg'
local function make_list(title_text, has_brackets, displayed_links, is_mini, font_style)
},
protection = {
class = 'imbox-protection',
image = 'Semi-protection-shackle-keyhole.svg'
},
license = {
class = 'imbox-license licensetpl',
image = 'Imbox license.png' -- @todo We need an SVG version of this
},
featured = {
class = 'imbox-featured',
image = 'Cscr-featured.svg'
},
notice = {
class = 'imbox-notice',
image = 'Information icon4.svg'
}
},
default              = 'notice',
showInvalidTypeError = true,
classes              = {'imbox'},
imageEmptyCell      = true,
below                = true,
templateCategory    = 'File message boxes'
},
local title = mw.title.new(mw.text.trim(title_text), cfg.title_namespace)
ombox = {
if not title then
types = {
error(cfg.invalid_title .. title_text)
speedy = {
end
class = 'ombox-speedy',
local talkpage = title.talkPageTitle and title.talkPageTitle.fullText or ''
image = 'Ambox warning pn.svg'
},
delete = {
class = 'ombox-delete',
image = 'Ambox warning pn.svg'
},
content = {
class = 'ombox-content',
image = 'Ambox important.svg'
},
style = {
class = 'ombox-style',
image = 'Edit-clear.svg'
},
move = {
class = 'ombox-move',
image = 'Merge-split-transwiki default.svg'
},
protection = {
class = 'ombox-protection',
image = 'Semi-protection-shackle-keyhole.svg'
},
notice = {
class = 'ombox-notice',
image = 'Information icon4.svg'
}
},
default              = 'notice',
showInvalidTypeError = true,
classes              = {'ombox'},
allowSmall          = true,
imageEmptyCell      = true,
imageRightNone      = true
},
-- TODO: Get link_descriptions and show into the configuration module.
tmbox = {
-- link_descriptions should be easier...
types = {
local link_descriptions = {
speedy = {
{ ['mini'] = 'v', ['full'] = 'view', ['html_title'] = 'View this template',
class = 'tmbox-speedy',
['link'] = title.fullText, ['url'] = false },
image = 'Ambox warning pn.svg'
{ ['mini'] = 't', ['full'] = 'talk', ['html_title'] = 'Discuss this template',
},
['link'] = talkpage, ['url'] = false },
delete = {
{ ['mini'] = 'e', ['full'] = 'edit', ['html_title'] = 'Edit this template',
class = 'tmbox-delete',
['link'] = title:fullUrl('action=edit'), ['url'] = true },
image = 'Ambox warning pn.svg'
{ ['mini'] = 'h', ['full'] = 'hist', ['html_title'] = 'History of this template',
},
['link'] = title:fullUrl('action=history'), ['url'] = true },
content = {
{ ['mini'] = 'm', ['full'] = 'move', ['html_title'] = 'Move this template',
class = 'tmbox-content',
['link'] = mw.title.new('Special:Movepage'):fullUrl('target='..title.fullText), ['url'] = true },
image = 'Ambox important.svg'
{ ['mini'] = 'w', ['full'] = 'watch', ['html_title'] = 'Watch this template',  
},
['link'] = title:fullUrl('action=watch'), ['url'] = true }
style = {
class = 'tmbox-style',
image = 'Edit-clear.svg'
},
move = {
class = 'tmbox-move',
image = 'Merge-split-transwiki default.svg'
},
protection = {
class = 'tmbox-protection',
image = 'Semi-protection-shackle-keyhole.svg'
},
notice = {
class = 'tmbox-notice',
image = 'Information icon4.svg'
}
},
default              = 'notice',
showInvalidTypeError = true,
classes              = {'tmbox'},
allowSmall          = true,
imageRightNone      = true,
imageEmptyCell      = true,
imageEmptyCellStyle  = true,
templateCategory    = 'Talk message boxes'
}
}
 
}
local ul = mw.html.create('ul')
if has_brackets then
ul:addClass(cfg.classes.brackets)
:cssText(font_style)
end
for i, _ in ipairs(displayed_links) do
if displayed_links[i] then add_link(link_descriptions[i], ul, is_mini, font_style) end
end
return ul:done()
end
 
function p._navbar(args)
-- TODO: We probably don't need both fontstyle and fontcolor...
local font_style = args.fontstyle
local font_color = args.fontcolor
local is_collapsible = args.collapsible
local is_mini = args.mini
local is_plain = args.plain
local collapsible_class = nil
if is_collapsible then
collapsible_class = cfg.classes.collapsible
if not is_plain then is_mini = 1 end
if font_color then
font_style = (font_style or '') .. '; color: ' .. font_color .. ';'
end
end
local navbar_style = args.style
local div = mw.html.create():tag('div')
div
:addClass(cfg.classes.navbar)
:addClass(cfg.classes.plainlinks)
:addClass(cfg.classes.horizontal_list)
:addClass(collapsible_class) -- we made the determination earlier
:cssText(navbar_style)
 
if is_mini then div:addClass(cfg.classes.mini) end
 
local box_text = (args.text or cfg.box_text) .. ' '
-- the concatenated space guarantees the box text is separated
if not (is_mini or is_plain) then
div
:tag('span')
:addClass(cfg.classes.box_text)
:cssText(font_style)
:wikitext(box_text)
end
local template = args.template
local displayed_links = choose_links(template, args)
local has_brackets = args.brackets
local title_arg = get_title_arg(is_collapsible, template)
local title_text = args[title_arg] or (':' .. mw.getCurrentFrame():getParent():getTitle())
local list = make_list(title_text, has_brackets, displayed_links, is_mini, font_style)
div:node(list)
 
if is_collapsible then
local title_text_class
if is_mini then
title_text_class = cfg.classes.collapsible_title_mini
else
title_text_class = cfg.classes.collapsible_title_full
end
div:done()
:tag('div')
:addClass(title_text_class)
:cssText(font_style)
:wikitext(args[1])
end
return mw.getCurrentFrame():extensionTag{
name = 'templatestyles', args = { src = cfg.templatestyles }
} .. tostring(div:done())
end
 
function p.navbar(frame)
return p._navbar(require('Module:Arguments').getArgs(frame))
end
 
return p

Revision as of 21:26, 21 May 2021

Documentation for this module may be created at Module:Message box/configuration/doc

--------------------------------------------------------------------------------
--                          Message box configuration                         --
--                                                                            --
-- This module contains configuration data for [[Module:Message box]].        --
--------------------------------------------------------------------------------

return {
	ambox = {
		types = {
			speedy = {
				class = 'ambox-speedy',
				image = 'Ambox warning pn.svg'
			},
			delete = {
				class = 'ambox-delete',
				image = 'Ambox warning pn.svg'
			},
			content = {
				class = 'ambox-content',
				image = 'Ambox important.svg'
			},
			style = {
				class = 'ambox-style',
				image = 'Edit-clear.svg'
			},
			move = {
				class = 'ambox-move',
				image = 'Merge-split-transwiki default.svg'
			},
			protection = {
				class = 'ambox-protection',
				image = 'Semi-protection-shackle-keyhole.svg'
			},
			notice = {
				class = 'ambox-notice',
				image = 'Information icon4.svg'
			}
		},
		default                     = 'notice',
		allowBlankParams            = {'talk', 'sect', 'date', 'issue', 'fix', 'subst', 'hidden'},
		allowSmall                  = true,
		smallParam                  = 'left',
		smallClass                  = 'mbox-small-left',
		substCheck                  = true,
		classes                     = {'metadata', 'ambox'},
		imageEmptyCell              = true,
		imageCheckBlank             = true,
		imageSmallSize              = '20x20px',
		imageCellDiv                = true,
		useCollapsibleTextFields    = true,
		imageRightNone              = true,
		sectionDefault              = 'article',
		allowMainspaceCategories    = true,
		templateCategory            = 'Article message templates',
	        templateCategoryRequireName = true,
		templateErrorCategory       = 'Article message templates with missing parameters',
		templateErrorParamsToCheck  = {'issue', 'fix', 'subst'},
		removalNotice               = '[[Help:Maintenance template removal|Learn how and when to remove this template message]]'
	},
	
	cmbox = {
		types = {
			speedy = {
				class = 'cmbox-speedy',
				image = 'Ambox warning pn.svg'
			},
			delete = {
				class = 'cmbox-delete',
				image = 'Ambox warning pn.svg'
			},
			content = {
				class = 'cmbox-content',
				image = 'Ambox important.svg'
			},
			style = {
				class = 'cmbox-style',
				image = 'Edit-clear.svg'
			},
			move = {
				class = 'cmbox-move',
				image = 'Merge-split-transwiki default.svg'
			},
			protection = {
				class = 'cmbox-protection',
				image = 'Semi-protection-shackle-keyhole.svg'
			},
			notice = {
				class = 'cmbox-notice',
				image = 'Information icon4.svg'
			}
		},
		default              = 'notice',
		showInvalidTypeError = true,
		classes              = {'cmbox'},
		imageEmptyCell       = true
	},
	
	fmbox = {
		types = {
			warning = {
				class = 'fmbox-warning',
				image = 'Ambox warning pn.svg'
			},
			editnotice = {
				class = 'fmbox-editnotice',
				image = 'Information icon4.svg'
			},
			system = {
				class = 'fmbox-system',
				image = 'Information icon4.svg'
			}
		},
		default              = 'system',
		showInvalidTypeError = true,
		classes              = {'fmbox'},
		imageEmptyCell       = false,
		imageRightNone       = false
	},
	
	imbox = {
		types = {
			speedy = {
				class = 'imbox-speedy',
				image = 'Ambox warning pn.svg'
			},
			delete = {
				class = 'imbox-delete',
				image = 'Ambox warning pn.svg'
			},
			content = {
				class = 'imbox-content',
				image = 'Ambox important.svg'
			},
			style = {
				class = 'imbox-style',
				image = 'Edit-clear.svg'
			},
			move = {
				class = 'imbox-move',
				image = 'Merge-split-transwiki default.svg'
			},
			protection = {
				class = 'imbox-protection',
				image = 'Semi-protection-shackle-keyhole.svg'
			},
			license = {
				class = 'imbox-license licensetpl',
				image = 'Imbox license.png' -- @todo We need an SVG version of this
			},
			featured = {
				class = 'imbox-featured',
				image = 'Cscr-featured.svg'
			},
			notice = {
				class = 'imbox-notice',
				image = 'Information icon4.svg'
			}
		},
		default              = 'notice',
		showInvalidTypeError = true,
		classes              = {'imbox'},
		imageEmptyCell       = true,
		below                = true,
		templateCategory     = 'File message boxes'
	},
	
	ombox = {
		types = {
			speedy = {
				class = 'ombox-speedy',
				image = 'Ambox warning pn.svg'
			},
			delete = {
				class = 'ombox-delete',
				image = 'Ambox warning pn.svg'
			},
			content = {
				class = 'ombox-content',
				image = 'Ambox important.svg'
			},
			style = {
				class = 'ombox-style',
				image = 'Edit-clear.svg'
			},
			move = {
				class = 'ombox-move',
				image = 'Merge-split-transwiki default.svg'
			},
			protection = {
				class = 'ombox-protection',
				image = 'Semi-protection-shackle-keyhole.svg'
			},
			notice = {
				class = 'ombox-notice',
				image = 'Information icon4.svg'
			}
		},
		default              = 'notice',
		showInvalidTypeError = true,
		classes              = {'ombox'},
		allowSmall           = true,
		imageEmptyCell       = true,
		imageRightNone       = true
	},
	
	tmbox = {
		types = {
			speedy = {
				class = 'tmbox-speedy',
				image = 'Ambox warning pn.svg'
			},
			delete = {
				class = 'tmbox-delete',
				image = 'Ambox warning pn.svg'
			},
			content = {
				class = 'tmbox-content',
				image = 'Ambox important.svg'
			},
			style = {
				class = 'tmbox-style',
				image = 'Edit-clear.svg'
			},
			move = {
				class = 'tmbox-move',
				image = 'Merge-split-transwiki default.svg'
			},
			protection = {
				class = 'tmbox-protection',
				image = 'Semi-protection-shackle-keyhole.svg'
			},
			notice = {
				class = 'tmbox-notice',
				image = 'Information icon4.svg'
			}
		},
		default              = 'notice',
		showInvalidTypeError = true,
		classes              = {'tmbox'},
		allowSmall           = true,
		imageRightNone       = true,
		imageEmptyCell       = true,
		imageEmptyCellStyle  = true,
		templateCategory     = 'Talk message boxes'
	}
}