]> git.sommitrealweird.co.uk Git - sommitrealweird.git/commitdiff
Actually add comments to blog, tidy up rst handling to make sure we get xhtml1.1...
authorBrett Parker <iDunno@sommitrealweird.co.uk>
Sat, 12 Sep 2009 14:27:08 +0000 (15:27 +0100)
committerBrett Parker <iDunno@sommitrealweird.co.uk>
Sat, 12 Sep 2009 14:27:08 +0000 (15:27 +0100)
media/style/main.css
sommitrealweird/blog/templates/blog/blog_index.html
sommitrealweird/blog/templates/blog/single_entry_rst.html
sommitrealweird/bpcms/templates/bpcms/bpcms.html [new file with mode: 0644]
sommitrealweird/generic/docutils_xhtml11.py [new file with mode: 0644]
sommitrealweird/generic/templatetags/xhtml11rst.py [new file with mode: 0644]
sommitrealweird/settings.py
sommitrealweird/urls.py

index 56ecd36233756a2cecab2e6c78346767ac29d38f..c3bf811bc43a2029527a0ce71566d874c38058e8 100644 (file)
@@ -190,3 +190,42 @@ dl dt {
 #content ul li p.first {
     margin: 0;
 }
 #content ul li p.first {
     margin: 0;
 }
+
+div.comments {
+    border-top: 1px solid #afafaf;
+}
+
+div.comments h3 {
+    margin-top: 0.2em;
+    padding-top: 0;
+}
+
+div.comments div.comment {
+    border-bottom: 1px solid #afafaf;
+}
+
+div.comment_new p label {
+    width: 25%;
+    padding-right: 0.7em;
+    text-align: right;
+    display: block;
+    float: left;
+    vertical-align: top;
+}
+
+div.comment_new p label:after {
+    content: ":";
+}
+
+div.comment_new p input[type="text"] {
+    width: 30em;
+}
+
+div.comment_new p textarea {
+    width: 25em;
+}
+
+div.comments a[name="comments"] {
+    text-decoration: none;
+    display: none;
+}
index f7f3ab0373d0a588f7734cfe1281e5ec6dda6db7..672780400c4bee6e527f23ae6c8c1a57aae8d7b2 100644 (file)
@@ -1,5 +1,6 @@
 {% extends "base.html" %}
 {% load xhtml11rst %}
 {% extends "base.html" %}
 {% load xhtml11rst %}
+{% load comments %}
 
 {% block extrahead %}
 <link rel="alternate" type="application/atom+xml" title="iDunno's Blog - Atom Feed" href="{{ BLOG_FEED_ROOT }}/blog/" />
 
 {% block extrahead %}
 <link rel="alternate" type="application/atom+xml" title="iDunno's Blog - Atom Feed" href="{{ BLOG_FEED_ROOT }}/blog/" />
@@ -25,7 +26,8 @@
                         {% endif %}
                     {% endif %}
                 {% endfor %}
                         {% endif %}
                     {% endif %}
                 {% endfor %}
-                <a href="{{ entry.get_absolute_url }}">permalink</a></p>
+                {% get_comment_count for entry as comment_count %}
+                <a href="{{ entry.get_absolute_url }}">permalink</a> | <a href="{{ entry.get_absolute_url }}#comments">Comments</a>: {{ comment_count }}</p>
         {% endfor %}
         {% if paginated and has_more_than_one_page %}
             <p class="paginator">Pages: 
         {% endfor %}
         {% if paginated and has_more_than_one_page %}
             <p class="paginator">Pages: 
index 9b49f5539dccb7dcd4f0867a877530bed3c7c791..0d99d90a3eda7c73ba75546d35b5d27a538eaf90 100644 (file)
@@ -1,6 +1,7 @@
 {% extends "base.html" %}
 
 {% load xhtml11rst %}
 {% extends "base.html" %}
 
 {% load xhtml11rst %}
+{% load comments %}
 
 {% block content %}
 <h1>{{ entry.title }}</h1>
 
 {% block content %}
 <h1>{{ entry.title }}</h1>
         {% endif %}
     {% endfor %}
     {% endif %}
         {% endif %}
     {% endfor %}
     {% endif %}
-    <a href="{{ entry.get_absolute_url }}">permalink</a>
+    {% get_comment_count for entry as comment_count %}
+    <a href="{{ entry.get_absolute_url }}">permalink</a> | Comments: {{ comment_count }}
 </p>
 </p>
+{% if comment_count %}
+    <div class="comments">
+    <a name="comments"></a>
+    {% get_comment_list for entry as comment_list %}
+    {% for comment in comment_list %}
+    <div class="comment">
+        <h3>{{ comment.user_name }} - {{ comment.submit_date|date:"Y-m-d H:i" }}</h3>
+        {{ comment.comment }}
+    </div>
+    {% endfor %}
+    </div>
+{% endif %}
+<div class="comment_new">
+    {% render_comment_form for entry %}
+</div>
 {% endblock %}
 {% endblock %}
diff --git a/sommitrealweird/bpcms/templates/bpcms/bpcms.html b/sommitrealweird/bpcms/templates/bpcms/bpcms.html
new file mode 100644 (file)
index 0000000..7b96bb9
--- /dev/null
@@ -0,0 +1,9 @@
+{% extends "base.html" %}
+
+{% block extrahead %}
+{% if extracss %}
+{% for css in extracss %}
+<link rel="stylesheet" type="text/css" href="/css-docs/{{ css.slug }}" />
+{% endfor %}
+{% endif %}
+{% endblock %}
diff --git a/sommitrealweird/generic/docutils_xhtml11.py b/sommitrealweird/generic/docutils_xhtml11.py
new file mode 100644 (file)
index 0000000..4b7d9b9
--- /dev/null
@@ -0,0 +1,32 @@
+# Author: Brett Parker <iDunno@sommitrealweird.co.uk>
+
+"""
+HTML1.1 Writer.
+"""
+
+__docformat__ = 'reStructuredText'
+
+import sys
+import os
+import os.path
+import codecs
+import docutils
+from docutils import frontend, nodes, utils, writers
+from docutils.writers import html4css1
+
+class Writer(html4css1.Writer):
+
+    config_section = 'xhtml11 writer'
+    config_section_dependencies = ('writers', 'html4css1 writer')
+
+    def __init__(self):
+        html4css1.Writer.__init__(self)
+        self.translator_class = HTMLTranslator
+
+class HTMLTranslator(html4css1.HTMLTranslator):
+
+    def is_compactable(self, node):
+        return False
+
+    def should_be_compact_paragraph(self, node):
+        return False
diff --git a/sommitrealweird/generic/templatetags/xhtml11rst.py b/sommitrealweird/generic/templatetags/xhtml11rst.py
new file mode 100644 (file)
index 0000000..3bc212a
--- /dev/null
@@ -0,0 +1,22 @@
+from django import template
+from django.conf import settings
+from django.utils.encoding import smart_str, force_unicode
+from django.utils.safestring import mark_safe
+from generic import docutils_xhtml11
+
+register = template.Library()
+
+def restructuredtext(value):
+    try:
+        from docutils.core import publish_parts
+    except ImportError:
+        if settings.DEBUG:
+            raise template.TemplateSyntaxError, "Error in {% restructuredtext %} filter: The Python docutils library isn't installed."
+        return force_unicode(value)
+    else:
+        docutils_settings = getattr(settings, "RESTRUCTUREDTEXT_FILTER_SETTINGS", {})
+        parts = publish_parts(source=smart_str(value), writer=docutils_xhtml11.Writer(), settings_overrides=docutils_settings)
+        return mark_safe(force_unicode(parts["fragment"]))
+restructuredtext.is_safe = True
+
+register.filter(restructuredtext)
index f0a5725bf29ebe99bb5ce0aba1c1d860475922c0..73ea9ce99678f0d96fd2d303cef75b3cd122180a 100644 (file)
@@ -67,6 +67,7 @@ INSTALLED_APPS = (
     'django.contrib.sites',
     'django.contrib.admin',
     'django.contrib.markup',
     'django.contrib.sites',
     'django.contrib.admin',
     'django.contrib.markup',
+    'django.contrib.comments',
     'bpcms',
     'generic',
     'blog',
     'bpcms',
     'generic',
     'blog',
index dc24d72990bf072f98dc7d31eb03e68093c5b023..6106b9f61afdb47f47c7b6f5ca6ef76ba1311f8e 100644 (file)
@@ -26,7 +26,9 @@ urlpatterns = patterns('',
     (r'^blog/', include('blog.urls')),
     (r'^photo/', include('photo.urls')),
     (r'^photos/', include('photo.urls')),
     (r'^blog/', include('blog.urls')),
     (r'^photo/', include('photo.urls')),
     (r'^photos/', include('photo.urls')),
+    (r'^css-doc/(?P<slug>.*)$', 'bpcms.views.css_view'),
     (r'^feeds/rss/(?P<url>.*)/', 'django.contrib.syndication.views.feed', {'feed_dict': rssfeeds_dict}),
     (r'^feeds/(?P<url>.*)/', 'django.contrib.syndication.views.feed', {'feed_dict': feeds_dict}),
     (r'^feeds/rss/(?P<url>.*)/', 'django.contrib.syndication.views.feed', {'feed_dict': rssfeeds_dict}),
     (r'^feeds/(?P<url>.*)/', 'django.contrib.syndication.views.feed', {'feed_dict': feeds_dict}),
+    (r'^comments/', include('django.contrib.comments.urls')),
     (r'^(?:content/|)', include('bpcms.urls'))
 )
     (r'^(?:content/|)', include('bpcms.urls'))
 )