From e887885d025332998a5d271bb5addfefe8b3b22a Mon Sep 17 00:00:00 2001 From: klm Date: Wed, 8 Apr 1998 23:59:16 +0000 Subject: Implement rudimentary admin-configuration long-description help. I now have to refine it, but it's simple and it works. It uses the anchor href "target" option to display the help in a named alternate window. I presume that in browsers that do not support this feature they will simply go to another page, where the user can hit 'back' when they're ready. Also, right-aligned the short descriptions on the left column of the table, so they snug up to the value column. --- cgi/admin | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) (limited to 'cgi') diff --git a/cgi/admin b/cgi/admin index 79bc94fac..edab48693 100755 --- a/cgi/admin +++ b/cgi/admin @@ -31,7 +31,7 @@ def main(): CGI input indicates that we're returning from submission of some new settings, which is processed before producing the new version.""" - global doc, list_name # For encompassing try/except. + global list_name # For encompassing try/except. doc = Document() path = os.environ['PATH_INFO'] @@ -64,6 +64,9 @@ def main(): cgi_data = cgi.FieldStorage() if len(cgi_data.keys()): + if cgi_data.has_key('VARHELP'): + print FormatOptionHelp(cgi_data['VARHELP'].value, list) + return if not cgi_data.has_key('adminpw'): AddErrorMessage(doc, 'Error: You must supply the admin password to' @@ -172,12 +175,12 @@ def FormatOptionsSection(category, list): options = GetConfigOptions(list, category) + big_table = Table(cellspacing=3, cellpadding=4) + + # Get and portray the text label for the category. for k, v in CATEGORIES: if k == category: label = v - - big_table = Table(cellspacing=3, cellpadding=4) big_table.AddRow([Center(Header(2, label))]) - big_table.AddCellInfo(max(big_table.GetCurrentRowIndex(), 0), 0, colspan=2, bgcolor="#99ccff") @@ -203,7 +206,7 @@ def FormatOptionsSection(category, list): # ... but do col header before anything else. ColHeader() did_col_header = 1 - big_table.AddRow(GetGuiItem(item, list)) + big_table.AddRow(GetGuiItem(item, category, list)) big_table.AddCellInfo(max(big_table.GetCurrentRowIndex(), 0), 1, bgcolor="#cccccc") big_table.AddCellInfo(max(big_table.GetCurrentRowIndex(), 0), 0, @@ -212,7 +215,25 @@ def FormatOptionsSection(category, list): big_table.AddCellInfo(big_table.GetCurrentRowIndex(), 0, colspan=2) return big_table -def GetGuiItem(table_entry, list): +def FormatOptionHelp(varref, list): + print "Content-type: text/html\n\n" + item = None + reflist = string.split(varref, '/') + if len(reflist) == 2: + category, varname = reflist + options = GetConfigOptions(list, category) + for i in options: + if i and i[0] == varname: + item = i + break + if not item: + return "Option %s/%s not found. %s" % (category, varname, + os.environ['PATH_INFO']) + if len(item) < 6: + return "Option %s has no extended help." % varname + return item[5] + +def GetGuiItem(table_entry, category, list): """Return the contents for a table row representing an options item. Elements of the table_entry list are: @@ -255,7 +276,14 @@ def GetGuiItem(table_entry, list): r, c = None, None res = string.join(getattr(list, varname), '\n') gui_part = TextArea(varname, res, r, c, wrap='off') - return [table_entry[4], gui_part] + descr = '
' + descr + if elaboration: + ref = '?VARHELP=' + category + "/" + varname + descr = Container(descr, Link(ref, " (Details)", + target="MMHelp"), "
") + else: + descr = descr + "" + return [descr, gui_part] def FormatMembershipOptions(list): container = Container() -- cgit v1.3.1