Archive
Tags
android (3)
ant (2)
beautifulsoup (1)
debian (1)
decorators (1)
django (9)
dovecot (1)
encryption (1)
fix (4)
gotcha (2)
hobo (1)
htmlparser (1)
imaplib (2)
java (1)
json (2)
kerberos (2)
linux (7)
lxml (5)
markdown (4)
mechanize (6)
multiprocessing (1)
mysql (2)
nagios (2)
new_features (3)
open_source (5)
optparse (2)
parsing (1)
perl (2)
postgres (1)
preseed (1)
pxe (4)
pyqt4 (1)
python (41)
raid (1)
rails (1)
red_hat (1)
reportlab (4)
request_tracker (2)
rt (2)
ruby (1)
scala (1)
screen_scraping (7)
shell_scripting (8)
soap (1)
solaris (3)
sql (2)
sqlalchemy (2)
tips_and_tricks (1)
twitter (2)
ubuntu (1)
vmware (2)
windows (1)
zimbra (2)

There is this really nice plugin for WordPress called sociable that makes it easy to make links to various social bookmarking sites. There did not seem to be anything similar in Django, so I made a clone. It does not do everything that the sociable plugin does yet, but it is incredibly flexible. This code is licensed under LGPL.

You can get the latest version here or you can get the whole repository with mercurial:

hg clone http://code.tylerlesmann.com/django-sociable

You will probably want the sociable images also. You can get them from here.

Install is like many other python packages:

python setup.py install

Using django-sociable is easy. After install, edit your settings.py. You will need to specify a MEDIA_URL, if you have not already. Now add SOCIABLE_IMAGE_PATH, which is the path relative to the MEDIA_URL to find the sociable images. The last thing to add is put sociable into your INSTALLED_APPS.

The next step is defining a Site because django-sociable uses this to construct your submission link. You do not want it pointing to example.com. The easiest way to do this is from the Django admin site.

You are ready to use the django-sociable templatetags in your templates. Here's an example of its use from this very blog:

<div>
{% load sociable_tags %}
{% get_sociable Reddit Digg as sociable_links with url=object.get_absolute_url title=object.headline %}
{% for link in sociable_links %}
    <a href="{{ link.link }}">
        <img alt="{{ link.site }}" title="{{ link.site }}" src="{{ link.image }}" />
    </a>
{% endfor %}
</div>

Load sociable_tags. Use the get_sociable tag to get the information you need to build the links. Specify the sites to target, then the variable to map the information to, and finally the arguments. The only required argument is url, which should be a context variable containing link to submit. You can also submit title, excerpt, and source. Use the list of information from get_sociable in whatever way you like. Each element of the list has three attributes. The site attribute is the name of the target site. The link contains the full submission link. The image is the absolute path to the image corresponding to the site.

Here is a full list of the acceptable target sites:

BarraPunto blinkbits BlinkList BlogMemes blogmarks Blogsvine blogtercimlap Faves Book.mark.hu Bumpzee co.mments connotea del.icio.us De.lirio.us Digg DotNetKicks DZone eKudos email Facebook Fark feedmelinks Furl Fleck GeenRedactie Google Gwar Haohao HealthRanker Hemidemi IndianPad Internetmedia kick.ie Kirtsy laaik.it Leonaut LinkArena LinkaGoGo LinkedIn Linkter Live Ma.gnolia Meneame MisterWong MisterWong.DE Mixx muti MyShare MySpace N4G Netvibes NewsVine Netvouz NuJIJ Ping.fm PlugIM Pownce ppnow Print Propeller Ratimarks Rec6 Reddit SalesMarks Scoopeo scuttle Segnalo Shadows Simpy Slashdot Smarking Socialogs Spurl SphereIt Sphinn StumbleUpon Symbaloo Taggly Technorati TailRank ThisNext Tipd Tumblr TwitThis Upnews Webnews.de Webride Wikio Wists Wykop Xerpi YahooBuzz YahooMyWeb YCombinator Yigg

Posted by Tyler Lesmann on March 9, 2009 at 18:16 and commented on 9 times
Tagged as: django new_features open_source python

I have added tagging functionality to this blog. You can expect a post on how I accomplished this very soon.

Posted by Tyler Lesmann on March 5, 2009 at 18:27
Tagged as: new_features

I finally got around to integrating Django's comments into this blog.

Posted by Tyler Lesmann on December 20, 2008 at 11:38 and commented on 2 times
Tagged as: new_features