def viewer(request): work_uri = request.GET.get('work') parts = Work.get(work_uri).hasPart() part_uri = request.GET.get('part', parts[0].uri) cantos = WorkPart.get(part_uri).hasPart() canto_uri = request.GET.get('canto') if canto_uri not in [str(c.uri) for c in cantos]: canto_uri = cantos[0].uri lines = WorkPart.get(canto_uri).hasPart() line_uri = request.GET.get('line') if line_uri not in [str(l.uri) for l in lines]: line_uri = lines[0].uri docs = [] for text in Work.get(work_uri).hasTextOf(): docs.extend(text.isTextIn()) doc_uri = request.GET.get('doc', docs[0].uri) response_dict = { 'part': {'selected': part_uri, 'items': [p.json() for p in parts]}, 'canto':{'selected': canto_uri,'items':[c.json() for c in cantos]}, 'line': {'selected': line_uri, 'items': [l.json() for l in lines]}, 'doc': {'selected': doc_uri, 'items': [d.json() for d in docs]} } if request.GET.get('format') == 'json': return HttpResponse(json.dumps(response_dict)) response_dict['work_uri'] = work_uri return render_to_response( 'rdfviewer/viewer.html', response_dict, context_instance=RequestContext(request))
def index(request): works = Work.all() return render_to_response( 'rdfviewer/index.html', {'works': works}, context_instance=RequestContext(request))