In order to generate a web page, you must do two things:
Use the function make-html-page (defined in hwk3-lib.ss) to create an html-page.
make-html-page consumes three things: a string for the page title, a color for the page background, and a list of html-objects to display on the page. There are several kinds of html-object, and the data definition at the end of this document lists these.
Example: If I want to create a web page containing my name and a link to the COMP 210 home page, I can write
(define kathi-page (make-html-page "My Page" "WHITE" (cons (make-html-paragraph (cons "Kathi" empty)) (cons (make-html-link "http://www.cs.owlnet.rice.edu/~comp210/" "The COMP 210 Home Page") empty)))See the data definitions below for an explanations of the other make-html-... functions.
Use the function html-to-file (also defined in the library) to write the page into a file.
To see the html that the above example generates, set the library to hwk3-lib.ss and type the following:
(html-to-file kathi-page "210test.html")This creates a file 210test.html in your working directory. You can view this file in your favorite browser.
Example: If I want a page containing a list of the names of the 210 instructors, I can write
(define instructor-page (make-html-page "Instructors" "YELLOW" (cons (make-html-list (cons "Kathi" (cons "John" (cons "Geraldine" (cons "Philippe" empty)))) false) empty))
Each of the functions which creates a file simply returns true. Why? The return value is an arbitrary choice, since by having only possible return value, the value doesn't convey any information.
html-to-file : html-page string -> boolean
Consumes an html-page structure and writes the html for that
structure into the file named by the string. Always returns true.
produce-test-page : html-object string -> boolean
Writes a page containing only the given html-object to the
given filename. Always returns true.
produce-test-page/list : list-of-html-object string -> boolean
Writes a page containing only the given html-objects to the given
filename. Always returns true.
filename-for-stock : stock -> string
Consumes a stock and returns a filename for that stock's web page.
category-filename : symbol -> string
Consumes a category name and returns a string the
name followed by ".html".
;; THE HTML STRUCTURES (define-struct html-list (items numbered?)) (define-struct html-paragraph (contents)) (define-struct html-link (URL text)) (define-struct html-page (title bgcolor contents))
;; THE HTML DATA DEFINITION
;; An html-color is one of ;; - "WHITE" ;; - "BLUE" ;; - "RED" ;; - "YELLOW" ;; - "GREEN"
;; An html-atom is one of ;; - a string ;; - a symbol ;; - a number
;; A list of html-atoms (lo-html-atoms) is iether ;; - empty, or ;; - (cons a loha) ;; where a is an html-atom and ;; loha is a list of html atoms
;; An html-object is one of ;;
;; - an html-atom
;; - (make-html-list items numbered?) ;; where items is a lo-html-objects and ;; numbered? is a boolean
;; - (make-html-paragraph contents) ;; where contents is a lo-html-objects
;; - (make-html-link URL text) ;; where URL is a string and ;; text is an html-atom
;; A list of html-objects (lo-html-objects) is either ;; - empty, or ;; - (cons obj loh) ;; where obj is an html-object and ;; loh is a lo-html-objects
;; An html-page is a structure ;; (make-html-page title bg contents) ;; where title is a string, ;; bg is an html-color, and ;; contents is a lo-html-objects