First, let's take a look at the Recipe Menu Page. Here is the HTML...
<HTML> <HEAD> <TITLE>Recipe Menu</TITLE> </HEAD> <BODY> <H1>Recipe Menu</H1> If you would like, please <A HREF="RecipeEntry.html">enter your favorite recipe</A> or browse the recipes entered so far... <UL> </UL> <P> IMPORTANT: If this page seems to be missing recently added documents, click the "Reload Page" button on your Web Browser to update the menu. <P> <ADDRESS> This page is being maintained automatically by NetForms. </ADDRESS> </BODY> </HTML>
When someone clicks on the "enter your favorite recipe" link, they will be taken to our entry form (click HERE to see what it looks like) which is made up of standard HTML that looks like this...
<HTML> <TITLE>Recipe Entry Form</TITLE> <H1>Recipe Entry Form</H1> <FORM method=POST action="/NetForms.acgi$/Recipes/Recipe.fdml"> Author: <INPUT TYPE="text" NAME="Author" SIZE="30" MAXLENGTH="30"> <P> Recipe Name: <INPUT TYPE="text" NAME="RecipeName" SIZE="30" MAXLENGTH="30"> <P> Ingredients:<BR> <TEXTAREA name="Ingredients" rows=10 cols=60></TEXTAREA> <P> Directions:<BR> <TEXTAREA name="Directions" rows=10 cols=60></TEXTAREA> <P> <INPUT type=submit value="Submit Recipe"> <INPUT type=reset value="Start Over"><P> </FORM> </HTML>
The interesting part of our recipe system is the "Recipe.FDML" file, which is where we specify exactly how each incoming form should be processed. Let's look at the file...
<CREATEDOC>"/Recipes/<REPLACE_FN RecipeName>.html"</CREATEDOC> <MENUDOC>"/Recipes/RecipeMenu.html" <LI> <A HREF="<HTMLFILENAME>"> <REPLACE RecipeName></A></MENUDOC> <HTML> <HEAD> <TITLE><REPLACE RecipeName></TITLE> </HEAD> <BODY> <H1><REPLACE RecipeName></H1> <Address> This article submitted by <REPLACE Author> on <DATE>. </Address> <HR> <H3>Ingredients -</H3> <BULLET Ingredients> <P> <H3>Directions -</H3> <REPLACE Directions> <HR> Article complete. Click <A HREF="/Recipes/RecipeMenu.html">HERE</A> to return to the Recipe Menu Page. </BODY> </HTML>
Another important thing to notice is that the Replace command works within directives. This is very important, so that we can specify various and (hopefully) unique file names for each article entered.
Line 2 tells NetForms to update the menu page (which is also our Recipe Home Page). It specifies the full path of the HTML document to be updated and then includes HTML syntax to define exactly how the line should look. Within the MenuDoc directive is the command HTMLFILENAME, which will be substituted with a path to the newly created HTML file. Notice also that, in addition to the URL, you can specify what the user will see on the line in the menu too. You could, in addition to just the recipe name, show the author, date, or whatever you like right on the menu. (The date the article was entered is very useful.)
Line 3, the <HTML> command, is absolutely required in an FDML document. It is good form in any HTML doc, but isn't required by most browsers. NetForms, though, uses this line to tell where the NetForms directives end and the HTML formatting begins.
Line 5 inserts the Recipe Name into the title of the document.
Line 8 inserts the Recipe Name into a highlight section right at the top of the document.
Line 14 inserts the ingredient list as a series of bullet points. Bullets probably aren't necessary, but they look nice. If you wanted the ingredients to be plain text, you could just use a REPLACE command, like line 17 does to insert the directions.
That's it, you have a pretty decent Recipe Web Server in just 60 lines of HTML! Now you could use AppleSearch (or another search engine) to index the recipes and perform full text searches.
You may want to poke around a bit at this point. Try making some changes to our example: