Tue Oct 10 00:04:21 ART 2006  Alberto Bertogli <albertito@gmail.com>
  tagged 0.16
Wed Aug  9 14:54:30 ART 2006  Alberto Bertogli <albertito@gmail.com>
  * Handle empty lines in print_darcs_diff().
  A "setpref" patch can output empty lines when seen with darcs_diff. Handle
  that case by ignoring them.
  
  Thanks to VMiklos from reporting it.
Mon Jul 31 02:29:33 ART 2006  Alberto Bertogli <albertito@gmail.com>
  tagged 0.16-rc1
Mon Jul 31 02:28:34 ART 2006  Alberto Bertogli <albertito@gmail.com>
  * Remove some unnecessary newlines in html output.
Mon Jul 31 02:10:03 ART 2006  Alberto Bertogli <albertito@gmail.com>
  * Make browsing files in tree root easier.
  This patch makes it easier to browse files in the root of the tree, by making
  it simpler to return to the root tree view.
Mon Jul 31 01:54:05 ART 2006  Alberto Bertogli <albertito@gmail.com>
  * Allow projects to link to external sites.
  Add a 'repoprojurl' configuration option to put a reference to an external
  project site. It appears in the project summary, just like url.
  
  It also supports multidir, both automatic detection in the third_party
  directory, and static construction.
  
  Thanks to Alexandre Rossi for the idea and preliminary patch.
Mon Jul 31 01:24:50 ART 2006  Alberto Bertogli <albertito@gmail.com>
  * Convert remaining auriga references to example.com.
Mon Jul 31 01:10:20 ART 2006  Alberto Bertogli <albertito@gmail.com>
  * Implement url and scriptname autodetection.
  This patch implements autodetection of the url and scriptname of darcsweb.
  It's based on a suggestion from Tobias Gruetzmacher.
  
  It relies on variables according to the CGI/1.1 standard, and works only if
  cache is not enabled. If it is, the variables must be set manually as before.
  
  The problem with the cache is multi-host access: if a page not in the cache is
  accesed as http://hosta/dw/..., then the cached page will reference "hosta".
  If then it's accessed from hostb, there will be a reference to hosta that it's
  possibly broken. It's actually a quite common case when you have localhost and
  external access.
Fri Jul 14 16:27:30 ART 2006  Alberto Bertogli <albertogli@telpin.com.ar>
  * Add autourl support for multidir.
  This patch adds a new option for multidir config entries, named "autourl". If
  set, it will take the contents of "_darcs/third_party/darcsweb/url" and use it
  as repourl.
  
  Thanks to Marco Baringer for suggestion and preliminary patch.
Fri Jul 14 15:09:52 ART 2006  Alberto Bertogli <albertogli@telpin.com.ar>
  * Use example.com for url examples.
Thu Jul  6 14:04:59 ART 2006  Alberto Bertogli <albertogli@telpin.com.ar>
  * Put directories in blue on tree view.
  To make directories easy to spot, make them blue and with a "/" at the end.
  Then they become obvious, but not too distracting.
  
  Thanks to Dan Pescu for all the suggestions.
Mon May 29 12:04:37 ART 2006  Alberto Bertogli <albertogli@telpin.com.ar>
  * Escape repository descriptions.
  Escape all repository descriptions, because they might contain unfrendly
  characters for XML (including HTML, ATOM and RSS).
  
  Thanks to Clive Crous for the report and a slightly different patch.
Sat May 13 20:23:21 ART 2006  Alberto Bertogli <albertogli@telpin.com.ar>
  * Support the new pristine directory.
  
  darcs 1.0.7 uses a new name for the pristine directory, "pristine", instead of
  the classic "current".
  
  This patch adds support for that directory, without dropping "current" because
  it's still heavily used in existing repositories.
Tue Mar  7 23:13:19 ART 2006  Alberto Bertogli <albertogli@telpin.com.ar>
  tagged 0.15
diff -rN -u old-darcsweb/config.py.sample new-darcsweb/config.py.sample
--- old-darcsweb/config.py.sample	2006-10-10 00:27:17.000000000 -0300
+++ new-darcsweb/config.py.sample	2006-10-10 00:27:17.000000000 -0300
@@ -1,12 +1,6 @@
 
 # base configuration, common to all repos
 class base:
-	# this script's name, usually just "darcsweb.cgi" unless you rename it
-	myname = "darcsweb.cgi"
-
-	# our url, used only to generate RSS links, without the script name
-	myurl = "http://albertito.homeip.net:8026/darcsweb"
-
 	# location of the darcs logo
 	darcslogo = "darcs.png"
 
@@ -16,6 +10,14 @@
 	# the CSS file to use
 	cssfile = 'style.css'
 
+	# this script's name, usually just "darcsweb.cgi" unless you rename
+	# it; if you leave this commented it will be detected automatically
+	#myname = "darcsweb.cgi"
+
+	# our url, used only to generate RSS links, without the script name;
+	# if you leave this commented it will be detected automatically
+	#myurl = "http://example.com/darcsweb"
+
 	# optionally, you can specify the path to the darcs executable; if you
 	# leave this commented, the one on $PATH will be used (this is
 	# normally what you want)
@@ -38,6 +40,8 @@
 	# fine.
 	# If you leave the entry commented, no cache will be ever used;
 	# otherwise the directory is assumed to exist and be writeable.
+	# If you use this option you must set the "myname" and "myurl"
+	# variables.
 	#cachedir = '/tmp/darcsweb-cache'
 
 	# By default, darcsweb's search looks in the last 100 commits; you can
@@ -73,7 +77,7 @@
 	repodir = '/usr/src/repo1'
 
 	# an url so people know where to do "darcs get" from
-	repourl = 'http://auriga.wearlab.de/~alb/repos/repo1/'
+	repourl = 'http://example.com/repos/repo1/'
 
 	# the encoding used in the repo
 	# NOTE: if you use utf8, you _must_ write 'utf8' (and not the variants
@@ -91,12 +95,17 @@
 	# either, a default one is used)
 	#footer = "I don't like being cold"
 
+	# Each repository may show a link to some website associated with it.
+	# This is typically useful if you've got a website describing the
+	# software in your repository.
+	#repoprojurl = 'http://example.com/projects/repo1/'
+
 
 class repo2:
 	reponame = 'repo2'
 	repodesc = 'Second example repository'
 	repodir = '/usr/src/repo2'
-	repourl = 'http://auriga.wearlab.de/~alb/repos/repo2/'
+	repourl = 'http://example.com/repos/repo2/'
 	repoencoding = 'latin1'
 
 
@@ -118,9 +127,12 @@
 	multidir = '/usr/local/src'
 	#multidir_deep = False
 	repodesc = 'Repository for %(name)s'
-	repourl = 'http://auriga.wearlab.de/~alb/repos/%(name)s/'
+	repourl = 'http://example.com/repos/%(name)s/'
 	repoencoding = 'latin1'
 
+	# optional, see above
+	#repoprojurl = 'http://example.com/projects/%(name)s/'
+
 	# if you want to exclude some directories, add them to this list (note
 	# they're relative to multidir, not absolute)
 	#exclude = 'dir1', 'dir2'
@@ -135,4 +147,13 @@
 	# True. It defaults to False.
 	#autoexclude = True
 
+	# if you want urls to be picked up automatically from the file named
+	# "_darcs/third_party/darcsweb/url" (one line only), set this to
+	# True. It defaults to False.
+	#autourl = True
+
+	# if you want the projects urls to be picked up automatically from the
+	# file named "_darcs/third_party/darcsweb/extdoc" (one line only), set
+	# this to True. It defaults to False.
+	#autoprojurl = True
 
diff -rN -u old-darcsweb/darcsweb.cgi new-darcsweb/darcsweb.cgi
--- old-darcsweb/darcsweb.cgi	2006-10-10 00:27:17.000000000 -0300
+++ new-darcsweb/darcsweb.cgi	2006-10-10 00:27:17.000000000 -0300
@@ -218,9 +218,13 @@
 	return 0
 
 def realpath(fname):
+	realf = filter_file(config.repodir + '/_darcs/pristine/' + fname)
+	if os.path.exists(realf):
+		return realf
 	realf = filter_file(config.repodir + '/_darcs/current/' + fname)
-	if not os.path.exists(realf):
-		realf = filter_file(config.repodir + '/' + fname)
+	if os.path.exists(realf):
+		return realf
+	realf = filter_file(config.repodir + '/' + fname)
 	return realf
 
 def log_times(cache_hit, repo = None, event = None):
@@ -1043,6 +1047,8 @@
 			continue
 
 		l = l.strip()
+		if not l:
+			continue
 
 		if l[0] == '+':
 			cl = 'class="pre" style="color:#008800;"'
@@ -1199,7 +1205,7 @@
 		print """\
 <div class="pre">\
 <a id="l%(c)d" href="#l%(c)d" class="linenr">%(c)4d</a> %(l)s\
-</div>
+</div>\
 		""" % {
 			'c': count,
 			'l': l
@@ -1303,7 +1309,7 @@
 <a href="%(link)s" title="%(title)s" class="annotate_desc">%(date)s %(desc)s</a> \
 <a href="%(link)s" title="%(title)s" class="linenr">%(c)4d</a> \
 <a href="%(link)s" title="%(title)s" class="line">%(text)s</a>\
-</div>
+</div>\
 		""" % {
 			'class': lineclass,
 			'style': linestyle,
@@ -1335,7 +1341,8 @@
 
 	print '<div class="title">&nbsp;</div>'
 	print '<table cellspacing="0">'
-	print '  <tr><td>description</td><td>%s</td></tr>' % config.repodesc
+	print '  <tr><td>description</td><td>%s</td></tr>' % \
+			escape(config.repodesc)
 	if owner:
 		print '  <tr><td>owner</td><td>%s</td></tr>' % escape(owner)
 	if len(ps) > 0:
@@ -1343,6 +1350,10 @@
 			ps[0].local_date_str
 	print '  <tr><td>url</td><td><a href="%(url)s">%(url)s</a></td></tr>' %\
 			{ 'url': config.repourl }
+	if config.repoprojurl:
+		print '  <tr><td>project url</td>'
+		print '  <td><a href="%(url)s">%(url)s</td></tr>' % \
+			{ 'url': config.repoprojurl }
 	print '</table>'
 
 	print_shortlog(15)
@@ -1733,7 +1744,9 @@
 
 		if f in dlist:
 			print """
-  <td><a class="list" href="%(myrname)s;a=tree;f=%(fullf)s">%(f)s</a></td>
+  <td>
+    <a class="link" href="%(myrname)s;a=tree;f=%(fullf)s">%(f)s/</a>
+  </td>
   <td class="link">
     <a href="%(myrname)s;a=filehistory;f=%(fullf)s">history</a> |
     <a href="%(myrname)s;a=tree;f=%(fullf)s">tree</a>
@@ -1765,21 +1778,24 @@
 	print_header()
 	print_navbar(f = fname)
 	filepath = os.path.dirname(fname)
-	print """
-	<div class="title"><b>
-	"""
 
-	# and the linked, with links
-	parts = filepath.split('/')
-	print '/ '
-	sofar = '/'
-	for p in parts:
-		if not p: continue
-		sofar += '/' + p
-		print '<a href="%s;a=tree;f=%s">%s</a> /' % \
-				(config.myreponame, sofar, p)
+	if filepath == '/':
+		print '<div><a class="title" href="%s;a=tree">/</a></div>' % \
+			(config.myreponame)
+	else:
+		print '<div class="title"><b>'
+
+		# and the linked, with links
+		parts = filepath.split('/')
+		print '/ '
+		sofar = '/'
+		for p in parts:
+			if not p: continue
+			sofar += '/' + p
+			print '<a href="%s;a=tree;f=%s">%s</a> /' % \
+					(config.myreponame, sofar, p)
 
-	print '</b></div>'
+		print '</b></div>'
 
 	print_blob(fname)
 	print_footer()
@@ -1866,7 +1882,7 @@
   	""" % {
 		'reponame': config.reponame,
 		'url': config.myurl + '/' + config.myreponame,
-		'desc': config.repodesc,
+		'desc': escape(config.repodesc),
 		'lastmod': str_lastmod,
 	}
 
@@ -1940,7 +1956,7 @@
   	""" % {
 		'reponame': config.reponame,
 		'url': config.myurl + '/' + config.myreponame,
-		'desc': config.repodesc,
+		'desc': escape(config.repodesc),
 	}
 
 	ps = get_last_patches(20)
@@ -2050,6 +2066,7 @@
 
 def do_listrepos():
 	import config as all_configs
+	expand_multi_config(all_configs)
 
 	# the header here is special since we don't have a repo
 	print "Content-type: text/html; charset=utf-8\n"
@@ -2093,7 +2110,6 @@
 
 	# some python magic
 	alt = True
-	expand_multi_config(all_configs)
 	for conf in dir(all_configs):
 		if conf.startswith('__'):
 			continue
@@ -2116,7 +2132,7 @@
 </td>
 </tr>
 		""" % {
-			'myname': all_configs.base.myname,
+			'myname': config.myname,
 			'dname': name,
 			'name': urllib.quote(name),
 			'desc': shorten_str(desc, 60)
@@ -2178,17 +2194,42 @@
 			else:
 				desc = c.repodesc % { 'name': name }
 
+			if 'autourl' in dir(c) and c.autourl:
+				dpath = fulldir + \
+					'/_darcs/third_party/darcsweb/url'
+				if os.access(dpath, os.R_OK):
+					url = open(dpath).read()
+				else:
+					url = c.repourl % { 'name': name }
+			else:
+				url = c.repourl % { 'name': name }
+
+			if 'autoprojurl' in dir(c) and c.autoprojurl:
+				dpath = fulldir + \
+					'/_darcs/third_party/darcsweb/projurl'
+				if os.access(dpath, os.R_OK):
+					projurl = open(dpath).read()
+				elif 'repoprojurl' in dir(c):
+					projurl = c.repoprojurl % {'name': name}
+				else:
+					projurl = None
+			elif 'repoprojurl' in dir(c):
+				projurl = c.repoprojurl % { 'name': name }
+			else:
+				projurl = None
+
 			rdir = fulldir
-			url = c.repourl % { 'name': name }
 			class tmp_config:
 				reponame = name
 				repodir = rdir
 				repodesc = desc
 				repourl = url
 				repoencoding = c.repoencoding
+				repoprojurl = projurl
 
 				if 'footer' in dir(c):
 					footer = c.footer
+
 			config.__setattr__(name, tmp_config)
 
 def fill_config(name = None):
@@ -2213,17 +2254,38 @@
 
 	# fill the configuration
 	base = all_configs.base
-	config.myname = base.myname
-	config.myurl = base.myurl
+	if 'myname' not in dir(base):
+		# SCRIPT_NAME has the full path, we only take the file name
+		config.myname = os.path.basename(os.environ['SCRIPT_NAME'])
+	else:
+		config.myname = base.myname
+
+	if 'myurl' not in dir(base) and 'cachedir' not in dir(base):
+		n = os.environ['SERVER_NAME']
+		p = os.environ['SERVER_PORT']
+		s = os.environ['SCRIPT_NAME']
+		if p == '80':
+			p = ''
+		else:
+			p = ':' + p
+		config.myurl = 'http://%s%s%s' % (n, p, s)
+	else:
+		config.myurl = base.myurl
+
 	config.darcslogo = base.darcslogo
 	config.darcsfav = base.darcsfav
 	config.cssfile = base.cssfile
 	if name:
-		config.myreponame = base.myname + '?r=' + urllib.quote(name)
+		config.myreponame = config.myname + '?r=' + urllib.quote(name)
 		config.reponame = c.reponame
 		config.repodesc = c.repodesc
 		config.repodir = c.repodir
 		config.repourl = c.repourl
+
+		config.repoprojurl = None
+		if 'repoprojurl' in dir(c):
+			config.repoprojurl = c.repoprojurl
+
 		# repoencoding must be a tuple
 		if isinstance(c.repoencoding, str):
 			config.repoencoding = (c.repoencoding, )


