The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Apache::VimColor - Apache mod_perl Handler for syntax highlighting in HTML.

DESCRIPTION

This apache handler converts text files in syntax highlighted HTML output using Text::VimColor. If allowed by the configuration the visitor can also download the text-file without syntax highlighting.

Since Text::VimColor isn't the fastest module this version can use Cache::Cache to cache the parsed files. Also the ETag and LastModified HTTP headers are set to help browsers and proxy servers to cache the URL.

SYNOPSIS

This module requires mod_perl2 (see http://perl.apache.org/) and Text::VimColor.

The apache configuration neccessary might look a bit like this:

  # in httpd.conf (or any other apache configuration file)
  <Location /source>
    SetHandler          perl-script
    PerlHandler         Apache::VimColor

    # Below here is optional
    PerlSetVar  AllowDownload  "True"
    PerlSetVar  CacheType      "File"
    PerlSetVar  CacheSize      1048576 # 1 MByte
    PerlSetVar  CacheExpire    7200    # 2 hours
    PerlSetVar  StyleSheet     "http://domain.com/stylesheet.css"
    PerlSetVar  TabSize        8
    PerlSetVar  LineNumbers    "True"
  </Location>

For a complete list of all options and descriptions see below.

CONFIGURATION DIRECTIVES

All features of the this PerlHandler can be set in the apache configuration using the PerlSetVar directive. For example:

    PerlSetVar  AllowDownload   true    # inside <Files>, <Location>, ...
                                        # apache directives
AllowDownload

Setting this option to true will allow plaintext downloads of the files. A link will be included in the output. The default is not to allow downloads.

CacheType

Selects the caching method to use. Depending on your choices a Cache::Cache module will be loaded and used. The default is not to use any caching. CacheType can be one of:

    Memory
    SharedMemory
    File

Although the default is not to use caching, if CacheSize is given and CacheType is not, then Memory is being used. Obviously these values correspond to the Cache::*Cache modules.

The modules are loaded at runtime. If errors occur they are logged to Apache's errorlog.

CacheSize

Sets the maximum size of the cache in bytes. If CacheSize is non-zero the Cache::SizeAware*Cache variants will be used.

CacheExpire

CacheExpire sets the expiration time. The value must be given in seconds. Defaults to 3600 seconds (one hour). See Cache::Cache for details.

TabStop

Sets the width of one tab symbol. The default is eight spaces.

StyleSheet

If you want to include a custom stylesheet you can set this option. The string will be included in the html-output as-is, you will have to take care of relative filenames yourself.

All highlighted text is withing a span-tag with one of the following classes:

    Comment
    Constant
    Error
    Identifier
    PreProc
    Special
    Statement
    Todo
    Type
    Underlined
LineNumbers

Sets wether or not line numbers will be displayed. The Default is not to display line numbers.

SEE ALSO

perl(1), mod_perl(3), Apache(3), Text::VimColor, Cache::Cache

AUTHOR

  Florian octo Forster
  octo(at)verplant.org
  http://verplant.org/

COPYRIGHT

Copyright (c) 2005 Florian Forster.

All rights reserved. This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself.