Due: Thursday, Feburary 14, 11:59pm via turnin (assignment
name hwk5)
Collaboration Policy:
Pairs Permitted
For this assignment, you will implement the same blog editing program that we covered in class using the Scheme web API.
Expected program behavior: The sequence of screens is as in the class handout (with the exception that you should implement the choice of whether to accept using a radio button or check box, rather than a submit button). Specifically, the main page (editing) provides input areas for entering the title and contents of a new blog post, a "preview" button and a list of existing posts. Pressing the preview button brings up a page showing the new post, with date. This page has a radio or checkbox input indicating whether to accept the post and a "Continue" button. Pressing the continue button returns to the entry page. If the previewed post was accepted, the post now appears in the list of posts and the title and content areas are empty. If the post was not accepted, the text and contents areas contain the previously previewed text (for further editing). Your solution should satisfy all of the requirements listed on the class handout.
Here is the sketchy text version that I presented in class (missing details), as well as an annotated version of the adder as a Scheme web script.
You can figure out most of this assignment using the add example linked above (same as the one passed out in class). The servlets directory (described below) has examples of other servlets that use more of the html features. You may find it handy to look at those. For documentation on the API, search for send/suspend in the DrScheme helpdesk. Use only the HelpDesk link under "Web Server Manual" -- the one under "Teachpacks" won't work.
Use the (module ...) language level if you are working
in DrScheme. The usual PLAI language levels will insert metadata at
the top of your file that the web server will subsequently choke on.
The module language tells DrScheme to skip the metadata.
To use empty, first, etc, you'll need to
change the require clause at the top of the add example to the following:
(require (lib "servlet.ss" "web-server")
(lib "list.ss"))
Learning HTML: You should be able to figure out the HTML needed for this assignment via examples. If you look at the pre-course survey and "View Source" in your web browser, for example, you can see how to create forms, input buttons, radio buttons, etc. You shouldn't need to spend lots of time reading HTML tutorials for this. Feel free to post questions to the board. Don't be embarrassed -- lots of students in the class are new to web programming.
Quasiquoting: you may notice sample servlets quoting lists with "`" instead of "'", called quasiquoting, as opposed to quoting. Quasiquoting provides the ability to force evaluation on specific elements of a quasiquoted expression instead of directly returning the expression. To force evaluation of an element in a quasiquoted expression, prefix the element with the character ",". For example, to generate the list '(1 2 3 4) you may write `(1 2 ,(+ 0 3) 4). Quasiquoting can be used as a convenient way of inserting dynamic elements into HTML templates for this assignment, similar to inline patterns found in other web languages. For more information on this technique, search the Help Desk for "quasiquote" and look at the explanations for the "," and ",@" operators. Feel free to post to the board with any questions on this (ie, the point of this assignment is not for you to spend hours figuring out this mechanism -- feel free to post sample code with questions as long as that code isn't from your servlet).
On your own computer
The wording of this section denotes local file paths using "\" slashes as in Windows. The PLT Scheme Web Server works on multiple platforms, so you will need to change the direction of slashes if your OS requires slashes in a different direction for local paths. The PLT directory in these directions refers to the directory where you have installed Scheme on your machine.
On CCC Unix:
If you are writing your servlet in DrScheme, executing it within DrScheme will check for compile-time errors such as unbound variable names. You can't run the script from within DrScheme (it expects the web interface). If your script generates a run-time error, your browser will show the message "servlet didn't load". You can then find the contents of the error message in Standard Out (the shell window in which you started the server or a separate window if you ran the server by double-clicking the web-server executable icon).
Submit a single web script file called blog.ss. This
file should be self-contained and should run as a Scheme servlet.
Make sure your name is at the top of your file (in a comment).
Do we need to include the "clear" button shown in the
handout?
No, no clear button is required.
Do we need to store the blog posts across server
sessions?
No. Your blog posts do not need to persist across web server sessions
(ie, if the server dies, the previous posts may reset to empty). The
point of this assignment is in seeing how continuations form the basis
of web programming. Techniques for making data persist are orthogonal,
so we'll ignore them for this assignment. A simple list of the
existing posts will suffice.
Can we use a mix of Scheme and other languages?
No. All of your code for this assignment should be in
Scheme,
Do we have to be able to clone windows, etc?
Cloning is an issue of handling state properly. I expect that you'll
maintain the accepted posts as a list within your script. I believe
that will support cloning, but if not, the list of posts (properly
maintained) is all we're looking for.