Automating Web Page Authoring
One of APGen's primary uses is automating the creation and maintainenance of web pages and web sites. As we all know, creating and maintaining web sites requires a lot of manual, repetitive work. In addition to automating authoring and maintenance tasks for online, dynamic web sites, APGen is also valuable for authoring static web sites, including offline sites, CDs, and HTML help.
Active Server Pages can be used to automate creation of some web site content, but ASP programming has limitations. ASP imposes a load on the web server each time a page is viewed. Loading the web server limits performance, and this problem gets much worse as the amount and complexity of code increases. APGen allows developers to take advantage of reuse, encapsulation, and automation to simplify web site creation and maintenance, without any degradation in performance. In addition, many tasks can be automated using APGen that realistically can not be accomplished using ASP.
Automating Web Page Authoring is related to but different from using APGen to optimize web sites. The first step is to decide which processes to automate. The next step is to consider implementation, and start with the tasks that offer the biggest productivity gains. We will review some tasks that can be automated. For working source code, see the Web Authoring Examples. This will help you develop new ways to use APGen to reduce your workload as a web developer.
Deciding What Tasks to Automate
Here is a short checklist that will help you determine which tasks to automate:
- Make a list of the tasks that consume the most web developer time.
- Which tasks are repetitive? Repetitive tasks should be automated. Non-repetitive tasks usually don't consume enough time to justify the time required to automate the task. Eliminate non-repetitive tasks from the list.
- Prioritize this list. The first tasks to be automated should be the tasks where: (1) Automation is easiest to implement; and (2) where the most time can be saved by automation.
Examples of tasks that can/should be automated:
- Writing common content. "Common content" means any text, ASP code, or HTML that is used in more than one place on the web site. Common content can be placed in an APG script procedure in a common include file. Or it can be placed in an XML file or a database, and extracted using an APG script procedure in a common include file. This procedure can be called any time the content is needed. The obvious benefit is easier maintenance - the whole site can be changed by making a single change in a single file or database record. Procedures can use parameters so that the generated content is changed as needed. Common content might include page headers, footers, layout, menus, logos, and common phrases. When creating a new page, just call the procedure instead of manually inserting the common content.
- Building navigation bars and menus. Creating and maintaining navigation bars (navbars) and menus requires a lot of time and effort. Almost every web site has a navbar and/or menu. The navbar and/or menus are repeated on most pages in the site, and they are often modified for each page to make it easier for the user to see their location within a section of the site. Many HTML editors have shortcuts for building and maintaining navbars and menus, but these editors lack the flexibility and power of scripting. Also, these editors often require specific web servers or web server extensions. With APGen, you can write procedures that create any navbar/menu layout and behavior. A good way to implement this is to store the site diagram data (information about pages and the hierarchy of pages) in an XML file or a database. The navbar and menu scripts use the site diagram data to build the appropriate navigation display and links for each page. Adding, moving, deleting, or renaming a page requires a change in the site diagram data, and then a rebuild of the site. The navbars and menus on all affected pages are automatically updated. No more broken links! No more navbar maintenance!
- Building the site. When APG script is added to web pages, the pages needs to be executed to generate the output files. The easiest way to execute many APG scripts is to write a build script, which is similar to a makefile. After making changes to a page or APG script procedure, you can execute the build script, which in turn executes all the APG scripts in the site. Running the build script builds the entire site. Alternately, the build script can be an administrator ASP page the rebuilds the entire site.
- Creating new pages. The process of creating new pages can be automated using APGen. An APG script can be written that creates new pages and computes any standard content. This script can call any of the "common content" procedures you've already written. This is an example of an APG script generating an APG script.
- Template pages. APGen allows you to separate the development of site-wide layout and content from the development of individual page layout and content. Shared layout, script, and content can be generated by one or more template APG scripts. Page specific content can be written separate from the shared content. When you build your site, the template content and the page specific content are merged into an output page. Changing the standard layout across your site requires changing a single template, and rebuilding your site.
If you develop a great way of automating work on one web site, you can often adapt the technique and scripts to other web sites. The up-front time investment in automating your work will save you countless hours and days in the future.
Examples
Examples that show how to automate web authoring tasks are installed with APGen. They can be found in the subdirectories of
Program Files\APGen\Examples\Aut_Auth\
These topics discuss how the examples are implemented: