Changeset 506


Ignore:
Timestamp:
Jun 5, 2010, 6:26:21 PM (11 years ago)
Author:
zecrazytux
Message:

Refactoring of bearmail.cgi using BearMail::Dispatch
Improved the documentation
Another step towards bearmail packaging, using a single configuration file and
an optional environment variable
See #15

Location:
bearmail
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • bearmail/README.webgui

    r305 r506  
    22223. Configure your web server
    2323
    24   You will need to map 'bearmail.cgi' to the [...]public/bearmail.cgi URL.
    25   For instance in Apache-speak:
     24  Bearmail UI can be hosted by either CGI or Apache mod_perl2.
    2625
    27     Alias       /foobar/             /home/bob/bearmail/public/
    28     ScriptAlias /foobar/bearmail.cgi /home/bob/bearmail/bin/bearmail.cgi
     26  Here is a sample configuration file for Apache using CGI:
    2927
    30   Bearmail may be served from any URL, it uses relative links as much
    31   as possible and a bit of auto-configuration magic when necessary.
    32   Which means than the Bearmail webgui is easily 'relocatable'.
     28        #
     29        ### CGI bearmail hosting
     30        #
     31       
     32        <VirtualHost *:80>
     33                ServerAdmin admin@company
     34                DocumentRoot /bearmail/bearmail/public
     35       
     36                # Optional: /etc/bearmail/bearmail.conf by default
     37                SetEnv BEARMAIL_CONF /path/to/bearmail/conf/bearmail.conf
    3338
    34   FIXME: document mod_perl2 configuration.
     39                ScriptAlias /bearmail /bearmail/bearmail/bin/bearmail.cgi
     40        </VirtualHost>
    3541
     42
     43  And one for Apache mod_perl2:
     44
     45        #
     46        ### mod_perl bearmail hosting
     47        #
     48       
     49        <VirtualHost *:80>
     50               ServerAdmin admin@company
     51               DocumentRoot /path/to/bearmail/public
     52       
     53               # Optional: /etc/bearmail/bearmail.conf by default
     54               SetEnv BEARMAIL_CONF /path/to/bearmail/conf/bearmail.conf
     55
     56
     57                # Optional: if using not-packaged Bearmail, libs not being in
     58                # standard @INC
     59                PerlOptions +Parent
     60                PerlSwitches -I/bearmail/bearmail/lib
     61                PerlOptions +GlobalRequest
     62
     63                PerlModule BearMail::Dispatch
     64                <Location /bearmail>
     65                        SetHandler perl-script
     66                        PerlHandler BearMail::Dispatch
     67                </Location>
     68        </VirtualHost>
  • bearmail/bin/bearmail.cgi

    r354 r506  
    2020use strict;
    2121use CGI::Carp qw/fatalsToBrowser/;
    22 use CGI::Application::Dispatch;
    23 use Cwd;
    24 
    25 my $bearmail_dir = $ENV{'BEARMAIL'} || cwd().'/..';
    26 
    27 CGI::Application::Dispatch->dispatch(
    28     prefix      => 'BearMail::Web',
    29     default     => 'login',
    30     args_to_new => {
    31         TMPL_PATH => "$bearmail_dir/template/",
    32         PARAMS    => {
    33             cfg_file => "$bearmail_dir/etc/bearmail/bearmail.conf",
    34         }
    35     },
    36 );
     22use BearMail::Dispatch;
     23BearMail::Dispatch->dispatch();
  • bearmail/conf/bearmail.conf

    r454 r506  
    1 # Bearmail global configuration file
     1# Bearmail global configuration
    22#
    33# These parameters affect all Bearmail related programs, wether CLI
     
    1111#   editor and VCS, adminsys and grep-friendly.
    1212#
    13 #   The 'path' argument is optionnal. The default path is
     13#   The 'path' argument is optional. The default path is
    1414#   /etc/bearmail/mailmap.
    1515#
     
    3535#
    3636master_password = no_hash_no_superuser
     37
     38
     39#
     40# Bearmail webui configuration
     41#
     42# These parameters affect the Bearmail webUI only.
     43
     44# bearmail_tmpl_path - Webui template path
     45#
     46bearmail_tmpl_path = /usr/share/bearmail/web/template
  • bearmail/lib/BearMail/Dispatch.pm

    r500 r506  
    1818package BearMail::Dispatch;
    1919use base 'CGI::Application::Dispatch';
     20use Config::Auto;
    2021use strict;
    2122use warnings;
     
    2425
    2526sub dispatch_args {
    26   my $bearmail_dir = $ENV{'BEARMAIL'};
     27  my $bearmail_conf = $ENV{'BEARMAIL_CONF'};
     28  $bearmail_conf ||= "/etc/bearmail/bearmail.conf";
     29
     30  my $config = Config::Auto::parse("$bearmail_conf");
    2731
    2832  return {
     
    3034    default => 'login',
    3135    args_to_new => {
    32         TMPL_PATH => "$bearmail_dir/template/",
     36        TMPL_PATH => $config->{'bearmail_tmpl_path'},
    3337        PARAMS    => {
    34             cfg_file => "$bearmail_dir/conf/bearmail.conf",
     38            cfg_file => "$bearmail_conf",
    3539        }
    3640    },
  • bearmail/public/index.html

    r99 r506  
    55  <head>
    66    <title>BearMail</title>
    7     <meta http-equiv="Refresh" content="0; bearmail.cgi" />
     7    <meta http-equiv="Refresh" content="0; bearmail" />
    88  </head>
    99  <body>
    10     <p>If you are not redirect, please try <a href="bearmail.cgi">bearmail.cgi</a>.
     10    <p>If you are not redirect, please try <a href="bearmail">bearmail</a>.
    1111  </body>
    1212</html>
Note: See TracChangeset for help on using the changeset viewer.