Login

Snippets by moxypark

Snippet List

Twitter template tags and filters

A simple template filter for parsing tweets (linking @ replies, hashtages and standard URLs whilst stripping out links to yFrog and TwitPic images), and two simple tags for displaying the yFrog and TwitPic images linked to in tweets. If you put the snippet in a file called tweets.py, as long as it lives in an app's templatetags directory, you should be able to do the following (where `text` refers to the text of a tweet): {% load twitter %} <p>{{ text|tweet }}</p> {% yfrog_images text 1 'fancybox' %} {% twitpic_images text 1 'fancybox' %} The first argument in the two tags controls how many images to render. Set this to -1 for an unlimited number, per tweet. Thumbnail images are displayed, and you can specify the class that is applied to the `<a>` tags rendered. Here I've used 'fancybox', and I would normally include jQuery code to turn the images inside the `<a>` tags into lightboxes.

  • twitter
Read More

RadioSelectWithHelpText

A Django form widget which displays help text for individual items in a set of radio buttons. It overrides the RadioSelect widget, adding a small bit of HTML after each <input> element, with the help text for each item. It was developed for a Django Dash project I'm working on (called transphorm.me), so isn't as feature-rich as it could be, but if you have any trouble installing it - or if I've miscopied any of my code in my rush - please let me know.

  • newforms
  • forms
  • widgets
  • radioselect
Read More

moxypark has posted 2 snippets.