bsw/jbe@1309: local access_token = param.get("access_token") bsw/jbe@1309: local client_id = param.get("client_id") bsw/jbe@1309: local login_url = param.get("login_url") bsw/jbe@1309: local format = param.get("format") bsw/jbe@1309: bsw/jbe@1309: if format ~= "html" and format ~= "raw_html" then bsw/jbe@1309: format = "json" bsw/jbe@1309: end bsw/jbe@1309: bsw/jbe@1309: local items = config.meta_navigation_items_func(app.access_token and app.access_token.member or nil, client_id, login_url) bsw/jbe@1309: bsw/jbe@1309: if format == "json" then bsw/jbe@1309: slot.set_layout(nil, "application/json") bsw/jbe@1309: local r = json.array() bsw/jbe@1309: for i, item in ipairs(items) do bsw/jbe@1309: r[#r+1] = json.object{ bsw/jbe@1309: name = item.name, bsw/jbe@1309: description = item.description, bsw/jbe@1309: url = item.url, bsw/jbe@1309: active = item.active bsw/jbe@1309: } bsw/jbe@1309: end bsw/jbe@1309: slot.put_into("data", json.export(json.object{ result = r })) bsw/jbe@1309: elseif format == "html" then bsw/jbe@1309: slot.set_layout(nil, "application/json") bsw/jbe@1309: local html = config.meta_navigation_style_func(items) .. config.meta_navigation_html_func(items) .. config.meta_navigation_script_func(items) bsw/jbe@1309: slot.put_into("data", json.export(json.object{ result = html })) bsw/jbe@1309: elseif format == "raw_html" then bsw/jbe@1309: slot.set_layout(nil, "text/html") bsw/jbe@1309: local html = config.meta_navigation_style_func(items) .. config.meta_navigation_html_func(items) .. config.meta_navigation_script_func(items) bsw/jbe@1309: slot.put_into("data", html) bsw/jbe@1309: end bsw/jbe@1309: bsw/jbe@1309: