Code Snippets? I’ll give you code snippets!
by Mike
Well I actually won’t give you code snippets, but I will give you the ability to store and organize them.
Storing code snippets is not the worlds greatest unconquered problem or anything like that, however that being said I have tried much of the software out there for storing code snippets and I still feel like I want to create my own. I have a few interesting ideas that I think may be really neat for storing and retrieving code snippets(at least I think they are neat), so I have decided to code them.
I cannot imagine I will do anything new with this project that isn’t readily available amongst the dozens of code snippet sites out there but at the very least I will try collate the things I really like into one site and maybe accomplish something different along the way.
So what are the goals?
- I want to practice my Django skills
- I want to store some code snippets
Pretty simple huh? I hope so, because I really don’t want to spend months and months solving a problem other people have already solved reinventing the wheel.
Supplementary to the goals listed I want to make it really easy to post code snippets(as well as send them to other people), I want the website to feel light so I will remove much of the cruft you see in other code snippet websites and stick to the basics.
I am not going to mention much else about the features I want to develop until I get the ball rolling on the project and get an initial alpha release out(I only have put in about 2 hours of development time), I don’t want to get expectations to high bite off more than I can chew
As for releasing the project, I am not sure how I am going to go about that, depending on how useful I find it, I may release it as a service of some sort. I have also been toying around with open sourcing it, don’t ask me about licenses yet though(everyone seems to have an opinion after what Zed Shaw said the other day), I will decide on the license if/when I decide to release the project.
That being said, I am off to do some more work on this. More updates soon.
Comments
Good post. You know my views on this, as we have discussed on GTalk.
Basically, if you’re going to have many regular users, parse most formatting and syntax highlighting on the client-side.
Optionally, if you have a small user-base, keep it server-side.
Finally, when you store the snippet, make sure you don’t store the accompanying formatting/html/css with it. Otherwise you’ll have to parse it again if you ever want to export, or something. Know what I mean?
I agree with the stuff that Josh mentioned. Maybe the level of parsing to do on the server-side would be to break things down into an XML form, something like:
do something fubar
I think the pros of this method are that you lessen the load a little on the client-side, and allow a single submission to be outputted in a variety of languages. You definitely introduce some other added complexities though. For example, even though you won’t parse the actual code on the client-side, you still have to “parse” the XML on the client-side to produce output.
Now mind you, I don’t know what’s already out there for client-side parsing. I’m just offering a potential solution that is flexible. By using XML you could also take advantage of some XSL/XSLT, if you’re into that stuff. Looking forward to seeing this when you have something up and running
Okay, I didn’t know your comment system removed greater/less than signs instead of transforming them into < and >
What I had there can be seen at http://www.cs.ualberta.ca/~gedge/code_snippet_xml.txt
I have been thinking of something similar to what you are saying here. I have been pen-and-papering a bunch of ideas to handle this problem. Ideally I want to be able to store the snippet in a sane way, I want to make sure it is sanitized when it goes in there(as to avoid malicious code) , I want to make it easy to handle the syntax highlighting and allow for an attractive display of the code, and I want to make it somewhat easy to export snippets in a variety of formats.