Commits

TakeruWolf committed 717606d

dynamic preview url

  • Participants
  • Parent commits 656a98d

Comments (0)

Files changed (3)

markitup/templates/markitup/editor.html

 $(document).ready(function() {
   var element = $("#{{ textarea_id }}");
   if(!element.hasClass("markItUpEditor")) {
+    mySettings["previewParserPath"] = "{{ preview_url }}";
     element.markItUp(mySettings);
   }
   {% if AUTO_PREVIEW %}$('a[title="Preview"]').trigger('mouseup');{% endif %}

markitup/templatetags/markitup_tags.py

 from django import template
+from django.core.urlresolvers import reverse
 from markitup import settings
 from markitup.util import absolute_url
 from markitup.fields import render_func
     else:
         auto_preview = settings.MARKITUP_AUTO_PREVIEW
     return {'textarea_id': textarea_id,
-            'AUTO_PREVIEW': auto_preview}
+            'AUTO_PREVIEW': auto_preview,
+            'preview_url': reverse('markitup_preview')}

markitup/widgets.py

 from django import forms
 from django.utils.safestring import mark_safe
 from django.contrib.admin.widgets import AdminTextareaWidget
+from django.core.urlresolvers import reverse
 
 from markitup import settings
 from markitup.util import absolute_url
           $(document).ready(function() {
             var element = $("#%(id)s");
             if(!element.hasClass("markItUpEditor")) {
+              mySettings["previewParserPath"] = "%(preview_url)s";
               element.markItUp(mySettings);
             }
             %(auto_preview)s
           });
           })(jQuery);
         </script>
-        """ % {'id': attrs['id'], 'auto_preview': auto_preview }
+        """ % {'id': attrs['id'], 'auto_preview': auto_preview,
+               'preview_url': reverse('markitup_preview')}
 
         return mark_safe(html)