summaryrefslogtreecommitdiff
path: root/cgi/edithtml
diff options
context:
space:
mode:
authorviega1998-06-14 01:00:28 +0000
committerviega1998-06-14 01:00:28 +0000
commit73e488770ae493feeaf08ac9d21bd14eccdb2da2 (patch)
tree950823c4949a13fcf3b3dcb82df1310bbe6be6ba /cgi/edithtml
parent8dfd4643c7d8216cfbf6e180ed7b868715b9e775 (diff)
downloadmailman-73e488770ae493feeaf08ac9d21bd14eccdb2da2.tar.gz
mailman-73e488770ae493feeaf08ac9d21bd14eccdb2da2.tar.zst
mailman-73e488770ae493feeaf08ac9d21bd14eccdb2da2.zip
Replaced with Mailman.runcgi-wrapped code that runs Mailman.Cgi.<script>
Diffstat (limited to 'cgi/edithtml')
-rwxr-xr-xcgi/edithtml160
1 files changed, 5 insertions, 155 deletions
diff --git a/cgi/edithtml b/cgi/edithtml
index 509bf25a7..7b6574da2 100755
--- a/cgi/edithtml
+++ b/cgi/edithtml
@@ -16,160 +16,10 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-"""Script which implements admin editing of the list's html templates."""
+import paths
-import sys
-import os, cgi, string, crypt, types
-import paths # path hacking
-import mm_utils, maillist, mm_cfg
-import htmlformat
+def edithtml():
+ import Mailman.Cgi.edithtml
-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.HeadlessDocument()
-
-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, 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 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.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)
-
-
-def FormatHTML(doc):
- doc.AddItem(htmlformat.Header(1,'%s:' % list.real_name))
- doc.AddItem(htmlformat.Header(1, template_info))
-
- doc.AddItem('<hr>')
-
- link = htmlformat.Link(list.GetRelativeScriptURL('admin'),
- 'View or edit the list configuration information.')
- doc.AddItem(htmlformat.FontSize("+1", link))
- doc.AddItem('<p>')
-
- doc.AddItem('<hr>')
-
- form = htmlformat.Form(os.path.join(list.GetRelativeScriptURL('edithtml'),
- template_name))
- doc.AddItem(form)
-
- password_table = htmlformat.Table()
- password_table.AddRow(['Enter the admin password to edit html:',
- htmlformat.PasswordBox('adminpw')])
- password_table.AddRow(['When you are done making changes...',
- htmlformat.SubmitButton('submit', 'Submit Changes')])
-
- form.AddItem(password_table)
-
- text = mm_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."))
- doc.AddItem(htmlformat.Header(3,"HTML Unchanged."))
- doc.AddItem('<hr>')
- return
- code = cgi_info['html_code'].value
- f = open(os.path.join(list._template_dir, template_name), 'w')
- f.write(code)
- f.close()
- 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
+from Mailman.runcgi import *
+wrap_func(edithtml)