Line 319: |
Line 319: |
| --local display_label = "" | | --local display_label = "" |
| --if (jsondata[p.keys.label] ~= nil) then display_label = p.splitString(jsondata[p.keys.label], '@')[1] end | | --if (jsondata[p.keys.label] ~= nil) then display_label = p.splitString(jsondata[p.keys.label], '@')[1] end |
− | if (title.nsText ~= "Category") then wikitext = wikitext .. "\n" .. p.setCategories({categories=json_res_store.res[p.keys.category], sortkey=display_label}).wikitext end--items | + | if (title.nsText ~= "Category") then wikitext = wikitext .. "\n" .. p.setCategories({categories=jsondata[p.keys.category], sortkey=display_label}).wikitext end--items |
− | wikitext = wikitext .. p.setCategories({categories=json_res_store.res[p.keys.subcategory], sortkey=display_label}).wikitext --classes/categories | + | wikitext = wikitext .. p.setCategories({categories=jsondata[p.keys.subcategory], sortkey=display_label}).wikitext --classes/categories |
| | | |
| if (smw_res ~= nil) then | | if (smw_res ~= nil) then |
Line 349: |
Line 349: |
| local schema = p.defaultArg(args.jsonschema, nil) | | local schema = p.defaultArg(args.jsonschema, nil) |
| local context = p.buildContext({jsonschema=schema}).context | | local context = p.buildContext({jsonschema=schema}).context |
− | local ignore_properties = {[p.keys.category]=true} -- don't render type/category on every subclass
| |
| local res = "" | | local res = "" |
| if schema == nil then return res end | | if schema == nil then return res end |
Line 365: |
Line 364: |
| :wikitext( schema_label ) | | :wikitext( schema_label ) |
| for k,v in pairs(jsondata) do | | for k,v in pairs(jsondata) do |
− | if (not ignore_properties[k]) then | + | if (schema['properties'] ~= nil and schema['properties'][k] ~= nil and (type(v) ~= 'table' or v[1] ~= nil)) then --literal or literal array |
− | if (schema['properties'] ~= nil and schema['properties'][k] ~= nil and (type(v) ~= 'table' or v[1] ~= nil)) then --literal or literal array
| + | local def = schema['properties'][k] |
− | local def = schema['properties'][k]
| + | --mw.logObject(def) |
− | --mw.logObject(def)
| + | local label = k |
− | local label = k
| + | if def['title'] ~= nil then label = def['title'] end |
− | if def['title'] ~= nil then label = def['title'] end
| + | --res = res .. title ": " .. v |
− | --res = res .. title ": " .. v
| + | local cell = tbl:tag( 'tr' ) |
− | local cell = tbl:tag( 'tr' )
| + | :tag( 'th' ) |
− | :tag( 'th' )
| + | :wikitext( label ) |
− | :wikitext( label )
| + | :done() |
− | :done()
| + | :tag( 'td' ) |
− | :tag( 'td' )
| + | if (type(v) == 'table') then |
− | if (type(v) == 'table') then
| + | for i,e in pairs(v) do |
− | for i,e in pairs(v) do
| + | if (type(e) ~= 'table') then |
− | if (type(e) ~= 'table') then
| + | local p_type = p.defaultArgPath(context, {k, '@type'}, '@value') |
− | local p_type = p.defaultArgPath(context, {k, '@type'}, '@value')
| + | if (p_type == '@id') then e = "[[" .. string.gsub(e, "Category:", ":Category:") .. "]]" end |
− | if (p_type == '@id') then e = "[[" .. string.gsub(e, "Category:", ":Category:") .. "]]" end
| + | cell:wikitext("\n* " .. e .. "") |
− | cell:wikitext("\n* " .. e .. "")
| |
− | end
| |
| end | | end |
− | else
| |
− | local p_type = p.defaultArgPath(context, {k, '@type'}, '@value')
| |
− | if (p_type == '@id') then v = "[[" .. string.gsub(v, "Category:", ":Category:") .. "]]" end
| |
− | cell:wikitext( v )
| |
| end | | end |
| + | else |
| + | local p_type = p.defaultArgPath(context, {k, '@type'}, '@value') |
| + | if (p_type == '@id') then v = "[[" .. string.gsub(v, "Category:", ":Category:") .. "]]" end |
| + | cell:wikitext( v ) |
| end | | end |
| end | | end |