Make sure to make local backups of your code to your own media at every significant development point. Students have lost their work because of a server crash, and you do not want that to happen to you..
Set up your directory structure. If you haven't yet done so, create a subdirectory in your html directory, named 'final', that will hold everything related to the project. In 'final', create new subdirectories in which you will store files according to their function. You may want to create a directory for your CGI-scripts (cgi-bin), your style sheets (styles), your HTML source files (source), or user data (data). If you are including images in your HTML pages you may also want to include a special directory (img), etc. The important thing is to sort out separate functionalities of your project and to group the parts accordingly. This will make it easier for you to locate items when you add a document path to a script, a link in an HTML page, etc.
You should also strive to develop a consistent naming scheme for directories and files. Names should indicate the functionality of the item. A directory or file name should tell you what it is used for without having to open it. Consistency is most important and will greatly help you with the programming tasks.
The directory structure should look somewhat like this:
Create your HTML Pages. As a starting point, create static HTML pages of your resumes. Organize each page into sections delimited as <div>s: contact information, education, skills, work experience, etc. When you're done, you should have two or three static HTML pages--depending on how many resumes you are going to offer--that are your reference to the final output your cgi scripts shall produce.
Validate your pages as XHTML 1.0 Strict at the W3C Validation Service.
Create the Mozilla and IE style-sheets. An efficient way to proceed is to create a master style-sheet. This should be a sheet that works well with your favorite browser and reasonably well with other browsers. (Mark-up in XHTML should greatly facilitate this task.) Then, make a copy of the sheet and edit the copy for 'the other' browser. The styles should be noticeably different. Make sure that BOTH style-sheets work well on all browsers you have access to. It's the best insurance that nothing will go wrong.
More importantly, validate your sheets at the W3C CSS Validation Service.
There are four fields that the starting form page must send to the browser--first name, last name, email address, and resume requested. Work on your validation scripts for both client- and server-side. (Your client-side validation script should be located in a separate file as well. For development purposes, you could first incorporate it in a static HTML page and then save it in a separate file once it is tested and works properly.) Your program should be checking that all four form fields contain reasonably good data (strings, patterns, but not just white space).
Before you work on connecting your CGI script to the printing routines of the resume, have it print out all the data required to proceed: the form data, user agent, remote address, and the time. Proceed only after you have tested your script and are confident that it captures the form data and other items and works correctly.
A note on time: You can use either one of the time( )
or localtime( )
Perl functions to capture the time. The returned value will be written to file with the other data. To provide a sorting capability by date, so it is better to use the integer value of time( )
and store it in the data file.
Disassemble your HTML pages. Across your HTML pages, certain parts will be the same. Other parts--like style sheets and the actual resume content--will be different. (See this example: green indicates static parts, red variable content.) Put static and variable fragments into designated directories under a consistent naming scheme, so that they can easily be retrieved.
Disregarding the user input for the moment, extend your CGI script and have it reassemble and print one of your resumes. You should create an array with a list of source files to be printed in order, and a print subroutine (function) that takes the list as an argument and prints each element. Look at this demonstration script as an example.
Once your CGI script prints out one resume correctly, create arrays of source files for the remaining resumes. Then, write a conditional statement block that tests for resume requested and user agent. Connect the printing routine to the conditional statement. When this is done, your CGI script should return different resumes with browser-specific style sheets.
Corresponding to the files-writing routines in hw 4, write the user data (name, resume, requested, remote address, time) to file in a delimited data format. The data file needs 644 permissions [-rw-r--r--], so that the server will be able to write to the file. (This will be in your own account so only the owner's permissions need to allow a write operation.)
Writing to file. You will need to provide some mechanism that displays the data file as an HTML page. This output must present the data sorted by last name, resume requested, or time requested. To make this easy, organize the data in your data file in such manner that the field to be sorted is the first item on a line. Assuming you want to present the data sorted by time, your data structure could look as follows:
time::last_name::first_name::email::resume_requested::remote_address
Then, to sort the data file, you only need to read the data file into an array (see Perl File Handles, reading and writing files) and sort the array (see Perl sorting).
Updating a file. Follow the following steps to update the data file:
Displaying the file data. Follow the following steps to display the data file:
split( )
the data and print it, as an HTML table, for example