annotate app/main/api/navigation.lua @ 1637:6fb549c147cb
Show delegations in member profile only when available
 | author | bsw | 
 | date | Tue Feb 09 00:31:34 2021 +0100 (2021-02-09) | 
 | parents | 32cc544d5a5b | 
 | children |  | 
 
 | rev | line source | 
| bsw/jbe@1309 | 1 local access_token = param.get("access_token") | 
| bsw/jbe@1309 | 2 local client_id = param.get("client_id") | 
| bsw/jbe@1309 | 3 local login_url = param.get("login_url") | 
| bsw/jbe@1309 | 4 local format = param.get("format") | 
| bsw/jbe@1309 | 5 | 
| bsw/jbe@1309 | 6 if format ~= "html" and format ~= "raw_html" then | 
| bsw/jbe@1309 | 7   format = "json" | 
| bsw/jbe@1309 | 8 end | 
| bsw/jbe@1309 | 9 | 
| bsw/jbe@1309 | 10 local items = config.meta_navigation_items_func(app.access_token and app.access_token.member or nil, client_id, login_url) | 
| bsw/jbe@1309 | 11 | 
| bsw/jbe@1309 | 12 if format == "json" then | 
| bsw/jbe@1309 | 13   slot.set_layout(nil, "application/json") | 
| bsw/jbe@1309 | 14   local r = json.array() | 
| bsw/jbe@1309 | 15   for i, item in ipairs(items) do | 
| bsw/jbe@1309 | 16     r[#r+1] = json.object{ | 
| bsw/jbe@1309 | 17       name = item.name, | 
| bsw/jbe@1309 | 18       description = item.description, | 
| bsw/jbe@1309 | 19       url = item.url, | 
| bsw/jbe@1309 | 20       active = item.active | 
| bsw/jbe@1309 | 21     } | 
| bsw/jbe@1309 | 22   end | 
| bsw/jbe@1309 | 23   slot.put_into("data", json.export(json.object{ result = r })) | 
| bsw/jbe@1309 | 24 elseif format == "html" then | 
| bsw/jbe@1309 | 25   slot.set_layout(nil, "application/json") | 
| bsw/jbe@1309 | 26   local html = config.meta_navigation_style_func(items) .. config.meta_navigation_html_func(items) .. config.meta_navigation_script_func(items) | 
| bsw/jbe@1309 | 27   slot.put_into("data", json.export(json.object{ result = html })) | 
| bsw/jbe@1309 | 28 elseif format == "raw_html" then | 
| bsw/jbe@1309 | 29   slot.set_layout(nil, "text/html") | 
| bsw/jbe@1309 | 30   local html = config.meta_navigation_style_func(items) .. config.meta_navigation_html_func(items) .. config.meta_navigation_script_func(items) | 
| bsw/jbe@1309 | 31   slot.put_into("data", html) | 
| bsw/jbe@1309 | 32 end | 
| bsw/jbe@1309 | 33 | 
| bsw/jbe@1309 | 34 |