Module:Asbox: Difference between revisions

From Zoophilia Wiki
Jump to navigationJump to search
meta>Codehydro
save
meta>Codehydro
back from dinner
Line 4: Line 4:
local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:Asbox'})
local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:Asbox'})
local output = mw.html.create('table')
local output = mw.html.create('table')
local page = mw.title.getCurrentTitle();
output
output
:addClass('metadata plainlinks stub')
:addClass('metadata plainlinks stub')
Line 12: Line 13:
:tag('td'):wikitext(args.icon or string.format('[[File:%s|%spx|alt=%s]]',args.image, args.pix and ('|' .. args.pix) or '',args.imagealt or 'Stub icon'))
:tag('td'):wikitext(args.icon or string.format('[[File:%s|%spx|alt=%s]]',args.image, args.pix and ('|' .. args.pix) or '',args.imagealt or 'Stub icon'))
end
end
local buffer = '\'\'This ' .. (args.subject and args.subject .. ' ' or '') .. (args.article or 'article') .. ' ' .. (args.qualifier and args.qualifier .. ' ' or '') .. '[[Wikipedia:stub|stub]].  You can help Wikipedia by [' .. tostring(mw.title.getCurrentTitle():fullUrl('action=edit', 'relative')) .. ' expanding it].\'\''
local buffer = '\'\'This ' .. (args.subject and args.subject .. ' ' or '') .. (args.article or 'article') .. ' ' .. (args.qualifier and args.qualifier .. ' ' or '') .. '[[Wikipedia:stub|stub]].  You can help Wikipedia by [' .. tostring(page:fullUrl('action=edit', 'relative')) .. ' expanding it].\'\''
if args.name then
if args.name then
buffer = buffer .. '{{navbar|{{{name}}}|mini=yes|style=position: absolute; right: 15px; display: none;}}'
buffer = buffer .. frame:expandTemplate{title = 'navbar', args = {'test', mini = 'yes', style = 'position: absolute; right: 15px; display: none;'}}
end
end
if args.note then
if args.note then
buffer = buffer .. '<br /><span style="font-style: normal; font-size: smaller;">{{{note}}}</span>'
buffer = buffer .. '<br /><span style="font-style: normal; font-size: smaller;">' .. args.note .. '</span>'
end
end
output
output
:tag('td'):wikitext(buffer)
:tag('td'):wikitext(buffer)
output = tostring(output)
if page.nsText == '' --[[Article space]] then
output = output .. '[[Category:All stub articles]]'
for k = 0,2 do
if args['category' .. (k > 0 and k or '')] then
output = string.format('%s[[Category:%s]]', output, args['category' .. (k > 0 and k or '')])
end
end
end
if args.demo == nil and page.basePageTitle ~= 'Template:Asbox' then
if frame:preprocess('{{FULLPAGENAME}}') == args.name then
output = output .. frame:expandTemplate{title = 'Asbox/templatepage', args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:Asbox'})}
elseif not page.isSubpage and page.nsText == 'Template' then
output = output .. '[[Category:Stub message templates needing attention|' .. (args.name and 'E' or 'W') .. page.text .. ']]'
end
end
return output
return output
end
end


return p
return p

Revision as of 03:30, 24 December 2014

Documentation for this module may be created at Module:Asbox/doc

local p = {}

function p.main(frame)
	local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:Asbox'})
	local output = mw.html.create('table')
	local page = mw.title.getCurrentTitle();
	output
		:addClass('metadata plainlinks stub')
		:css('background','transparent')
		:attr('role','presentation')
	if args.icon or args.image then
		output
			:tag('td'):wikitext(args.icon or string.format('[[File:%s|%spx|alt=%s]]',args.image, args.pix and ('|' .. args.pix) or '',args.imagealt or 'Stub icon'))
	end
	local buffer = '\'\'This ' .. (args.subject and args.subject .. ' ' or '') .. (args.article or 'article') .. ' ' .. (args.qualifier and args.qualifier .. ' ' or '') .. '[[Wikipedia:stub|stub]].  You can help Wikipedia by [' .. tostring(page:fullUrl('action=edit', 'relative')) .. ' expanding it].\'\''
	if args.name then
		buffer = buffer .. frame:expandTemplate{title = 'navbar', args = {'test', mini = 'yes', style = 'position: absolute; right: 15px; display: none;'}}
	end
	if args.note then
		buffer = buffer .. '<br /><span style="font-style: normal; font-size: smaller;">' .. args.note .. '</span>'
	end
	output
		:tag('td'):wikitext(buffer)
	output = tostring(output)
	if page.nsText == '' --[[Article space]] then
		output = output .. '[[Category:All stub articles]]'
		for k = 0,2 do
			if args['category' .. (k > 0 and k or '')] then
				output = string.format('%s[[Category:%s]]', output, args['category' .. (k > 0 and k or '')])
			end
		end
	end
	if args.demo == nil and page.basePageTitle ~= 'Template:Asbox' then
		if frame:preprocess('{{FULLPAGENAME}}') == args.name then
			output = output .. frame:expandTemplate{title = 'Asbox/templatepage', args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:Asbox'})}
		elseif not page.isSubpage and page.nsText == 'Template' then 
			output = output .. '[[Category:Stub message templates needing attention|' .. (args.name and 'E' or 'W') .. page.text .. ']]'
		end
	end
	return output
end

return p