This assignment continutes the web page generation assignment from last week. Several of the programs in this assignment ask you to use your programs from assignment 2. Copy the necessary programs from assignment 2 into your files for this assignment. (Feel free to use our solutions if yours didn't work.)
This assignment will create several HTML files in your working directory. Therefore, you may want to work in a new directory for this assignment.
Download and set DrScheme to use the library hwk3-lib.ss.
The following problems refer to two sets of data definitions: the ones for Sammy's inventory database from assignment 2 and a set of data definitions for HTML. The HTML data definitions page describes the functions in the library that you should use to generate web pages. There are links from the problems below to the parts of the data definition that you need for that problem.
The data definitions in assignment 2 did not include one for inventories. Here is the data definition for an inventory:
;; An inventory is either ;; - empty, or ;; - (cons S I) ;; where S is a stock and I is an inventory
A Note on Inventories: This week's library provides the same base-inventory that you worked with last week. Now that you've studied lists, you can create your own inventories, e.g., by cons-ing new stock items onto the base-inventory.
Note: This assignment is not as long as it looks! By using the design recipes, you should be able to develop each of these programs without much difficulty. To avoid being overwhelmed by the amount of information here, do one problem at a time, and don't try to understand the provided data definitions and functions all at once.
Functions consuming the same kind of data should use the same templates. Be sure to show each template you use, but you only need to show each template once.
(3 pts) Develop a program cd-count which consumes an inventory and returns the total number of CDs in the inventory (include all copies of each CD in the total).
(8 pts) On-line music stores usually have one page for each album that they carry; this page contains pricing and other information for that album. This exercise generates such pages.
Develop a program create-paragraph which consumes a html-object and returns a html-paragraph with that one item.
Develop a program create-paragraphs which consumes a stock item and returns a list of four html-paragraphs, one each for the artist, title, CD's advertised price, and tape's advertised price of that item. The advertised price is the price in that format, if that format is available, and the string "N/A", if not.
Test your program using the library function produce-test-page/list, which consumes a list of html-objects and a filename and writes a web page containing those objects to the named file. (Note that a list of html-paragraphs is also a list of html-objects.)
Develop a program gen-stock-page which consumes a stock and produces an html-page. The page should contain a separate paragraph for each piece of album data (artist, title, CD price, tape price), where the paragraphs are made using create-paragraphs.
Develop a program produce-all-stock-pages which consumes an inventory and returns true. The program writes one web page file for each stock item in the inventory. Use html-to-file from the library to write each page to a file. The library provides a function filename-for-stock which consumes a stock and returns a filename to use for the stock's page.
(4 pts) Once we generate separate pages for each stock item, we need an index page that contains links to these separate pages. This problem generates such an index.
Develop a program gen-html-inventory-list-contents which consumes an inventory and returns a list of html-links. For each stock item in the inventory, the program creates a link to the web page for that stock item. Use the album title as the text in the link and the library function filename-for-stock to compute the filename for the stock's web page.
Test your program using the library function produce-test-page/list.
Develop a program gen-html-inventory-list which consumes an inventory and returns an html-list. The html-list should contain a list of html-links, one for each stock item in the inventory.
Test your program using the library function produce-test-page, which consumes an html-object (such as a html-list) and a filename, and writes a web page containing the object to the named file.
(6 pts) Listing all of Sammy's inventory on one web page makes it harder for customers to browse categories of music. We therefore want to create separate listings for each category. The remaining problems generate such a web site.
Develop a program produce-category-page which consumes a category and an inventory and returns true. The program should write to file a page containing a list of links to the stock items that are in that category. Use the library function category-filename to compute the filename for a category's web page.
Develop a program produce-all-category-pages which consumes a list of categories and an inventory and returns true. The program should create the category page for each category in the input list. Note that for this program, you do not need to look at what kind of inventory you have; instead, your template needs only to take the structure of the list of categories into account.
Develop a program produce-category-index which consumes a list of categories and returns true. The program should write to the file "210SammyCategories.html" a page containing a list of links, one to each category page. Use the library function category-filename to compute the filename for a category's web page.
|Kathi Fisler||This page was generated on Fri Sept 10 18:01:35 CDT 1999.|