home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 15 / AACD15.ISO / AACD / Programming / Python2 / Python20_source / Tools / faqwiz / faqconf.py next >
Encoding:
Python Source  |  2000-10-25  |  14.4 KB  |  578 lines

  1. """FAQ Wizard customization module.
  2.  
  3. Edit this file to customize the FAQ Wizard.  For normal purposes, you
  4. should only have to change the FAQ section titles and the small group
  5. of parameters below it.
  6.  
  7. """
  8.  
  9. # Titles of FAQ sections
  10.  
  11. SECTION_TITLES = {
  12.     # SectionNumber : SectionTitle; need at least one entry
  13.     1: "General information and availability",
  14. }
  15.  
  16. # Parameters you definitely want to change
  17.  
  18. SHORTNAME = "Generic"            # FAQ name with "FAQ" omitted
  19. PASSWORD = ""                # Password for editing
  20. OWNERNAME = "FAQ owner"            # Name for feedback
  21. OWNEREMAIL = "nobody@anywhere.org"    # Email for feedback
  22. HOMEURL = "http://www.python.org"    # Related home page
  23. HOMENAME = "Python home"        # Name of related home page
  24. RCSBINDIR = "/usr/local/bin/"        # Directory containing RCS commands
  25.                     # (must end in a slash)
  26.  
  27. # Parameters you can normally leave alone
  28.  
  29. MAXHITS = 10                # Max #hits to be shown directly
  30. COOKIE_LIFETIME = 28*24*3600        # Cookie expiration in seconds
  31.                     # (28*24*3600 = 28 days = 4 weeks)
  32. PROCESS_PREFORMAT = 1                   # toggle whether preformatted text
  33.                                         # will replace urls and emails with 
  34.                                         # HTML links
  35.  
  36. # Markers appended to title to indicate recently change
  37. # (may contain HTML, e.g. <IMG>); and corresponding 
  38.  
  39. MARK_VERY_RECENT = " **"        # Changed very recently
  40. MARK_RECENT = " *"            # Changed recently
  41. DT_VERY_RECENT = 24*3600        # 24 hours
  42. DT_RECENT = 7*24*3600            # 7 days
  43.  
  44. EXPLAIN_MARKS = """
  45. <P>(Entries marked with ** were changed within the last 24 hours;
  46. entries marked with * were changed within the last 7 days.)
  47. <P>
  48. """
  49.  
  50. # Version -- don't change unless you edit faqwiz.py
  51.  
  52. WIZVERSION = "1.0.4"            # FAQ Wizard version
  53.  
  54. import os, sys
  55. if os.name in ['nt',]:
  56.     # On NT we'll probably be running python from a batch file,
  57.     # so sys.argv[0] is not helpful
  58.     FAQCGI = 'faq.bat'            # Relative URL of the FAQ cgi script
  59.     # LOGNAME is not typically set on NT
  60.     os.environ[ 'LOGNAME' ] = "FAQWizard"
  61. else:
  62.     # This parameter is normally overwritten with a dynamic value
  63.     FAQCGI = 'faqw.py'            # Relative URL of the FAQ cgi script
  64.     FAQCGI = os.path.basename(sys.argv[0]) or FAQCGI
  65. del os, sys
  66.  
  67. # Perl (re module) style regular expression to recognize FAQ entry
  68. # files: group(1) should be the section number, group(2) should be the
  69. # question number.  Both should be fixed width so simple-minded
  70. # sorting yields the right order.
  71.  
  72. OKFILENAME = r"^faq(\d\d)\.(\d\d\d)\.htp$"
  73.  
  74. # Format to construct a FAQ entry file name
  75.  
  76. NEWFILENAME = "faq%02d.%03d.htp"
  77.  
  78. # Load local customizations on top of the previous parameters
  79.  
  80. try:
  81.     from faqcust import *
  82. except ImportError:
  83.     pass
  84.  
  85. # Calculated parameter names
  86.  
  87. COOKIE_NAME = SHORTNAME + "-FAQ-Wizard"    # Name used for Netscape cookie
  88. FAQNAME = SHORTNAME + " FAQ"        # Name of the FAQ
  89.  
  90. # ----------------------------------------------------------------------
  91.  
  92. # Anything below this point normally needn't be changed; you would
  93. # change this if you were to create e.g. a French translation or if
  94. # you just aren't happy with the text generated by the FAQ Wizard.
  95.  
  96. # Most strings here are subject to substitution (string%dictionary)
  97.  
  98. # RCS commands
  99.  
  100. import os
  101. if os.name in ['nt', ]:
  102.     SH_RLOG = RCSBINDIR + "rlog %(file)s < NUL"
  103.     SH_RLOG_H = RCSBINDIR + "rlog -h %(file)s  < NUL"
  104.     SH_RDIFF = RCSBINDIR + "rcsdiff -r%(prev)s -r%(rev)s %(file)s < NUL"
  105.     SH_REVISION = RCSBINDIR + "co -p%(rev)s %(file)s < NUL"
  106.     ### Have to use co -l, or the file is not marked rw on NT
  107.     SH_LOCK = RCSBINDIR + "co -l %(file)s < NUL"
  108.     SH_CHECKIN =  RCSBINDIR + "ci -u %(file)s < %(tfn)s"
  109. else:
  110.     SH_RLOG = RCSBINDIR + "rlog %(file)s </dev/null 2>&1"
  111.     SH_RLOG_H = RCSBINDIR + "rlog -h %(file)s </dev/null 2>&1"
  112.     SH_RDIFF = RCSBINDIR + "rcsdiff -r%(prev)s -r%(rev)s %(file)s </dev/null 2>&1"
  113.     SH_REVISION = RCSBINDIR + "co -p%(rev)s %(file)s </dev/null 2>&1"
  114.     SH_LOCK = RCSBINDIR + "rcs -l %(file)s </dev/null 2>&1"
  115.     SH_CHECKIN =  RCSBINDIR + "ci -u %(file)s <%(tfn)s 2>&1"
  116. del os
  117.  
  118. # Titles for various output pages (not subject to substitution)
  119.  
  120. T_HOME = FAQNAME + " Wizard " + WIZVERSION
  121. T_ERROR = "Sorry, an error occurred"
  122. T_ROULETTE = FAQNAME + " Roulette"
  123. T_ALL = "The Whole " + FAQNAME
  124. T_INDEX = FAQNAME + " Index"
  125. T_SEARCH = FAQNAME + " Search Results"
  126. T_RECENT = "What's New in the " + FAQNAME
  127. T_SHOW = FAQNAME + " Entry"
  128. T_LOG = "RCS log for %s entry" % FAQNAME
  129. T_REVISION = "RCS revision for %s entry" % FAQNAME
  130. T_DIFF = "RCS diff for %s entry" % FAQNAME
  131. T_ADD = "Add an entry to the " + FAQNAME
  132. T_DELETE = "Deleting an entry from the " + FAQNAME
  133. T_EDIT = FAQNAME + " Edit Wizard"
  134. T_REVIEW = T_EDIT + " - Review Changes"
  135. T_COMMITTED = T_EDIT + " - Changes Committed"
  136. T_COMMITFAILED = T_EDIT + " - Commit Failed"
  137. T_CANTCOMMIT = T_EDIT + " - Commit Rejected"
  138. T_HELP = T_EDIT + " - Help"
  139.  
  140. # Generic prologue and epilogue
  141.  
  142. PROLOGUE = '''
  143. <HTML>
  144. <HEAD>
  145. <TITLE>%(title)s</TITLE>
  146. </HEAD>
  147.  
  148. <BODY BACKGROUND="http://www.python.org/pics/RedShort.gif"
  149.       BGCOLOR="#FFFFFF"
  150.       TEXT="#000000"
  151.       LINK="#AA0000"
  152.       VLINK="#906A6A">
  153. <H1>%(title)s</H1>
  154. '''
  155.  
  156. EPILOGUE = '''
  157. <HR>
  158. <A HREF="%(HOMEURL)s">%(HOMENAME)s</A> /
  159. <A HREF="%(FAQCGI)s?req=home">%(FAQNAME)s Wizard %(WIZVERSION)s</A> /
  160. Feedback to <A HREF="mailto:%(OWNEREMAIL)s">%(OWNERNAME)s</A>
  161.  
  162. </BODY>
  163. </HTML>
  164. '''
  165.  
  166. # Home page
  167.  
  168. HOME = """
  169. <H2>Search the %(FAQNAME)s:</H2>
  170.  
  171. <BLOCKQUOTE>
  172.  
  173. <FORM ACTION="%(FAQCGI)s">
  174.     <INPUT TYPE=text NAME=query>
  175.     <INPUT TYPE=submit VALUE="Search"><BR>
  176.     <INPUT TYPE=radio NAME=querytype VALUE=simple CHECKED>
  177.         Simple string
  178.     /
  179.     <INPUT TYPE=radio NAME=querytype VALUE=regex>
  180.         Regular expression
  181.     /<BR>
  182.     <INPUT TYPE=radio NAME=querytype VALUE=anykeywords>
  183.         Keywords (any)
  184.     /
  185.     <INPUT TYPE=radio NAME=querytype VALUE=allkeywords>
  186.         Keywords (all)
  187.     <BR>
  188.     <INPUT TYPE=radio NAME=casefold VALUE=yes CHECKED>
  189.         Fold case
  190.     /
  191.     <INPUT TYPE=radio NAME=casefold VALUE=no>
  192.         Case sensitive
  193.     <BR>
  194.     <INPUT TYPE=hidden NAME=req VALUE=search>
  195. </FORM>
  196.  
  197. </BLOCKQUOTE>
  198.  
  199. <HR>
  200.  
  201. <H2>Other forms of %(FAQNAME)s access:</H2>
  202.  
  203. <UL>
  204. <LI><A HREF="%(FAQCGI)s?req=index">FAQ index</A>
  205. <LI><A HREF="%(FAQCGI)s?req=all">The whole FAQ</A>
  206. <LI><A HREF="%(FAQCGI)s?req=recent">What's new in the FAQ?</A>
  207. <LI><A HREF="%(FAQCGI)s?req=roulette">FAQ roulette</A>
  208. <LI><A HREF="%(FAQCGI)s?req=add">Add a FAQ entry</A>
  209. <LI><A HREF="%(FAQCGI)s?req=delete">Delete a FAQ entry</A>
  210. </UL>
  211. """
  212.  
  213. # Index formatting
  214.  
  215. INDEX_SECTION = """
  216. <P>
  217. <HR>
  218. <H2>%(sec)s. %(title)s</H2>
  219. <UL>
  220. """
  221.  
  222. INDEX_ADDSECTION = """
  223. <P>
  224. <LI><A HREF="%(FAQCGI)s?req=new&section=%(sec)s">Add new entry</A>
  225. (at this point)
  226. """
  227.  
  228. INDEX_ENDSECTION = """
  229. </UL>
  230. """
  231.  
  232. INDEX_ENTRY = """\
  233. <LI><A HREF="%(FAQCGI)s?req=show&file=%(file)s">%(title)s</A>
  234. """
  235.  
  236. LOCAL_ENTRY = """\
  237. <LI><A HREF="#%(sec)s.%(num)s">%(title)s</A>
  238. """
  239.  
  240. # Entry formatting
  241.  
  242. ENTRY_HEADER1 = """
  243. <HR>
  244. <H2><A NAME="%(sec)s.%(num)s">%(title)s</A>\
  245. """
  246.  
  247. ENTRY_HEADER2 = """\
  248. </H2>
  249. """
  250.  
  251. ENTRY_FOOTER = """
  252. <A HREF="%(FAQCGI)s?req=edit&file=%(file)s">Edit this entry</A> /
  253. <A HREF="%(FAQCGI)s?req=log&file=%(file)s">Log info</A>
  254. """
  255.  
  256. ENTRY_LOGINFO = """
  257. / Last changed on %(last_changed_date)s by
  258. <A HREF="mailto:%(last_changed_email)s">%(last_changed_author)s</A>
  259. """
  260.  
  261. # Search
  262.  
  263. NO_HITS = """
  264. No hits.
  265. """
  266.  
  267. ONE_HIT = """
  268. Your search matched the following entry:
  269. """
  270.  
  271. FEW_HITS = """
  272. Your search matched the following %(count)s entries:
  273. """
  274.  
  275. MANY_HITS = """
  276. Your search matched more than %(MAXHITS)s entries.
  277. The %(count)s matching entries are presented here ordered by section:
  278. """
  279.  
  280. # RCS log and diff
  281.  
  282. LOG = """
  283. Click on a revision line to see the diff between that revision and the
  284. previous one.
  285. """
  286.  
  287. REVISIONLINK = """\
  288. <A HREF="%(FAQCGI)s?req=revision&file=%(file)s&rev=%(rev)s"
  289. >%(line)s</A>\
  290. """
  291. DIFFLINK = """\
  292.  (<A HREF="%(FAQCGI)s?req=diff&file=%(file)s&\
  293. prev=%(prev)s&rev=%(rev)s"
  294. >diff -r%(prev)s -r%(rev)s</A>)\
  295. """
  296.  
  297. # Recently changed entries
  298.  
  299. NO_RECENT = """
  300. <HR>
  301. No %(FAQNAME)s entries were changed in the last %(period)s.
  302. """
  303.  
  304. VIEW_MENU = """
  305. <HR>
  306. View entries changed in the last...
  307. <UL>
  308. <LI><A HREF="%(FAQCGI)s?req=recent&days=1">24 hours</A>
  309. <LI><A HREF="%(FAQCGI)s?req=recent&days=2">2 days</A>
  310. <LI><A HREF="%(FAQCGI)s?req=recent&days=3">3 days</A>
  311. <LI><A HREF="%(FAQCGI)s?req=recent&days=7">week</A>
  312. <LI><A HREF="%(FAQCGI)s?req=recent&days=28">4 weeks</A>
  313. <LI><A HREF="%(FAQCGI)s?req=recent&days=365250">millennium</A>
  314. </UL>
  315. """
  316.  
  317. ONE_RECENT = VIEW_MENU + """
  318. The following %(FAQNAME)s entry was changed in the last %(period)s:
  319. """
  320.  
  321. SOME_RECENT = VIEW_MENU + """
  322. The following %(count)s %(FAQNAME)s entries were changed
  323. in the last %(period)s, most recently changed shown first:
  324. """
  325.  
  326. TAIL_RECENT = VIEW_MENU
  327.  
  328. # Last changed banner on "all" (strftime format)
  329. LAST_CHANGED = "Last changed on %c %Z"
  330.  
  331. # "Compat" command prologue (this has no <BODY> tag)
  332. COMPAT = """
  333. <H1>The whole %(FAQNAME)s</H1>
  334. See also the <A HREF="%(FAQCGI)s?req=home">%(FAQNAME)s Wizard</A>.
  335. <P>
  336. """
  337.  
  338. # Editing
  339.  
  340. EDITHEAD = """
  341. <A HREF="%(FAQCGI)s?req=help">Click for Help</A>
  342. """
  343.  
  344. REVIEWHEAD = EDITHEAD
  345.  
  346.  
  347. EDITFORM1 = """
  348. <FORM ACTION="%(FAQCGI)s" METHOD=POST>
  349. <INPUT TYPE=hidden NAME=req VALUE=review>
  350. <INPUT TYPE=hidden NAME=file VALUE=%(file)s>
  351. <INPUT TYPE=hidden NAME=editversion VALUE=%(editversion)s>
  352. <HR>
  353. """
  354.  
  355. EDITFORM2 = """
  356. Title: <INPUT TYPE=text SIZE=70 NAME=title VALUE="%(title)s"><BR>
  357. <TEXTAREA COLS=72 ROWS=20 NAME=body>%(body)s
  358. </TEXTAREA><BR>
  359. Log message (reason for the change):<BR>
  360. <TEXTAREA COLS=72 ROWS=5 NAME=log>%(log)s
  361. </TEXTAREA><BR>
  362. Please provide the following information for logging purposes:
  363. <TABLE FRAME=none COLS=2>
  364.     <TR>
  365.     <TD>Name:
  366.     <TD><INPUT TYPE=text SIZE=40 NAME=author VALUE="%(author)s">
  367.     <TR>
  368.     <TD>Email:
  369.     <TD><INPUT TYPE=text SIZE=40 NAME=email VALUE="%(email)s">
  370.     <TR>
  371.     <TD>Password:
  372.     <TD><INPUT TYPE=password SIZE=20 NAME=password VALUE="%(password)s">
  373. </TABLE>
  374.  
  375. <INPUT TYPE=submit NAME=review VALUE="Preview Edit">
  376. Click this button to preview your changes.
  377. """
  378.  
  379. EDITFORM3 = """
  380. </FORM>
  381. """
  382.  
  383. COMMIT = """
  384. <INPUT TYPE=submit NAME=commit VALUE="Commit">
  385. Click this button to commit your changes.
  386. <HR>
  387. """
  388.  
  389. NOCOMMIT_HEAD = """
  390. To commit your changes, please correct the following errors in the
  391. form below and click the Preview Edit button.
  392. <UL>
  393. """
  394. NOCOMMIT_TAIL = """
  395. </UL>
  396. <HR>
  397. """
  398.  
  399. CANTCOMMIT_HEAD = """
  400. Some required information is missing:
  401. <UL>
  402. """
  403. NEED_PASSWD = "<LI>You must provide the correct password.\n"
  404. NEED_AUTHOR = "<LI>You must enter your name.\n"
  405. NEED_EMAIL = "<LI>You must enter your email address.\n"
  406. NEED_LOG = "<LI>You must enter a log message.\n"
  407. CANTCOMMIT_TAIL = """
  408. </UL>
  409. Please use your browser's Back command to correct the form and commit
  410. again.
  411. """
  412.  
  413. NEWCONFLICT = """
  414. <P>
  415. You are creating a new entry, but the entry number specified is not
  416. correct.
  417. <P>
  418. The two most common causes of this problem are:
  419. <UL>
  420. <LI>After creating the entry yourself, you went back in your browser,
  421.     edited the entry some more, and clicked Commit again.
  422. <LI>Someone else started creating a new entry in the same section and
  423.     committed before you did.
  424. </UL>
  425. (It is also possible that the last entry in the section was physically
  426. deleted, but this should not happen except through manual intervention
  427. by the FAQ maintainer.)
  428. <P>
  429. <A HREF="%(FAQCGI)s?req=new&section=%(sec)s">Click here to try
  430. again.</A>
  431. <P>
  432. """
  433.  
  434. VERSIONCONFLICT = """
  435. <P>
  436. You edited version %(editversion)s but the current version is %(version)s.
  437. <P>
  438. The two most common causes of this problem are:
  439. <UL>
  440. <LI>After committing a change, you went back in your browser,
  441.     edited the entry some more, and clicked Commit again.
  442. <LI>Someone else started editing the same entry and committed
  443.     before you did.
  444. </UL>
  445. <P>
  446. <A HREF="%(FAQCGI)s?req=show&file=%(file)s">Click here to reload
  447. the entry and try again.</A>
  448. <P>
  449. """
  450.  
  451. CANTWRITE = """
  452. Can't write file %(file)s (%(why)s).
  453. """
  454.  
  455. FILEHEADER = """\
  456. Title: %(title)s
  457. Last-Changed-Date: %(date)s
  458. Last-Changed-Author: %(author)s
  459. Last-Changed-Email: %(email)s
  460. Last-Changed-Remote-Host: %(REMOTE_HOST)s
  461. Last-Changed-Remote-Address: %(REMOTE_ADDR)s
  462. """
  463.  
  464. LOGHEADER = """\
  465. Last-Changed-Date: %(date)s
  466. Last-Changed-Author: %(author)s
  467. Last-Changed-Email: %(email)s
  468. Last-Changed-Remote-Host: %(REMOTE_HOST)s
  469. Last-Changed-Remote-Address: %(REMOTE_ADDR)s
  470.  
  471. %(log)s
  472. """
  473.  
  474. COMMITTED = """
  475. Your changes have been committed.
  476. """
  477.  
  478. COMMITFAILED = """
  479. Exit status %(sts)s.
  480. """
  481.  
  482. # Add/Delete
  483.  
  484. ADD_HEAD = """
  485. At the moment, new entries can only be added at the end of a section.
  486. This is because the entry numbers are also their
  487. unique identifiers -- it's a bad idea to renumber entries.
  488. <P>
  489. Click on the section to which you want to add a new entry:
  490. <UL>
  491. """
  492.  
  493. ADD_SECTION = """\
  494. <LI><A HREF="%(FAQCGI)s?req=new&section=%(section)s">%(section)s. %(title)s</A>
  495. """
  496.  
  497. ADD_TAIL = """
  498. </UL>
  499. """
  500.  
  501. ROULETTE = """
  502. <P>Hit your browser's Reload button to play again.<P>
  503. """
  504.  
  505. DELETE = """
  506. At the moment, there's no direct way to delete entries.
  507. This is because the entry numbers are also their
  508. unique identifiers -- it's a bad idea to renumber entries.
  509. <P>
  510. If you really think an entry needs to be deleted,
  511. change the title to "(deleted)" and make the body
  512. empty (keep the entry number in the title though).
  513. """
  514.  
  515. # Help file for the FAQ Edit Wizard
  516.  
  517. HELP = """
  518. Using the %(FAQNAME)s Edit Wizard speaks mostly for itself.  Here are
  519. some answers to questions you are likely to ask:
  520.  
  521. <P><HR>
  522.  
  523. <H2>I can review an entry but I can't commit it.</H2>
  524.  
  525. The commit button only appears if the following conditions are met:
  526.  
  527. <UL>
  528.  
  529. <LI>The Name field is not empty.
  530.  
  531. <LI>The Email field contains at least an @ character.
  532.  
  533. <LI>The Log message box is not empty.
  534.  
  535. <LI>The Password field contains the proper password.
  536.  
  537. </UL>
  538.  
  539. <P><HR>
  540.  
  541. <H2>What is the password?</H2>
  542.  
  543. At the moment, only PSA members will be told the password.  This is a
  544. good time to join the PSA!  See <A
  545. HREF="http://www.python.org/psa/">the PSA home page</A>.
  546.  
  547. <P><HR>
  548.  
  549. <H2>Can I use HTML in the FAQ entry?</H2>
  550.  
  551. Yes, if you include it in <HTML&rt; and </HTML> tags.
  552. <P>
  553. Also, if you include a URL or an email address in the text it will
  554. automatigally become an anchor of the right type.  Also, *word*
  555. is made italic (but only for single alphabetic words).
  556.  
  557. <P><HR>
  558.  
  559. <H2>How do I delineate paragraphs?</H2>
  560.  
  561. Use blank lines to separate paragraphs.
  562.  
  563. <P><HR>
  564.  
  565. <H2>How do I enter example text?</H2>
  566.  
  567. Any line that begins with a space or tab is assumed to be part of
  568. literal text.  Blocks of literal text delineated by blank lines are
  569. placed inside <PRE>...</PRE>.
  570. """
  571.  
  572. # Load local customizations again, in case they set some other variables
  573.  
  574. try:
  575.     from faqcust import *
  576. except ImportError:
  577.     pass
  578.