diff options
| author | klm | 1998-04-10 18:21:45 +0000 |
|---|---|---|
| committer | klm | 1998-04-10 18:21:45 +0000 |
| commit | ac21666e924b43fd04ff1062ce667326ac1ff5fc (patch) | |
| tree | 460bc74d2c63482c98dcd7f33b33432f2900ea2b | |
| parent | 4b3689f5299c2f0d4b71107f4cd50ba07114753b (diff) | |
| download | mailman-ac21666e924b43fd04ff1062ce667326ac1ff5fc.tar.gz mailman-ac21666e924b43fd04ff1062ce667326ac1ff5fc.tar.zst mailman-ac21666e924b43fd04ff1062ce667326ac1ff5fc.zip | |
Implemented an overview listinfo page, arrived at when visiting the
listinfo script without a path to a particular list - or with an
invalid list path. It presents a table of links to the collection of
advertised lists on the site and some information about how to get to
the info page for unadvertised lists, and also how to get to the admin
page overview.
This code was also restructured to enclose inline code within a
function.
| -rwxr-xr-x | cgi/listinfo | 168 |
1 files changed, 125 insertions, 43 deletions
diff --git a/cgi/listinfo b/cgi/listinfo index 81ac3d6f4..a6b15880b 100755 --- a/cgi/listinfo +++ b/cgi/listinfo @@ -4,7 +4,7 @@ Errors are redirected to logs/errors.""" -__version__ = "$Revision: 405 $" +__version__ = "$Revision: 410 $" # No lock needed in this script, because we don't change data. @@ -13,7 +13,8 @@ sys.path.append('/home/mailman/mailman/modules') import os, string from regsub import gsub -import mm_utils, maillist, htmlformat +import mm_utils, maillist, mm_cfg +from htmlformat import * try: sys.stderr = mm_utils.StampedLogger("error", label = 'listinfo', @@ -21,54 +22,135 @@ try: except IOError: pass # Oh well - SOL on redirect, errors show thru. -doc = htmlformat.HeadlessDocument() +def main(): + try: + path = os.environ['PATH_INFO'] + except KeyError: + path = "" + list_info = mm_utils.GetPathPieces(path) -path = os.environ['PATH_INFO'] + if len(list_info) == 0: + FormatListinfoOverview() + return -list_info = mm_utils.GetPathPieces(path) + list_name = string.lower(list_info[0]) -if len(list_info) < 1: - doc.AddItem(htmlformat.Header(2, "Invalid options to CGI script.")) - print doc.Format() - sys.exit(0) + try: + list = maillist.MailList(list_name) + except: + list = None -list_name = string.lower(list_info[0]) + if not (list and list._ready): + FormatListinfoOverview(error="List <em>%s</em> not found." % list_name) + return -try: - list = maillist.MailList(list_name) -except: - doc.AddItem(htmlformat.Header(2, "%s: No such list." % list_name )) - print doc.Format() - sys.exit(0) + FormatListListinfo(list) -if not list._ready: - doc.AddItem(htmlformat.Header(2, "%s: No such list." % list_name)) - print doc.Format() - sys.exit(0) +def FormatListinfoOverview(error=None): + "Present a general welcome and itemize the (public) lists." + doc = Document() + legend = "%s Maillists" % mm_cfg.DEFAULT_HOST_NAME + doc.SetTitle(legend) + + table = Table(border=0, width="100%") + table.AddRow([Center(Header(2, legend))]) + table.AddCellInfo(max(table.GetCurrentRowIndex(), 0), 0, + colspan=2, bgcolor="#99ccff") + + if error: + table.AddRow([Center(FontAttr(error, color="ff5060", size="+1"))]) + table.AddCellInfo(max(table.GetCurrentRowIndex(), 0), 0, + colspan=2) + + advertised = [] + for n in mm_utils.list_names(): + l = maillist.MailList(n) + l.Unlock() + if l.advertised: advertised.append(l) + + if not advertised: + welcome_items = ( + "Welcome!<p>" + " There currently are no publicly-advertised ", + Link(mm_cfg.MAILMAN_URL, "mailman"), + " maillists on %s." % mm_cfg.DEFAULT_HOST_NAME, + ) + else: + + welcome_items = ( + "Welcome!<p>" + " Below is the collection of publicly-advertised ", + Link(mm_cfg.MAILMAN_URL, "mailman"), + " maillists on %s." % mm_cfg.DEFAULT_HOST_NAME, + (' Click on a list name to visit the info page' + ' for that list. There you can learn about the list,' + ' enter a subscription to it, and find the list of' + ' subscribers.'), + ) + + welcome_items = (welcome_items + + (" To visit the info page for an unadvertised list," + " open a URL similar to this one, but with a '/' and" + + + (" the %slist name appended." + % ((error and "right ") or "")) + + + '<p> List administrators, you can visit ', + Link(os.path.join(mm_cfg.DEFAULT_URL, 'admin/'), + "the list admin overview page"), + " to find the management interface for your list." + "<p>(Send questions or comments to ", + Link("mailto:%s" % mm_cfg.MAILMAN_OWNER, + mm_cfg.MAILMAN_OWNER), + ".)<p>")) -replacements = list.GetStandardReplacements() + table.AddRow([apply(Container, welcome_items)]) + table.AddCellInfo(max(table.GetCurrentRowIndex(), 0), 0, colspan=2) + if advertised: + table.AddRow([Italic("List"), Italic("Description")]) + for l in advertised: + table.AddRow([Link(l.GetScriptURL('listinfo'), Bold(l.real_name)), + l.description]) + + doc.AddItem(table) + + print doc.Format(bgcolor="#ffffff") + +def FormatListListinfo(list): + "Expand the listinfo template against the list's settings, and print." + + doc = HeadlessDocument() + + replacements = list.GetStandardReplacements() + + if not list.digestable or not list.nondigestable: + replacements['<mm-digest-radio-button>'] = "" + replacements['<mm-undigest-radio-button>'] = "" + else: + replacements['<mm-digest-radio-button>'] = list.FormatDigestButton() + replacements['<mm-undigest-radio-button>'] = \ + list.FormatUndigestButton() + replacements['<mm-plain-digests-button>'] = list.FormatPlainDigestsButton() + replacements['<mm-mime-digests-button>'] = list.FormatMimeDigestsButton() + replacements['<mm-subscribe-box>'] = list.FormatBox('email') + replacements['<mm-subscribe-button>'] = list.FormatButton('email-button', + text='Subscribe') + replacements['<mm-new-password-box>'] = list.FormatSecureBox('pw') + replacements['<mm-confirm-password>'] = list.FormatSecureBox('pw-conf') + replacements['<mm-subscribe-form-start>'] = \ + list.FormatFormStart('subscribe') + replacements['<mm-roster-form-start>'] = list.FormatFormStart('roster') + replacements['<mm-editing-options>'] = list.FormatEditingOption() + replacements['<mm-info-button>'] = SubmitButton('UserOptions', + 'Edit Options').Format() + replacements['<mm-roster-option>'] = list.FormatRosterOptionForUser() + + # Do the expansion. + doc.AddItem(list.ParseTags('listinfo.html', replacements)) + + print doc.Format() -if not list.digestable or not list.nondigestable: - replacements['<mm-digest-radio-button>'] = "" - replacements['<mm-undigest-radio-button>'] = "" -else: - replacements['<mm-digest-radio-button>'] = list.FormatDigestButton() - replacements['<mm-undigest-radio-button>'] = list.FormatUndigestButton() -replacements['<mm-plain-digests-button>'] = list.FormatPlainDigestsButton() -replacements['<mm-mime-digests-button>'] = list.FormatMimeDigestsButton() -replacements['<mm-subscribe-box>'] = list.FormatBox('email') -replacements['<mm-subscribe-button>'] = list.FormatButton('email-button', - text='Subscribe') -replacements['<mm-new-password-box>'] = list.FormatSecureBox('pw') -replacements['<mm-confirm-password>'] = list.FormatSecureBox('pw-conf') -replacements['<mm-subscribe-form-start>'] = list.FormatFormStart('subscribe') -replacements['<mm-roster-form-start>'] = list.FormatFormStart('roster') -replacements['<mm-editing-options>'] = list.FormatEditingOption() -replacements['<mm-info-button>'] = \ - htmlformat.SubmitButton('UserOptions', - 'Edit Options').Format() -replacements['<mm-roster-option>'] = list.FormatRosterOptionForUser() -doc.AddItem(list.ParseTags('listinfo.html', replacements)) -print doc.Format() +if __name__ == "__main__": + main() |
