Version vom 2. März 2023, 07:46 Uhr von imported>Oetterer
This module is rated as ready for general use. It has reached a mature form and is thought to be bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing. |
This module depends on the following other modules: |
Usage[Quelltext bearbeiten]
{{#invoke:Navbox os|main}}
In other modules[Quelltext bearbeiten]
You can use this module in other modules like this:
local navbox = require('Module:Navbox os')._main
return navbox()
local _NAVBOX = require('Module:Navbox')._navbox
local _SMWUTIL = require('Module:SmwUtil')
local _TT = require('Module:TableTools')
-- helper vars, standing in for missing config
local navboxSep = ' • '
local p = {}
-- prename some function
local iosMatcher
local function compileNavbox(navboxData)
local html = mw.html.create('')
local navboxData = navboxData
if not navboxData or _TT.size(navboxData) == 0 then
return html
end
local navboxOrder = _TT.keysToList(navboxData, function(a, b) return a:upper() < b:upper() end )
local arguments = {
navbar = 'off',
title = 'Übersicht Betriebssysteme',
state = 'expanded',
}
local num = 1
for _, family in pairs(navboxOrder) do
if navboxData[family] and #navboxData[family] > 0 then
arguments['group' .. num] = '[[' .. family .. ']]'
arguments['list' .. num] = table.concat(navboxData[family], navboxSep)
num = num + 1
end
end
return html:node(_NAVBOX(arguments))
end
local function getNavboxData()
local navboxData = {}
local result = _SMWUTIL.ask(
{ select = '[[Category:Betriebssysteme]]', fields = {'is member of os family#-=family', 'Was released in#-=year'} },
{ mainlabel = 'pageName', sort='was released in', order='desc' }
)
--if true then return result end
if result then
for _, osdata in pairs(result) do
if osdata.pageName and osdata.family then
local osName = iosMatcher(osdata.pageName)
local family = iosMatcher(osdata.family)
if not navboxData[family] then
navboxData[family] = {}
end
table.insert(navboxData[family], '[[' .. iosMatcher(osName) .. ']] (' .. tostring(osdata.year) .. ')')
end
end
end
return navboxData
end
iosMatcher = function(str)
if str:match('^IOS.*') then
str = 'i' .. str:sub(2)
end
return str
end
function p._main()
local navboxData = getNavboxData()
return tostring(compileNavbox(navboxData))
end
function p.main(frame)
return p._main()
end
function p.dl(arg)
return _main()
end
return p