# 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". It would be much nicer if the the titles reflect what type of mail is in the archive.

MHonArc allows you to change the titles via the `-title` and `-ttitle` options. 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 something like 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 that are older than a specified time period, are older than a specified date/time, or the number of messages have reached the maximum number specified.

For example, if you want an archive to only contain messages that are less than a month, you can do something like 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. I know, having to use seconds to specify the expiration age seems cumbersome. 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 than the given date/time, 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 of messages 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. For example, their may be some spam messages and you do not want them cluttering your archive (and providing free advertising). Or, there may be archived messages that you believe are 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.

You are now asking, "How do I know what a message's number is?". One way is to look at the number in the message's filename. I.e. 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, so one 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 generated by MHonArc. Here, we give a quick introduction on how customization can be done. For more information, see the Page Layout section.

In this introduction, the task we will be performing is to add a footer at the bottom of each page in the archive to contain the following markup:

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

To modify page layout, we will need to create a resource file and give it a filename "`myresource.mrc`". The name we give the file is completely arbitrary. There is nothing special about the name "`myresource.mrc`".

Within `myresource.mrc`, we add the following to tell MHonArc to include our footer at the bottom of each page:

    <!-- 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>

Now, when we invoke `mhonarc`, we tell it about our resource file so our footer will show up:

    prompt> mhonarc -rcfile myresource.mrc ...