It’s like saying “a seller” with a lisp.
/əˈθɛlər/
uh-the-luh
It’s like saying “a seller” with a lisp.
/əˈθɛlər/
uh-the-luh
I wrote my own wordbreak filter for django
I realised quickly that when I wrote a long unbroken piece of text in one of my chirps, the div would expand (not good). I did experiment with the overflow:auto CSS property to make the div scrollable horizontally when required but wanted a different method. Facebook uses a <wbr> tag in long words to break them up but in my research I found that ­ was the most commonly supported amongst most browsers.
The filter works at the template level and uses a single int to determine the number of spaces to insert the break lines. Here’s an example: {{ object.content|wordbreak:”10″ }}
At every nth character of a word that is more than n characters long, a string of the datetime now plus a custom string plus the datetime again is placed. The string is then conditionally escaped to make the string safe to render and then the custom string is replaced with ­.
from django.utils.html import conditional_escape
from django.utils.safestring import mark_safe
from datetime import datetime
import re
from django import template
register = template.Library()
@register.filter
def wordbreak (string, arg):
search = '([^ ]{' + arg + '})'
t = datetime.now()
wbr = t.strftime("%A%d%B%Y%f") + 'wbr_here' + t.strftime("%A%d%B%Y%f")
saferesult = conditional_escape(re.sub( search, '\\1' + wbr, string ))
result = saferesult.replace(wbr,'­')
return mark_safe(result)
source code also available at http://www.djangosnippets.org/snippets/1432/
A quick update on my progress, I’ve updated the Chirp app quite a lot and so the list of things I need to do has changed.
I’ve yet to implement the buzz-counter. I’ll do that later today I think.
There’s no no such thing as a ‘Whistle’. I’ve made all replies to Chirps, Chirps themselves. This allows super quick database lookups for friends’ chirps. I’ll repost the new code later today I hopes.
Chirps no longer have titles. This won’t be a blog, no need for titles. Really should have considered that a while ago but ah well.
Proper paging. Still can’t get my head around that yet but hopefully it’ll come together this weekend!
So anyway!! Here’s the landing page I’m currently in the process of making. It also shows the new logo I’ve come up with. The green (#2F4F4F) section will contain a short introduction to the site and the white section will show recent chirps.
Adding the buzz counter to chirps so I can get a list of current top chirps.
Proper paging of chirps.
Friends of friends chirps.
Template handling of chirps that don’t have titles.
(Not in that particular order)
Updated! This post is now old and out-of-date, I’ve updated the sourcecode and it can be seen at my-implementation-of-a-twitter-clone-in-django-take-2
This is my first ever django app so any feedback would be greatly appreciated. I worked on something simple like this so I can learn the ins and outs of django nice and quickly while still producing something that is of some use in the actual site itself.
As athe.la will be very community-based, I thought it would only be appropriate to have my own kind of twitter so people can post their thoughts and reply to each other.
Further Reading:
A simple ‘Twitter’ clone in Django
s-o-l sourcecode