As reported in last week‘s blog post, we worked further on the features of the Playground, especially on the gist support.
GitHub describes gists as a “[...] simple way to share snippets and pastes with others. All gists are git repositories, so they are automatically versioned, forkable and usable as a git repository”. The main idea for the Playground is to be able use those gists as custom code examples.
The implementation of that feature was harder than we thought, because the API for accessing gists is not that well documented and accessible. The easiest way to get a clean API for it was to implement a custom YQL table for accessing the gists. With that table, we can now access the gists using the YQL data store, which is already included in qooxdoo. So getting the gists into the playground is just some lines of qooxdoo code. But getting the gists from the Playground back to GitHub is another problem we decided not to solve, because it would be a lot of work with not that much of an added value.
For accessing the gists in the user interface, we added a special gist menu to the Playgrounds toolbar, which has some special features: First, you can easily enter you own GitHub user name and load your own gists (if you don’t have your own gists already, try “wittemann” to to see it in action). You might not want to have all your gists listed in the playground, because not all of them are qooxdoo code! Thus we added a filter which limits the gists shown according to a [qx] in each gist’s description. With that, you can easily “tag” your gists as qooxdoo snippets.
As already mentioned, we did not implement an integrated editing feature for gists. But of course, adding as well as editing a gist should be as easy as possible. To satisfy the first requirement we added a button for adding gists to the menu, which opens the GitHub page for adding new gists. The same applies for editing, every gist listed has an additional button, which opens the edit page of that gist on GitHub.
If you use the Playground on a daily basis, you don’t want to type in your user name every time. We also thought of that and added cookie support to the Playground. The gist user name, gist filtering and the toggle state of the Playground’s syntax highlighting are stored in a cookie and restored every time you start the Playground.
Last but not least, the gists also made it into the URL. Adding #gist=id to the Playground URL will load the gist with the given id on startup. That makes it easy to share code snippets stored on GitHub, even for all versions of Internet Explorer, which have problems handling the very long URLs the Playground usually uses for code sharing.
To wrap it up, we added a couple of new features to the Playgorund:
- bit.ly support for URL shortening
- Loading, filtering and using gists
- Loading gists by URL parameter
- Cookie support for storing some preferences
Give it a try in the latest devel version of the Playground. This devel snapshot may not be all too stable yet, and the recently added features are still experimental. But we wanted to let you try out the features early. Please tell us what you think of the new features and enhancements! Hope you like it.
Pingback: qooxdoo » News » The week in qooxdoo (2010-01-22)