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