Commits

Jens Diemer committed 4db7f6b

remove special template tag with normal template features. maybe it's simpler to put "markup" valiable into contexte!
---
djangobb_forum/templates/djangobb_forum/base.html | 24 ++++++++++++--------
.../djangobb_forum/includes/markup_editor.html | 5 ++++
djangobb_forum/templatetags/forum_extras.py | 15 ------------
3 files changed, 19 insertions(+), 25 deletions(-)
create mode 100644 djangobb_forum/templates/djangobb_forum/includes/markup_editor.html

Comments (0)

Files changed (3)

djangobb_forum/templates/djangobb_forum/base.html

 		var STATIC_URL = "{{ STATIC_URL }}";
 		var POST_PREVIEW_URL = "{% url djangobb:post_preview %}";
 	</script>
-	{% if post %}
-		{% set_markup_editor request.user post.markup %}
-	{% else %}
-		{% set_markup_editor request.user %}
-	{% endif %}
 	<script type="text/javascript" src="{{ STATIC_URL }}admin/js/jquery.min.js" onerror="JavaScript:alert('Error loading file [{{ STATIC_URL }}admin/js/jquery.min.js] !');" ></script>
 	{% if user.is_authenticated %}
-		<script type="text/javascript" >
-		   $(document).ready(function() {
-			$(".markup").markItUp(mySettings);
-		   });
-		</script>
+    	{% if post %}
+            {% with markup=post.markup %}
+                {% include "djangobb_forum/includes/markup_editor.html" %}
+            {% endwith %}
+        {% else %}
+            {% with markup=user.forum_profile.markup %}
+                {% include "djangobb_forum/includes/markup_editor.html" %}
+            {% endwith %}
+        {% endif %}
+    	<script type="text/javascript">
+    	   $(document).ready(function() {
+    		$(".markup").markItUp(mySettings);
+    	   });
+    	</script>
 	{% endif %}
 
     <!-- Highlightjs goodies -->

djangobb_forum/templates/djangobb_forum/includes/markup_editor.html

+<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}djangobb_forum/js/markitup/skins/markitup/style.css" />
+<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}djangobb_forum/js/markitup/sets/{{ markup }}/style.css" />
+<script type="text/javascript" src="{{ STATIC_URL }}djangobb_forum/js/markitup/jquery.markitup.pack.js"></script>
+<script type="text/javascript" src="{{ STATIC_URL }}djangobb_forum/js/markitup/sets/{{ markup }}/set.js"></script>
+<script type="text/javascript" src="{{ STATIC_URL }}djangobb_forum/js/markup/{{ markup }}/board.js"></script>

djangobb_forum/templatetags/forum_extras.py

         theme=selected_theme
     )
 
-@register.simple_tag
-def set_markup_editor(user, markup=None):
-    markup_style = '' 
-    if user.is_authenticated():
-        markup_style = '''
-            <link rel="stylesheet" type="text/css" href="%(static_url)sdjangobb_forum/js/markitup/skins/markitup/style.css" />
-            <link rel="stylesheet" type="text/css" href="%(static_url)sdjangobb_forum/js/markitup/sets/%(markup)s/style.css" />
-            <script type="text/javascript" src="%(static_url)sdjangobb_forum/js/markitup/jquery.markitup.pack.js"></script>
-            <script type="text/javascript" src="%(static_url)sdjangobb_forum/js/markitup/sets/%(markup)s/set.js"></script>
-            <script type="text/javascript" src="%(static_url)sdjangobb_forum/js/markup/%(markup)s/board.js"></script>
-        ''' % dict(
-            static_url=settings.STATIC_URL,
-            markup=markup if markup else user.forum_profile.markup
-        )
-    return markup_style