-def document_detail(request, name, template_name='wiki/document_details.html'):
-
- document = getstorage().get_or_404(name)
-
- access_time = datetime.now()
- last_documents = request.session.get("wiki_last_docs", {})
- last_documents[name] = access_time
-
- if len(last_documents) > MAX_LAST_DOCS:
- oldest_key = min(last_documents, key=last_documents.__getitem__)
- del last_documents[oldest_key]
- request.session['wiki_last_docs'] = last_documents
-
- return direct_to_template(request, template_name, extra_context={
- 'document': document,
- 'document_info': document.info,
- 'document_meta': document.meta,
- 'forms': {"text_save": DocumentTextSaveForm(), "add_tag": DocumentTagForm()},
+def editor(request, pk, template_name='wiki/bootstrap.html'):
+ doc = get_object_or_404(Document, pk=pk, deleted=False)
+
+ save_form = forms.DocumentTextSaveForm(user=request.user, prefix="textsave")
+ text = doc.materialize()
+ revision = doc.revision
+ history = get_history(doc)
+ return render(request, template_name, {
+ 'serialized_document_data': json.dumps({
+ 'document': text,
+ 'document_id': doc.pk,
+ 'title': doc.meta().get('title', ''),
+ 'history': history,
+ 'version': len(history),
+ 'revision': revision.pk,
+ 'stage': doc.stage,
+ 'assignment': str(doc.assigned_to),
+ }),
+ 'serialized_templates': json.dumps([
+ {'id': t.id, 'name': t.name, 'content': t.content} for t in Template.objects.filter(is_partial=True)
+ ]),
+ 'forms': {
+ "text_save": save_form,
+ "text_revert": forms.DocumentTextRevertForm(prefix="textrevert"),
+ "text_publish": forms.DocumentTextPublishForm(prefix="textpublish"),
+ },
+ 'pk': doc.pk,