Share Snipplr

Archive for the ‘Development’ Category

I can’t count the number of times on this blog I’ve mentioned the importance of keeping websites like Snipplr open. I don’t mean online and in business, I mean keeping the data (your data) freely available for you to import and export as you see fit. That’s the point of the Snipplr API – to let you manage your snippets without ever having to even visit Snipplr.com. Today I’m releasing a new feature to continue this trend.

Many users have asked for a way to backup all their snippets. Just in case Snipplr goes offline or you want to move your code to another site. Ask an ye shall receive.

On your settings page you’ll find a new link that will let you download a zip file containing all of your snippets.

I pushed out another round of updates this afternoon. The biggest change was the switch from Pear’s Text_Highlighter module to GeShi. While I prefer the Pear version, GeShi supports many more languges and is easier to maintain. A bonus I wasn’t expecting is that PHP functions are linked to their man page on PHP.net. Very cool.

This morning I added a list of the top ten most active members on Snipplr to the Popular page.

Also, last night I announced that Snipplr can import your existing snippets from other websites such as BigBold.com and ProgrammingIsHard.com. All of your snippets will be added to Snipplr automatically – even your tags. This morning I enabled importing from TextSnippets.com as well.

When you’re trying to get people to switch from a competitor
to your product, you need to understand barriers to
entry . . . or people won’t switch, and you’ll be
waiting tables.

He’s right. I’ve received many emails from visitors saying how much they like Snipplr and how it integrates with TextMate and WordPress, but they just can’t switch because they have too many snippets stored on other websites like BigBold.com and copycat newcomer ProgrammingIsHard.com.

This morning I decided to do something about the problem and help users make the switch to Snipplr. I’ve added a new section to your Snipplr Settings page that let’s you import your existing snippets from other websites.

All you have to do is enter your username and Snipplr will automagically copy your snippets from their old home into Snipplr. It’ll even keep your tags in tact, too. It’s simple, quick, and painless.

Last night’s update introduced a bug that added extra slashes () to any snippets you posted that contained quotation marks or newlines – in other words, every snippet. The bug has been fixed, and I’ve gone through each snippet and corrected any that were broken. Sorry for the confusion.

I spent a couple hours at Starbucks this afternoon and added user comments to Snipplr. (A much requested feature.) Now you can post feedback, suggestions, and critiques for each snippet on the site. You can also subscribe to comments for a particular snippet by clicking on the RSS icon in the comments section (below the snippet).

In an effort to give visitors as much flexibility as possible in formatting their comments, I’ve opted to use John Gruber’s extremely useful Markdown syntax. An overview of the syntax is available to get you up to speed quickly.

As always, please send me any feedback you have. You can contact me here, or leave your comments below.

Tonight I’m releasing an offical Snipplr API which will allow anyone to write their own plugins to communicate with Snipplr. You can use the API to talk to Snipplr from other websites, your favorite text editor, or any desktop app. It’s up to you. You’re in control now.

The Snipplr API uses the standard XML-RPC protocol and offers the following methods.

snippet.list – Returns a list of snippets based on the search criteria you provide.

snippet.get – Retrieves the details (including source code) for a given snippet.

snippet.post – Allows you to store a new snippet into Snipplr.

snippet.delete – Allows you to delete a snippet.

user.checkkey – Validates a user’s API key.

languages.list – Returns a list of available languages.

I’d appreciate feedback letting me know about any problems you run into or features you’d like added.

Also, for all the TextMate hackers out there, I’ve got an offer for you. I’d like to replace the current TextMate Snipplr bundle with a more maintainable Ruby version. (The current one is a mess that uses shell scripting.) I only know a little Ruby, so along with their name on Snipplr and my eternal thanks, the first person to send in a good, working Snipplr plugin for TextMate gets a free Snipplr t-shirt In fact, if you want to write a plugin for another editor (BBEdit!), and I approve it, I’ll send you a Snipplr t-shirt as well.

Using the API

Server:

http://snipplr.com

End Point:

/xml-rpc.php

Full URL:

http://snipplr.com/xml-rpc.php

snippet.list

snippet.list returns an XML formatted list of snippets matching the specified criteria. Takes two parameters (must be passed in this order):

api_key: Required. The API key of the Snipplr user. Snipplr returns all of this user’s snippets. An error message will be returned if the API key is invalid.

tags: Optional. A space delimited list of tags (keywords) to filter the results by. Snipplr returns snippets which contain at least one of the keywords in the snippet’s title or that match one of the snippet’s tags.

sort: Optional. Can be one of these three values: “title”, “date”, “random”.

limit: Optional. The number of snippets to return.

Note: snippet.list only returns snippets owned by the user or marked as favorites of the user. It does not search all of the snippets on Snipplr.

snippet.get

snippet.get returns a snippet’s details. Takes one parameter:

snippet_id: Required. The ID of the snippet to fetch. An error message will be returned if the ID is invalid.

snippet.get currently returns the following snippet properties:

id

user_id

username

title

language

comment

created (datetime when snippet was created)

source

snipplr_url (url to view snippet)

tags (space delimited list of the snippet’s tags)

snippet.post

snippet.post stores a new snippet into Snipplr. Takes four parameters (must be passed in this order):

api_key: Required. The API key of the Snipplr user to which the snippet will belong. An error message will be returned if the API key is invalid.

title: Required. The title of the snippet.

code: Required. The snippet’s source code.

tags: Optional. A space delimited list of keywords to tag the snippet with.

language: Optional. The language to mark the snippet as. Use the language name found in Snipplr’s URLs. For example, “javascript” or “c-plus-plus”.

snippet.delete

snippet.delete deletes a snippet from your Snipplr account. Returns 1 on success, 0 if the snippet could not be deleted. Takes two parameters (must be passed in this order):

api_key: Required. The API key of the Snipplr user that created the snippet you are deleting. An error message will be returned if the API key is invalid.

snippet_id: Required. The ID of the snippet you are deleting.

user.checkkey

user.checkkey validates a user’s API key. Returns 1 if the key is valid. 0 if not valid. Takes one parameter.

api_key: The API key to validate.

languages.list

languages.list returns a list of supported languages in Snipplr. It returns their urlname and pretty name. The urlname is the value you pass into the snippet.post method. The pretty name is a nicely formatted version of urlname. It’s just there for your reference. This method takes no parameters.

I pushed out a new version of Snipplr early this morning. There are a lot of improvements – both above and under the hood. In deciding what to work on over the holiday weekend, I picked out the best suggestions from all the emails I’ve received and combined that list with my own bug fixes.

Revamped RSS feeds allowing you to make a feed from any page. This will let you subscribe to individual tags. (Another much requested feature.)

Releasing an “official” Snipplr API using XMl-RPC. Right now the TextMate bundle communicates using a simple GET/POST query. I hope having a documented API will encourage developers to write plugins for BBEdit, Vim, Emacs, and all the other text editors out there.

I’m also toying with the idea of classifying snippets based on spoken language. So people who only speak English can ignore all the Spanish snippets and vice-versa. Thoughts?

Again, as always, please let me know of any bugs you find or suggestions you have. You can leave your comments below or contact me here.

Wow. Snipplr made it to number one on del.icio.us yesterday. This brought in a ton of new users and a lot of great suggestions for improving the website. That said, I thought I’d share my current todo list of features/changes I’m working on this weekend. Most of these are suggestions from visitors. So, if you have your own suggestions or additions to the list below, please post in the comments.

New Languages to be Supported

Feature Requests I’m Working On

In the user profiles, people can set their spoken language and also set Snipplr to only show them Snippets in that language.

Option to make snippets private.

Make snippets viewable only to certain users you pick. (Not sure if I’ll do this one right away. But I’m considering it.)

So, that list along with my own bug fixes are what I’m working on at the moment and what I hope to accomplish this weekend.

One note regarding the programming languages above. It’s easy for me to add support for additional languages (I just add them to the language dropdown box). The trick is to add syntax highlighting for them. Currently, I’m using the Text_Highlighter class available from the Pear repository. If anyone would like to contribute additional language highlighting classes for it, I’d be very grateful.