|
|
Line 1: |
Line 1: |
| local p = {} | | local p = {} |
|
| |
| --from [[Module:SMW]]
| |
| local concat
| |
| local dump
| |
| local print
| |
| concat = function(...)
| |
| local args = {...}
| |
| if #args == 0 then
| |
| error('you must supply at least one argument to \'concat\' (got none)')
| |
| end
| |
| local firstArg = table.remove(args, 1)
| |
| if type(firstArg) == 'string' or type(firstArg) == 'number' then
| |
| firstArg = print(firstArg)
| |
| else
| |
| firstArg = ''
| |
| end
| |
| if #args == 0 then
| |
| return firstArg
| |
| else
| |
| return firstArg .. concat(unpack(args))
| |
| end
| |
| end
| |
| dump = function(entity, indent, omitType)
| |
| local entity = entity
| |
| local indent = indent and indent or ''
| |
| local omitType = omitType
| |
| if type( entity ) == 'table' then
| |
| local subtable
| |
| if not omitType then
| |
| subtable = '(table)[' .. #entity .. ']:'
| |
| end
| |
| indent = indent .. '\t'
| |
| for k, v in pairs( entity ) do
| |
| subtable = concat(subtable, '\n', indent, k, ': ', dump(v, indent, omitType))
| |
| end
| |
| return subtable
| |
| elseif type( entity ) == 'nil' or type( entity ) == 'function' or type( entity ) == 'boolean' then
| |
| return ( not omitType and '(' .. type(entity) .. ') ' or '' ) .. print(entity)
| |
| elseif type( entity ) == 'string' then
| |
| entity = mw.ustring.gsub(mw.ustring.gsub(entity, "\\'", "'"), "'", "\\'")
| |
| return concat(omitType or '(string) ', '\'', entity, '\'')
| |
| else
| |
| -- number value expected
| |
| return concat(omitType or '(' .. type( entity ) .. ') ', entity)
| |
| end
| |
| end
| |
| print = function(v)
| |
| if type( v ) == 'table' then
| |
| return table.concat(v, ',')
| |
| elseif type( v ) == 'boolean' then
| |
| return ( v and 'true' or 'false' )
| |
| elseif type(v) == 'string' or type(v) == 'number' then
| |
| return tostring(v)
| |
| else
| |
| return ''
| |
| end
| |
| end
| |
|
| |
|
| |
|
| |
|
| function p.proposalSupport(frame) | | function p.proposalSupport(frame) |
| local args = frame:getParent().args | | local args = frame:getParent().args |
| return dump(args) | | local supporters = #args |
| --[[local supporters = #args
| |
| local list = "" | | local list = "" |
| for i=1, #args do | | for i=1, #args do |
Line 69: |
Line 9: |
| end | | end |
| local final = '<div data-sort-value="' .. supporters .. '">' .. list .. '\n</div>' | | local final = '<div data-sort-value="' .. supporters .. '">' .. list .. '\n</div>' |
| return final]]-- | | return final |
| end | | end |
|
| |
|
| return p | | return p |