# Common Tasks

The following section describes how to perform some common tasks with MHonArc, beyond those mentioned in Quick Start. To get a complete picture of the capabilities of MHonArc, see the Resources section.

- Setting the Index Title
- Changing Index Listing Order
- Removing Messages
  - Automatic Removal
  - Manual Removal
- Customizing Page Layout

## Setting the Index Title

If you tested MHonArc out on some of your mail, you may have noticed that the titles of the main (date) and thread index pages are not very descriptive: "Mail Index" and "Mail Thread Index", respectively. MHonArc allows you to change the titles via the `-title` and `-ttitle` options so the index page titles provide a better reflection of the type of mail archived.

The `-title` option sets main index title, and the `-ttitle` option sets the thread index title. Example:

    prompt> mhonarc -title "The Widget List Archive" \
    	       -ttitle "The Widget List Thread Archive" ...

## Changing Index Listing Order

By default, messages are listed in chronological order on the main and thread index pages.

NOTE: | The chronological order in the thread index is based on the root messages of each thread.

For many, the default listing order is not what is desired. A common desire is to have messages in the main index listed in reverse chronological order; ie. the most recent messages are listed first while the oldest are listed last. Or, one may want to list messages by author since the target audience is more interested in looking up messages by certain authors than by date.

Following is the list options available for changing the listing order on index pages:

Option | Description
`-authsort` | Sort main index by author.
`-reverse` | Reverse the listing order in the main index.
`-sort` | List messages by date in main index.
`-subsort` | List messages by subject in main index.
`-treverse` | List thread in reverse order.
`-tsort` | List threads by date.
`-tsubsort` | List threads by subject.

For example, to get a reverse chronological listing, do the following:

    prompt> mhonarc -sort -reverse ...

## Removing Messages

There are two ways to delete messages from an archive: automatic and manual.

### Automatic Removal

MHonArc supports the ability to automatically remove archive messages older than a specified time period, older than a specified date/time, or by exceeding a specified maximum number.

For example, if you want an archive to only contain messages that are less than a month old, do the following:

    prompt> mhonarc -expireage 2635200 -add -outdir /path/to/archive mailbox

Here, we used the `-expireage` option to tell MHonArc to remove messages older than 2635200 seconds (30.5 days) when adding new messages. Having to use seconds to specify the expiration age may be cumbersome, therefore, a table is provided in the EXPIREAGE reference page listing common time periods and their equivalence in seconds.

A less used option that will cause automatic deletion is the `-expiredate` option. This allows you to specify an exact date/time where any messages older will be automatically removed. For example:

    prompt> mhonarc -expiredate "1 Jan 1999 00:00:00" -add -outdir /path/to/archive mailbox

In this example, before MHonArc adds any new messages, it will delete any messages with a date earlier than January 1, 1999. See the EXPIREDATE reference page for more information and for the correct expiration date syntax.

An archive can also have a maximum number limit. When the maximum number is reached, the oldest messages are automatically removed. The following is an example of setting the maximum size of an archive:

    prompt> mhonarc -maxsize 500 -add -outdir /path/to/archive mailbox

### Manual Removal

Sometimes it becomes necessary to remove specific messages from archive: Their may be some spam messages cluttering up your archive, or there may be messages not appropriate for the archive's intended audience.

To remove specific messages, use the `-rmm` option. For example:

    prompt> mhonarc -rmm 24 28 39 48

will delete messages 24, 28, 39, and 48.

The number assigned to a message is part of the message's filename. Each converted message is writting to a filename containing the number of message. For example, `msg00024.html`, `msg00028.html`, `msg00039.html`, and `msg00048.html` denote messages 24, 28, 39, and 48.

Checking filenames can be awkward, an alternative is to use the `-scan` option. For example:

    prompt> mhonarc -scan -outdir /home/ehood/html/archive
    Reading database ...
    117 messages in /home/ehood/html/archive:

    Msg #  YYYY/MM/DD  From             Subject
    -----  ----------  ---------------  -------------------------------------------
       62  1996/07/30  Kwin Kramer      Reading STDIN not from keyboard -- or, Syst
       23  1996/07/31  Christopher M.   Re: Setting @INC to include my own modules
        9  1996/08/01  Dan Kirkwood     object as hash key loses methods
        2  1996/08/01  James F'jord Ly  Re: We're HIRING hot hackers!
        1  1996/08/01  Christopher Cha  Curious Multi-Dimensional array behavior
       14  1996/08/01  I R A Aggie      Re: Patch for arithmetic bug in 5.003 ?
        3  1996/08/01  Bernard Bellon   Re: How do you grab a URL in perl?
       38  1996/08/01  Mohammed Dewan   Help needed badly win3.1 and perl.
       59  1996/08/01  Mohammed Dewan   Using file in perl.
        4  1996/08/01  Dan Gildor       Re: Threaded Discusion groups embeded in We
        5  1996/08/01  kendall shaw     addicted to emacs lisp
        6  1996/08/01  Ye He            Q: Sybase extension to Perl
       83  1996/08/01  I R A Aggie      Re: Browser/Page matching CGI script
        7  1996/08/01  Chris Schleiche  Re: Simple program looks good, but gives er
       13  1996/08/01  Steve McCullagh  Perl 5.002 and $| errors
    ...

With -scan, you can get a listing of an archive to your terminal. The listing can be used to determine the message number for a message if you know the message's subject and author.

The `-rmm` also supports the ability to specify message number ranges and message-ids. See the RMM reference page for more information and examples.

## Customizing Page Layout

One of the most powerful features of MHonArc is the ability to customize the layout of pages. In this section, we give a quick introduction on how customization can be done. For more information, see Page Layout.

In this introduction, we want to add a footer at the bottom of each page containing the following markup:

    <hr>
    Please visit <a href="http://www.mhonarc.org">www.mhonarc.org</a>.

Create a new file called "`myresource.mrc`" and edit `myresource.mrc` to include the following:

    <!-- Define a custom resource variable representing our link. -->
    <DefineVar>
    MY-FOOTER-LINK
    <hr>
    Please visit <a href="http://www.mhonarc.org">www.mhonarc.org</a>.
    </DefineVar>

    <!-- Modify appropriate resources to print our link at the bottom
         of MHonArc generated pages. Notice how the custom resource
         variable defined above can be used to include our link. -->

    <!-- Main index pages -->
    <IdxPgEnd>
    $MY-FOOTER-LINK$
    </body>
    </html>
    </IdxPgEnd>

    <!-- Thread index pages -->
    <TIdxPgEnd>
    $MY-FOOTER-LINK$
    </body>
    </html>
    </TIdxPgEnd>

    <!-- Message pages -->
    <MsgPgEnd>
    $MY-FOOTER-LINK$
    </body>
    </html>
    </MsgPgEnd>

The file you created is formally called a resource file. A resource file is a plain text file containing resource settings affecting the behavior of MHonArc. In this case, the resource defined above tells MHonArc to include our custom footer on all pages.

To inform MHonArc about your resource file, you must specify it when invoking `mhonarc`:

    prompt> mhonarc -rcfile myresource.mrc ...