Webcal for dB2K

Webcal is a web based CGI application that provides calendaring and appointment functionality over the Internet or within an intranet. The application is available in a personnel edition (and a groupware edition will be offered sometime soon). Webcal for dB2K is based on the Webcal for Perl application distributed by Extropia.com.

Installation

Webcal for dB2K runs on a web server. We assume that you have a Web server installed, that the dB2K runtime and BDE are installed on the server, and that the server is configured to run CGI application.

To install Webcal for dB2K, create a folder called "Webcal" in your web server's webroot. Unzip all the files from the Webcal archive into the newly created folder. Webcal is designed to run from a single folder. The Executables, object files, images, and tables and indexes must all reside in the same folder. Future versions of Webcal for dB2K may provide more flexibility, but I have attempted to make the personnel edition as easy as possible.

Next start dB2K, change the Navigator's Lookin entryfield to the Webcal folder, and run "Makeit.prg"

Configure the Web Server

You must configure to web server to run Webcal for dB2K. If you are using Apache, you can configure the server to run Webcal for dB2K by adding the following segment to the Apache configuration file (httpd.conf):

<Directory "F:/your_webroot/webcal/">
    Options Indexes FollowSymLinks ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
    DirectoryIndex Webcal.exe
    AddHandler cgi-script .exe
</Directory>

You might also want to require users to log into Webcal for dB2K. This can be done with the personal edition of Webcal for dB2K by using your web server's user authentication system. For users of Apache, adding the following to the above <Directory> settings will enable Apache's user authentication:

    AuthType Basic
    AuthName "Webcal for dB2K"
    AuthUserFile "F:/your_webroot/webcal/users.txt"
    require valid-user

Note: If you want to keep the AuthUserFile outside web space, you can save it anywhere in your computer's file system. Simply adjust the path in the above directive.

The password file "users.txt" is a plain text file. In this file you store the username and password. Apache uses the following syntax: username:password. The password can be stored as plain text. If, however, you would like to encrypt the password, you can use Apache's htpasswd.exe utility. This command line utility is found in the Apache "Bin" folder. Information is available with the "htpasswd /?" command line parameter.

How it works

Webcal for dB2K is composed of two program files and two custom class files. The main program file is WEBCAL.PRG. This program handles streaming the calendar pages and navigating from date to date. When the program is called, it creates the CGI object and manages the program branching. Notice that WEBCAL.PRG creates a CGI object from WEBCAL.CC. This custom class contains data manipulation methods and all the HTML pages used in the application. It is subclassed from WEBCLASS.CC, which is a required file.

The second program file is EVENTS.PRG. This program handles the adding, editing, and deleting of calendar events. It too creates a CGI object from WEBCAL.CC. EVENTS.PRG is always called from within WEBCAL.PRG and should never be called directly from a Web browser.

Customizing Webcal for dB2K

Webcal for dB2K is built on dB2K's object technology. This means that you can subclass the calendar object and thereby customize the application to your needs.

To customize Webcal for dB2K, create a new program file named, perhaps, myWebcal.cc. (a sample file named myWebcalSample.cc is included in the distribution archive.) Add the following class declaration to this file

Class myWebcal of Webcal from 'webcal.cc'

endclass

Next open WEBCAL.PRG and EVENTS.PRG in the Source Code Editor. In both files modify lines 35 and 36 so that the oCGI object is created from myWebcal rather then Webcal. The new code should look like the following:

   Set proc to myWebcal.cc additive 
   oCGI = new myWebcal() 

Finally, for the customization to work correctly, you must compile (or recompile) myWebcal.cc. In addition you must remake (i.e. compile and build) WEBCAL.PRG and EVENTS.PRG. You can use MAKEIT.PRG to do these tasks. Uncomment the line that compiles myWebcal.cc, save and run the program.

Custom colors
Webcal for dB2K uses three custom colors which are properties of the CGI calendar object. The default colors are set as:

  this.HeaderColor =  "#FF9900"
  this.SelectedColor = "#6699FF"
  this.BackgroundColor = "#EEEEEE"

You can change these colors in your newly created myWebcal.cc file. For example, the following colors will make Webcal look similar to a One-Click web application generated by dQuery/Web.

  // dB2K Color Scheme
  this.HeaderColor =  "#b38d37"       
  this.SelectedColor = "#009999"      
  this.BackgroundColor = "#fefad8"    

Add these lines at the top of myWebcal.cc, recompile the file, and the new color scheme will be used throughout the application.

If needed, you can also modify two additional colors:

  this.TableBorder = "#999999"
  this.FontColorAnchor = "#000000"

Custom Heading
You can easily change the visible header of the HTML pages by overriding a method called streamLogo(). The default stream logo uses the following code:

function streamLogo

   with(this.fOut)
      puts('<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0" WIDTH="100%">')
      puts('  <TR BGCOLOR="#666666">')
      puts('    <TD>')
      puts('      <TABLE CELLSPACING="1" CELLPADDING="1" BORDER="0" WIDTH="100%">')
      puts('        <TR>')
      puts('          <TD BGCOLOR="#FFFFFF" VALIGN="TOP">')
      puts('              <img src="erthntwk.gif" ALIGN=middle>')
      puts('             <font size=+1><B>Webcal for dB2K</B></font>')
      puts('          </TD>')
      puts('        </TR>')
      puts('      </TABLE>')
      puts('    </TD>')
      puts('  </TR>')
      puts('</TABLE>')
   endwith
   return

Custom changes might include changing the image file to your own logo and using your company name. Or you might rewrite the entire method. An alternative header example is included in myWebcalSample.cc.

Custom Layout
Webcal for dB2K uses modules to construct the dayView and monthView pages. To generate the dayView page, we call a method called "streamDayView()". The following dBL code is the default for this method.

function streamDayView()
    this.streamStyle()
    this.streamLogo()  
      
    this.fOut.puts('<TABLE WIDTH=100%><TR BGCOLOR="#FFFFFF"><TD>')
    this.fOut.puts('<TABLE WIDTH=100%><TR><TD WIDTH="20%" VALIGN="TOP">')

       this.streamViewWidget()
       this.streamDayWidget()
       this.streamMonthWidget()
       this.streamYearWidget()
       this.streamAddForm()

    this.fOut.puts('</TD><TD WIDTH="80%" VALIGN="TOP">')

       this.streamDay()

    this.fOut.puts('</TD></TR></TABLE>')
    this.fOut.puts('</TABLE> </TD></TR></TABLE>')

    this.streamFooter()
    return   

When this method is called, it creates a web page similar the following layout:

streamLogo()
streamViewWidget()
streamDay()
or
streamMonth()
streamDayWidget()
streamMonthWidget()
streamYearWidget()
streamAddForm()

Click here to see the individual Widgets.

You can override the default streamDayView() and/or streamMonthView() in myWEBCAL.cc and thereby modify the page layout. For example, you can remove the header by removing the streamLogo() method. You can also reorganize the page by using a HTML table and streaming the different widgets in the respective cell. myWebcalSample.cc contains an example of an alternate layout.

Additional Comments

Throughout this application dates are passed from page to page. The CGI date is always in the following STRING format: YYYY-MM-DD. The name is always 'date'.

File list

Required Files:

Supporting Files:

Planned Enhancements