Difference between revisions of "Module:Extension"
getLicenseCategory
>Ricordisamoa (add AGPL-3.0) |
>Ricordisamoa (getLicenseCategory) |
||
Line 7: | Line 7: | ||
local cats = { | local cats = { | ||
GPL = 'GPL licensed extensions', | GPL = 'GPL licensed extensions', | ||
LGPL = 'LGPL licensed extensions', | |||
AGPL = 'AGPL licensed extensions', | |||
MIT = 'MIT licensed extensions', | |||
BSD = 'BSD licensed extensions', | |||
MPL = 'MPL licensed extensions', | |||
WTFPL = 'WTFPL licensed extensions', | |||
Apache = 'Apache licensed extensions', | |||
PD = 'Public domain licensed extensions', | |||
CC = 'Creative Commons licensed extensions' | CC = 'Creative Commons licensed extensions' | ||
} | } | ||
local licenses = { | local licenses = { | ||
['GPL'] = { '[' .. addr.GNU .. 'copyleft/gpl.html GNU General Public License]', | ['GPL'] = { '[' .. addr.GNU .. 'copyleft/gpl.html GNU General Public License]', 'GPL' }, | ||
['GPL-2.0'] = { '[' .. addr.GNU .. 'licenses/gpl-2.0.html GNU General Public License 2.0]', | ['GPL-2.0'] = { '[' .. addr.GNU .. 'licenses/gpl-2.0.html GNU General Public License 2.0]', 'GPL' }, | ||
['GPL-2.0+'] = { '[' .. addr.GNU .. 'licenses/gpl-2.0.html GNU General Public License 2.0] or later', | ['GPL-2.0+'] = { '[' .. addr.GNU .. 'licenses/gpl-2.0.html GNU General Public License 2.0] or later', 'GPL' }, | ||
['GPL-3.0'] = { '[' .. addr.GNU .. 'licenses/gpl-3.0.html GNU General Public License 3.0]', | ['GPL-3.0'] = { '[' .. addr.GNU .. 'licenses/gpl-3.0.html GNU General Public License 3.0]', 'GPL' }, | ||
['GPL-3.0+'] = { '[' .. addr.GNU .. 'licenses/gpl-3.0.html GNU General Public License 3.0] or later', | ['GPL-3.0+'] = { '[' .. addr.GNU .. 'licenses/gpl-3.0.html GNU General Public License 3.0] or later', 'GPL' }, | ||
['AGPL-3.0'] = { '[' .. addr.GNU .. 'licenses/agpl-3.0.html GNU Affero General Public License 3.0]', | ['AGPL-3.0'] = { '[' .. addr.GNU .. 'licenses/agpl-3.0.html GNU Affero General Public License 3.0]', 'AGPL' }, | ||
['AGPL-3.0+'] = { '[' .. addr.GNU .. 'licenses/agpl-3.0.html GNU Affero General Public License 3.0] or later', | ['AGPL-3.0+'] = { '[' .. addr.GNU .. 'licenses/agpl-3.0.html GNU Affero General Public License 3.0] or later', 'AGPL' }, | ||
['LGPL'] = { '[' .. addr.GNU .. 'copyleft/lesser.html GNU Lesser General Public License]' }, | ['LGPL'] = { '[' .. addr.GNU .. 'copyleft/lesser.html GNU Lesser General Public License]', 'LGPL' }, | ||
['LGPL-3.0'] = { '[' .. addr.GNU .. 'licenses/lgpl-3.0.html GNU Lesser General Public License 3.0]' }, | ['LGPL-3.0'] = { '[' .. addr.GNU .. 'licenses/lgpl-3.0.html GNU Lesser General Public License 3.0]', 'LGPL' }, | ||
['FDL'] = { '[' .. addr.GNU .. 'licenses/fdl.html GNU Free Documentation License]' }, | ['FDL'] = { '[' .. addr.GNU .. 'licenses/fdl.html GNU Free Documentation License]' }, | ||
} | } | ||
Line 118: | Line 126: | ||
end | end | ||
return res | return res | ||
end | |||
local function getLicenseCategory( str ) | |||
local str = mw.ustring.lower( str ) | |||
local cnf = licenses[str] | |||
if cnf then | |||
if #cnf > 1 then | |||
return tcat( cats[cnf[2]] ) | |||
end | |||
else | |||
return tcat( 'Extensions with unknown license' ) | |||
end | |||
end | end | ||
Line 149: | Line 169: | ||
function p.getType( frame ) | function p.getType( frame ) | ||
return getType( frame.args[1] ) | return getType( frame.args[1] ) | ||
end | |||
function p.getLicenseCategory( frame ) | |||
return getLicenseCategory( frame.args[1] ) | |||
end | end | ||
return p | return p |