Module:ProfessionList: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
mNo edit summary
No edit summary
Line 72: Line 72:
for _, page in ipairs(pages) do
for _, page in ipairs(pages) do
-- first iterate through activities
-- combine the activityJSON and recipeJSON into one table
local JSONs = {}
if page.activityJSON ~= nil then
if page.activityJSON ~= nil then
if type(page.activityJSON)=='string' then
if type(page.activityJSON)=='string' then
table.insert(JSONs,page.activityJSON)
page.recipeJSON = { page.activityJSON }
else
end
for _, json in page.activityJSON do
for _, JSON in ipairs(page.activityJSON) do
local item = mw.text.jsonDecode(JSON)
json.type = 'activity'
item.page = page.pageName
table.insert(JSONs,json)
item.pageImage = page.pageImage
end
item.type = 'activity'
table.insert(output,item)
end
end
end
end
-- same iteration through recipes
if page.recipeJSON ~= nil then
if page.recipeJSON ~= nil then
if type(page.recipeJSON)=='string' then
if type(page.recipeJSON)=='string' then
table.insert(JSONs,page.recipeJSON)
page.recipeJSON = { page.recipeJSON }
else
for _, json in page.recipeJSON do
json.type = 'recipe'
table.insert(JSONs,json)
end
end
end
for _, JSON in ipairs(page.recipeJSON) do
end
-- iterate through combined list of JSONs and extract the info
if JSONs[1] ~= nil then
for _, JSON in ipairs(JSONs) do
--decode the JSON to a Lua table, add data from the page that had it
local item = mw.text.jsonDecode(JSON)
local item = mw.text.jsonDecode(JSON)
item.page = page.pageName
item.page = page.pageName
item.pageImage = page.pageImage
item.pageImage = page.pageImage
item.type = 'recipe'
--insert into output table
table.insert(output,item)
table.insert(output,item)
end
end
end
end
end
end