tags #360326 patch
tags #360354 patch
thans

Hi, 

Since doc-base 0.8.10 the files in /var/lib/doc-base/documents are encoded 
in UTF-8, please add support for this in doc-central. Also there's no need 
to convert section names to lower case, because doc-base makes them
consistent. The attached patch fixes the issues together with #360354 and 
#360326. Could you please apply it for lenny?

Regards,
robert
diff -Nur doc-central-1.8.2.old/cgi/browse.cgi doc-central-1.8.2/cgi/browse.cgi
--- doc-central-1.8.2.old/cgi/browse.cgi	2005-01-27 23:11:11.000000000 +0100
+++ doc-central-1.8.2/cgi/browse.cgi	2008-03-03 22:54:28.000000000 +0100
@@ -22,7 +22,7 @@
 print '''<DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
 <head>
-  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <title>Doc-base section index</title>
 </head>
 
@@ -41,7 +41,7 @@
 ''' % Section
 
 for doc in docutils.documents:
-	if (doc.section == string.lower(Section)):
+	if (doc.section == Section):
 		print '<tr><td bgcolor="#ffffff">'
 		print '<table cellpadding=3 cellspacing=0 border=0>'
 		print '<tr><td bgcolor="#eeeeff" align="right" valign="top"><strong>title:</strong></td><td bgcolor="#ffffff"><a href="%s">%s</a>&nbsp;<br></td></tr>' % (docutils.makedoclink(doc), doc.title)
diff -Nur doc-central-1.8.2.old/cgi/contents.cgi doc-central-1.8.2/cgi/contents.cgi
--- doc-central-1.8.2.old/cgi/contents.cgi	2005-02-26 03:53:44.000000000 +0100
+++ doc-central-1.8.2/cgi/contents.cgi	2008-03-03 22:49:29.000000000 +0100
@@ -23,7 +23,7 @@
 				print "<UL>"
 				hdr=1
 			print '<LI><A HREF="%s">%s</A>' % \
-				(docutils.makesectionlink(subsect), string.capitalize(docutils.stripsection(subsect, mydepth)))
+				(docutils.makesectionlink(subsect), docutils.stripsection(subsect, mydepth))
 			showsection(subsect)
 	if (hdr==1):
 		print "</UL>"
@@ -41,7 +41,7 @@
 print '''<DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
 <head>
-  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+  <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"
diff -Nur doc-central-1.8.2.old/cgi/docconfig.py doc-central-1.8.2/cgi/docconfig.py
--- doc-central-1.8.2.old/cgi/docconfig.py	2005-01-27 23:11:11.000000000 +0100
+++ doc-central-1.8.2/cgi/docconfig.py	2008-03-03 22:40:38.000000000 +0100
@@ -18,24 +18,20 @@
 ## System defaults
 
 # Location of the doc-base registries. 
-docbasedirs		= [ "/usr/share/doc-base" ]
+docbasedirs		= [ "/var/lib/doc-base/documents" ]
 
 # Descriptions for the various documentation settings. These should probably
 # also be in some policy document.
 SectionDescr		=  {
-	"apps"			: "Documents applications available on your system",
-	"apps/graphics"		: "Image processing and other graphics programs",
-	"apps/math"		: "Mathematics software",
-	"apps/net"		: "Network, mail, news and websoftware ",
-	"apps/programming"	: "Programming tools",
-	"apps/shells"		: "Shells",
-	"apps/sound"		: "Audio software",
-	"apps/system"		: "System management tools",
-	"apps/text"		: "Text processing software",
-	"apps/tools"		: "General utilities",
-	"apps/viewers"		: "Documentation and graphics viewers",
-	"debian"		: "Documentation on the Debian distribution and project",
-	"devel"			: "Information for software developers",
-	"help"			: "General documentation, FAQs and HOWTOs",
-	"text"			: "Document and text formats",
+	"Graphics"		: "Image processing and other graphics programs",
+	"Science/Mathematics"	: "Mathematics software",
+	"Network"		: "Network, mail, news and websoftware ",
+	"Programming"		: "Programming tools",
+	"Shells"		: "Shells",
+	"Sound"			: "Audio software",
+	"System"		: "System management tools",
+	"Text"			: "Text processing software",
+	"Viewers"		: "Documentation and graphics viewers",
+	"Debian"		: "Documentation on the Debian distribution and project",
+	"Help"			: "General documentation, FAQs and HOWTOs"
 	}
diff -Nur doc-central-1.8.2.old/cgi/docinfo.py doc-central-1.8.2/cgi/docinfo.py
--- doc-central-1.8.2.old/cgi/docinfo.py	2005-01-27 23:11:11.000000000 +0100
+++ doc-central-1.8.2/cgi/docinfo.py	2008-03-04 00:04:29.000000000 +0100
@@ -3,7 +3,7 @@
 # about a single document.
 
 # Import all system packages we need
-import sys, os, rfc822, string
+import sys, os, rfc822, string, re
 # Import all our own packages
 import sectionedfile
 
@@ -13,6 +13,10 @@
 # Default sorting order
 SortMethod	= [ SORT_TITLE ]
 
+pat_paragraph	= re.compile('^ \.\n', re.MULTILINE)
+pat_verbatim    = re.compile('((^  +[^ ].*\n)+)', re.MULTILINE)
+pat_url		= re.compile('((http|ftp)s?://[a-zA-Z0-9-]+\.[a-zA-Z0-9-./]+)')
+
 class DocumentationInfo:
 	def __init__(self,docfile=None):
 		'''DocumentationInfo constructor. If a filename is passed assume
@@ -48,6 +52,23 @@
 			elif (a>b):
 				return 1
 		return 0
+
+	def _html_encode(self, text):
+		'''HTML encodes text '''
+		text=string.replace(text, '&', '&amp;')
+		text=string.replace(text, '<', '&lt;')
+		text=string.replace(text, '>', '&gt;')
+		return text
+
+
+	def _parse_abstract(self, abstract):
+		'''This function converts abstract section'''
+		abstract=self._html_encode(abstract)
+		abstract=re.sub(pat_paragraph, '<P>', abstract)
+		abstract=re.sub(pat_verbatim, '<PRE>\n\g<1></PRE>', abstract)
+		abstract=re.sub(pat_url, '<A HREF="\g<1>">\g<1></A>', abstract)
+		return abstract
+
 		
 	def parse_info(self,docfile):
 		'''This function reads a doc-base registry file. We use the 
@@ -64,9 +85,9 @@
 		if part.has_key("Author"):
 			self.author=part.getheader("Author")
 		if part.has_key("Abstract"):
-			self.abstract=part.getheader("Abstract")
+			self.abstract=self._parse_abstract(part.getrawheader("Abstract"))
 		if part.has_key("Section"):
-			self.section=string.lower(part.getheader("Section"))
+			self.section=part.getheader("Section")
 		
 		while dd.unblock():
 			part=rfc822.Message(dd,0)
diff -Nur doc-central-1.8.2.old/cgi/docutils.py doc-central-1.8.2/cgi/docutils.py
--- doc-central-1.8.2.old/cgi/docutils.py	2005-12-13 02:08:27.000000000 +0100
+++ doc-central-1.8.2/cgi/docutils.py	2008-03-03 22:35:00.000000000 +0100
@@ -38,8 +38,8 @@
 	This means that we make sure that all intermediate sections are also
 	in the list, and that the list is sorter alphabetically.'''
 
-	for i in range(len(sections)):
-		sections[i]=string.capitalize(sections[i])
+#	for i in range(len(sections)):
+#		sections[i]=string.capitalize(sections[i])
 
 	for sect in sections:
 		lst=string.split(sect,'/')
diff -Nur doc-central-1.8.2.old/cgi/search.cgi doc-central-1.8.2/cgi/search.cgi
--- doc-central-1.8.2.old/cgi/search.cgi	2005-01-27 23:11:11.000000000 +0100
+++ doc-central-1.8.2/cgi/search.cgi	2008-03-03 22:49:52.000000000 +0100
@@ -34,7 +34,7 @@
 print '''<DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
 <head>
-  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+  <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"
@@ -59,7 +59,7 @@
 		links = docutils.makedoclinks(doc)
 		if links != '':
 			print '<tr><th bgcolor="#eeeeff" align="right" valign="top"><strong>formats:</strong></th><td bgcolor="#ffffff">%s&nbsp;<br></td></tr>' % links
-		print '<tr><th bgcolor="#eeeeff" align="right" valign="top"><strong>section:</strong></th><td bgcolor="#ffffff"><a href="%s">%s</a>&nbsp;<br></td></tr>' % (docutils.makesectionlink(doc.section), string.capitalize(doc.section))
+		print '<tr><th bgcolor="#eeeeff" align="right" valign="top"><strong>section:</strong></th><td bgcolor="#ffffff"><a href="%s">%s</a>&nbsp;<br></td></tr>' % (docutils.makesectionlink(doc.section), doc.section)
 		print '<tr><th bgcolor="#eeeeff" align="right" valign="top"><strong>author:</strong></th><td bgcolor="#ffffff">%s&nbsp;<br></td></tr>' % doc.author
 		print '<tr><th bgcolor="#eeeeff" align="right" valign="top"><strong>abstract:</strong></th><td bgcolor="#ffffff">%s&nbsp;<br></td></tr>' % doc.abstract
 		if docutils.makeextralinks(doc.package):
diff -Nur doc-central-1.8.2.old/cgi/viewdoc.cgi doc-central-1.8.2/cgi/viewdoc.cgi
--- doc-central-1.8.2.old/cgi/viewdoc.cgi	2005-01-27 23:11:11.000000000 +0100
+++ doc-central-1.8.2/cgi/viewdoc.cgi	2008-03-03 22:41:33.000000000 +0100
@@ -17,7 +17,7 @@
 print '''<DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
 <head>
-  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <title>%s</title>
 </head>
 
diff -Nur doc-central-1.8.2.old/debian/control doc-central-1.8.2/debian/control
--- doc-central-1.8.2.old/debian/control	2005-12-13 02:08:27.000000000 +0100
+++ doc-central-1.8.2/debian/control	2008-04-16 21:16:59.000000000 +0200
@@ -7,7 +7,7 @@
 
 Package: doc-central
 Architecture: all
-Depends: apache | httpd, python, info2www
+Depends: apache | httpd, python, info2www, doc-base (>= 0.8.10)
 Recommends: w3m | www-browser
 Description: web-based documentation browser
  Doc-Central is a tool to browse the documentation installed on your

Reply via email to