File Coverage

blib/lib/Siesta/Plugin/MessageFooter.pm
Criterion Covered Total %
statement 25 25 100.0
branch n/a
condition 2 2 100.0
subroutine 8 8 100.0
pod 3 3 100.0
total 38 38 100.0


line stmt bran cond sub pod time code
1             package Siesta::Plugin::MessageFooter;
2 4     4   4654 use strict;
  4         10  
  4         130  
3 4     4   22 use Siesta::Plugin;
  4         51  
  4         49  
4 4     4   109 use base 'Siesta::Plugin';
  4         7  
  4         416  
5 4     4   21 use Siesta;
  4         15  
  4         30  
6              
7 4     4   4914 use Sys::Hostname;
  4         5793  
  4         1794  
8              
9              
10             sub description {
11 1     1 1 543 'Add a message footer';
12             }
13              
14              
15              
16             sub process {
17 4     4 1 8554 my $self = shift;
18 4         16 my $mail = shift;
19 4         35 my $list = $self->list;
20              
21             # get the raw footer or return
22 4   100     1899 my $rawfooter = $self->pref('footer') || return 0;
23              
24              
25             # from
26             # http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/mailman/mailman/Mailman/Handlers/Decorate.py
27 3         7032 my %vars = ( 'real_name' => $list->name,
28             'list_name' => $list->name,
29             # For backwards compatibility
30             '_internal_name' => $list->name,
31             'host_name' => $self->pref('host_name'),
32             'web_page_url' => $self->pref('web_page_url'),
33             'description' => $self->pref('description'),
34             'info' => $self->pref('info'),
35             'cgiext' => $self->pref('cgiext'),
36             'list' => $list,
37              
38             );
39            
40              
41             # bake it
42 3         37 my $footer = Siesta->bake(\$rawfooter, %vars);
43            
44             # and add it to the end of the mail
45 3         36 $mail->body_set($mail->body()."\n$footer");
46              
47             # and bug out
48 3         91 return 0;
49             }
50              
51             sub options {
52             +{
53 22     22 1 185 'footer'
54             => {
55             'description' =>
56             'a footer to add to the end of every mail. See Siesta::Plugin::MessageFooter for more details',
57             'type' => 'text',
58             'default' => '',
59             'widget' => 'textbox',
60             },
61             'host_name'
62             => {
63             'description' =>
64             'the hostname (default is the hostname worked out by Sys::Hostname)',
65             'type' => 'text',
66             'default' => hostname,
67             'widget' => 'textbox',
68             },
69             'web_page_url'
70             => {
71             'description' =>
72             'the url of of the list web page',
73             'type' => 'text',
74             'default' => '',
75             'widget' => 'textbox',
76             },
77             'cgiext'
78             => {
79             'description' =>
80             'cgi extension',
81             'type' => 'text',
82             'default' => '',
83             'widget' => 'textbox',
84             },
85              
86             'description'
87             => {
88             'description' =>
89             'a short description of the list',
90             'type' => 'text',
91             'default' => '',
92             'widget' => 'textbox',
93             },
94             'info'
95             => {
96             'description' =>
97             'a longer description of the list',
98             'type' => 'text',
99             'default' => '',
100             'widget' => 'textbox',
101             },
102             };
103             }
104              
105             1;
106              
107             =pod
108            
109             =head1 NAME
110              
111             Siesta::Plugin::MessageFooter - add a configurable footer to the end of every mail.
112            
113             =head1 SYNOPSIS
114            
115             The [% real_name %] list :
116             Web [% web_page_url %]
117             Owner [% list.owner.email %]
118            
119             =head1 DESCRIPTION
120              
121             This allows you to put configurable footers at the end of every mail.
122              
123             The variables passed to the I style footer are listed below.
124              
125             Most are provided for Mailman backwards compatability.
126              
127             =over 4
128              
129             =item real_name
130              
131             The name of the list
132              
133             =item list_name
134              
135             ditto
136              
137             =item _internal_name
138              
139             erm, ditto again
140              
141             =item host_name
142              
143             The 'host_name' preference or the system's hostname as worked out
144             by I.
145              
146             The hostname preference can be set using the web interface or by using
147              
148             % nacho modify-plugin MessageFooter host_name
149              
150             =item web_page_url
151              
152             The 'web_page_url' preference.
153              
154             =item description
155              
156             The 'description' preference.
157              
158             =item list
159              
160             A copy of the list object that this plugin is being called from.
161              
162             =back
163            
164             =head1 COPYRIGHT
165            
166             (c)opyright 2003 - The Siesta Dev Team
167            
168             =cut
169