CGI Framework Compiling and using staticgen |
||||||||||||||||||||||||||||||
![]() |
![]() |
Compiling and using staticgen After installing CGI Framework components, the next logical step is compile and test the two basic tools supplied: staticgen and TestTool. Both tools are standalone programs that use all the components provided by CGI Framework package. Compiling and testing them are the shortest way to understand the PageBuilder and TagInterpreter components. Playing with staticgen staticgen is a command line tool. It is composed by just 2 units:
The main program does not deserve comments. The data module "looks" like that: ![]() Inside the data module we have a IBDatabase and a IBTransaction, to provide access (oops) to our data. However its not mandatory to have a database to use staticgen. IBDatabase and IBTransaction are used in an almost standard way. And maybe you will need only to change the password and character set parameters on the IBDatabase component. staticgen hard-codes the database password inside the program. It's one of the worst security decisions you can make. If you are using a production server for your tests, please do not redistribute staticgen with your password coded in. staticgen also includes a TPageBuilder, a TPBTagInterpreter and a TDBIbxTagInterpreter. Selecting PbdMain, and double-clicking its "TagInterpreters" property we have: ![]() Above figure show how a PageBuilder is binded to one or more TagInterpreters. In that case both TagInterpreters are linked to our sole PageBuilder. PBTagInt is a instance of TPBTagInterpreter and process tags on the "pb:" namespace. DBIbxTagInt is a instance of TDBIbxTagInterpreter and process "db:" tags. staticgen code is deceptively simple. More than a half of the code simple deals with command line options. By the way: the program usage is: staticgen sourceTemplate [ targetFile ] [ -t:templateDir ] [ -d:interbaseDatabase ] where:
The only "useful" code is the data module is the "Process" method:
And inside that routine, the only "useful" line of code is:
It generate the HTML page and stores the whole code in "content" to be subsequently stored in the target file. All the "real" code goes inside the components dropped in the data module. Is something so simple of any use? Yes for sure. All the pages on that site where create with staticgen. It guaranties the uniform looking of that site and makes my live a lot easier. |
![]() |
|||||||||||||||||||||||||||
![]() |
||||||||||||||||||||||||||||||
Copyleft (2002) Ivan C. Cruz Site contents may be reproduced in all or in part since you provide a clear statement citing that site as your source. That site was built and tested with Mozilla. If some components looks misalligned or not properly rendered, it may be your browser fault. In that case, please, consider an upgrade. |