allow custom "last" value in url, eg to view all patches on one page --> to head
Sun Nov 13 11:23:24 UTC 2011 pinterface <pix@kepibu.org>
* Add support for calling an external program to generate README markup
Sun Nov 13 11:07:41 UTC 2011 pinterface <pix@kepibu.org>
* minidom chokes on form feed character
Sat Nov 5 10:18:50 UTC 2011 pinterface <pix@kepibu.org>
* Show README in summary view, if it exists
Blatantly stealing the idea from Github, but not as fully implemented.
Tue Nov 1 10:19:57 UTC 2011 pinterface <pix@kepibu.org>
* Add Owner and Last Change columns to repo listing
This is a little ugly due to the global config object. Boo.
Tue Nov 1 09:54:21 UTC 2011 pinterface <pix@kepibu.org>
* Skip comments and blank lines in the author file
Tue Nov 1 08:30:12 UTC 2011 pinterface <pix@kepibu.org>
* Add ability to specify a mailing list URL for repositories
Tue Nov 1 08:12:39 UTC 2011 pinterface <pix@kepibu.org>
* Don't require myurl be specified when cachedir is in use
Wed Nov 24 15:52:33 UTC 2010 Alberto Bertogli <albertito@blitiri.com.ar>
tagged 1.2-rc1
Fri Oct 15 12:55:46 UTC 2010 Dave Love <fx@gnu.org>
* Use diff --quiet.
Prevents `Copying pristine' messages in output with darcs pre-2.5.
Fri Jun 25 00:32:55 UTC 2010 Alberto Bertogli <albertito@blitiri.com.ar>
* Do not use string exceptions
String exceptions are deprecated and will soon no longer be supported at all.
Most of the instances of string exceptions in our code were not meant to be
catched, but just to get meaningful backtraces.
This patch replaces them with appropriate, usually generic, exceptions that
serve the same purpose.
Sun Mar 28 18:21:44 UTC 2010 Simon Michael <simon@joyful.com>
* log view: display the patch name just once, tighten up whitespace
Sun Mar 28 16:40:18 UTC 2010 Simon Michael <simon@joyful.com>
* allow custom "last" value in url, eg to view all patches on one page
diff -rN -u old-darcsweb/config.py.sample new-darcsweb/config.py.sample
--- old-darcsweb/config.py.sample 2013-07-24 05:54:53.000000000 +0000
+++ new-darcsweb/config.py.sample 2013-07-24 05:54:53.000000000 +0000
@@ -84,6 +84,10 @@
# option.
#disable_annotate = True
+ # If you'd like a wider range of README file types than darcsweb
+ # provides, set readme_converter to a program which takes a single
+ # argument--the name of the readme file--and outputs HTML.
+ #readme_converter = 'ruby -rubygems /var/lib/gems/1.8/gems/github-markup-0.5.3/bin/github-markup'
#
diff -rN -u old-darcsweb/darcsweb.cgi new-darcsweb/darcsweb.cgi
--- old-darcsweb/darcsweb.cgi 2013-07-24 05:54:53.000000000 +0000
+++ new-darcsweb/darcsweb.cgi 2013-07-24 05:54:53.000000000 +0000
@@ -23,6 +23,8 @@
iso_datetime = '%Y-%m-%dT%H:%M:%SZ'
+PATCHES_PER_PAGE = 50
+
# In order to be able to store the config file in /etc/darcsweb, it has to be
# added to sys.path. It's mainly used by distributions, which place the
# default configuration there. Add it second place, so it goes after '.' but
@@ -77,7 +79,7 @@
def filter_file(s):
if '..' in s or '"' in s:
- raise 'FilterFile FAILED'
+ raise Exception, 'FilterFile FAILED'
if s == '/':
return s
@@ -114,7 +116,7 @@
return s.decode(e).encode('utf8', 'replace')
except UnicodeDecodeError:
pass
- raise 'DecodingError', config.repoencoding
+ raise UnicodeDecodeError, config.repoencoding
def escape(s):
@@ -629,10 +631,12 @@
def repo_get_owner():
try:
fd = open(config.repodir + '/_darcs/prefs/author')
- author = fd.readlines()[0].strip()
+ for line in fd:
+ line = line.strip()
+ if line != "" and line[0] != "#":
+ return line.strip()
except:
- author = None
- return author
+ return None
def run_darcs(params):
"""Runs darcs on the repodir with the given params, return a file
@@ -680,7 +684,7 @@
def getdiff(self):
"""Returns a list of lines from the diff -u corresponding with
the patch."""
- params = 'diff -u --match "hash %s"' % self.hash
+ params = 'diff --quiet -u --match "hash %s"' % self.hash
f = run_darcs(params)
return f.readlines()
@@ -926,16 +930,16 @@
return patch
def get_diff(hash):
- return run_darcs('diff -u --match "hash %s"' % hash)
+ return run_darcs('diff --quiet -u --match "hash %s"' % hash)
def get_file_diff(hash, fname):
- return run_darcs('diff -u --match "hash %s" "%s"' % (hash, fname))
+ return run_darcs('diff --quiet -u --match "hash %s" "%s"' % (hash, fname))
def get_file_headdiff(hash, fname):
- return run_darcs('diff -u --from-match "hash %s" "%s"' % (hash, fname))
+ return run_darcs('diff --quiet -u --from-match "hash %s" "%s"' % (hash, fname))
def get_patch_headdiff(hash):
- return run_darcs('diff -u --from-match "hash %s"' % hash)
+ return run_darcs('diff --quiet -u --from-match "hash %s"' % hash)
def get_raw_diff(hash):
import gzip
@@ -995,7 +999,7 @@
# minidom know the source encoding
s = ""
for i in src:
- s += fixu8(i)
+ s += fixu8(i).replace(' ', '^L')
dom = xml.dom.minidom.parseString(s)
@@ -1087,6 +1091,29 @@
return parse_annotate(run_darcs(cmd))
+def get_readme():
+ import glob
+ readmes = glob.glob("README*")
+ if len(readmes) == 0: return False, False
+ import re
+ for p in readmes:
+ file = os.path.basename(p)
+ if re.search('\.(md|markdown)$', p):
+ import codecs
+ import markdown
+ f = codecs.open(p, encoding=config.repoencoding[0])
+ str = f.read()
+ html = markdown.markdown(str, ['extra', 'codehilite(css_class=page_body)'])
+ return file, fixu8(html)
+ elif re.search('README$', p):
+ f = open(p)
+ str = f.read()
+ return file, '<pre>%s</pre>' % fixu8(escape(str))
+ # We can't handle this ourselves, try shelling out
+ if not config.readme_converter: return False, False
+ cmd = '%s "%s"' % (config.readme_converter, readmes[0])
+ inf, outf = os.popen2(cmd, 't')
+ return os.path.basename(readmes[0]), fixu8(outf.read())
#
@@ -1144,7 +1171,7 @@
print '<div %s>' % cl + escape(l) + '</div>'
-def print_shortlog(last = 50, topi = 0, fname = None):
+def print_shortlog(last = PATCHES_PER_PAGE, topi = 0, fname = None):
ps = get_last_patches(last, topi, fname)
if fname:
@@ -1218,7 +1245,14 @@
print "</table>"
-def print_log(last = 50, topi = 0):
+def print_readme():
+ head, body = get_readme()
+ if not head: return False
+ print '<div class="title">%s</div>' % head
+ print '<section>%s</section' % body
+
+
+def print_log(last = PATCHES_PER_PAGE, topi = 0):
ps = get_last_patches(last, topi)
if topi != 0:
@@ -1248,8 +1282,6 @@
<i>%(author)s [%(date)s]</i><br/>
</div>
<div class="log_body">
- %(desc)s<br/>
- <br/>
%(comment)s
</div>
@@ -1343,6 +1375,35 @@
cssclass='page_body')
print pygments.highlight(code, lexer, formatter)
+ print """<script type='text/javascript'>
+(function () {
+ if (!document.getElementsByClassName || !document.evaluate || !window.addEventListener)
+ return;
+
+ function fakeAnchors () {
+ var pbody = document.getElementsByClassName("page_body")[0];
+ var anchor = window.location.hash;
+ if (!pbody || "" == anchor || "#" == anchor) return;
+
+ /* Avoid xpath injection, because so far as I can tell there's no way to set
+ xpath variables from JavaScript. */
+ if (anchor.match(/['"]/)) return;
+
+ anchor = anchor.substr(1);
+ var parts = anchor.split(/ /);
+ var xpq = '//span[string()="'+parts[0]+'"]';
+ for (var i = 1; i < parts.length; i++) {
+ xpq += '//following-sibling::span[1][string()="'+parts[i]+'"]';
+ }
+ var res = document.evaluate(xpq, pbody, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
+ if (!res || !res.singleNodeValue) return;
+
+ res.singleNodeValue.scrollIntoView(true);
+ };
+ window.addEventListener("DOMContentLoaded", fakeAnchors, false);
+ window.addEventListener("hashchange", fakeAnchors, false);
+})();
+</script>"""
def print_annotate(ann, style):
print '<div class="page_body">'
@@ -1485,9 +1546,14 @@
print ' <tr><td>project url</td>'
print ' <td><a href="%(url)s">%(url)s</a></td></tr>' % \
{ 'url': config.repoprojurl }
+ if config.repolisturl:
+ print ' <tr><td>mailing list url</td>'
+ print ' <td><a href="%(url)s">%(url)s</a></td></tr>' % \
+ { 'url': config.repolisturl }
print '</table>'
print_shortlog(15)
+ print_readme()
print_footer()
@@ -1983,22 +2049,22 @@
sys.stdout.write(l.text)
-def do_shortlog(topi):
+def do_shortlog(topi, last=PATCHES_PER_PAGE):
print_header()
print_navbar()
- print_shortlog(topi = topi)
+ print_shortlog(topi = topi, last = last)
print_footer()
-def do_filehistory(topi, f):
+def do_filehistory(topi, f, last=PATCHES_PER_PAGE):
print_header()
print_navbar(f = fname)
- print_shortlog(topi = topi, fname = fname)
+ print_shortlog(topi = topi, fname = fname, last = last)
print_footer()
-def do_log(topi):
+def do_log(topi, last=PATCHES_PER_PAGE):
print_header()
print_navbar()
- print_log(topi = topi)
+ print_log(topi = topi, last = last)
print_footer()
def do_atom():
@@ -2238,6 +2304,8 @@
<tr>
<th>Project</th>
<th>Description</th>
+<th>Owner</th>
+<th>Last Change</th>
<th></th>
</tr>
""" % {
@@ -2250,7 +2318,9 @@
# some python magic
alt = True
- for conf in dir(all_configs):
+ confs = dir(all_configs)
+ confs.sort(key=str.lower)
+ for conf in confs:
if conf.startswith('__'):
continue
c = all_configs.__getattribute__(conf)
@@ -2262,9 +2332,14 @@
if alt: print '<tr class="dark">'
else: print '<tr class="light">'
alt = not alt
+ try: orig_repodir = config.repodir
+ except: orig_repodir = None
+ config.repodir = c.repodir
print """
<td><a class="list" href="%(myname)s?r=%(name)s;a=summary">%(dname)s</a></td>
<td>%(desc)s</td>
+<td>%(owner)s</td>
+<td>%(lastchange)s</td>
<td class="link"><a href="%(myname)s?r=%(name)s;a=summary">summary</a> |
<a href="%(myname)s?r=%(name)s;a=shortlog">shortlog</a> |
<a href="%(myname)s?r=%(name)s;a=log">log</a> |
@@ -2275,8 +2350,11 @@
'myname': config.myname,
'dname': name,
'name': urllib.quote(name),
- 'desc': shorten_str(desc, 60)
+ 'desc': shorten_str(desc, 60),
+ 'owner': escape(repo_get_owner() or ''),
+ 'lastchange': how_old(os.stat(c.repodir + '/_darcs/patches').st_mtime),
}
+ config.repodir = orig_repodir
print "</table>"
print_footer(put_rss = 0)
@@ -2371,6 +2449,20 @@
else:
projurl = None
+ if 'autolisturl' in dir(c) and c.autolisturl:
+ dpath = fulldir + \
+ '/_darcs/third_party/darcsweb/listurl'
+ if os.access(dpath, os.R_OK):
+ listurl = open(dpath).readline().rstrip("\n")
+ elif 'repolisturl' in dir(c):
+ listurl = c.repolisturl % rep_dict
+ else:
+ listurl = None
+ elif 'repolisturl' in dir(c):
+ listurl = c.repolisturl % rep_dict
+ else:
+ listurl = None
+
rdir = fulldir
class tmp_config:
reponame = dname
@@ -2379,6 +2471,7 @@
repourl = url
repoencoding = c.repoencoding
repoprojurl = projurl
+ repolisturl = listurl
if 'footer' in dir(c):
footer = c.footer
@@ -2404,7 +2497,7 @@
break
else:
# not found
- raise "RepoNotFound", name
+ raise Exception, "Repo not found: " + repr(name)
# fill the configuration
base = all_configs.base
@@ -2414,7 +2507,7 @@
else:
config.myname = base.myname
- if 'myurl' not in dir(base) and 'cachedir' not in dir(base):
+ if 'myurl' not in dir(base):
n = os.environ['SERVER_NAME']
p = os.environ['SERVER_PORT']
s = os.path.dirname(os.environ['SCRIPT_NAME'])
@@ -2441,6 +2534,10 @@
if 'repoprojurl' in dir(c):
config.repoprojurl = c.repoprojurl
+ config.repolisturl = None
+ if 'repolisturl' in dir(c):
+ config.repolisturl = c.repolisturl
+
# repoencoding must be a tuple
if isinstance(c.repoencoding, str):
config.repoencoding = (c.repoencoding, )
@@ -2497,6 +2594,11 @@
else:
config.disable_annotate = False
+ if "readme_converter" in dir(base):
+ config.readme_converter = base.readme_converter
+ else:
+ config.readme_converter = False
+
#
@@ -2532,7 +2634,7 @@
url_request = os.environ['QUERY_STRING']
# create a string representation of the request, ignoring all the
# unused parameters to avoid DoS
- params = ['r', 'a', 'f', 'h', 'topi']
+ params = ['r', 'a', 'f', 'h', 'topi', 'last']
params = [ x for x in form.keys() if x in params ]
url_request = [ (x, form[x].value) for x in params ]
url_request.sort()
@@ -2637,7 +2739,11 @@
topi = int(filter_num(form["topi"].value))
else:
topi = 0
- do_shortlog(topi)
+ if form.has_key("last"):
+ last = int(filter_num(form["last"].value))
+ else:
+ last = PATCHES_PER_PAGE
+ do_shortlog(topi=topi,last=last)
elif action == "filehistory":
if form.has_key("topi"):
@@ -2645,14 +2751,22 @@
else:
topi = 0
fname = filter_file(form["f"].value)
- do_filehistory(topi, fname)
+ if form.has_key("last"):
+ last = int(filter_num(form["last"].value))
+ else:
+ last = PATCHES_PER_PAGE
+ do_filehistory(topi, fname, last=last)
elif action == "log":
if form.has_key("topi"):
topi = int(filter_num(form["topi"].value))
else:
topi = 0
- do_log(topi)
+ if form.has_key("last"):
+ last = int(filter_num(form["last"].value))
+ else:
+ last = PATCHES_PER_PAGE
+ do_log(topi, last=last)
elif action == 'headblob':
fname = filter_file(form["f"].value)
diff -rN -u old-darcsweb/style.css new-darcsweb/style.css
--- old-darcsweb/style.css 2013-07-24 05:54:53.000000000 +0000
+++ new-darcsweb/style.css 2013-07-24 05:54:53.000000000 +0000
@@ -9,11 +9,12 @@
body {
font-family: sans-serif;
- font-size: 12px;
+ font-size: 1em;
margin:0px;
border:solid #d9d8d1;
border-width:1px;
- margin:10px;
+ margin:0.8em;
+ margin-bottom: 60%;
}
a {
@@ -25,37 +26,29 @@
}
div.page_header {
- height:25px;
- padding:8px;
- font-size:18px;
+ padding:0.5em;
+ font-size:1.5em;
font-weight:bold;
background-color:#d9d8d1;
}
-div.page_header a:visited {
- color:#0000cc;
-}
-
div.page_header a:hover {
color:#880000;
}
div.page_nav {
- padding:8px;
-}
-div.page_nav a:visited {
- color:#0000cc;
+ padding:0.5em;
}
div.page_path {
- padding:8px;
+ padding:0.5em;
border:solid #d9d8d1;
border-width:0px 0px 1px
}
div.page_footer {
- height:17px;
- padding:4px 8px;
+ overflow:auto;
+ padding:0.25em 0.5em;
background-color: #d9d8d1;
}
@@ -66,7 +59,7 @@
}
div.page_body {
- padding:8px;
+ padding:0.5em;
}
div.search_box {
@@ -75,18 +68,16 @@
}
input.search_text {
- font-size:xx-small;
+ font-size:0.66em;
background-color: #edece6;
- vertical-align: top;
}
input.search_button {
- font-size:xx-small;
- vertical-align: top;
+ font-size:0.66em;
}
div.title, a.title {
- display:block; padding:6px 8px;
+ display:block; padding:0.5em;
font-weight:bold;
background-color:#edece6;
text-decoration:none;
@@ -98,34 +89,35 @@
}
div.title_text {
- padding:6px 0px;
+ padding: 0.5em 0;
border: solid #d9d8d1;
border-width:0px 0px 1px;
}
div.log_body {
- padding:8px 8px 8px 150px;
+ padding:0.5em;
+ padding-left:10.5em;
}
span.age {
position:relative;
float:left;
- width:142px;
+ width:10em;
font-style:italic;
}
div.log_link {
- padding:0px 8px;
- font-size:10px;
+ padding:0 0 0 0.625em;
+ font-size:0.8em;
font-family:sans-serif;
font-style:normal;
position:relative;
float:left;
- width:136px;
+ width:12.5em;
}
div.list_head {
- padding:6px 8px 4px;
+ padding:0.5em;
border:solid #d9d8d1;
border-width:1px 0px 0px;
font-style:italic;
@@ -153,12 +145,11 @@
table {
/*clear:both;*/
- padding:8px 4px;
+ padding:0.5em 0.25em;
}
th {
- padding:2px 5px;
- font-size:12px;
+ padding:0.25em 0.5em;
text-align:left;
}
@@ -183,20 +174,15 @@
}
td {
- padding:2px 5px;
- font-size:12px;
- vertical-align:top;
+ padding:0.25em 0.5em;
}
td.link {
- padding:2px 5px;
- font-family:sans-serif;
- font-size:10px;
+ font-size:0.8em;
}
div.pre {
font-family:monospace;
- font-size:12px;
white-space:pre;
}
@@ -228,7 +214,6 @@
a.annotate_desc {
color:#999999;
text-decoration:none;
- font-size:11px;
}
a.annotate_desc:hover {
@@ -237,16 +222,13 @@
a.rss_logo {
float:right;
- padding:3px 0px;
- width:35px;
- line-height:10px;
- border:1px solid;
- border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e;
+ padding:0.25em 0.5em;
+ border:1px outset;
color:#ffffff;
background-color:#ff6600;
font-weight:bold;
font-family:sans-serif;
- font-size:10px;
+ font-size:0.8em;
text-align:center;
text-decoration:none;
}
@@ -256,10 +238,10 @@
}
img.logo {
- border-width:0px;
+ border-width:0;
vertical-align:top;
- margin-left:12pt;
- margin-right:5pt;
+ margin-left:1em;
+ margin-right:0.25em;
}