Module:ProfessionList: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 48:
-- the queryString is just a selection of pages, from any combination of SMW properties and categories
-- for pages with multiple recipes or activities, will make on entry into the results table for each
-- screenFunction takes a decoded recipe/activity JSON and returns true if it is to be kept
function p.generate_recipe_table(queryString,screenFunction)
-- first formulate the query to get the list of pages
Line 66 ⟶ 67:
end
-- outputcollate structure
local outputrecipes = {}
-- iterate through pages found
Line 79 ⟶ 80:
for _, JSON in ipairs(page.activityJSON) do
local item = mw.text.jsonDecode(JSON)
item.pagepageName = page.pageName
item.pageImage = page.pageImage
item.type = 'activity'
table.insert(outputrecipes,item)
end
end
Line 93 ⟶ 94:
for _, JSON in ipairs(page.recipeJSON) do
local item = mw.text.jsonDecode(JSON)
item.pagepageName = page.pageName
item.pageImage = page.pageImage
item.type = 'recipe'
table.insert(outputrecipes,item)
end
end
Line 102 ⟶ 103:
end
-- output structure
local output = {}
-- screen using screenfunction
for _, item in ipairs(recipes) do
if screenfunction(item) then
table.insert(output,item)
end
end
 
-- sort the output by the .level parameter
table.sort(output, function(item1, item2)
Line 120 ⟶ 131:
end
 
 
return p
11,305

edits