Module:Sandbox/BrandonXLF/3: Difference between revisions

Content deleted Content added
No edit summary
Theme navbox-image
 
(25 intermediate revisions by the same user not shown)
Line 1:
-- Sandbox, do not delete
 
return {
local getArgs = require('Module:Arguments').getArgs
aria_label = 'Navbox',
local p = {}
nowrap_item = '%s<span class="nowrap">%s</span>',
 
templatestyles = mw.getCurrentFrame():extensionTag{
local function getCountry(country)
name = 'templatestyles', args = { src = 'User:BrandonXLF/styles2.css' }
local title = mw.title.new(country)
},
hlist_templatestyles = 'Hlist/styles.css',
if not title or not title.exists then
plainlist_templatestyles = 'Plainlist/styles.css',
return country
-- do not localize marker table
end
marker = {
oddeven = '\127_ODDEVEN_\127',
return '[[' .. country .. ']]'
restart = '\127_ODDEVEN0_\127',
end
regex = '\127_ODDEVEN(%d?)_\127'
 
},
local function getTimespan(timespan)
category = {
return ' (' .. timespan .. ')'
orphan = '[[Category:Navbox orphans]]',
end
horizontal_lists = 'Navigational boxes without horizontal lists',
 
background_colors = 'Navboxes using background colours',
local function getImage(image)
illegible = 'Potentially illegible navboxes',
local file = nil
borders = 'Navboxes using borders',
 
},
if string.match(image, ".-%.") then
keyword = {
file = mw.getCurrentFrame():expandTemplate{title = "flagicon image", args = {image}}
border_subgroup = 'subgroup',
elseif string.match(image, ".-%s%(.-%)") then
border_child = 'child',
local country, var = string.match(image,"(.-)%s%((.-)%)")
border_none = 'none',
file = mw.getCurrentFrame():expandTemplate{title = "flagdeco", args = {country, var, noredlink = 'y'}}
evenodd_swap = 'swap',
else
navbar_off = 'off',
file = mw.getCurrentFrame():expandTemplate{title = "flagdeco", args = {image, noredlink = 'y'}}
navbar_plain = 'plain',
end
nocat_false = 'false',
 
nowrapitems_yes = 'yes',
return file
orphan_yes = 'yes',
end
state_collapsed = 'collapsed',
 
state_off = 'off',
function p.main(frame)
state_plain = 'plain',
local args = getArgs(frame)
subgroups = {'subgroup', 'child', ''},
local hasImages = false
subpage_doc = 'doc',
local entries = {}
subpage_sandbox = 'sandbox',
local i = 1
subpage_testcases = 'testcases',
 
tracking_no = 'no'
for i, entry in ipairs(args) do
},
local country, timespan, image
class = {
autocollapse = 'autocollapse',
for line in args[i]:gmatch('[^\n]+') do
collapsible = 'mw-collapsible',
line = mw.text.trim(line)
collapsed = 'mw-collapsed',
-- Warning
local key, val = line:match('^([a-z]*):? *(.*)$')
navbox = 'navbox', -- WMF currently hides 'navbox' from mobile,
-- so you probably shouldn't change the navbox class.
if key == '' then
navbox_abovebelow = 'navbox-abovebelow notheme',
country = getCountry(val)
navbox_group = 'navbox-group notheme',
elseif key == 'date' then
navbox_image = 'navbox-image',
timespan = getTimespan(val)
navbox_inner = 'navbox-inner notheme',
elseif key == 'flag' then
navbox_list = 'navbox-list notheme',
image = getImage(val)
navbox_list_with_group = 'navbox-list-with-group',
else
navbox_part = 'navbox-', -- do not l10n
return require('Module:Error').error{'Invalid key ' .. key .. ' in argument ' .. i}
navbox_styles = 'navbox-styles',
end
navbox_subgroup = 'navbox-subgroup',
end
navbox_title = 'navbox-title notheme', -- l10n only if you change pattern.navbox_title below
navbox_odd_part = 'odd', -- do not l10n
if not country then
navbox_even_part = 'even', -- do not l10n
return require('Module:Error').error{'A country is required in argument ' .. i}
nomobile = 'nomobile',
end
nowraplinks = 'nowraplinks',
noviewer = 'noviewer' -- used to remove images from MediaViewer
if not timespan then
},
return require('Module:Error').error{'A date is required in argument ' .. i}
pattern = {
end
listnum = '^list(%d+)$',
class = 'class',
table.insert(entries, {
countrysandbox = country'/sandbox$',
navbox = 'Template:Navbox',
timespan = timespan,
nowrap = '^<span class="nowrap">',
image = image,
style = 'style$',
})
navbox_title = '<th[^>]*"navbox%-title"',
hlist = 'hlist',
if image then
plainlist = 'plainlist',
hasImages = true
},
end
arg = {
iabove = i + 1'above',
aboveclass = 'aboveclass',
end
abovestyle = 'abovestyle',
basestyle = 'basestyle',
local outTable = mw.html.create('table')
bodyclass = 'bodyclass',
:css({
paddingbodystyle = '5pxbodystyle',
floatborder = args.float or 'leftborder',
['background-color']below = '#f8f9fabelow',
borderbelowclass = '1px solid #aaabelowclass',
widthbelowstyle = '20embelowstyle',
['font-size']evenodd = '90%evenodd',
evenstyle = 'evenstyle',
})
group1 = 'group1',
 
group2 = 'group2',
outTable:tag('tr')
group_and_num = 'group%d',
:tag('th')
groupstyle_and_num = 'group%dstyle',
:attr('colspan', hasImages and 2 or 1)
groupclass = 'groupclass',
:css({
['text-align']groupstyle = 'centergroupstyle',
['font-size']groupwidth = 'largergroupwidth',
innerstyle = 'innerstyle',
['font-weight'] = 'bold'
image = 'image',
})
imageclass = 'imageclass',
:wikitext(args.title and args.title or 'Historical affiliations')
imageleft = 'imageleft',
 
imageleftstyle = 'imageleftstyle',
for i, entry in ipairs(entries) do
imagesetyle = 'imagestyle',
local row = outTable:tag('tr')
list_and_num = 'list%d',
listclass_and_num = 'list%dclass',
if entry.image then
liststyle_and_num = 'list%dstyle',
row:tag('td')
list1padding = 'list1padding',
:css('vertical-align', 'top')
listclass = 'listclass',
:wikitext(entry.image)
listpadding = 'listpadding',
elseif hasImages then
liststyle = 'liststyle',
row:tag('td')
name = 'name',
end
navbar = 'navbar',
navboxclass = 'navboxclass',
row:tag('td')
nocat = 'nocat',
:css({
widthnowrapitems = '100%nowrapitems',
oddstyle = 'oddstyle',
['vertical-align'] = 'top'
orphan = 'orphan',
})
state = 'state',
:wikitext(entry.country .. entry.timespan)
style = 'style',
end
templatestyles = 'templatestyles',
 
child_templatestyles = 'child templatestyles',
return tostring(outTable)
title = 'title',
end
titleclass = 'titleclass',
 
titlestyle = 'titlestyle',
return p
tracking = 'tracking'
},
-- names of navbar arguments
navbar = {
name = 1,
fontstyle = 'fontstyle',
mini = 'mini'
}
}