Difference between revisions of "Module:Extension"

1,169 bytes added ,  13:40, 3 October 2021
m
Alpha sort licenses
>Pppery
(Sync from sandbox)
>P858snake
m (Alpha sort licenses)
 
(26 intermediate revisions by 6 users not shown)
Line 21: Line 21:
CC    = 'Creative Commons licensed extensions',
CC    = 'Creative Commons licensed extensions',
ECL    = 'Educational Community licensed extensions',
ECL    = 'Educational Community licensed extensions',
Unlicense = 'The Unlicense licensed extensions',
BLANK  = 'Extensions with no license specified'
BLANK  = 'Extensions with no license specified'
}
}
local licenses = {
local licenses = {
['AGPL-3.0']    = { addr.GNU .. 'agpl-3.0.html', 'GNU Affero General Public License 3.0', 'AGPL' },
['AGPL-3.0-only']    = { addr.GNU .. 'agpl-3.0.html', 'GNU Affero General Public License 3.0', 'AGPL' },
['AGPL-3.0-or-later'] = { addr.GNU .. 'agpl-3.0.html', 'GNU Affero General Public License 3.0 or later', 'AGPL' },
['Apache-2.0']  = { '//www.apache.org/licenses/LICENSE-2.0', 'Apache License 2.0', 'Apache' },
['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' },
['BSD-4-Clause'] = { addr.GNU .. 'license-list.html#OriginalBSD', 'BSD 4-clause "Original" License', 'BSD' },
['CC-BY-3.0']    = { addr.CC .. 'by/3.0/', 'Creative Commons Attribution 3.0', 'CC' },
['CC-BY-3.0-US'] = { addr.CC .. 'by/3.0/us/', 'Creative Commons Attribution 3.0 United States', 'CC' },
['CC-BY-NC-3.0'] = { addr.CC .. 'by-nc/3.0/', 'Creative Commons Attribution NonCommercial 3.0', 'CC' },
['CC-BY-NC-SA-2.5'] = { addr.CC .. 'by-nc-sa/2.5/', 'Creative Commons Attribution NonCommercial Share Alike 2.5', 'CC' },
['CC-BY-NC-SA-3.0'] = { addr.CC .. 'by-nc-sa/3.0/', 'Creative Commons Attribution NonCommercial Share Alike 3.0', 'CC' },
['CC-BY-NC-SA-4.0'] = { addr.CC .. 'by-nc-sa/4.0/', 'Creative Commons Attribution NonCommercial Share Alike 4.0', 'CC' },
['CC-BY-SA-2.0'] = { addr.CC .. 'by-sa/2.0/', 'Creative Commons Attribution Share Alike 2.0', 'CC' },
['CC-BY-SA-2.0-UK'] = { addr.CC .. 'by-sa/2.0/uk/', 'Creative Commons Attribution Share Alike 2.0 England and Wales', 'CC' },
['CC-BY-SA-2.5'] = { addr.CC .. 'by-sa/2.5/', 'Creative Commons Attribution Share Alike 2.5', 'CC' },
['CC-BY-SA-3.0'] = { addr.CC .. 'by-sa/3.0/', 'Creative Commons Attribution Share Alike 3.0', 'CC' },
['CC-BY-SA-4.0'] = { addr.CC .. 'by-sa/4.0/', 'Creative Commons Attribution Share Alike 4.0', 'CC' },
['CC0-1.0']      = { '//creativecommons.org/publicdomain/zero/1.0/', 'Creative Commons Zero v1.0 Universal', 'PD' },
['ECL-2.0']      = { '', '[[wikipedia:Educational Community License|Educational Community License 2.0]]', 'ECL' },
['FDL']          = { addr.GNU .. 'fdl.html', 'GNU Free Documentation License', 'FDL' },
['GPL-2.0']      = { addr.GNU .. 'old-licenses/gpl-2.0-standalone.html', 'GNU General Public License 2.0', 'GPL' },
['GPL-2.0']      = { addr.GNU .. 'old-licenses/gpl-2.0-standalone.html', 'GNU General Public License 2.0', 'GPL' },
['GPL-2.0-only'] = { addr.GNU .. 'old-licenses/gpl-2.0-standalone.html', 'GNU General Public License 2.0 only', 'GPL' },
['GPL-2.0-only'] = { addr.GNU .. 'old-licenses/gpl-2.0-standalone.html', 'GNU General Public License 2.0 only', 'GPL' },
Line 30: Line 52:
['GPL-3.0-only'] = { addr.GNU .. 'gpl-3.0-standalone.html', 'GNU General Public License 3.0 only', 'GPL' },
['GPL-3.0-only'] = { addr.GNU .. 'gpl-3.0-standalone.html', 'GNU General Public License 3.0 only', 'GPL' },
['GPL-3.0-or-later'] = { addr.GNU .. 'gpl-3.0-standalone.html', 'GNU General Public License 3.0 or later', 'GPL' },
['GPL-3.0-or-later'] = { addr.GNU .. 'gpl-3.0-standalone.html', 'GNU General Public License 3.0 or later', 'GPL' },
['AGPL-3.0']     = { addr.GNU .. 'agpl-3.0.html', 'GNU Affero General Public License 3.0', 'AGPL' },
['ISC']         = { addr.OSI .. 'ISC', 'ISC License', 'ISC' },
['AGPL-3.0-or-later'] = { addr.GNU .. 'agpl-3.0.html', 'GNU Affero General Public License 3.0 or later', 'AGPL' },
['LGPL-2.1']    = { addr.GNU .. 'old-licenses/lgpl-2.1-standalone.html', 'GNU Lesser General Public License 2.1', 'LGPL' },
['LGPL-2.1']    = { addr.GNU .. 'old-licenses/lgpl-2.1-standalone.html', 'GNU Lesser General Public License 2.1', 'LGPL' },
['LGPL-2.1-only'] = { addr.GNU .. 'old-licenses/lgpl-2.1-standalone.html', 'GNU Lesser General Public License 2.1 only', 'LGPL' },
['LGPL-2.1-only'] = { addr.GNU .. 'old-licenses/lgpl-2.1-standalone.html', 'GNU Lesser General Public License 2.1 only', 'LGPL' },
Line 38: Line 59:
['LGPL-3.0-only'] = { addr.GNU .. 'lgpl-3.0-standalone.html', 'GNU Lesser General Public License 3.0 only', 'LGPL' },
['LGPL-3.0-only'] = { addr.GNU .. 'lgpl-3.0-standalone.html', 'GNU Lesser General Public License 3.0 only', 'LGPL' },
['LGPL-3.0-or-later'] = { addr.GNU .. 'lgpl-3.0-standalone.html', 'GNU Lesser General Public License 3.0 or later', 'LGPL' },
['LGPL-3.0-or-later'] = { addr.GNU .. 'lgpl-3.0-standalone.html', 'GNU Lesser General Public License 3.0 or later', 'LGPL' },
['FDL']          = { addr.GNU .. 'fdl.html', 'GNU Free Documentation License', 'FDL' },
['MIT']          = { addr.OSI .. 'mit-license.php', 'MIT License', 'MIT' },
['MIT']          = { addr.OSI .. 'mit-license.php', 'MIT License', 'MIT' },
['ISC']          = { addr.OSI .. 'ISC', 'ISC License', 'ISC' },
['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' },
['BSD-4-Clause'] = { addr.GNU .. 'license-list.html#OriginalBSD', 'BSD 4-clause "Original" License', 'BSD' },
['MPL-1.0']      = { addr.Mozilla .. 'MPL/1.0/', 'Mozilla Public License 1.0', 'MPL' },
['MPL-1.0']      = { addr.Mozilla .. 'MPL/1.0/', 'Mozilla Public License 1.0', 'MPL' },
['MPL-2.0']      = { addr.Mozilla .. 'MPL/2.0/', 'Mozilla Public License 2.0', 'MPL' },
['MPL-2.0']      = { addr.Mozilla .. 'MPL/2.0/', 'Mozilla Public License 2.0', 'MPL' },
['PD']          = { '', '[[wikipedia:Public domain|Public domain]]', 'PD' },
['Unlicense']    = { 'https://unlicense.org/', 'The Unlicense', 'Unlicense' },
['WTFPL']        = { 'http://www.wtfpl.net', 'WTFPL 2.0', 'WTFPL' },
['WTFPL']        = { 'http://www.wtfpl.net', 'WTFPL 2.0', 'WTFPL' },
['Apache-2.0']  = { '//www.apache.org/licenses/LICENSE-2.0', 'Apache License 2.0', 'Apache' },
['Zlib']        = { addr.OSI .. 'Zlib', 'zlib License' },
['Zlib']        = { addr.OSI .. 'Zlib', 'zlib License' },
['CC0-1.0']      = { '//creativecommons.org/publicdomain/zero/1.0/', 'Creative Commons Zero v1.0 Universal', 'PD' },
['CC-BY-3.0']    = { addr.CC .. 'by/3.0/', 'Creative Commons Attribution 3.0', 'CC' },
['CC-BY-SA-2.0'] = { addr.CC .. 'by-sa/2.0/', 'Creative Commons Attribution Share Alike 2.0', 'CC' },
['CC-BY-SA-2.5'] = { addr.CC .. 'by-sa/2.5/', 'Creative Commons Attribution Share Alike 2.5', 'CC' },
['CC-BY-NC-SA-2.5'] = { addr.CC .. 'by-nc-sa/2.5/', 'Creative Commons Attribution NonCommercial Share Alike 2.5', 'CC' },
['CC-BY-NC-SA-3.0'] = { addr.CC .. 'by-nc-sa/3.0/', 'Creative Commons Attribution NonCommercial Share Alike 3.0', 'CC' },
['CC-BY-NC-3.0'] = { addr.CC .. 'by-nc/3.0/', 'Creative Commons Attribution NonCommercial 3.0', 'CC' },
['CC-BY-SA-3.0'] = { addr.CC .. 'by-sa/3.0/', 'Creative Commons Attribution Share Alike 3.0', 'CC' },
['CC-BY-SA-4.0'] = { addr.CC .. 'by-sa/4.0/', 'Creative Commons Attribution Share Alike 4.0', 'CC' },
['ECL-2.0']      = { '', '[[wikipedia:Educational Community License|Educational Community License 2.0]]', 'ECL' },
['PD']          = { '', '[[wikipedia:Public domain|Public domain]]', 'PD' },
['unspecified']  = { '', 'No license specified', 'BLANK'}
['unspecified']  = { '', 'No license specified', 'BLANK'}
}
}
Line 92: Line 98:
['user activity']  = { '[[Manual:Security|User activity]]',                      'User activity extensions' },
['user activity']  = { '[[Manual:Security|User activity]]',                      'User activity extensions' },
variable            = { '[[Manual:Variables|Variable]]',                          'Variable extensions' },
variable            = { '[[Manual:Variables|Variable]]',                          'Variable extensions' },
-- DEPRECATED TYPES (as per 2007-09 taxonomy discussion)
category            = { 'Category',                                              'Category extensions',  deprecated = true },
form                = { 'Form',                                                  'Form extensions',      deprecated = true },
list                = { 'List',                                                  'List extensions',      deprecated = true },
namespace          = { '[[Manual:Namespaces|Namespace]]',                        'Namespace extensions', deprecated = true },
['table']          = { 'Table',                                                  'Table extensions',    deprecated = true },
}
}


Line 104: Line 104:
pfunc = 'parser function',
pfunc = 'parser function',
special = 'special page',
special = 'special page',
}
-- DEPRECATED TYPES (multiple types handled via type1,type2,...)
local deprecatedTypes = {
['link, tag, special'] = { 'link', 'tag', 'special page' },
['parser function, special'] = { 'parser function', 'special page' },
['tag, parser function'] = { 'tag', 'parser function' },
['tag, parser function, special'] = { 'tag', 'parser function', 'special page' },
['tag, special'] = { 'tag', 'special page' },
['parser, pfunc'] = { 'parser function' },
['parser, hook, special'] = { 'tag' --[[ sic ]], 'hook', 'special page' },
}
}


Line 142: Line 131:
if cnf then
if cnf then
res = cnf[1] .. '[[Category:' .. cnf[2] .. translation .. ']]'
res = cnf[1] .. '[[Category:' .. cnf[2] .. translation .. ']]'
if cnf.deprecated then
res = res .. '\'\'-deprecated\'\'' ..
tcat( 'Extensions with deprecated types' )
end
else
else
cnf = deprecatedTypes[str]
if str == '_missing_' then
if cnf then
local dtypes = {}
for _, sstr in ipairs( cnf ) do
table.insert( dtypes, getType( sstr ) )
end
res = table.concat( dtypes, ', ' ) ..
'<br />\'\'(deprecated, please use [[Special:MyLanguage/Template:Extension/doc#type|type1,type2'
if #cnf > 2 then
res = res .. ',type3'
end
res = res .. ']] instead)\'\'' .. tcat( 'Extensions with deprecated types' )
elseif str == '_missing_' then
res = tcat( 'Extensions with invalid or missing type' )
res = tcat( 'Extensions with invalid or missing type' )
elseif str == '_demomode_' then
elseif str == '_demomode_' then
Line 177: Line 150:


local function getExtData()
local function getExtData()
local pg = mw.title.getCurrentTitle().rootPageTitle:partialUrl() -- need to get rid of translation subpage.
local pg
local pframe = mw.getCurrentFrame():getParent()
if pframe and pframe.args.repo then
pg = pframe.args.repo
else
pg = mw.title.getCurrentTitle().rootPageTitle:partialUrl() -- need to get rid of translation subpage.
end
return mw.loadData( 'Module:ExtensionJson' )[pg]
return mw.loadData( 'Module:ExtensionJson' )[pg]
end
end
Line 288: Line 267:
     return ''
     return ''
end
end
-- --
-- Get the requires.MediaWiki value from extension.json
-- @link https://www.mediawiki.org/wiki/Manual:Extension.json/Schema#requires
-- --
function p.getMediaWikiRequirement( frame )
-- If the first arg is given, it'll be the manual override value.
    if frame.args[1] ~= nil and mw.text.trim( frame.args[1] ) ~= "" then
    return frame.args[1] .. cat( 'Extensions with manual MediaWiki version' )
    end
-- Otherwise, look it up from extension.json.
local data = getExtData()
if data and data.requires and data.requires.MediaWiki then
return data.requires.MediaWiki
end
-- If neither are given, just categorize.
return cat( 'Extensions without MediaWiki version' )
end
function p.getHooks(frame)
function p.getHooks(frame)
local hookOutput = frame.args.header
local hookOutput = frame.args.header
Line 297: Line 295:
local argument = pframe.args["hook" .. index]
local argument = pframe.args["hook" .. index]
if argument and mw.text.trim(argument) ~= "" then
if argument and mw.text.trim(argument) ~= "" then
hooks[argument] = true
hooks[#hooks + 1] = mw.text.trim(argument)
foundLocalHooks = true
foundLocalHooks = true
else
else
Line 306: Line 304:
if not foundLocalHooks then
if not foundLocalHooks then
local data = getExtData()
local data = getExtData()
if data == nil then
if data == nil or data.Hooks == nil then
return ""
return ""
end
end
hooks = data.Hooks
for hook, _ in pairs(data.Hooks) do
if hooks == nil then
hooks[#hooks + 1] = hook
return ""
end
end
table.sort(hooks)
end
end
local first = true
local first = true
for hook, _ in pairs(hooks) do
for _, hook in ipairs(hooks) do
if first then
if first then
first = false
first = false
Line 321: Line 319:
hookOutput = hookOutput .. frame.args.delim
hookOutput = hookOutput .. frame.args.delim
end
end
hookOutput = hookOutput .. frame:expandTemplate{title="Extension/HookInUse",args={hook,templatemode=frame.args.templatemode}}
hookOutput = hookOutput .. frame:expandTemplate{title="Extension/HookInUse",args={hook,templatemode=pframe.args.templatemode}}
end
end
return hookOutput .. frame.args.footer
return hookOutput .. frame.args.footer
Line 333: Line 331:
if config == nil then
if config == nil then
return ""
return ""
end
local prefix = "wg"
local skip_prefix = false
if data.manifest_version and data.manifest_version >= 2 then
if data.config_prefix then
prefix = data.config_prefix
end
else
if config._prefix then
prefix = config._prefix
skip_prefix = true
end
end
end
local out = ""
local out = ""
for key, _ in pairs(config) do
for key, _ in pairs(config) do
out = out .. "* $wg" .. key .. "\n"
if key ~= '_prefix' or not skip_prefix then
out = out .. "* $" .. prefix .. key .. "\n"
end
end
end
return out
return out
Line 356: Line 368:
end
end
return out
return out
end
function p.unmaintained(frame)
local content = mw.title.getCurrentTitle():getContent()
if not content:find("{{[uU]nmaintained extension") and not content:find("{{TNT|[uU]nmaintained extension")
and not content:find("{{User:Jeroen[ _]De[ _]Dauw/unmaintained") then
local args = {}
local pargs = frame:getParent().args
if pargs.templatemode == "nocats" then
args.nocat = "yes"
end
args.alternative = pargs.alternative
return frame:expandTemplate{title="Unmaintained extension",args=args}
end
end
end
function p.maintenanceLinks(frame)
function p.maintenanceLinks(frame)
Line 364: Line 389:
local out = ""
local out = ""
local content = mw.title.new(base):getContent()
local content = mw.title.new(base):getContent()
-- Check if the source page was deleted or not
-- Check if the source page was archived or not
if content:find("{{[aA]rchived ?[Ee]xtension") or content:find("{{TNT|[Aa]rchived ?[Ee]xtension") then
if content:find("{{[aA]rchived ?[Ee]xtension") or content:find("{{TNT|[Aa]rchived ?[Ee]xtension") then
return "<span style='display:none'>[[Template:Extension/archived]]</span>"
return "<span style='display:none'>[[Template:Extension/archived]]</span>"
--Check if the source page was archived or not
--Check if the source page was deleted or not
elseif content:find("{{[dD]eleted extension security warning") then
elseif content:find("{{[dD]eleted extension security warning") then
return "<span style='display:none'>[[Template:Extension/vulnerabilities]]</span>"
return "<span style='display:none'>[[Template:Extension/vulnerabilities]]</span>"
end
end
end
end
function p.isOnGerrit(frame)
local title = mw.title.getCurrentTitle()
if not title:inNamespace("Extension") and not title:inNamespace("Skin") then
return "n/a"
end
local base = frame:expandTemplate{title="translatable"}
local content = mw.title.new(base):getContent()
if content:find("{{WikimediaDownload") or content:find("TNT|WikimediaDownload") or content:find("|repo%s*=") then
return "yes"
end
end
-- --
-- Get a category if the extension isn't in Module:ExtensionJson.
--
function p.getExtensionJsonCategory( frame )
if getExtData() == nil then
return cat( 'Extensions not in ExtensionJson' )
end
end
return p
return p
Anonymous user