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 |
||
page.recipeJSON = { page.activityJSON } |
|||
end |
|||
for _, JSON in ipairs(page.activityJSON) do |
|||
local item = mw.text.jsonDecode(JSON) |
|||
⚫ | |||
item.page = page.pageName |
|||
⚫ | |||
item.pageImage = page.pageImage |
|||
end |
|||
⚫ | |||
⚫ | |||
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 |
||
page.recipeJSON = { page.recipeJSON } |
|||
else |
|||
⚫ | |||
⚫ | |||
table.insert(JSONs,json) |
|||
end |
|||
end |
end |
||
⚫ | |||
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 |
||
⚫ | |||
--insert into output table |
|||
table.insert(output,item) |
table.insert(output,item) |
||
end |
end |
||
end |
end |
||
⚫ | |||
end |
end |
||