February 16, 2009 will

Django Techblog Comment test

Please test the comment system on this post. Django Techblog was build for my own needs to be able to easily display code in posts and to allow readers to insert code in to comments without linking to external sites.

To insert code in to a comment use the [code] tag, you may optionally supply a language to syntax highlight the pasted code. For example [code python]import this[/code] should produce something along the following lines:

import this

Some other tags you can use are: [b] [i] [s] [size] [url] [quote]

To get things started, lets pretend we are discussing the following piece of code which is in use in this blog, and is used to send out mails when a comment is made. The decorator is my version of Django's signals, which I will probably blog about at some point!

@broadcast.recieve()
def new_comment(object, comment):
    if isinstance(object, models.Post):
        comment.moderated = True
        comment.visible = True
        comment.group = "blog.%s" % object.blog.slug
        comment.save()

        domain = Site.objects.get_current().domain
        td = {}
        td['name'] = object.blog.owner.get_full_name()
        td['comment'] = comment.content_text
        td['post'] = object.title
        td['url'] = "http://%s%s#comment%s" % (domain, object.get_absolute_url(), comment.id)
        mailer.send("admin/mail/newcomment.txt", td, "New Comment", object.blog.owner.email)

    else:
        raise broadcast.RejectBroadcast
Use Markdown for formatting
*Italic* **Bold** `inline code` Links to [Google](http://www.google.com) > This is a quote > ```python import this ```
your comment will be previewed here
gravatar
Brandon Thomson
Looks great Will!

       # This page was edited for the first time, so create all the pages
      numChoices = int(self.request.get('numChoices'))
      thePage.written = True
      thePage.locked = False
gravatar
WIll McGugan
It even works with Django template code
 <head>
    <title>{% block title %}YOU FORGOT THE TITLE!{% endblock %}</title>
    {# <link rel="stylesheet" href="/media/css/common.css" type="text/css" ></link> #}
    <link rel="stylesheet" href="/media/css/blog_base.css" type="text/css" ></link>
    {# <link rel="stylesheet" href="/media/css/code.css" type="text/css" ></link> #}
    {% block css %}{% endblock %}
    <link rel="icon" type="image/png" href="/media/images/favicon.png" ></link>
    <script type="text/javascript" src="/media/js/jquery-1.3.1.min.js"> </script>
    {% block js_head %}{% endblock %}
    {% if feeds %}
        {% for feed in feeds %}
            <link href="{{ feed.url }}" rel="alternate" type="application/rss+xml" title="{{ feed.title }}" />
        {% endfor %}
    {% endif %}
    {% block head %}{% endblock %}
    {% markupsection sections "head" %}
    {% markupsection sections "css" %}
    {% markupsection sections "js-head" %}
</head>
gravatar
Rene Dudfield
#include <stdio.h>

int cool(char * thing) {
printf(“%s”, thing);
}

int main( int argc, const char* argv ) {
cool(“html mangler”);
}
gravatar
INTERNET
INTERNET
gravatar
INTERNET
THE INTERNET
gravatar
Will McGugan
Giving serious thought to removing the size tag!
gravatar
WIll McGugan
import this
gravatar
Karpo
Hi Will, how are you?
Well, I’m just starting to read your book “Beginning Game Development with Python and Pygame” and it’s cool. I’ve read only 1 chapter and I realised that I want to focus on web development with Python, that’s why I’m writing to you.
¿Have you published any book like the one I'm reading but focused on web development? If not, ¿could you recommend me how to start making web apps. with django?

My regards from Argentina,

Please answer me soon.

Alan

PS: If you type
  or [code c ] it also works! Please write all the supported lenguages.[/i]
gravatar
Karpo
For Rene Dudfield:


 #include <stdio.h>
int cool(char * thing) {
printf(%s, thing);
}
int main( int argc, const char* argv ) {
cool(html mangler);
}
gravatar
WIll McGugan
Karpo
¿Have you published any book like the one I'm reading but focused on web development? If not, ¿could you recommend me how to start making web apps. with django?
Glad you like my book. There is a Django book by Apress that may be a good start, but it is a little out of date. There are some newer books that cover 1.0 – have a look on Amazon. If you cant find a book, there are plenty of tutorials and the Django site has great documentation.
gravatar
WIll McGugan
Just a test to see if I have set up postfix correctly….
gravatar
Wil McGugan
And a test to see if comments work on Chrome…
gravatar
Nathan Grubb
I look forward to seeing the blog system!

And now, for a test:

 <?php
echo "Test";
?>



gravatar
WIll McGugan
Nathan, this is the bog system!
gravatar
WIll McGugan
Hello
gravatar
Benjamin
The comment system looks great. It would be great if you could edit your comments afterwards. I just misspelled my last comment. There are some comment systems which allow editing within some seconds after submitting. A preview feature would also be nice and could serve the same purpose, to be able to check again your comment.