From 6bf8f9bc3d930eaac1ca1439d5dcee8585bf7f80 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Wed, 11 Dec 2013 13:29:06 +0100 Subject: [PATCH] Push partial templates to the editor --- apps/wiki/templates/wiki/bootstrap.html | 6 +++++- apps/wiki/views.py | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/wiki/templates/wiki/bootstrap.html b/apps/wiki/templates/wiki/bootstrap.html index 5d59d784..159a4f4e 100644 --- a/apps/wiki/templates/wiki/bootstrap.html +++ b/apps/wiki/templates/wiki/bootstrap.html @@ -55,10 +55,14 @@ ); {% endif %} - var data = {% autoescape off%}{{serialized_document_data}}{%endautoescape%}; + {% autoescape off%} + var data = {{serialized_document_data}}, + templates = {{serialized_templates}} + {%endautoescape%} var editor_init = function(Editor) { Editor.setBootstrappedData('data', data); + Editor.setBootstrappedData('documentToolbar', templates); Editor.start(config); }; diff --git a/apps/wiki/views.py b/apps/wiki/views.py index 2bb168fe..b88d2df1 100644 --- a/apps/wiki/views.py +++ b/apps/wiki/views.py @@ -16,7 +16,7 @@ from django.views.decorators.http import require_POST, require_GET from django.shortcuts import get_object_or_404, render from django.utils import simplejson -from catalogue.models import Book, Chunk +from catalogue.models import Book, Chunk, Template import nice_diff from wiki import forms from wiki.helpers import (JSONResponse, JSONFormInvalid, JSONServerError, @@ -89,6 +89,9 @@ def editor(request, slug, chunk=None, template_name='wiki/bootstrap.html'): 'history': get_history(chunk), 'version': chunk.revision() }), + 'serialized_templates': simplejson.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") -- 2.20.1