EMP (Easy Maintenance Pages) v.093
Allan Bowhill (2003)

EMP (Easy Maintenance Pages) is a heirarchical web delivery system.
It is written in C++. It is small, fast and has a clean appearance.
It makes a web site of categorized links that is easy to maintain.

EMP delivers formatted tables of links. These reside in a topical heirarchy 
that you define. Now, you too can run a site like Yahoo. You can create 
categories, subcategories, sub-sub categories ... as much as the Unix 
filesystem will bear, with links to other websites in each category.

The design of EMP is centered on ease of maintenance. There is no HTML to edit.
There is no scripting to do. EMP requires a mimimum amount of effort from
the web site administrator, and the rest is taken care of by the program.

==

EMP leverages the Unix filesystem heirarchy to create an integrated web site.

It mirrors directories as categories in a website heirarchy, and associates links for 
each category from records it finds in a flat text file called "links" that optionally
resides in each directory.

Whatever directories you create under the EMP document tree become 
categories that are divided into individual web pages on your site. When you want 
to add a hypertext link to a category, add three lines (the URL, clickable text 
and description) to the "links" file that resides in that category's directory.

Once changes are made, EMP will make categories and links immediately viewable.
Navigation and addressing of categories is taken care of internally by the program.

Performance is efficient. CGI requests that feed into EMP are logically encoded 
to be brief. HTML is minimal. A short CSS sytlesheet in main.h takes care of layout.
The binary is small, (about 30k). 

fts(3) is used to walk the directory heirarchy. On first hits, this is relatively 
expensive, but on subsequent hits soon after, the FreeBSD directory-cache takes over, 
yeilding drastic performance increases. So if you are lucky enough to be slash-dotted, 
you will be probably optimized too. 

In casual testing on small directory heirarchies, EMP is about 3 times slower than the 
find utility, and on large heirarchies it is only marginally slower than find. Only one 
file gets read per CGI call to the program if EMP is run without a configuration file.



Installation
============

Manually:

1. Unpack the distribution

	> gzip -dc emp-0.93.tar.gz | tar xvf -

2. Compile the software:

	> ./configure
	> make 

   Don't run "make install". It will probably not place EMP in the 
   desired directory.

3. Change the ownership and persmissions of the EMP
   binary to reflect your system's security setup.

4. Copy the EMP binary to a cgi-enabled directory:

	> cp EMP /usr/local/www/cgi-bin/EMP.cgi


Configuration
=============

Minimal Configuration
=====================

To deliver web pages, EMP must be able to find its document root directory, and this directory
must contain some content that EMP can deliver in a web page.

Minimally, if you create a directory called "emp" in '/usr/local/www' or in same directory
in which EMP was installed, it will regard this as its document root.

For minimal content, EMP's document root must contain either a subdirectory or a file called
"links" in order to generate an empty web page in return.

A sample links file (links.sample) is included in the EMP distribution. To see how
it translates to HTML, copy it to the EMP document root, rename it to 'links'
and make a request to EMP through your web browser.

For example, if you installed EMP.cgi into your cgi-bin directory, you would 
type the following address into your web browser to view the example:

	http://yoursite/cgi-bin/emp.cgi

To configure EMP in a more customized way, read the instructions below.

Configuring the EMP document root
=================================

EMP can locate its document root in one of two ways, depending on how you choose to run it:

a.) Without a configuration file: EMP will use hard-coded values compiled into the binary
b.) With a configuration file: EMP reads a configuration file every time it is run.

By default, EMP tries to operate without a configuration file, which is the generally
accepted behavior for most CGI programs.

To allow EMP to operate without a configuration file, the EMP document root
directory must be named "emp" and must exist in "/usr/local/www" or in the same 
directory in which EMP.cgi resides. When EMP starts, "/usr/local/www" is checked 
first. If no document root is found, then the local directory is checked.

If EMP can't find the document root in either of these directories, it looks 
for a configuration file (emp.cfg) to find out where its document root is 
located on the system.

It looks in two places for "emp.cfg". First, in "/usr/local/etc" - then,
failing that - in the local directory where EMP.cgi was installed.

If it finds an "emp.cfg" in either location, it scans the file for the directory
associated with the "emproot" keyword:


# sample emp configuration file
#
emproot = "/foo/bar/temp/test_emp_root_dir"


The path listed as the EMP document root (emproot) must be enclosed by quotes.
Since the Unix filesystem accepts blank characters in a filename, any embedded
blanks will be considered part of the path. 

For instance, the following configuration file will tell EMP that its document 
root is the directory called: "The Easy Maintenance Pages" under "/usr/me":


# sample emp configuration file
#
emproot = "/usr/me/The Easy Maintenance Pages"


(Note that the existence of '/usr/local/www/emp' or './emp' will cause EMP to
ignore any configuration file. Make sure to rename these directories 
if you want EMP to read its configuration file)


Configure Content
=================

There are two types of disk entities that EMP will automatically recognize 
as content anywhere under its document root.

	1. Directories and subdirectories
	2. Files named "links" residing in any directory or subdirectory

EMP will also treat symlinks to directories or files as the objects themselves.

If you want to add content to an EMP-generated website, add a subdirectory, links 
file (or symlink to either) anywhere under the EMP document root.


Adding categories
=================

To add a category to your website, create a new directory under the EMP document
root, or to any of its subdirectories.

Give the new directory the name of the subject you want displayed as a category.
This gets displayed at the top of the wegb page for that category.

For example, to create a category called 'Search Engines' do the following somewhere 
inside the EMP directory structure:

	> mkdir 'Search Engines'

This category will be invisible to the outside world until you create a links file
in the directory 'Search Engines', or add a subdirectory under it.

If you add a subdirectory under 'Search Engines', a hyptertext link will appear
on the web page of someone who navigates to it.

	> cd 'Search Engines'
	> mkdir 'English Language'

Now a visitor to your web site will see 'English Language' listed as a subcategory 
of 'Search Engines'


Moving categories
-----------------

To move a category to another category, just use "mv":

	> mv 'Search Engines' 'Web Tools'

Now someone who navigates to this part of your web site will see everything
previously listed under 'Search Engines' as being listed under 'Web Tools'.


Adding links
============

If you create a file called "links" in a directory, EMP will read it to
generate hypertext links you define.

	> cd 'Search Engines'
	> vi links

The links file is a simple structured document that makes it easy to maintain
many categorized links without writing HTML. 

To have EMP generate a viewable hypertext link in a category's web page, add 
a link record to the links file.

To add a link record, write three lines of left-justified text to the links file:


http://www.google.com
Google
A very big search engine


This link record will appear as a row in an HTML table to the user who
navigates to the category: "Search Engines" on your web site. The clickable
text will be "Google" and "A very big search engine" will appear to the 
right of the link.

Here is what the fields mean in each record:

1.) The first line is the URL of the site to link to. 
2.) The second line is the text the user can click to get to the URL. 
3.) The third line is a short one-line description of the site.

Just make sure each link entry you add has all three lines in order mentioned 
above, and make sure that each record is seperated by at least one blank line:


http://www.google.com
Google
A very big search engine

http://www.altavista.digital.com
Altavista
Another very big search engine


Category Titles
---------------

If you want to have an associated description of the category appear in 
the top bar of the the user's web browser window, you can add a single line 
at the top of the links file:


This is my collection of search engines

http://www.google.com
Google
A very big search engine

http://www.altavista.digital.com
Altavista
Another very big search engine


If you choose to use this feature, make sure it is the first line in the links
file, and is followed by at least one blank line.


=========================================================================
That's it. Have fun!

If you have a bug you discovered or feature you would like added, write 
me (Allan Bowhill) at:

	abowhill@blarg.net

=========================================================================
####
