Module:Software
Jump to navigation
Jump to search
[Create] Documentation
local languages = require("Module:Languages")
local p = {}
FEATURES = { -- maps Template:Software yes/no parameters to description strings (used to build the category names)
sendPosition = 'send your position',
uploadOSMData = 'upload changes to OSM',
tracking = 'record GPS tracks',
}
-- debug with e.g. =p.featureCategories(nil, {platform='foo;bar;android', sendPosition='yes'})
function p.featureCategories (frame, debugArgs)
local args = debugArgs or frame:getParent().args
if languages.languageFromTitle(mw.title.getCurrentTitle()) ~= 'en' then
-- TODO: add category with language prefix if category exists
return ''
end
local sortKey
if not args.license then
sortKey = '?'
elseif string.lower(args.license):find('proprietary') then
if args.status == 'broken' then
return ''
end
sortKey = 'Proprietary'
else
if args.status == 'unmaintained' then
sortKey = 'Unmaintained'
elseif args.status == 'broken' then
sortKey = 'X'
else
sortKey = 'Open source' -- educated guess
end
end
local txt = ''
-- TODO: add category 3D software
if not args.platform then
return txt
end
local platforms = {}
for _, item in pairs(mw.text.split(args.platform, '[;,]')) do
key = mw.ustring.lower(
mw.text.split( -- take the first word to detect e.g. "Android 5.0+" as android
mw.text.trim(item), ' '
)[1]
)
platforms[key] = true
end
if platforms.android then
for arg, desc in pairs(FEATURES) do
if args[arg] and args[arg] ~= '' and args[arg] ~= 'no' then
txt = txt .. '[[Category:Android apps that can ' .. desc .. '|' .. sortKey .. ']]'
end
end
end
return txt
end
return p