diff options
| author | bwarsaw | 1998-06-19 19:57:31 +0000 |
|---|---|---|
| committer | bwarsaw | 1998-06-19 19:57:31 +0000 |
| commit | aff327f7d375d3ccf5aa6a165f93d8d9454ce0ea (patch) | |
| tree | 47ee88da43726e203f453c6cc80d386e11ed537e /Mailman/Cgi/edithtml.py | |
| parent | 002f566bfd5619df6c215bfe5597aeace7a59499 (diff) | |
| download | mailman-aff327f7d375d3ccf5aa6a165f93d8d9454ce0ea.tar.gz mailman-aff327f7d375d3ccf5aa6a165f93d8d9454ce0ea.tar.zst mailman-aff327f7d375d3ccf5aa6a165f93d8d9454ce0ea.zip | |
Diffstat (limited to 'Mailman/Cgi/edithtml.py')
| -rw-r--r-- | Mailman/Cgi/edithtml.py | 195 |
1 files changed, 106 insertions, 89 deletions
diff --git a/Mailman/Cgi/edithtml.py b/Mailman/Cgi/edithtml.py index faf35e715..795ae2bcb 100644 --- a/Mailman/Cgi/edithtml.py +++ b/Mailman/Cgi/edithtml.py @@ -19,80 +19,128 @@ """Script which implements admin editing of the list's html templates.""" import sys -import os, cgi, string, crypt, types -import mm_utils, maillist, mm_cfg -import htmlformat +import os, cgi, string, types +from Mailman import Utils, MailList +from Mailman import htmlformat + #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 main(): + # XXX: blech, yuck, ick + global doc + global list + global template_info + global template_name + 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.HeadlessDocument() -doc = InitDocument() + doc = InitDocument() -path = os.environ['PATH_INFO'] -list_info = mm_utils.GetPathPieces(path) + path = os.environ['PATH_INFO'] + list_info = Utils.GetPathPieces(path) -if len(list_info) < 1: - doc.AddItem(htmlformat.Header(2, "Invalid options to CGI script.")) - print doc.Format() - sys.exit(0) + 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]) + list_name = string.lower(list_info[0]) -try: - list = maillist.MailList(list_name, lock=0) -except: - doc.AddItem(htmlformat.Header(2, "%s : No such list" % list_name)) - print doc.Format() - sys.exit(0) + try: + list = MailList.MailList(list_name, lock=0) + 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 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 + 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('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.GetRelativeScriptURL('edithtml'), - template), info) - - template_list.AddItem(l) - doc.AddItem(htmlformat.FontSize("+2", template_list)) - doc.AddItem(list.GetMailmanFooter()) - print doc.Format() - sys.exit(0) + 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.GetRelativeScriptURL('edithtml'), + template), info) + + template_list.AddItem(l) + doc.AddItem(htmlformat.FontSize("+2", template_list)) + doc.AddItem(list.GetMailmanFooter()) + print doc.Format() + sys.exit(0) + + try: + cgi_data = cgi.FieldStorage() + if len(cgi_data.keys()): + if not cgi_data.has_key('adminpw'): + m = 'Error: You must supply the admin password to edit html.' + doc.AddItem(htmlformat.Header(3, + htmlformat.Italic( + htmlformat.FontAttr( + m, color="ff5060")))) + doc.AddItem('<hr>') + else: + try: + list.ConfirmAdminPassword(cgi_data['adminpw'].value) + ChangeHTML(list, cgi_data, template_name, doc) + except: + m = 'Error: Incorrect admin password.' + doc.AddItem(htmlformat.Header(3, + htmlformat.Italic( + htmlformat.FontAttr( + m, color="ff5060")))) + doc.AddItem('<hr>') + + + + FormatHTML(doc) + + finally: + try: + doc.AddItem(list.GetMailmanFooter()) + print doc.Format() + except: + pass + + + +def InitDocument(): + return htmlformat.HeadlessDocument() def FormatHTML(doc): + # XXX: blech, yuck, ick + global list + global template_info + global template_name + doc.AddItem(htmlformat.Header(1,'%s:' % list.real_name)) doc.AddItem(htmlformat.Header(1, template_info)) @@ -117,9 +165,10 @@ def FormatHTML(doc): form.AddItem(password_table) - text = mm_utils.QuoteHyperChars(list.SnarfHTMLTemplate(template_name)) + text = Utils.QuoteHyperChars(list.SnarfHTMLTemplate(template_name)) form.AddItem(htmlformat.TextArea('html_code', text, rows=40, cols=75)) + def ChangeHTML(list, cgi_info, template_name, doc): if not cgi_info.has_key('html_code'): doc.AddItem(htmlformat.Header(3,"Can't have empty html page.")) @@ -133,35 +182,3 @@ def ChangeHTML(list, cgi_info, template_name, doc): doc.AddItem(htmlformat.Header(3, 'HTML successfully updated.')) doc.AddItem('<hr>') -try: - cgi_data = cgi.FieldStorage() - if len(cgi_data.keys()): - if not cgi_data.has_key('adminpw'): - m = 'Error: You must supply the admin password to edit html.' - doc.AddItem(htmlformat.Header(3, - htmlformat.Italic( - htmlformat.FontAttr( - m, color="ff5060")))) - doc.AddItem('<hr>') - else: - try: - list.ConfirmAdminPassword(cgi_data['adminpw'].value) - ChangeHTML(list, cgi_data, template_name, doc) - except: - m = 'Error: Incorrect admin password.' - doc.AddItem(htmlformat.Header(3, - htmlformat.Italic( - htmlformat.FontAttr( - m, color="ff5060")))) - doc.AddItem('<hr>') - - - - FormatHTML(doc) - -finally: - try: - doc.AddItem(list.GetMailmanFooter()) - print doc.Format() - except: - pass |
