Mailman Web UI Look and Feel Customization, including SSIs
A worst-case web ui integration with mailman, involving dynamic SSIs, implemented on v2.1.7.
- HTML files in mailman/templates/en were placed in a directory on the www server to
be slugged with the ssi template. Outermost HTML, Head and body tags removed.
1.1) the archtoc.html, archtocentry.html, archliststart.html, archlistend.html,
archidxentry.html files were *not* included in the files to be slugged, as they are
already pieces of the archive templating system.
1.2) A file called "empty.html" containing just a comment was placed over there and
in the local template/en directory as well, to receive an empty shell.
- all of the files are slugged on the web server with the SSI directives(prior to
being pulled over HTTP to activate the SSIs).
autoslug-part1.bsh
#!/usr/bin/bash
# usage: pass in name of template directory for processing
if [ $1 ]
then
echo ""
echo "Using template directory: $1"
echo ""
for i in ls content
do
cp $1/top-half.html $i
cat content/$i >> $i
cat $1/bottom-half.html >> $i
echo "created $i"
done
else
echo "usage: pass in name of template directory for processing"
fi
2.1) The SSI source template has been split in two pieces, and concated to the
exported mailman templates.
- Pull the prepared mailman template slugged with look and feel over HTTP:
Autoslug-part2.bsh
#!/bin/bash
# usage: run in the mailman template directory
for i in ls *.html
do
python http-get-file.py http://server.do.main/mailman-template/ $i > $i
echo "http copied $i"
done
echo "restoring saved splits"
cp archidxfoot.html-savesplit archidxfoot.html
cp archidxhead.html-savesplit archidxhead.html
http-get-file.py
import urllib
import sys
opener = urllib.FancyURLopener({})
f = opener.open(sys.argv[1]+sys.argv[2])
the_template = f.read()
print(the_template)
3.1) The result of these scripts are placed in the mailman/template/en directory and
these have had all their SSIs completed.
3.2) archidxfoot.html and archidxhead.html need to have their tops and bottoms cut
off, respectively. These are saved in -savesplit files to avoid having to redo this
manually every time a tiny revision is made and autoslug-part2 is re-run. This is the
meaning of the "restoring saved splits" lines.
3.3) Empty.html needs to be manually split into empty-top.html and
empty-bottom.html. Also an empty-top-no-sidebar.html was created from empty-top.html
for the mailman admin pages (they are too wide in places to accommodate a sidedar).
3.4) The rest of the templates remain as is.
Minor modifications to htmlformat.py and HTMLFormatter.py are all that remain.
Empty-top uses python Template class for the title tag-for example at the top of
empty-top.html <TITLE>$list_name Info Page</TITLE>, the modified Format() function
will replace $list_name with the name of the list.
- The changes are marked with ##RJKMod
*htmlformat.py*
###At the top of file
#RJKmod:
from string import Template
###In class Document
class Document(Container):
title = None
language = None
bgcolor = mm_cfg.WEB_BG_COLOR
suppress_head = 0
#RJKmod: Use custom top-half and bottom-half files
use_custom_template = 1
...
###The modified Document.Format() function:
def Format(self, indent=0, **kws):
charset = 'us-ascii'
if self.language:
charset = Utils.GetCharSet(self.language)
output = ['Content-Type: text/html; charset=%s\n' % charset]
if not self.suppress_head:
if not self.use_custom_template: #RJKmod
kws.setdefault('bgcolor', self.bgcolor)
...distribution code...
output.append('%s<BODY %s>' % (tab, SPACE.join(quals)))
else: #RJKmod
try:
f_templ =
file('/usr/local/mailman/templates/en/empty-top.html')
if self.title.count( 'Administrati') or self.title.count(
'Edit'):
f_templ =
file('/usr/local/mailman/templates/en/empty-top-no-sidebar.html')
templ_content = f_templ.read()
t = Template( templ_content )
output.append( t.safe_substitute( list_name = self.title
) )
finally:
f_templ.close()
# Always do this...
output.append(Container.Format(self, indent))
if not self.suppress_head:
if not self.use_custom_template: #RJKmod
output.append('%s</BODY>' % tab)
output.append('%s</HTML>' % tab)
else: #RJKmod
try:
f_templ =
file('/usr/local/mailman/templates/en/empty-bottom.html')
templ_content = f_templ.read()
output.append( templ_content )
finally:
f_templ.close()
return NL.join(output)
###Modified Logo function to remove logo
def MailmanLogo():
t = Table(border=0, width='100%')
## RJKmod
return t
*HTMLFormatter.py*
### Remove the footer
class HTMLFormatter:
def GetMailmanFooter(self):
##RJKmod
return Container('')
The documented setting of DEFAULT_EMAIL_HOST and
DEFAULT_URL_HOST needs to be made in mm_cfg.
HTH,
-Rich
participants (1)
-
Kucera, Rich