Difference between revisions of "Module:Extension"
Jump to navigation
Jump to search
generalised the use of “+” as “ or later”, as specified in SPDX 2.0; removed explicit .*\+$ licenses; change tested in the debugging console and on some pages; this change will simplify translation of the “ or later”
>Seb35 (+CC-BY-SA-2.5, added "or later" versions for CC-BY-SA licenses) |
>Seb35 (generalised the use of “+” as “ or later”, as specified in SPDX 2.0; removed explicit .*\+$ licenses; change tested in the debugging console and on some pages; this change will simplify translation of the “ or later”) |
||
Line 22: | Line 22: | ||
} | } | ||
local licenses = { | local licenses = { | ||
['GPL-2.0 | ['GPL-2.0'] = { '[' .. addr.GNU .. 'gpl-2.0.html GNU General Public License 2.0]', 'GPL' }, | ||
['GPL-3.0'] = { '[' .. addr.GNU .. 'gpl-3.0.html GNU General Public License 3.0]', 'GPL' }, | |||
['AGPL-3.0'] = { '[' .. addr.GNU .. 'agpl-3.0.html GNU Affero General Public License 3.0]', 'AGPL' }, | |||
['GPL-3.0 | ['LGPL-2.1'] = { '[' .. addr.GNU .. 'lgpl-2.1.html GNU Lesser General Public License 2.1]', 'LGPL' }, | ||
['AGPL-3.0 | ['LGPL-3.0'] = { '[' .. addr.GNU .. 'lgpl-3.0.html GNU Lesser General Public License 3.0]', 'LGPL' }, | ||
['FDL'] = { '[' .. addr.GNU .. 'fdl.html GNU Free Documentation License]' }, | |||
['LGPL-2.1 | ['MIT'] = { '[' .. addr.OSI .. 'mit-license.php MIT License]', 'MIT' }, | ||
['ISC'] = { '[' .. addr.OSI .. 'ISC ISC License]', 'ISC' }, | |||
['LGPL-3.0 | ['BSD-2-Clause'] = { '[' .. addr.OSI .. 'BSD-2-Clause BSD 2-clause "Simplified" License]', 'BSD' }, | ||
['BSD-3-Clause'] = { '[' .. addr.OSI .. 'BSD-3-Clause BSD 3-clause "Modified" License]', 'BSD' }, | |||
['FDL'] | ['BSD-4-Clause'] = { '[' .. addr.GNU .. 'license-list.html#OriginalBSD BSD-4-Clause BSD 4-clause "Original" License]', 'BSD' }, | ||
['MIT'] | ['MPL-1.0'] = { '[' .. addr.Mozilla .. 'MPL/1.0/ Mozilla Public License 1.0]', 'MPL' }, | ||
['ISC'] | ['MPL-2.0'] = { '[' .. addr.Mozilla .. 'MPL/2.0/ Mozilla Public License 2.0]', 'MPL' }, | ||
['BSD-2-Clause'] | ['WTFPL'] = { '[http://www.wtfpl.net WTFPL 2.0]', 'WTFPL' }, | ||
['BSD-3-Clause'] | ['Apache-2.0'] = { '[http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0]', 'Apache' }, | ||
['BSD-4-Clause'] | ['Zlib'] = { '[' .. addr.OSI .. 'Zlib zlib License]' }, | ||
['MPL-1.0'] | ['CC0-1.0'] = { '[//creativecommons.org/publicdomain/zero/1.0/ Creative Commons Zero v1.0 Universal]' }, | ||
['MPL-2.0'] | ['CC-BY-3.0'] = { '[' .. addr.CC .. 'by/3.0/ Creative Commons Attribution 3.0]', 'CC' }, | ||
['WTFPL'] | ['CC-BY-SA-2.0'] = { '[' .. addr.CC .. 'by-sa/2.0/ Creative Commons Attribution Share Alike 2.0]', 'CC' }, | ||
['Apache-2.0'] | ['CC-BY-SA-2.5'] = { '[' .. addr.CC .. 'by-sa/2.5/ Creative Commons Attribution Share Alike 2.5]', 'CC' }, | ||
['Zlib'] | ['CC-BY-SA-3.0'] = { '[' .. addr.CC .. 'by-sa/3.0/ Creative Commons Attribution Share Alike 3.0]', 'CC' }, | ||
['CC0-1.0'] | ['CC-BY-SA-4.0'] = { '[' .. addr.CC .. 'by-sa/4.0/ Creative Commons Attribution Share Alike 4.0]', 'CC' }, | ||
['CC-BY-3.0'] | ['ECL-2.0'] = { '[[wikipedia:Educational Community License|Educational Community License 2.0]]', 'ECL' }, | ||
['CC-BY-SA-2.0'] | ['PD'] = { '[[wikipedia:Public domain|Public domain]]', 'PD' }, | ||
['CC-BY-SA-2.5 | |||
['CC-BY-SA-3.0'] | |||
['CC-BY-SA-4.0'] | |||
['ECL-2.0'] | |||
['PD'] | |||
} | } | ||
local types = { | local types = { | ||
Line 156: | Line 147: | ||
local function getLicenseCategory( str ) | local function getLicenseCategory( str ) | ||
if mw.ustring.sub( str, -1 ) == '+' then | |||
str = mw.ustring.sub( str, 1, -2 ) | |||
end | |||
local cnf = licenses[str] | local cnf = licenses[str] | ||
if cnf then | if cnf then | ||
Line 167: | Line 161: | ||
local function getFormattedLicense( str ) | local function getFormattedLicense( str ) | ||
local cnf = licenses[ | local orlater = '' | ||
local license = str | |||
if mw.ustring.sub( str, -1 ) == '+' then | |||
license = mw.ustring.sub( str, 1, -2 ) | |||
orlater = ' or later' | |||
end | |||
local cnf = licenses[license] | |||
if cnf then | if cnf then | ||
return cnf[1] | return cnf[1] .. orlater | ||
else | else | ||
return str | return str |