def navigation(environ, start_response): db, dbname, path_components, q = wsgi_response(environ, start_response) path = os.getcwd().replace('functions/', '') obj = db[path_components] config = f.WebConfig() prev = ' '.join(obj.prev.split()[:7]) next = ' '.join(obj.next.split()[:7]) current = obj.philo_id[:7] if q['format'] == "json": if check_philo_virtual(db, path_components): obj = db[path_components[:-1]] obj_text = f.get_text_obj(obj, path, query_args=q['byte']) return json.dumps({ 'current': current, 'text': obj_text, 'prev': prev, 'next': next, 'shrtcit': f.cite.make_abs_doc_shrtcit_mobile(db, obj), 'citation': f.cite.make_abs_doc_cite_mobile(db, obj) }) if obj.philo_type == 'doc': concatenate_files(path, "t_o_c", debug=db.locals["debug"]) return render_template(obj=obj, philo_id=obj.philo_id[0], dbname=dbname, f=f, navigate_doc=navigate_doc, db=db, q=q, config=config, template_name='t_o_c.mako', report="t_o_c", ressources=f.concatenate.report_files) obj_text = f.get_text_obj(obj, path, query_args=q['byte']) concatenate_files(path, "navigation", debug=db.locals["debug"]) return render_template(obj=obj, philo_id=obj.philo_id[0], dbname=dbname, f=f, navigate_doc=navigate_doc, db=db, q=q, obj_text=obj_text, prev=prev, next=next, config=config, template_name='object.mako', report="navigation", ressources=f.concatenate.report_files)
def go_to_obj(environ,start_response): status = '200 OK' headers = [('Content-type', 'application/json; charset=UTF-8'),("Access-Control-Allow-Origin","*")] start_response(status,headers) environ["SCRIPT_FILENAME"] = environ["SCRIPT_FILENAME"].replace('scripts/go_to_obj.py', '') db, path_components, q = parse_cgi(environ) path = db.locals['db_path'] path = path[:path.rfind("/data")] philo_obj = ObjectWrapper(q['philo_id'].split(), db) prev_obj = ' '.join(philo_obj.prev.split()[:7]) next_obj = ' '.join(philo_obj.next.split()[:7]) text = f.get_text_obj(philo_obj, path) yield json.dumps({'text': text, "prev": prev_obj, "next": next_obj})