[Oi-commits] r1315 - in trunk: forum media/css st/templatetags templates/forum

oi-commits at pardus.org.tr oi-commits at pardus.org.tr
Thu May 1 00:18:54 EEST 2008


Author: erenturkay
Date: Thu May  1 00:18:54 2008
New Revision: 1315

Added:
   trunk/forum/postmarkup.py
Modified:
   trunk/forum/views.py
   trunk/media/css/forum.css
   trunk/st/templatetags/library.py
   trunk/templates/forum/reply.html
   trunk/templates/forum/topic.html
Log:
fully quation support, as well as bbcode. should be tested carefully for html injection

Modified: trunk/forum/views.py
=================================================================
--- trunk/forum/views.py	(original)
+++ trunk/forum/views.py	Thu May  1 00:18:54 2008
@@ -208,7 +208,7 @@
             post = get_object_or_404(Post, pk=quote_id)
 
             if post in topic.post_set.all():
-                form = PostForm(auto_id=True, initial={'text': '[quote]%s|%s|%s[/quote]' % (post.author.username, post.created, post.text)})
+                form = PostForm(auto_id=True, initial={'text': '[quote <b>%s</b> kullanıcısından alıntı...]%s[/quote]' % (request.user.username, post.text)})
             # if quote doesn't belong to this topic, just redirect to what user gets :)
             else:
                 return HttpResponseRedirect(post.get_absolute_url())

Modified: trunk/media/css/forum.css
=================================================================
--- trunk/media/css/forum.css	(original)
+++ trunk/media/css/forum.css	Thu May  1 00:18:54 2008
@@ -310,15 +310,16 @@
     font-weight: bold;
 }
 
-.quote {
+blockquote {
     border: 1px solid #CCCCCC;
     padding: 10px;
-    margin-bottom: 8px;
+    width: 90%;
+    margin-bottom: 2px;
     background-color: #E1E3FF;
     color: #51615D;
 }
 
-.quote p {
+blockquote em {
     padding-left: 12px;
     font-style: italic;
 }

Modified: trunk/st/templatetags/library.py
=================================================================
--- trunk/st/templatetags/library.py	(original)
+++ trunk/st/templatetags/library.py	Thu May  1 00:18:54 2008
@@ -6,6 +6,8 @@
 from django.utils.timesince import timesince
 from oi.settings import MEDIA_ROOT, MEDIA_URL
 
+from oi.forum.postmarkup import render_bbcode
+
 register = Library()
 
 @register.filter
@@ -27,29 +29,8 @@
     return miniature_url
 
 @register.filter
-def renderquote(context):
-    def render(text):
-        if text.find("[quote]") > 0 and text.find("[/quote]") > 0:
-            first_find = text.find("[quote]")
-            second_find = text.find("[/quote]")
-
-            # get [quote]user|date|message[/quote]
-            quote_string = text[first_find:second_find+8]
-
-            # clean it, just gets user|date|message
-            clean_string = quote_string[7:-8]
-
-            try:
-                username, date, data = clean_string.split("|")
-                replace_string = '<div class="quote"><b>%s</b> kullanıcısından alıntı. Tarih: %s <p>%s</p></div>' % (username, date, data)
-
-                return text.replace(quote_string, replace_string)
-            except ValueError:
-                return text
-        else:
-            return text
-
-    return render(context)
+def renderbbcode(context):
+    return render_bbcode(context)
 
 @register.inclusion_tag('paginator.html', takes_context=True)
 def paginator(context, adjacent_pages=2):

Modified: trunk/templates/forum/reply.html
=================================================================
--- trunk/templates/forum/reply.html	(original)
+++ trunk/templates/forum/reply.html	Thu May  1 00:18:54 2008
@@ -14,7 +14,7 @@
 {% for field in form %}
     <dl>
         <dt><label for="{{ field.name }}">{{ field.label }}</label>{% if field.help_text %}<br /><span>{{ field.help_text }}</span>{% endif %}{% if field.errors %}<br /><span class="error">{{ field.errors }}</span>{% endif %}</dt>
-        <dd>{{ field }}</dd>
+        <dd>{{ field|safe }}</dd>
     </dl>
 {% endfor %}
 <input type="submit" value="Yanıtla" />

Modified: trunk/templates/forum/topic.html
=================================================================
--- trunk/templates/forum/topic.html	(original)
+++ trunk/templates/forum/topic.html	Thu May  1 00:18:54 2008
@@ -83,7 +83,7 @@
                 {% endif %}
         </div>
         <div class="post_message_content">
-            <div class="post_message_text">{{ post.text|renderquote|safe }}</div>
+            <div class="post_message_text">{{ post.text|renderbbcode|safe }}</div>
             {% if forloop.first %}
             <div class="post_message_tags">
                 <img src="/media/img/tag.png" alt="etiket" />{% for tag in topic.tags.all %}<span class="tag"><a href="/etiket/{{tag.name}}/">{{tag.name}}</a></span>{% endfor %}


More information about the Oi-commits mailing list