Previous Page TOC Next Page



24


Introducing the FrontPage Developer's Kit


by William Robert Stanek

FrontPage is the most powerful Web publishing and administration tool available. Not only can you personalize FrontPage, you can also create customized tools to meet your specific needs. These tools can include new templates for pages and Webs, wizards for creating pages and Webs, and programs that automate publishing tasks. To create customized tools for FrontPage publishing, you use the FrontPage Developer's Kit. The Developer's Kit has everything you need to help you customize FrontPage publishing.

This chapter introduces the Developer's Kit. In addition to learning how to obtain and install the kit, you will get a detailed look at what the kit contains and how to use the kit with FrontPage.

Using the Developer's Kit


The FrontPage Developer's Kit was created to help developers extend the functionality of FrontPage. You use this kit to create templates, wizards, utilities, and CGI scripts for use with FrontPage. Although this kit is primarily for developers who have some experience in programming and automation with object linking and embedding (OLE), the kit is meant to be easy to use regardless of your experience.

As you have seen in this book, templates are used as the basis for pages and Webs. Using the Developer's Kit, you can also create templates for frame-enhanced documents. These templates are called framesets. You learn all about creating framesets in Chapter 25, "Creating Your Own Templates." The good news is that you do not need any programming or OLE automation experience to create templates for pages, frames, and Webs.

Wizards are also used to create pages and Webs. As you have seen in this book, wizards aid the content creation process by presenting options that help you customize pages and Webs. Unlike templates, wizards are programs that run on your system and interface with FrontPage. To create a wizard, you need to use a programming language, such as Visual Basic or Visual C++. To interface with FrontPage, your program uses OLE automation. Thus, if you plan to create wizards, you should be familiar with programming and OLE automation. You learn how to create wizards in Chapter 26 "Creating Your Own Wizards."


NOTE

Visual Basic and Visual C++ are the best programming languages for creating FrontPage wizards because of their visual development nature. Creating the graphical interface for wizards is easy and quick if you use either of these languages.


Another use for OLE automation is to create utilities that can be used with FrontPage. An example of a FrontPage publishing utility is the Web Publishing Wizard you learn about in Chapter 41, "Designing and Publishing a Home Page." This wizard allows you to use the File Transfer Protocol to publish Webs. Using this wizard, you can transfer Webs to servers that do not support FrontPage extensions.

The Developer's Kit also helps you create CGI scripts that interface with the Personal Web Server. Again, the interface to FrontPage is handled with OLE automation. See Chapter 34, "Writing CGI Scripts," to learn more about CGI scripts.

Obtaining and Installing the Developer's Kit


Microsoft has plans to integrate the Developer's Kit into the commercial release of FrontPage. If the version of FrontPage you purchased does not include the Developer's Kit, you can obtain the kit from Microsoft's Web site at no charge. To do so, visit the Microsoft's home page for FrontPage at the following URL:

http://www.microsoft.com/frontpage/

From this page, you can follow links to the section containing the Developer's Kit. If you obtain the Developer's Kit from Microsoft's Web site, you will need to install it on your system. All the files in the FDK are compressed into a ZIP file that you have to uncompress using a ZIP utility such as PKZIP.


CAUTION

The Developer's Kit's ZIP file contains subdirectories. ZIP utilities that run from the DOS prompt do not automatically unpack your files into multiple directories. So, if your ZIP utility runs from the DOS prompt, be sure to use the -d flag to preserve the directory structure, as shown in the following example:




pkunzip -d fpdevkit.zip


At the time of this writing, the ZIP file for the Developer's Kit is 583KB. You need approximately 1.5MB of hard drive space to uncompress the ZIP file, which means that initially you need 2.1MB of free space on your hard drive. After you successfully uncompress the Developer's Kit, you can delete the original ZIP file.

What's in the Developer's Kit


The FrontPage Developer's Kit is quite extensive and includes many examples. These examples show you how to create templates, wizards, utilities, WebBots, and CGI scripts that interface with FrontPage. Each specific type of example has its own directory under the base installation directory for the Developer's Kit. These directories have the following names:

The sections that follow examine the contents of these directories and discuss how you can use the examples to help you customize FrontPage. You might want to review what the Developer's Kit contains, and then read this part of the book in its entirety before studying the examples.

The Template Examples


The template directory is in the base installation directory of the FrontPage Developer's Kit. The template directory contains template examples for pages, Webs, and frames with each example organized into subdirectories.

The template/pages directory has a page template containing a simple table stored in the subdirectory tablepag.tem. The template was created with the FrontPage Editor Save as Template option. When you use this option of the Editor, you create an HTML document with the .htm extension and a document that stores template information with an .inf extension. Files with the .inf extension are formatted like Windows INI files and contain parameters for the template, such as the template name and directory.

The template/webs directory contains a Web template stored in the subdirectory testcorp.tem. This sample Web template was created with the Web Template Maker Utility and was based on the Corporate Presence Web. The Web Template Maker Utility is one of the utilities included in the Developer's Kit. With this useful tool, you can base a Web template on any existing Web. Another subdirectory you'll find in this directory is wbtests.tem. You'll use the examples in this directory to test the SDK's custom WebBot components.

The template/frames directory contains a frameset called sample.frm. The .frm extension is used to indicate that the document is a frameset. You can use the sample document to help you create your own framesets.

The Wizard Examples


The wizards directory under the base installation of the FrontPage Developer's Kit contains sample wizards. Most of these wizards are programmed in Visual Basic 4, which is one of the easiest programming languages to learn and use. Because wizards are programs, you can run them just as you would any other program.


TIP

You can use the Windows Explorer to run any wizard. All you need to do is change to the directory containing the executable file and double-click the appropriate icon. Before you run a wizard, you should start the FrontPage Explorer and the Personal Web Server.


To better understand the sample wizards, change to the appropriate subdirectory, list the files, and examine all files except the binary executable file using a word processor or standard ASCII text editor. When you list and examine the files in wizard directories, you should see immediately that wizards are more complex than templates and not only because there are more files involved. Because most of the wizard examples are written in Visual Basic, the wizard directories contain six files that end with the extensions shown in Table 24.1.

Table 24.1. Files in wizard directories.

Extension Description
.exe The binary executable file for the wizard
.inf A Windows INI-formatted file that specifies parameters for the wizard, such as the wizard name and directory
.log A file that logs errors that occur when the wizard runs
.frm A form written in Visual Basic and used to create the wizard
.frx Another Visual Basic file containing program information
.vbp File used to set up program information for wizards written in Visual Basic
.vbz File used to set up flags, dependencies, and so on for wizards written in Visual Basic.

Examining the Page Wizards

The wizards/pages directory has subdirectories for two simple wizards: hello.wiz and calendar.wiz. Both wizards are created with Visual Basic and use the six types of files described in Table 24.1.

The Hello Page Wizard has three setup pages and is used to create a page that greets visitors to your Web site. Figure 24.1 shows the document this wizard creates. Because this example is so basic, it is the best example to examine piece by piece to learn more about creating wizards. When you look through the files used to create the Hello Page Wizard, start with the file named Hello.frm.

Figure 24.1. Document created by the Hello Page Wizard.

Like the Hello Page Wizard, the Calendar Page Wizard has three setup pages. As you can see from Figure 24.2, this wizard creates a document with a nicely formatted calendar for a specific month and year. The Calendar Page Wizard is a great example of how to create a useful wizard. Examine this wizard starting with the file named Calendar.frm to learn how to manage dates in your wizards and generate fairly complex documents that use tables.

Figure 24.2. Document created by the Calendar Page Wizard.

Pages you create with the Hello Page or Calendar Page Wizard are loaded into the FrontPage Editor. Thus, you can study these wizards to learn how OLE automation is used to access and launch the FrontPage Editor.

Examining the Web Wizards

The wizards/webs directory contains two sample Web wizards: helloweb.wiz and realest.wiz. Both wizards are programmed in Visual Basic and use the six types of files described previously in Table 24.1.

The Hello Web Wizard creates a Web based on the same HTML document used by the Hello Page Wizard. Examine this Web to learn how to create OLE hooks to the FrontPage Explorer. You also can learn a lot about the difference between creating Webs and creating files by doing a line-by-line comparison between the Hello Page Wizard files and the files used by the Hello Web Wizard. Start by comparing the file named HelloWeb.frm to the file named Hello.frm.

The Real Estate Wizard is one of the most complex examples in the FrontPage Developer's Kit. This wizard creates a Web customized for real estate information. Because of the complexity of this Web wizard, you should examine its files only after you've looked at the other Web wizards.

Code Modules and Libraries

Sample wizards are not the only programs in the wizards directory. This directory also contains directories for Visual Basic modules and Visual C++ object libraries.

The wizards/vb directory has utility procedures to help you create wizards. The file botgen.bas contains a series of Visual Basic procedures that lets you insert different types of WebBots into output strings. In this way, your wizards can create pages that use WebBots. The file htmlgen.bas has Visual Basic procedures for handling HTML documents. The file wizutil.bas has miscellaneous utility procedures you can use in your wizards. You can use these procedures to add meta information to documents, add files to a list of files you want to update or create, to look up or set parameters for the wizard, and much more.

The wizards/vc directory contains object and type libraries for use with Visual C++. You can use these libraries in OLE automation. The files webber.tlb and webber.odl are used with the OLE identifier FrontPage.Explorer.1.1. The files wpe.tlb and wpe.odl are used with the OLE identifier FrontPage.Editor.1.1.

The Developer Kit Utilities


There are three very useful utilities in the Developer's Kit: the API Test Utility, the Web Template Maker, and a helper application called fplaunch. These utilities are written in Visual Basic and use OLE automation to interface with FrontPage. Not only are the utilities useful, but you also can learn a great deal by examining their source code.

The API Test Utility

The API Test Utility is a test suite of all the OLE automation functions you can use with FrontPage. You can use the source code in the utility/apitests directory as a starting point for any wizard you create. In fact, you can usually cut procedures out of the source code and paste them directly into your wizard's source code. When you run the utility by executing the apitests.exe binary executable file, you see the dialog box shown in Figure 24.3.

Figure 24.3. Using the API Test Utility.

Each push button in the dialog box enables you to test a specific set of related OLE automation functions. Most functions display a form that prompts you to enter information. For example, if you press the button labeled Web Information, the dialog box shown in Figure 24.4 is displayed. This dialog box lets you test OLE procedures that get a Web's title, URL, and meta information.

Figure 24.4. Testing OLE procedures.

The fplaunch Utility

The fplaunch utility is an extremely useful helper application that uses OLE automation to create an authoring interface between your Web browser and FrontPage. Using fplaunch, you can create HTML documents with links that access the FrontPage Explorer, open a specified Web, and then open a page for editing in the FrontPage Editor. To learn how to create your own helper applications, examine the source code in the utility/fplaunch directory.

Because you can set an optional user name parameter, fplaunch is a useful utility for Web administrators and anyone else authoring pages in your Webs. Before you can use fplaunch, you need to do the following:

  1. Configure your Web server and browser so they recognize fplaunch parameter files, which end in the .fpl extension.
  2. Create an fplaunch parameter file and a document that references the parameter file.

Configuring Your Server and Browser

As with most helper applications, you need to ensure your server and browser correctly identify files used by the helper application. To do this, you must update server and browser configuration files.

Because fplaunch parameter files should end in the .fpl extension, you configure your server to send files with this extension as a new MIME type. On most servers, MIME types are stored in a specific configuration file. For the Personal Web Server, the configuration file is called mime.typ and is located in the FrontPage Webs/Server/conf directory. You need to edit this file and add the following entry to the end of the file:




application/x-fplaunch       fpl

NOTE

The exact number of spaces between the MIME type and the extension designator does not matter. MIME types are broken down into basic categories, such as application. The application type identifies binary data that can be executed or used with another application. Each data type category has a subtype associated with it. MIME subtypes are defined as primary data types, additionally defined data types, and extended data types. The primary subtype is the primary type of data adopted for use as MIME content types. Additionally defined data types are additional subtypes that have been officially adopted as MIME content types. Extended data types are experimental subtypes that have not been officially adopted as MIME content types. You can easily identify extended subtypes because they begin with the letter x followed by a hyphen, such as x-fplaunch. The x-fplaunch subtype identifies an extended data type in fplaunch format.


After you save the MIME configuration file, restart the Personal Web Server. You are now ready to configure your browser for use with fplaunch. You do this by setting preferences from an options menu within the browser. Figure 24.5 shows the Option menu for helper applications in Netscape Navigator 3.

The helper application configurations shown in the figure are the default settings. If you visited a Web site using the Netscape browser with the sample helper application configuration and selected a link to an image file in TIFF format, the browser would ask what helper application you wanted to use to display the file. If you select a page link to an image file in JPEG or GIF format, the browser would display the file because it has direct support for JPEG and GIF images.

Figure 24.5. Setting helper application preferences in Netscape.

To set a helper application in Netscape Navigator 3, click the Create New Type button. This action opens the Configure New MIME Type dialog box that lets you enter the MIME type and subtype. In the MIME Type field, enter the keyword: application. In the MIME SubType field, enter the keyword: x-fplaunch. After you enter this information, click the OK button to close the Configure New MIME type dialog box.

In the File Extension field of the dialog box shown in Figure 24.5, enter the extension: fpl. In the Action field, select the radio button labeled Launch the Application. Next, click on the Action field's Browse button. This will open the Select an appropriate viewer dialog box. Using this dialog box, you search through your file system until you identify the file path to the binary executable for the fplaunch application. When you are finished, click OK. After you double-check the accuracy of your helper application entry, click OK in the Preferences dialog box.

Creating and Referencing a Parameter File

Creating a parameter file to use with fplaunch is easy. All you need to do is create an ASCII text file that sets the parameters that enable OLE automation to perform its magic on the FrontPage Explorer. There are three mandatory parameters and one optional parameter:

Parameter Description
Web server name The host name or IP address of the server storing the Web you want to access
Web name The name of the Web you want to access
user name Optional user name to enter in the login dialog
page URL In the named Web, the page URL of the file you want to edit

NOTE

All users must authenticate themselves to FrontPage, even if you set the user name parameter. When a user activates a link to fplaunch, she is prompted to enter her user name and password before FrontPage opens the Web for editing.


Use each of these parameters in the order presented and enter them on separate lines. Here is a sample parameter file called startcorp.fpl:




http://www.tvpress.com



corpres



william



index.htm

When a user clicks on a link containing a reference to startcorp.fpl, his browser starts fplaunch, fplaunch reads the parameter file, and then the server asks the user to authenticate with the user name filled in as william. The user can enter a new user name and password or enter a valid password for the user william. After authentication, the FrontPage Explorer loads a Web called corpres from the server at http://www.tvpress.com and open the file called index.htm for editing in the FrontPage Explorer.


NOTE

The parameter file must be placed in the subdirectory for your Web. If you installed FrontPage to the default location, the location of your Web is FrontPage Webs\Content\yourweb_name. Keep in mind, all entries in the parameter file must be valid. If you are practicing with FrontPage, you are probably using a local server with the server name as http://127.0.0.1.


After you save the parameter file to the subdirectory for your Web, you must create a document that references the parameter file.


TIP

The hypertext reference to the parameter file is best entered as a page link. You can create page links in the Current Web tab of the Create Link dialog box.



The Web Template Maker

The Web Template Maker creates Web templates that are based on existing Webs. The source code and binary executable file for the template maker is in the utility/webtmpl directory. Before you use the Web Template Maker, start the Personal Web Server and the FrontPage Explorer, and then open a Web on the server that has the Webs you want to use as the basis for templates.

Next, start the Web Template Maker. The list of existing Webs is displayed by title in the Available Webs area of the Template Maker dialog box. Select a Web to base a template on by moving the mouse pointer over the name of the Web and clicking the mouse pointer. In the New Web Template area of the dialog box shown in Figure 24.6, enter a title, name, and description for the template. The template name must be unique. You should also enter a unique title for the template.

When you finish defining the template, click the Make Web Template button to create the new template. From then on, when you select New from the File menu in the FrontPage Explorer, your new template will be available for use. To refresh the list of existing Webs after you create a new template, click the Refresh Web List button.

Figure 24.6. Creating templates with the Web Template Maker.

Examining the CGI Scripts


CGI scripts are external programs that run on Web servers. Originally, CGI scripts were used to perform advanced publishing tasks, such as processing input from fill-in forms and image maps. Because these tasks are automated in FrontPage, you primarily use CGI scripts to do advanced follow-up processing of form input. Also, if your server does not support FrontPage Server Extensions, you might need to use CGI scripts to perform general processing for forms and image maps as well.

The CGI scripts in the Developer's Kit are in the cgi directory under the base installation of the Developer's Kit. Because most CGI scripts are written in a UNIX shell or C, three of the four sample scripts are written in C. After you read Chapter 30, examine these scripts.

Using the Hello Script

The cgi/hello directory has a simple CGI script written in C called Hello. The purpose of this script is to generate a simple HTML document that says, "Hello CGI world." Listing 24.1 shows a similar but more useful script called Thanks.c. This script is used to thank customers for submitting a form and provides a link back to your Web's home page.

Listing 24.1 The Thanks.c script.




/* Thanks.c: a small script written in C that uses standard input and output */



#include <stdio.h>



int main (argc, argv)



int argc;



char *argv[];



{



printf("Content-type: text/html\n\n");



printf("<HTML>\n");



printf("<HEAD>\n");



printf("<TITLE>Thank, you!</TITLE>\n");



printf("</HEAD>\n");



printf("<BODY>\n");



printf("<H1>Thanks for submitting your comments to the customer



¬support staff!</H1>\n");



printf("<P>\n");



printf("<P><A HREF=".\">Return to our home page.</A></P>\n");



printf("</BODY>\n");



printf("</HTML>\n");



return 0;



}

Using the cgiwin32 Script

The cgiwin32 script is designed as an interface to the original CGI-WIN interface created for Windows 3.1 servers. Using this script written in C, you can use programs created for CGI-WIN with FrontPage compatible servers. All you have to do is create a link to the CGI-WIN script. You can add the link as an extra path argument to the cgiwin32.exe program in the URL that calls the script. For example, to link a script called crunch.exe, you could use the following URL:




cgi-bin/cgiwin32.exe/crunch.exe

In Chapter 11, "Using Forms and the Form Page Wizard," you read about forms and form handlers. All forms need a handler, such as the Registration bot or a custom CGI script. To use a CGI script, you must select the Custom CGI Script handler in the Forms Properties dialog box shown in Figure 24.7.

Figure 24.7. Using CGI scripts in your pages.

Next, click the Settings button. Then you must specify the script that will process the input in the Action field, as shown in Figure 24.8. You must use the full URL with the extra path information. When you have finished filling out information in the Settings For Custom Form dialog box, click the OK button.

Figure 24.8. Enter the name of the script with the extra path information in the Action field.

Using Script Handlers

The cgi/olecgi and cgi/olecgi/vb directories contain utilities for creating CGI script handlers. Using these utilities, you can create a gateway between the standard I/O interface used in CGI and dynamic linked libraries that can be used with OLE servers. Although most of the examples in these directories are written in C, the OLE DLLs themselves are written in Visual Basic.

The examples in these directories are meant to be used together. Because the examples are fairly advanced, wait until you are very comfortable with CGI, OLE, and programming concepts before you examine these examples.

Designer HTML and WebBot Extensions


Designer HTML is a new feature of FrontPage 97. With designer HTML, you gain the capability to select an alternate display for unknown markup in FrontPage and the capability to insert, copy, paste, and drag/drop HTML markup directly into the FrontPage Editor. Using the FrontPage 97 Developer's Kit and FrontPage WebBot extensions, you have access to these so-called designer features.

To get started, examine the designer HTML and custom WebBot examples provided in the developer's kit. In the designer directory, you will find examples of pages that use designer HTML. In the webbot directory, you will find custom WebBots that are used in the designer HTML examples as well as the Web test examples.

Most of the designer HTML features are built in. For example, if you copy a section of a document in Microsoft Word by using Ctrl+C, you can paste your selection to an open page in the FrontPage Editor by using Ctrl+V. FrontPage automatically converts the text to HTML.

When you want to create an alternate display for unknown markup or new HTML elements not supported by FrontPage, you do so using WebBot extensions. WebBot Extensions have a format similar to that of standard HTML and are defined within the context of the WEBBOT pseudo-tag. Like other tags, the WEBBOT pseudo-tag has a begin tag and an end tag.

The begin WEBBOT tag has the following general syntax:




<!--WEBBOT bot="HTMLMarkup" StartSpan -->

The end WEBBOT tag has the following general syntax:




<!--WEBBOT bot="HTMLMarkup" EndSpan -->

Between the begin and end tags is where you place elements you want displayed in the alternate format you are defining. Because you are defining an alternate display for HTML, you will always work with the HTML Markup WebBot. This WebBot is responsible for handling unknown markup.

The begin tag has three attributes that let you set the format of the display:

The first attribute, U-SRC, lets you define the relative or absolute URL for an image to insert in place of the unknown markup[md]sort of what FrontPage does with plug-ins, JavaScript, and Java. If the image is on the local file system, the image is imported into the Web and displayed. Here is an example of using the U-SRC attribute:




<!--WEBBOT bot="HTMLMarkup" StartSpan U-SRC="EMBED.GIF" -->



The HTML or other markup not recognized by FrontPage



<!--WEBBOT bot="HTMLMarkup" EndSpan -->

The ALT attribute lets you define an alternative representation for the element FrontPage doesn't support. This alternative representation can incorporate a limited set of HTML tags. These tags include:

Generally, you should not use U-SRC and ALT at the same time. An example of using the ALT attribute follows:




<!--WEBBOT bot="HTMLMarkup" StartSpan ALT="<U><B><STRIKE>Hideous Text</STRIKE></B></U>" -->



The HTML or other markup not recognized by FrontPage



<!--WEBBOT bot="HTMLMarkup" EndSpan -->

The final attribute, TAG, lets you define the heading or paragraph level for the element you are adding. If you define the element as the equivalent of a level 1 heading, textual portions of the element will be the size of text associated with a level 1 heading. If you define the element as the equivalent of normal text, textual portions of the element will be the size of normal text. Acceptable values for this attribute correspond to the six heading levels and normal paragraph text: H1, H2, H3, H4, H5, H6 and P.

The TAG attribute is normally combined with either the ALT or U-SRC attribute. Here is an example using the TAG attribute:




<!--WEBBOT bot="HTMLMarkup" StartSpan U-SRC="EMBED.GIF" TAG=H1 -->



The HTML or other markup not recognized by FrontPage



<!--WEBBOT bot="HTMLMarkup" EndSpan -->

Summary


The Developer's Kit was created to help you extend the functionality of FrontPage. With the Developer's Kit, you can create templates, wizards, utilities, and CGI scripts. Although you do not need to have experience in programming and OLE automation to create templates, you do need this experience to create wizards, utilities, and CGI scripts.

Previous Page Page Top TOC Next Page