+
+
+def document_gallery(request, directory):
+ try:
+ base_dir = os.path.join(settings.MEDIA_ROOT, settings.FILEBROWSER_DIRECTORY, directory)
+ images = [u'%s%s%s/%s' % (settings.MEDIA_URL, settings.FILEBROWSER_DIRECTORY, directory, f) for f in os.listdir(base_dir) if os.path.splitext(f)[1].lower() in (u'.jpg', u'.jpeg', u'.png')]
+ images.sort()
+ return HttpResponse(json.dumps(images))
+ except (IndexError, OSError), exc:
+ import traceback
+ traceback.print_exc()
+
+ raise Http404
+
+def document_diff(request, name, revA, revB):
+ differ = difflib.HtmlDiff(wrapcolumn=60)
+
+ docA = storage.get(name, int(revA))
+ docB = storage.get(name, int(revB))
+
+ return HttpResponse(differ.make_table(
+ docA.plain_text.splitlines(),
+ docB.plain_text.splitlines() ) )
+
+
+def document_history(reuqest, name):
+ return HttpResponse( json.dumps(storage.history(name), cls=DateTimeEncoder), mimetype='application/json')