66
77XXX TO DO
88
9+ XXX User Features TO DO
10+
911- next/prev/index links in do_show?
10- - customize rcs command pathnames
1112- explanation of editing somewhere
12- - various embellishments, GIFs, crosslinks, hints, etc.
13+ - embellishments, GIFs, crosslinks, hints, etc.
14+ - make references to other Q's and whole sections into links
15+ - support adding annotations, too
16+
17+ XXX Management Features TO DO
18+
1319- create new sections
1420- rearrange entries
1521- delete entries
16- - send email on changes
22+ - send email on changes?
23+ - send email on ERRORS!
1724- optional staging of entries until reviewed?
1825- freeze entries
19- - username/password for editors
20- - Change references to other Q's and whole sections
21- - support adding annotations, too
26+ - username/password for authors
27+ - read section titles from a file (could be a Python file: import faqcustom)
28+
29+ XXX Code organization TO DO
30+
31+ - customize rcs command pathnames (and everything else)
2232- make it more generic (so you can create your own FAQ)
2333- more OO structure, e.g. add a class representing one FAQ entry
2434
2737NAMEPAT = "faq??.???.htp"
2838NAMEREG = "^faq\([0-9][0-9]\)\.\([0-9][0-9][0-9]\)\.htp$"
2939
30- # Like so many other things, this should come from a file.
3140SECTIONS = {
3241 "1" : "General information and availability" ,
3342 "2" : "Python in the real world" ,
@@ -377,8 +386,11 @@ def do_info(self):
377386 return
378387 self .prologue ("Info for %s" % name )
379388 print '<PRE>'
380- sys .stdout .flush ()
381- os .system ("/depot/gnu/plat/bin/rlog -r %s </dev/null 2>&1" % self .name )
389+ p = os .popen ("/depot/gnu/plat/bin/rlog -r %s </dev/null 2>&1" %
390+ self .name )
391+ output = p .read ()
392+ p .close ()
393+ print cgi .escape (output )
382394 print '</PRE>'
383395 print '<A HREF="faq.py?req=rlog&name=%s">View full rcs log</A>' % name
384396
@@ -390,8 +402,10 @@ def do_rlog(self):
390402 return
391403 self .prologue ("RCS log for %s" % name )
392404 print '<PRE>'
393- sys .stdout .flush ()
394- os .system ("/depot/gnu/plat/bin/rlog %s </dev/null 2>&1" % self .name )
405+ p = os .popen ("/depot/gnu/plat/bin/rlog %s </dev/null 2>&1" % self .name )
406+ output = p .read ()
407+ p .close ()
408+ print cgi .escape (output )
395409 print '</PRE>'
396410
397411 def checkin (self ):
@@ -508,8 +522,12 @@ def set_cookie(self, author, email):
508522 value = "%s;%s" % (author , email )
509523 import urllib
510524 value = urllib .quote (value )
525+ try :
526+ hostname = os .environ ['HTTP_HOST' ]
527+ except KeyError :
528+ hostname = os .environ ['SERVER_NAME' ]
511529 print "Set-Cookie: %s=%s; path=/cgi-bin/;" % (name , value ),
512- print "domain=%s;" % os . environ [ 'HTTP_HOST' ] ,
530+ print "domain=%s;" % hostname ,
513531 print "expires=Sat, 01-Jan-2000 00:00:00 GMT"
514532
515533 def get_cookie (self ):
@@ -541,7 +559,7 @@ def showedit(self, name, title, text):
541559 email = email or e
542560 print """
543561 Title: <INPUT TYPE=text SIZE=70 NAME=title VALUE="%s"><BR>
544- <TEXTAREA COLS=80 ROWS=20 NAME=text>""" % title
562+ <TEXTAREA COLS=80 ROWS=20 NAME=text>""" % self . escape ( title )
545563 print cgi .escape (string .strip (text ))
546564 print """</TEXTAREA>
547565 <BR>
@@ -553,7 +571,19 @@ def showedit(self, name, title, text):
553571 <BR>
554572 Log message (reason for the change):<BR>
555573 <TEXTAREA COLS=80 ROWS=5 NAME=log>%s\n </TEXTAREA>
556- """ % (author , email , self .log )
574+ """ % (self .escape (author ), self .escape (email ), self .escape (self .log ))
575+
576+ def escape (self , s ):
577+ import regsub
578+ if '&' in s :
579+ s = regsub .gsub ("&" , "&" , s ) # Must be done first!
580+ if '<' in s :
581+ s = regsub .gsub ("<" , "<" , s )
582+ if '>' in s :
583+ s = regsub .gsub (">" , ">" , s )
584+ if '"' in s :
585+ s = regsub .gsub ('"' , """ , s )
586+ return s
557587
558588 def showheaders (self , headers ):
559589 print "<UL>"
@@ -709,9 +739,9 @@ def translate(self, text):
709739 list .append (cgi .escape (text [i :j ]))
710740 i = j
711741 url = prog .group (0 )
712- while url [- 1 ] in ");:,.?" :
742+ while url [- 1 ] in ");:,.?' \" " :
713743 url = url [:- 1 ]
714- url = cgi .escape (url )
744+ url = self .escape (url )
715745 if ':' in url :
716746 repl = '<A HREF="%s">%s</A>' % (url , url )
717747 else :
0 commit comments