File: contents.cgi

package info (click to toggle)
doc-central 1.8.2%2Bnmu2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 128 kB
  • ctags: 49
  • sloc: python: 475; sh: 12; makefile: 1
file content (60 lines) | stat: -rwxr-xr-x 1,462 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#! /usr/bin/python

# Import all system packages we need
import cgi, os, sys, string, re
# Import all our own stuff
import docinfo, docconfig, docutils

def showsection(sect):
	'''Recursively print a tree of all sections'''

	mydepth=docutils.sectiondepth(sect)
	hdr=0

	if len(sect):
		matcher=re.compile(re.escape(sect+"/"), re.IGNORECASE)
	else:
		matcher=re.compile("")

	for subsect in docutils.sections:
		height=(docutils.sectiondepth(subsect)-mydepth)
		if (matcher.match(subsect) and (height==1)):
			if (hdr==0):
				print "<UL>"
				hdr=1
			print '<LI><A HREF="%s">%s</A>' % \
				(docutils.makesectionlink(subsect), docutils.stripsection(subsect, mydepth))
			showsection(subsect)
	if (hdr==1):
		print "</UL>"

# Get our configuration
docutils.extractcookies()
docutils.extractcgiparams()
# Read the list of documents available
docutils.processdirs()

docutils.cleanupsections()

print "Content-Type: text/html\n"

print '''<DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>Doc-Base section index</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000cc" vlink="#000066"
  alink="#ff0000"><base target="main">
<a href="/dc/main.html">Home</a>
'''

showsection("")

print """
<form action="%s">
<input type="text" name="keyword">
<input type="submit" value="search">
</form>

</body></html>""" % docutils.scriptname("search.cgi");