MediaWiki API result

This is the HTML representation of the JSON format. HTML is good for debugging, but is unsuitable for application use.

Specify the format parameter to change the output format. To see the non-HTML representation of the JSON format, set format=json.

See the complete documentation, or the API help for more information.

{
    "batchcomplete": "",
    "continue": {
        "gapcontinue": "Utilisateur:Paul_TESSON",
        "continue": "gapcontinue||"
    },
    "warnings": {
        "main": {
            "*": "Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/> for notice of API deprecations and breaking changes."
        },
        "revisions": {
            "*": "Because \"rvslots\" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used."
        }
    },
    "query": {
        "pages": {
            "23525": {
                "pageid": 23525,
                "ns": 0,
                "title": "Scoutacaw",
                "revisions": [
                    {
                        "contentformat": "text/x-wiki",
                        "contentmodel": "wikitext",
                        "*": "http://https://novinirana.com/fa/hair-transplantation/\n\n\u06a9\u0627\u0634\u062a \u0645\u0648"
                    }
                ]
            },
            "14629": {
                "pageid": 14629,
                "ns": 0,
                "title": "TemplateBox",
                "revisions": [
                    {
                        "contentformat": "text/x-wiki",
                        "contentmodel": "wikitext",
                        "*": "--[[\n    @exports\n        usagesample( frame )\n        argcount( frame )\n        args2table( args, onGetKey, forCustom )\n        paramtable( frame )\n        description( frame )\n        templatedata( frame )\n]]\n\nlocal p = {}\n\n-- Helper function, not exposed\nfunction tobool(st)\n    if type( st ) == 'string' then\n        return st == 'true'\n    else\n        return not not st\n    end\nend\n\n\n-- Required to determine in which languages the interface texts without langcode are\nlocal contentLangcode = mw.language.getContentLanguage():getCode()\n-- Forward declaration\nlocal msg, langIsInit, userLang\nlocal messagePrefix = \"templatedata-doc-\"\nlocal i18n = {}\ni18n['params'] = \"Template parameters\"\ni18n['param-name'] = \"Parameter\"\ni18n['param-desc'] = \"Description\"\ni18n['param-type'] = \"Type\"\ni18n['param-default'] = \"Default\"\ni18n['param-status'] = \"Status\"\ni18n['param-status-optional'] = \"optional\"\ni18n['param-status-required'] = \"required\"\ni18n['param-status-suggested'] = \"suggested\"\ni18n['param-status-deprecated'] = \"deprecated\"\ni18n['param-default-empty'] = \"empty\"\n\nfunction initLangModule()\n    if langIsInit then\n        return\n    end\n\n    --! From [[:de:Modul:Expr]]; by [[:de:User:PerfektesChaos]]; \n    --! Derivative work: Rillke\n    userLang = mw.getCurrentFrame():preprocess( '{{int:lang}}' )\n\n    msg = function( key )\n        -- Retrieve localized message string in content language\n        -- Precondition:\n        --     key  -- string; message ID\n        -- Postcondition:\n        --     Return some message string\n        -- Uses:\n        --     >  messagePrefix\n        --     >  i18n\n        --     >  userLang\n        --     mw.message.new()\n        local m = mw.message.new( messagePrefix .. key )\n        local r = false\n        if m:isBlank() then\n            r = i18n[ key ]\n        else\n            m:inLanguage( userLang )\n            r = m:plain()\n        end\n        if not r then\n            r = '((('.. key .. ')))'\n        end\n        return r\n    end -- msg()\n    \n    langIsInit = true\nend\n\n-- A \"hash\" / table of everything TemplateData takes\n-- to ease maintenance.\n\n-- The type is automatically determined if t is omitted.\n-- If the type does not match or can't be converted, an error will be thrown!\n-- Available types (LUA-Types with exceptions): \n--      InterfaceText, boolean, number, selection, table, string\n-- selection*: - requires a selection-string of pipe-separated possibilities to be supplied\n-- InterfaceText*: A free-form string (no wikitext) in the content-language of the wiki, or, \n-- an object containing those strings keyed by language code.\nlocal paraminfoTemplate = {\n    description = {\n        default = '',\n        t = 'InterfaceText',\n        alias = 'desc'\n    }\n}\nlocal paraminfoTLParams = {\n    label = {\n        default = '',\n        t = 'InterfaceText'\n    },\n    required = {\n        default = false,\n        extract = function(pargs, number, paramVal)\n            local req = (pargs[number .. 'stat'] == 'required')\n            return tobool( paramVal or req )\n        end\n    },\n    suggested = {\n        default = false,\n        extract = function(pargs, number, paramVal)\n            local sugg = (pargs[number .. 'stat'] == 'suggested')\n            return tobool( paramVal or sugg )\n        end\n    },\n    description = {\n        default = '',\n        t = 'InterfaceText',\n        alias = 'd'\n    },\n    deprecated = {\n        default = false,\n        extract = function(pargs, number, paramVal)\n            local depr = (pargs[number .. 'stat'] == 'deprecated')\n            return tobool( paramVal or depr )\n        end\n    },\n    aliases = {\n        default = '',\n        t = 'table',\n        extract = function(pargs, number, paramVal)\n            local key = number .. 'aliases'\n            local tdkey = key .. '-td'\n            local aliases = pargs[tdkey] or pargs[key]\n            if aliases then\n                aliases = mw.text.split( aliases, '/', true )\n            end\n            return aliases\n        end\n    },\n    default = {\n        default = '',\n        t = 'string',\n        alias = 'def'\n    },\n    type = {\n        default = 'unknown',\n        t = 'selection',\n        selection = 'unknown|number|string|string/wiki-user-name|string/wiki-page-name|string/line|line|wiki-page-name|wiki-file-name|wiki-user-name|content|unbalanced-wikitext'\n    },\n    inherits = {\n        default = nil,\n        t = 'string'\n    }\n    -- sets will be treated differently because we can only have a plain structure in wikitext\n}\nlocal tableLayout = {\n    {\n        col = 'param-name',\n        width = '15%',\n        extract = function(item, renderCell, monolingual)\n            local alias, param = '', item.key\n            local aliasTT = '<tt style=\"color:#777; border:1px solid #6A6A6A\">'\n\n            param = '<code>' .. param .. '</code>'\n            if item.aliases then\n                alias = aliasTT .. table.concat(item.aliases, '</tt><br />' .. aliasTT) .. '</tt>'\n                param = table.concat({param, '<br /><div>', alias, '</div>'})\n            end\n            renderCell(param, colspan)\n        end\n    },  {\n        col = 'param-desc',\n        cols = 2,\n        width = '65%',\n        extract = function(item, renderCell, monolingual)\n            local label = item.label or ''\n            label = monolingual(label)\n            local labelLen = #label\n            local colspan = 2 - labelLen\n        \n            if labelLen > 0 then\n                renderCell(label)\n            end\n        \n            renderCell(monolingual(item.description), colspan)\n        end\n    },  {\n        col = 'param-default',\n        width = '10%',\n        extract = function(item, renderCell, monolingual)\n            local def = monolingual(item.default) or ''\n            if #def == 0 then\n                def = '<span class=\"mw-templatedata-doc-muted\" style=\"color:#777; font-variant:small-caps\">' .. msg('param-default-empty') .. '</span>'\n            end\n            renderCell(def)\n        end\n    },  {\n        col = 'param-status',\n        width = '10%',\n        extract = function(item, renderCell, monolingual)\n            local stat = msg('param-status-optional')\n            if item.required then\n                stat = '<b>' .. msg('param-status-required') .. '</b>'\n            elseif item.deprecated then\n                stat = msg('param-status-deprecated')\n            elseif item.suggested then\n                stat = msg('param-status-suggested')\n            end\n            renderCell(stat)\n        end\n    }\n}\n\n-- Initialize param info\n-- Avoids having to add redundant information to the preceding tables\nfunction init( which )\n    local setDefault = function(v)\n        if v.t == nil and v.default ~= nil then\n            v.t = type( v.default )\n        end\n        if v.selection then\n            v.selection = '|' .. v.selection .. '|'\n        end\n    end\n    for a, v in pairs( which ) do\n        setDefault(v)\n    end\nend\nfunction initParamTables()\n    init( paraminfoTemplate )\n    init( paraminfoTLParams )\nend\n\n------------------------------------------------------\n-------------------- USAGE PART ----------------------\n------------------------------------------------------\nfunction p.argcount( frame )\n    local pargs = ( frame:getParent() or {} ).args or {}\n    local ac = 0\n    for i, arg in pairs( pargs ) do\n        if ('number' == type(i)) then\n            ac = ac + 1\n        end\n    end\n    return ac\nend\n\nfunction p.usagesample( frame )\n    local pargs = ( frame:getParent() or {} ).args or {}\n    local multiline = (pargs.lines == 'multi' or pargs.print == 'multi' or pargs.print == 'infobox')\n    local align = pargs.print == 'infobox'\n    if not pargs.lines and not pargs.print and pargs.type == 'infobox' then\n        multiline = true\n        align = true\n    end\n    local sepStart = ' |'\n    local sepEnd = multiline  and '\\n' or ''\n    local sep = sepEnd\n    local subst = #(pargs.mustbesubst or '') > 0 and 'subst:' or ''\n    local beforeEqual = multiline  and ' ' or ''\n    local equal = beforeEqual .. '= '\n    local templateTitle = pargs.name or ''\n    local args, argName, result = {}\n    local maxArgLen, eachArg = 0\n    sep = sep .. sepStart\n    \n    local comapareLegacyVal = function(val)\n        return val == 'optional-' or val == 'deprecated'\n    end\n    local shouldShow = function(i)\n        if comapareLegacyVal(pargs[i .. 'stat']) or\n            comapareLegacyVal(pargs[i .. 'stat-td']) or\n            pargs[i .. 'deprecated'] == true then \n                return false\n            end\n        return true\n    end\n    \n    eachArg = function(cb)\n        for i, arg in pairs( pargs ) do\n            if ('number' == type(i)) then\n                argName = mw.text.trim( arg or '' )\n                if #argName == 0 then\n                    argName = tostring(i)\n                end\n                \n                if shouldShow(i) then\n                    cb(argName)\n                end\n            end\n        end\n    end\n    \n    if align then\n        eachArg(function( arg )\n            local argL = #arg\n            maxArgLen = argL > maxArgLen and argL or maxArgLen\n        end)\n    end\n    \n    eachArg(function( arg )\n        local space = ''\n        if align then\n            space = ('&nbsp;'):rep(maxArgLen - #arg)\n        end\n        table.insert( args, argName .. space .. equal )\n    end)\n    \n    if #args == 0 then\n        sep = ''\n        sepEnd = ''\n        sepStart = ''\n    end\n    if #templateTitle == 0 then\n        templateTitle = mw.title.getCurrentTitle().text\n    end\n    result = table.concat( args, sep )\n    result = table.concat({ mw.text.nowiki('{{'), subst, templateTitle, sep, result, sepEnd, '}}' })\n    if multiline then\n        -- Preserve whitespace in front of new lines\n        result = frame:callParserFunction{ name = '#tag', args = { 'poem', result } }\n    end\n    return result\nend\n\n------------------------------------------------------\n------------------- GENERAL PART ---------------------\n------------------------------------------------------\nfunction p.args2table(args, onGetKey, consumer)\n    initParamTables()\n    \n    local sets, asParamArray, laxtype, processParams, processDesc\n    if 'paramtable' == consumer then\n        asParamArray = true\n        processParams = true\n        laxtype = true\n    elseif 'templatedata' == consumer then\n        sets = true\n        processParams = true\n        processDesc = true\n        unstrip = true\n    elseif 'description' == consumer then\n        processDesc = true\n        laxtype = true\n    end\n    -- All kind of strange stuff with the arguments is done, so play safe and make a copy\n    local pargs = mw.clone( args )\n    -- Array-like table containing all parameter-numbers that were passed\n    local templateArgs = {}\n    -- Arguments that are localized (i.e. the user passed  1desc-en=English description of parameter one)\n    local i18nTemplateArgs = {}\n    -- Ensure that tables end up as array/object (esp. when they are empty)\n    local tdata = {description=\"\", params={}, sets={}}\n    local isArray  = { __tostring = function() return \"JSON array\"  end }    isArray.__index  = isArray\n    setmetatable(tdata.sets, isArray)\n    onGetKey = onGetKey or function( prefix, alias, param )\n        local key, key2, tdkey, tdkey2\n        key = prefix .. (alias or param)\n        key2 = prefix .. param\n        tdkey = key .. '-td'\n        tdkey2 = key2 .. '-td'\n        return tdkey, tdkey2, key, key2\n    end\n    \n    local extractData = function( pi, number )\n        local prefix = number or ''\n        local ppv, paramVal\n        local key1, key2, key3, key4\n        local paramKey, paramTable, processKey\n        if number then\n            paramKey = mw.text.trim( pargs[number] )\n            if '' == paramKey then\n                paramKey = tostring( number )\n            end\n            \n            paramTable = {}\n            if asParamArray then\n                paramTable.key = paramKey\n                table.insert(tdata.params, paramTable)\n            else\n                tdata.params[paramKey] = paramTable\n            end\n        end\n        for p, info in pairs( pi ) do\n            key1, key2, key3, key4 = onGetKey(prefix, info.alias, p)\n            paramVal = nil\n            \n            processKey = function(key)\n                if paramVal ~= nil then return end\n                local plain, multilingual = pargs[key], i18nTemplateArgs[key]\n                paramVal = multilingual or plain\n            end\n            processKey( key1 )\n            processKey( key2 )\n            processKey( key3 )\n            processKey( key4 )\n            \n            -- Ensure presence of entry in content language\n            ppv = pargs[key1] or pargs[key2] or pargs[key3] or pargs[key4] or info.default\n            if 'table' == type( paramVal ) then\n                if (nil == paramVal[contentLangcode]) then\n                    paramVal[contentLangcode] = ppv\n                end\n            else\n                paramVal = ppv\n            end\n\n            if 'function' == type( info.extract ) then\n                if 'string' == type( paramVal ) then\n                    paramVal = mw.text.trim( paramVal )\n                    if '' == paramVal then\n                        paramVal = nil\n                    end\n                end\n                paramVal = info.extract( pargs, number, paramVal )\n            end\n            \n            local insertValue = function()\n                if number then\n                    paramTable[p] = paramVal\n                else\n                    tdata[p] = paramVal\n                end\n            end\n            \n            if info.selection then\n                if info.selection:find( paramVal, 1, true ) then\n                    insertValue()\n                end\n            elseif 'InterfaceText' == info.t then\n                if ({ table=1, string=1 })[type( paramVal )] then\n                    insertValue()\n                end\n            else\n                local paramType = type( paramVal )\n                if 'string' == info.t and 'string' == paramType then\n                    paramVal = mw.text.trim( paramVal )\n                    if '' ~= paramVal then\n                        insertValue()\n                    end\n                elseif 'boolean' == info.t then\n                    paramVal = tobool(paramVal)\n                    insertValue()\n                elseif 'number' == info.t then\n                    paramVal = tonumber(paramVal)\n                    insertValue()\n                elseif paramType == info.t then\n                    insertValue()\n                elseif paramType == 'nil' then\n                    -- Do nothing\n                elseif not laxtype and 'string' == info.t and 'table' == paramType then\n                    -- Convert multilingual object into content language string\n                    paramVal = paramVal[contentLangcode]\n                    insertValue()\n                else\n                    if laxtype then\n                        insertValue()\n                    else\n                        error( p .. ': Is of type ' ..  paramType .. ' but should be of type ' .. (info.t or 'unknown'), 1 )\n                    end\n                end\n            end\n        end\n        -- Now, treat sets\n        if sets then\n            key1 = prefix .. 'set-td'\n            key2 = prefix .. 'set'\n            paramVal = pargs[key1] or pargs[key2]\n            if paramVal then\n                local found = false\n                for i, s in ipairs( tdata.sets ) do\n                    if s.label == paramVal then\n                        table.insert( s.params, p )\n                        found = true\n                    end\n                end\n                if not found then\n                    table.insert( tdata.sets, {\n                        label = paramVal, \n                        params = { p }\n                    } )\n                end\n            end\n        end\n    end\n    \n    -- First, analyse the structure of the provided arguments\n    for a, v in pairs( pargs ) do\n        if unstrip then\n            v = mw.text.unstrip( v )\n            pargs[a] = v\n        end\n        if type( a ) == 'number' then\n            table.insert( templateArgs, a )\n        else\n            local argSplit = mw.text.split( a, '-', true )\n            local argUnitl = {}\n            local argAfter = {}\n            local isTDArg = false\n            local containsTD = a:find( '-td', 1, true )\n            for i, part in ipairs( argSplit ) do\n                if isTDArg or (containsTD == nil and i > 1) then\n                    -- This is likely a language version\n                    table.insert( argAfter, part )\n                else\n                    table.insert( argUnitl, part )\n                end\n                if part == 'td' then\n                    isTDArg = true\n                end\n            end\n            if #argAfter > 0 then\n                argUnitl = table.concat( argUnitl, '-' )\n                argAfter = table.concat( argAfter, '-' )\n                i18nTemplateArgs[argUnitl] = i18nTemplateArgs[argUnitl] or {}\n                i18nTemplateArgs[argUnitl][argAfter] = v\n            end\n        end\n    end\n    -- Then, start building the actual template\n    if processDesc then\n        extractData( paraminfoTemplate )\n    end\n    if processParams then\n        for i, number in pairs( templateArgs ) do\n            extractData( paraminfoTLParams, number )\n        end\n    end\n    return tdata, #templateArgs\nend\n\n\n\n------------------------------------------------------\n------------ CUSTOM PARAMETER TABLE PART -------------\n------------------------------------------------------\n\n-- A custom key-pref-function\nlocal customOnGetKey = function( prefix, alias, param )\n    local key, key2, tdkey, tdkey2\n    key = prefix .. (alias or param)\n    key2 = prefix .. param\n    tdkey = key .. '-td'\n    tdkey2 = key2 .. '-td'\n    return key2, key, tdkey2, tdkey\nend\nlocal toUserLanguage = function(input, frame)\n    if type(input) == 'table' then\n        input = frame:expandTemplate{ title = 'LangSwitch', args = input }\n    end\n    return input\nend\n\nfunction p.description(frame)\n    local pargs = ( frame:getParent() or {} ).args or {}\n    local tdata, paramLen\n    local monolingual = function(input)\n        return toUserLanguage(input, frame)\n    end\n    tdata, paramLen = p.args2table(pargs, customOnGetKey, 'description')\n    return monolingual(tdata.description)\nend\n\n\nfunction p.paramtable(frame)\n    local pargs = ( frame:getParent() or {} ).args or {}\n    local tdata, paramLen\n    \n    if 'only' == pargs.useTemplateData then\n        return 'param table - output suppressed'\n    end\n    \n    -- Initialize the language-related stuff\n    initLangModule()\n    local monolingual = function(input)\n        return toUserLanguage(input, frame)\n    end\n\n    tdata, paramLen = p.args2table(pargs, customOnGetKey, 'paramtable')\n    \n    \n    if 0 == paramLen then\n        return ''\n    end\n    \n    local row, rows = '', {}\n    local renderCell = function(wikitext, colspan)\n        local colspan, oTd = colspan or 1, '<td>'\n        if colspan > 1 then\n            oTd = '<td colspan=\"' .. colspan .. '\">'\n        end\n        row = table.concat({ row, oTd, wikitext, '</td>' })\n    end\n    \n    -- Create the header\n    for i, field in ipairs( tableLayout ) do\n        local style = ' style=\"width:' .. field.width .. '\"'\n        local colspan = ''\n        if field.cols then\n            colspan = ' colspan=\"' .. field.cols .. '\"'\n        end\n        local th = '<th' .. style .. colspan .. '>'\n\n        row = row .. th .. msg(field.col) .. '</th>'\n    end\n    table.insert(rows, row)\n    \n    -- Now transform the Lua-table into an HTML-table\n    for i, item in ipairs( tdata.params ) do\n        row = ''\n        for i2, field in ipairs( tableLayout ) do\n            field.extract(item, renderCell, monolingual)\n        end\n        table.insert(rows, row)\n    end\n    return '<table class=\"wikitable templatebox-table\"><tr>' .. table.concat(rows, '</tr><tr>') .. '</tr></table>'\nend\n\n\n------------------------------------------------------\n----------------- TEMPLATEDATA PART ------------------\n------------------------------------------------------\n\n-- A real parser/transformer would look differently but it would likely be much more complex\n-- The TemplateData-portion for [[Template:TemplateBox]]\nfunction p.templatedata(frame)\n    local tdata\n    local args = frame.args or {}\n    local formatting = args.formatting\n    local pargs = ( frame:getParent() or {} ).args or {}\n    local useTemplateData = pargs.useTemplateData\n\n    if  (formatting == 'pretty' and useTemplateData ~= 'export') or\n        (not useTemplateData) or\n        (useTemplateData == 'export' and formatting ~= 'pretty') then\n            local warning = \"Warning: Module:TemplateBox - templatedata invoked but not requested by user (setting useTemplateData=1).\"\n            mw.log(warning)\n            tdata = '{\"description\":\"' .. warning .. '\",\"params\":{},\"sets\":[]}'\n            return tdata\n    end\n    \n    -- Load the JSON-Module which will convert LUA tables into valid JSON\n    local JSON = require('Module:JSON')\n    JSON.strictTypes = true\n    -- Obtain the object containing info\n    tdata = p.args2table(pargs, nil, 'templatedata')\n    -- And finally return the result\n    if formatting == 'pretty' then\n        return JSON:encode_pretty(tdata)\n    else\n        return JSON:encode(tdata)\n    end\nend\n\nreturn p"
                    }
                ]
            }
        }
    }
}