Matt's Blog: while { coding }
    Back to Matt's Homepage   |   Hire Matt

Snippetology

My new release today is called Snippetology which is a little app plugin for Django.

Do you ever want to allow a non-technical user to edit just a part of a webpage? Just one paragraph? Or just some text over in the corner? That’s what Snippetology is for. You create a named snippet of text in the database by using an editor in the Django Admin panel. Then in the the webpage template you include a little tag that retrieves that snippet by name from the database and displays it. From that point forward your user can edit the text in the Django Admin panel and their changes will appear in the part of the webpage that you let them control.

This is basic CMS stuff. Django, not being a CMS, does not do this for you. (Or at least it did not at the time I created this. Things are moving so fast with Django and the surrounding community that there could easily be a solution I’m unaware of.)

Like any good tool, there is an “advanced” use for it. Snippets can contain all sorts of things: tags for embedded videos or Flash animations, or behind the scenes stuff like CSS and Javascript. So anything can be in a snippet. Cool! (Well, cool as long as you trust your users. You DO trust your users, don’t you?)

Next I added a randomizing filter. What the filter does is select a random line from the text in a particular snippet. This makes for interesting possibilities. The randomizing feature was originally requested by a client for a tagline generator. But since then it has become clear that more uses exist. For instance, put a banner image tag with a link tag on each line and you’ve created your own ad rotator. And if you’ve been around the web for any length of time, you know that ad rotators get used for all sorts of oddball things. Which is kind of fun!

Snippetology is a dirt simple idea. It’s not a genius breakthrough type of thing. I think that’s part of why I like it so much. It’s got that Unix tools feel; it does one thing and does it well.

Actually, I take that back: It is now two tools that each do one thing well! I hope I see more opportunities in the future to create little tools like this. It’s fun and makes me think in new ways.

Update (May 14, 2009):
Other people like this idea. In fact, they like it so much that there are at least four other comparable projects out there that do the same thing! Clearly people aren’t finding solutions easily enough. It’s odd to think that this is a limitation of a large network. Yes, the Internet is huge, but you only can see what you can find or connect to. Things outside of your network (people you know, things you see, what you’re capable of finding with search) might as well not exist. How to solve this? I don’t know. It’s an interesting problem though.

Here’s a list of the other projects I’ve found so far that are like Snippetology:

  • django-flatcontent
  • django-chunks
  • django-flatblocks
  • django-generic-flatblocks