• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""FAQ Wizard customization module.
2
3Edit this file to customize the FAQ Wizard.  For normal purposes, you
4should only have to change the FAQ section titles and the small group
5of parameters below it.
6
7"""
8
9# Titles of FAQ sections
10
11SECTION_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
18SHORTNAME = "Generic"                   # FAQ name with "FAQ" omitted
19PASSWORD = ""                           # Password for editing
20OWNERNAME = "FAQ owner"                 # Name for feedback
21OWNEREMAIL = "nobody@anywhere.org"      # Email for feedback
22HOMEURL = "http://www.python.org"       # Related home page
23HOMENAME = "Python home"                # Name of related home page
24RCSBINDIR = "/usr/local/bin/"           # Directory containing RCS commands
25                                        # (must end in a slash)
26
27# Parameters you can normally leave alone
28
29MAXHITS = 10                            # Max #hits to be shown directly
30COOKIE_LIFETIME = 28*24*3600            # Cookie expiration in seconds
31                                        # (28*24*3600 = 28 days = 4 weeks)
32PROCESS_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
39MARK_VERY_RECENT = " **"                # Changed very recently
40MARK_RECENT = " *"                      # Changed recently
41DT_VERY_RECENT = 24*3600                # 24 hours
42DT_RECENT = 7*24*3600                   # 7 days
43
44EXPLAIN_MARKS = """
45<P>(Entries marked with ** were changed within the last 24 hours;
46entries marked with * were changed within the last 7 days.)
47<P>
48"""
49
50# Version -- don't change unless you edit faqwiz.py
51
52WIZVERSION = "1.0.4"                    # FAQ Wizard version
53
54import os, sys
55if 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"
61else:
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
65del 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
72OKFILENAME = r"^faq(\d\d)\.(\d\d\d)\.htp$"
73
74# Format to construct a FAQ entry file name
75
76NEWFILENAME = "faq%02d.%03d.htp"
77
78# Load local customizations on top of the previous parameters
79
80try:
81    from faqcust import *
82except ImportError:
83    pass
84
85# Calculated parameter names
86
87COOKIE_NAME = SHORTNAME + "-FAQ-Wizard" # Name used for Netscape cookie
88FAQNAME = 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
100import os
101if 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"
109else:
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"
116del os
117
118# Titles for various output pages (not subject to substitution)
119
120T_HOME = FAQNAME + " Wizard " + WIZVERSION
121T_ERROR = "Sorry, an error occurred"
122T_ROULETTE = FAQNAME + " Roulette"
123T_ALL = "The Whole " + FAQNAME
124T_INDEX = FAQNAME + " Index"
125T_SEARCH = FAQNAME + " Search Results"
126T_RECENT = "What's New in the " + FAQNAME
127T_SHOW = FAQNAME + " Entry"
128T_LOG = "RCS log for %s entry" % FAQNAME
129T_REVISION = "RCS revision for %s entry" % FAQNAME
130T_DIFF = "RCS diff for %s entry" % FAQNAME
131T_ADD = "Add an entry to the " + FAQNAME
132T_DELETE = "Deleting an entry from the " + FAQNAME
133T_EDIT = FAQNAME + " Edit Wizard"
134T_REVIEW = T_EDIT + " - Review Changes"
135T_COMMITTED = T_EDIT + " - Changes Committed"
136T_COMMITFAILED = T_EDIT + " - Commit Failed"
137T_CANTCOMMIT = T_EDIT + " - Commit Rejected"
138T_HELP = T_EDIT + " - Help"
139
140# Generic prologue and epilogue
141
142PROLOGUE = '''
143<HTML>
144<HEAD>
145<TITLE>%(title)s</TITLE>
146</HEAD>
147
148<BODY
149      BGCOLOR="#FFFFFF"
150      TEXT="#000000"
151      LINK="#AA0000"
152      VLINK="#906A6A">
153<H1>%(title)s</H1>
154'''
155
156EPILOGUE = '''
157<HR>
158<A HREF="%(HOMEURL)s">%(HOMENAME)s</A> /
159<A HREF="%(FAQCGI)s?req=home">%(FAQNAME)s Wizard %(WIZVERSION)s</A> /
160Feedback to <A HREF="mailto:%(OWNEREMAIL)s">%(OWNERNAME)s</A>
161
162</BODY>
163</HTML>
164'''
165
166# Home page
167
168HOME = """
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
215INDEX_SECTION = """
216<P>
217<HR>
218<H2>%(sec)s. %(title)s</H2>
219<UL>
220"""
221
222INDEX_ADDSECTION = """
223<P>
224<LI><A HREF="%(FAQCGI)s?req=new&amp;section=%(sec)s">Add new entry</A>
225(at this point)
226"""
227
228INDEX_ENDSECTION = """
229</UL>
230"""
231
232INDEX_ENTRY = """\
233<LI><A HREF="%(FAQCGI)s?req=show&amp;file=%(file)s">%(title)s</A>
234"""
235
236LOCAL_ENTRY = """\
237<LI><A HREF="#%(sec)s.%(num)s">%(title)s</A>
238"""
239
240# Entry formatting
241
242ENTRY_HEADER1 = """
243<HR>
244<H2><A NAME="%(sec)s.%(num)s">%(title)s</A>\
245"""
246
247ENTRY_HEADER2 = """\
248</H2>
249"""
250
251ENTRY_FOOTER = """
252<A HREF="%(FAQCGI)s?req=edit&amp;file=%(file)s">Edit this entry</A> /
253<A HREF="%(FAQCGI)s?req=log&amp;file=%(file)s">Log info</A>
254"""
255
256ENTRY_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
263NO_HITS = """
264No hits.
265"""
266
267ONE_HIT = """
268Your search matched the following entry:
269"""
270
271FEW_HITS = """
272Your search matched the following %(count)s entries:
273"""
274
275MANY_HITS = """
276Your search matched more than %(MAXHITS)s entries.
277The %(count)s matching entries are presented here ordered by section:
278"""
279
280# RCS log and diff
281
282LOG = """
283Click on a revision line to see the diff between that revision and the
284previous one.
285"""
286
287REVISIONLINK = """\
288<A HREF="%(FAQCGI)s?req=revision&amp;file=%(file)s&amp;rev=%(rev)s"
289>%(line)s</A>\
290"""
291DIFFLINK = """\
292 (<A HREF="%(FAQCGI)s?req=diff&amp;file=%(file)s&amp;\
293prev=%(prev)s&amp;rev=%(rev)s"
294>diff -r%(prev)s -r%(rev)s</A>)\
295"""
296
297# Recently changed entries
298
299NO_RECENT = """
300<HR>
301No %(FAQNAME)s entries were changed in the last %(period)s.
302"""
303
304VIEW_MENU = """
305<HR>
306View entries changed in the last...
307<UL>
308<LI><A HREF="%(FAQCGI)s?req=recent&amp;days=1">24 hours</A>
309<LI><A HREF="%(FAQCGI)s?req=recent&amp;days=2">2 days</A>
310<LI><A HREF="%(FAQCGI)s?req=recent&amp;days=3">3 days</A>
311<LI><A HREF="%(FAQCGI)s?req=recent&amp;days=7">week</A>
312<LI><A HREF="%(FAQCGI)s?req=recent&amp;days=28">4 weeks</A>
313<LI><A HREF="%(FAQCGI)s?req=recent&amp;days=365250">millennium</A>
314</UL>
315"""
316
317ONE_RECENT = VIEW_MENU + """
318The following %(FAQNAME)s entry was changed in the last %(period)s:
319"""
320
321SOME_RECENT = VIEW_MENU + """
322The following %(count)s %(FAQNAME)s entries were changed
323in the last %(period)s, most recently changed shown first:
324"""
325
326TAIL_RECENT = VIEW_MENU
327
328# Last changed banner on "all" (strftime format)
329LAST_CHANGED = "Last changed on %c %Z"
330
331# "Compat" command prologue (this has no <BODY> tag)
332COMPAT = """
333<H1>The whole %(FAQNAME)s</H1>
334See also the <A HREF="%(FAQCGI)s?req=home">%(FAQNAME)s Wizard</A>.
335<P>
336"""
337
338# Editing
339
340EDITHEAD = """
341<A HREF="%(FAQCGI)s?req=help">Click for Help</A>
342"""
343
344REVIEWHEAD = EDITHEAD
345
346
347EDITFORM1 = """
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
355EDITFORM2 = """
356Title: <INPUT TYPE=text SIZE=70 NAME=title VALUE="%(title)s"><BR>
357<TEXTAREA COLS=72 ROWS=20 NAME=body>%(body)s
358</TEXTAREA><BR>
359Log message (reason for the change):<BR>
360<TEXTAREA COLS=72 ROWS=5 NAME=log>%(log)s
361</TEXTAREA><BR>
362Please 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">
376Click this button to preview your changes.
377"""
378
379EDITFORM3 = """
380</FORM>
381"""
382
383COMMIT = """
384<INPUT TYPE=submit NAME=commit VALUE="Commit">
385Click this button to commit your changes.
386<HR>
387"""
388
389NOCOMMIT_HEAD = """
390To commit your changes, please correct the following errors in the
391form below and click the Preview Edit button.
392<UL>
393"""
394NOCOMMIT_TAIL = """
395</UL>
396<HR>
397"""
398
399CANTCOMMIT_HEAD = """
400Some required information is missing:
401<UL>
402"""
403NEED_PASSWD = "<LI>You must provide the correct password.\n"
404NEED_AUTHOR = "<LI>You must enter your name.\n"
405NEED_EMAIL = "<LI>You must enter your email address.\n"
406NEED_LOG = "<LI>You must enter a log message.\n"
407CANTCOMMIT_TAIL = """
408</UL>
409Please use your browser's Back command to correct the form and commit
410again.
411"""
412
413NEWCONFLICT = """
414<P>
415You are creating a new entry, but the entry number specified is not
416correct.
417<P>
418The 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
426deleted, but this should not happen except through manual intervention
427by the FAQ maintainer.)
428<P>
429<A HREF="%(FAQCGI)s?req=new&amp;section=%(sec)s">Click here to try
430again.</A>
431<P>
432"""
433
434VERSIONCONFLICT = """
435<P>
436You edited version %(editversion)s but the current version is %(version)s.
437<P>
438The 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&amp;file=%(file)s">Click here to reload
447the entry and try again.</A>
448<P>
449"""
450
451CANTWRITE = """
452Can't write file %(file)s (%(why)s).
453"""
454
455FILEHEADER = """\
456Title: %(title)s
457Last-Changed-Date: %(date)s
458Last-Changed-Author: %(author)s
459Last-Changed-Email: %(email)s
460Last-Changed-Remote-Host: %(REMOTE_HOST)s
461Last-Changed-Remote-Address: %(REMOTE_ADDR)s
462"""
463
464LOGHEADER = """\
465Last-Changed-Date: %(date)s
466Last-Changed-Author: %(author)s
467Last-Changed-Email: %(email)s
468Last-Changed-Remote-Host: %(REMOTE_HOST)s
469Last-Changed-Remote-Address: %(REMOTE_ADDR)s
470
471%(log)s
472"""
473
474COMMITTED = """
475Your changes have been committed.
476"""
477
478COMMITFAILED = """
479Exit status %(sts)s.
480"""
481
482# Add/Delete
483
484ADD_HEAD = """
485At the moment, new entries can only be added at the end of a section.
486This is because the entry numbers are also their
487unique identifiers -- it's a bad idea to renumber entries.
488<P>
489Click on the section to which you want to add a new entry:
490<UL>
491"""
492
493ADD_SECTION = """\
494<LI><A HREF="%(FAQCGI)s?req=new&amp;section=%(section)s">%(section)s. %(title)s</A>
495"""
496
497ADD_TAIL = """
498</UL>
499"""
500
501ROULETTE = """
502<P>Hit your browser's Reload button to play again.<P>
503"""
504
505DELETE = """
506At the moment, there's no direct way to delete entries.
507This is because the entry numbers are also their
508unique identifiers -- it's a bad idea to renumber entries.
509<P>
510If you really think an entry needs to be deleted,
511change the title to "(deleted)" and make the body
512empty (keep the entry number in the title though).
513"""
514
515# Help file for the FAQ Edit Wizard
516
517HELP = """
518Using the %(FAQNAME)s Edit Wizard speaks mostly for itself.  Here are
519some 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
525The 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
543At the moment, only PSA members will be told the password.  This is a
544good time to join the PSA!  See <A
545HREF="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
551Yes, if you include it in &lt;HTML&rt; and &lt;/HTML&gt; tags.
552<P>
553Also, if you include a URL or an email address in the text it will
554automatigally become an anchor of the right type.  Also, *word*
555is made italic (but only for single alphabetic words).
556
557<P><HR>
558
559<H2>How do I delineate paragraphs?</H2>
560
561Use blank lines to separate paragraphs.
562
563<P><HR>
564
565<H2>How do I enter example text?</H2>
566
567Any line that begins with a space or tab is assumed to be part of
568literal text.  Blocks of literal text delineated by blank lines are
569placed inside &lt;PRE&gt;...&lt;/PRE&gt;.
570"""
571
572# Load local customizations again, in case they set some other variables
573
574try:
575    from faqcust import *
576except ImportError:
577    pass
578