#!/usr/local/bin/python """Script which implements admin editing of the list's html templates.""" __version__ = "$Revision: 386 $" import sys sys.path.append('/home/mailman/mailman/modules') import os, cgi, string, crypt, types import mm_utils, maillist, mm_cfg import htmlformat try: sys.stderr = mm_utils.StampedLogger("error", label = 'edithtml', manual_reprime=1, nofail=0) except IOError: pass # Oh well - SOL on redirect, errors show thru. #Editable templates. We should also be able to edit the archive index, which #currently isn't a working template, but will be soon. template_data = (('listinfo.html', 'General list information page'), ('subscribe.html', 'Subscribe results page'), ('options.html', 'User specific options page'), ('handle_opts.html', 'Changing user options results page'), ('archives.html', 'Archives index page') ) def InitDocument(): return htmlformat.Document() doc = InitDocument() path = os.environ['PATH_INFO'] list_info = mm_utils.GetPathPieces(path) if len(list_info) < 1: doc.AddItem(htmlformat.Header(2, "Invalid options to CGI script.")) print doc.Format() sys.exit(0) list_name = string.lower(list_info[0]) try: list = maillist.MailList(list_name) except: doc.AddItem(htmlformat.Header(2, "%s : No such list" % list_name)) print doc.Format() sys.exit(0) if not list._ready: doc.AddItem(htmlformat.Header(2, "%s : No such list" % list_name)) print doc.Format() sys.exit(0) if len(list_info) > 1: template_name = list_info[1] for (template, info) in template_data: if template == template_name: template_info = info doc.SetTitle('%s -- Edit html for %s' % (list.real_name, template_info)) break else: doc.SetTitle('Edit HTML : Error') doc.AddItem(htmlformat.Header(2, "%s: Invalid template" % template_name)) doc.AddItem(list.GetMailmanFooter()) print doc.Format() sys.exit(0) else: doc.SetTitle('%s -- HTML Page Editing' % list.real_name) doc.AddItem(htmlformat.Header(1, '%s -- HTML Page Editing' % list.real_name)) doc.AddItem(htmlformat.Header(2, 'Select page to edit:')) template_list = htmlformat.UnorderedList() for (template, info) in template_data: l = htmlformat.Link(os.path.join(list.GetScriptURL('edithtml'), template), info) template_list.AddItem(l) doc.AddItem(htmlformat.FontSize("+2", template_list)) doc.AddItem(list.GetMailmanFooter()) print doc.Format() sys.exit(0) def FormatHTML(doc): doc.AddItem(htmlformat.Header(1,'%s:' % list.real_name)) doc.AddItem(htmlformat.Header(1, template_info)) doc.AddItem('
') doc.AddItem('