
On 5/14/06, kirby urner <kirby.urner@gmail.com> wrote:
I've fallen behind on Crunchy Frog.
Having been through the first version's tutorial, I was left wondering what the back end API looks like i.e. suppose I'm a teacher wanting to whip out some Crunchy Frog oeuvre d'evers, what would that look like? Do I need to know any HTML?
Yes, one needs to know html, or at the very least be able to make some small changes to an existing html file. My assumption is that most tutorials are available as html files. For those that haven't read the latest, hopefully more explicit tutorial, here's (in a nutshell) what Crunchy Frog requires and allows. 1. Requirement: tutorial written in (x)html. 2. Possibilities: a) Given some sample Python code (at the interpreter) in the html file: [Note: I know that I should have written >>> rather than >>> in the code below] <pre>
print "Hello world!" Hello world! a = 6*7 print a 42 </pre>
print times2(4) 8 """ </pre> One can embed an "editor" below with an "Evaluate" button which, when
One can embed a Python interpreter prompt by changing the first line above to: <pre vlam="interpreter"> "vlam" stands for "Very Little Added Markup." When the html file will be served to your browser by Crunchy Frog, an interpreter (somewhat similar to Ian Bicking's HTConsole) will appear just below the </pre> tag, allowing the user to try to reproduce the above example, or simply try other Python code. b) Given some sample code (not an interpreter example) in an html file: <pre> def times2(n): return n*2 </pre> One can embed an "editor" (html textarea) with an "Evaluate" button next to it by changing the first line to: <pre vlam="editor"> This "editor", which will appear just below the sample code again, will allow the user to enter some code in it (perhaps the example written above) and try running it as a Python script by pressing the "Evaluate" button. The output will appear below. The code in the editor can then be changed, and run again, as often as desired. c) Given some sample "doctest" result in an html file <pre> """ pressed, will run the above code and test to see if the doctest string can be reproduced. This is done by changing the first line to <pre vlam="doctest"> There's a bit more to it than what I wrote above, but it should give the flavor. André