def khan_view(khanpath=''): path = split_khanpath(khanpath) tree = get_tree() name, subtree = khan.get(tree, path) r = khan.getchildren(tree, path) if 'children' in r: def childmap(child): return { 'index': child[0], 'name': child[1], 'url': "/iiab/video/khan/" + join_khanpath(path + [child[0]]) } children = map(childmap, r['children']) return render_template('khan_index.html', breadcrumbs=r['breadcrumbs'], children=children) elif 'file' in r: base_url = config().get('VIDEO', 'video_url') webm = base_url + '/' + khanpath + ".webm" h264 = base_url + '/' + khanpath + ".m4v" title = r['breadcrumbs'][-1][1] return render_template('khan_video.html', breadcrumbs=r['breadcrumbs'], webm=webm, h264=h264, title=title) else: raise Exception("Unknown return type in Khan Academy tree")
def khan_json_view(khanpath=''): path = split_khanpath(khanpath) tree = get_tree() name, subtree = khan.get(tree, path) r = khan.getchildren(tree, path) return Response(json.dumps(r, indent=4), mimetype="application/json")