Module:License

require('strict')

local p = {} --p stands for package

local getArgs = require('Module:Arguments').getArgs

function p._license(args) local frame = mw.getCurrentFrame -- Parameters local text = frame:preprocess(args.text or '') local image = args.image local image_r = args.image_r or args['image-r'] local image_size = args.image_size or args['image-size'] or 'x48px' local image_r_size = args.image_r_size or args['image-r-size'] or image_size local warning = args.warning local category = args.category local category2 = args.category2 if category == '' then category = nil end if category2 == '' then category2 = nil end -- licenseContainer is the class that styles depend on local class_param = 'class="' .. 'licenseContainer licenseBanner dynlayout-exempt ' .. (args.class or '') .. '"' local id_param = '' if args.id then id_param = 'id="' .. args.id .. '"' end -- opening div local openDiv = ' ' -- closing div local closeDiv = ' ' -- license banner local leftField = ' ' if image then leftField = ' ' end leftField = table.concat({openDiv, leftField, closeDiv}, '\n') local centerField = table.concat({openDiv, openDiv, text, closeDiv}, '\n') if warning then centerField = centerField .. '\n' .. table.concat({			openDiv,			openDiv,			'',			closeDiv,			openDiv,			warning,			closeDiv,			closeDiv		}, '\n') end centerField = centerField .. '\n' .. closeDiv local rightField = ' ' if image_r then rightField = ' ' end rightField = table.concat({openDiv, rightField, closeDiv}, '\n') local licenseBanner = table.concat({		openDiv,		openDiv,		openDiv,		leftField,		centerField,		rightField,		closeDiv,		closeDiv,		closeDiv	}) -- Commons auto-detection local commonsAutoDetection = table.concat({		' \n',		'Public domain ',		'Public domain ',		'false ',		'false ',		'\n '	}) -- Categorization local namespace = args.namespace or mw.title.getCurrentTitle.nsText local noCatNamespaces = { ['Help'] = true, ['Help talk'] = true, ['Template'] = true, ['Template talk'] = true, ['Wikisource'] = true, ['Wikisource talk'] = true, ['Module'] = true, ['Module talk'] = true, ['Category'] = true, ['Category talk'] = true }	local categoryContent = '' if not noCatNamespaces[namespace] then if namespace == 'Author' or namespace == 'Author talk' then if category then category = 'Author-' .. category end if category2 then category2 = 'Author-' .. category2 end end if category then category = '' end if category2 then category2 = '' end categoryContent = (category or '') .. (category2 or '') end local templateStyles = frame:preprocess('') return templateStyles .. table.concat({		'',		licenseBanner,		commonsAutoDetection,		categoryContent .. closeDiv	}, '\n') end

function p.license(frame) return p._license(getArgs(frame)) end

return p