Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb.py @ 2174:3044a3fdae76
If default sorting is name, offer name-descending with one click.
Additionally no longer ignore case when sorting by name to match default
sorting. This makes e.g. a repository "FOO" being listed before "bar".
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Mon, 01 May 2006 19:17:34 +0200 |
parents | d1943df604c4 |
children | 714f4d25a7a9 |
comparison
equal
deleted
inserted
replaced
2173:d1943df604c4 | 2174:3044a3fdae76 |
---|---|
1008 def __init__(self, config): | 1008 def __init__(self, config): |
1009 def cleannames(items): | 1009 def cleannames(items): |
1010 return [(name.strip(os.sep), path) for name, path in items] | 1010 return [(name.strip(os.sep), path) for name, path in items] |
1011 | 1011 |
1012 self.motd = "" | 1012 self.motd = "" |
1013 self.repos_sorted = ('name', False) | |
1013 if isinstance(config, (list, tuple)): | 1014 if isinstance(config, (list, tuple)): |
1014 self.repos = cleannames(config) | 1015 self.repos = cleannames(config) |
1016 self.repos_sorted = ('', False) | |
1015 elif isinstance(config, dict): | 1017 elif isinstance(config, dict): |
1016 self.repos = cleannames(config.items()) | 1018 self.repos = cleannames(config.items()) |
1017 self.repos.sort() | 1019 self.repos.sort() |
1018 else: | 1020 else: |
1019 cp = ConfigParser.SafeConfigParser() | 1021 cp = ConfigParser.SafeConfigParser() |
1076 description = get("web", "description", "") | 1078 description = get("web", "description", "") |
1077 name = get("web", "name", name) | 1079 name = get("web", "name", name) |
1078 row = dict(contact=contact or "unknown", | 1080 row = dict(contact=contact or "unknown", |
1079 contact_sort=contact.upper() or "unknown", | 1081 contact_sort=contact.upper() or "unknown", |
1080 name=name, | 1082 name=name, |
1081 name_sort=name.upper(), | 1083 name_sort=name, |
1082 url=url, | 1084 url=url, |
1083 description=description or "unknown", | 1085 description=description or "unknown", |
1084 description_sort=description.upper() or "unknown", | 1086 description_sort=description.upper() or "unknown", |
1085 lastchange=d, | 1087 lastchange=d, |
1086 lastchange_sort=d[1]-d[0], | 1088 lastchange_sort=d[1]-d[0], |
1087 archives=archivelist(u, "tip", url)) | 1089 archives=archivelist(u, "tip", url)) |
1088 if not sortcolumn: | 1090 if (not sortcolumn |
1091 or (sortcolumn, descending) == self.repos_sorted): | |
1089 # fast path for unsorted output | 1092 # fast path for unsorted output |
1090 row['parity'] = parity | 1093 row['parity'] = parity |
1091 parity = 1 - parity | 1094 parity = 1 - parity |
1092 yield row | 1095 yield row |
1093 else: | 1096 else: |
1119 fname = req.form['static'][0] | 1122 fname = req.form['static'][0] |
1120 req.write(staticfile(static, fname) | 1123 req.write(staticfile(static, fname) |
1121 or tmpl("error", error="%r not found" % fname)) | 1124 or tmpl("error", error="%r not found" % fname)) |
1122 else: | 1125 else: |
1123 sortable = ["name", "description", "contact", "lastchange"] | 1126 sortable = ["name", "description", "contact", "lastchange"] |
1124 sortcolumn = "" | 1127 sortcolumn, descending = self.repos_sorted |
1125 if req.form.has_key('sort'): | 1128 if req.form.has_key('sort'): |
1126 sortcolumn = req.form['sort'][0] | 1129 sortcolumn = req.form['sort'][0] |
1127 descending = sortcolumn.startswith('-') | 1130 descending = sortcolumn.startswith('-') |
1128 if descending: | 1131 if descending: |
1129 sortcolumn = sortcolumn[1:] | 1132 sortcolumn = sortcolumn[1:] |
1130 if sortcolumn not in sortable: | 1133 if sortcolumn not in sortable: |
1131 sortcolumn = "" | 1134 sortcolumn = "" |
1132 | 1135 |
1133 sort = [("sort_%s" % column, | 1136 sort = [("sort_%s" % column, |
1134 "%s%s" % ((not descending and column == sortcolumn) | 1137 "%s%s" % ((not descending and column == sortcolumn) |
1135 and "-" or "", column)) | 1138 and "-" or "", column)) |
1136 for column in sortable] | 1139 for column in sortable] |