Show More
@@ -1050,7 +1050,8 b' class hgwebdir(object):' | |||||
1050 | if ui.configbool("web", "allow" + i, False): |
|
1050 | if ui.configbool("web", "allow" + i, False): | |
1051 | yield {"type" : i, "node": nodeid, "url": url} |
|
1051 | yield {"type" : i, "node": nodeid, "url": url} | |
1052 |
|
1052 | |||
1053 | def entries(**map): |
|
1053 | def entries(sortcolumn="", descending=False, **map): | |
|
1054 | rows = [] | |||
1054 | parity = 0 |
|
1055 | parity = 0 | |
1055 | for name, path in self.repos: |
|
1056 | for name, path in self.repos: | |
1056 | u = ui.ui() |
|
1057 | u = ui.ui() | |
@@ -1069,17 +1070,36 b' class hgwebdir(object):' | |||||
1069 | except OSError: |
|
1070 | except OSError: | |
1070 | continue |
|
1071 | continue | |
1071 |
|
1072 | |||
1072 |
|
|
1073 | contact = (get("ui", "username") or # preferred | |
1073 |
|
|
1074 | get("web", "contact") or # deprecated | |
1074 |
|
|
1075 | get("web", "author", "")) # also | |
1075 |
|
|
1076 | description = get("web", "description", "") | |
|
1077 | name = get("web", "name", name) | |||
|
1078 | row = dict(contact=contact or "unknown", | |||
|
1079 | contact_sort=contact.upper() or "unknown", | |||
|
1080 | name=name, | |||
|
1081 | name_sort=name.upper(), | |||
1076 | url=url, |
|
1082 | url=url, | |
1077 |
|
|
1083 | description=description or "unknown", | |
1078 |
|
|
1084 | description_sort=description.upper() or "unknown", | |
1079 |
last |
|
1085 | lastchange=d, | |
|
1086 | lastchange_sort=d[1]-d[0], | |||
1080 | archives=archivelist(u, "tip", url)) |
|
1087 | archives=archivelist(u, "tip", url)) | |
1081 |
|
1088 | if not sortcolumn: | ||
1082 | parity = 1 - parity |
|
1089 | # fast path for unsorted output | |
|
1090 | row['parity'] = parity | |||
|
1091 | parity = 1 - parity | |||
|
1092 | yield row | |||
|
1093 | else: | |||
|
1094 | rows.append((row["%s_sort" % sortcolumn], row)) | |||
|
1095 | if rows: | |||
|
1096 | rows.sort() | |||
|
1097 | if descending: | |||
|
1098 | rows.reverse() | |||
|
1099 | for key, row in rows: | |||
|
1100 | row['parity'] = parity | |||
|
1101 | parity = 1 - parity | |||
|
1102 | yield row | |||
1083 |
|
1103 | |||
1084 | virtual = req.env.get("PATH_INFO", "").strip('/') |
|
1104 | virtual = req.env.get("PATH_INFO", "").strip('/') | |
1085 | if virtual: |
|
1105 | if virtual: | |
@@ -1100,4 +1120,20 b' class hgwebdir(object):' | |||||
1100 | req.write(staticfile(static, fname) |
|
1120 | req.write(staticfile(static, fname) | |
1101 | or tmpl("error", error="%r not found" % fname)) |
|
1121 | or tmpl("error", error="%r not found" % fname)) | |
1102 | else: |
|
1122 | else: | |
1103 | req.write(tmpl("index", entries=entries)) |
|
1123 | sortable = ["name", "description", "contact", "lastchange"] | |
|
1124 | sortcolumn = "" | |||
|
1125 | if req.form.has_key('sort'): | |||
|
1126 | sortcolumn = req.form['sort'][0] | |||
|
1127 | descending = sortcolumn.startswith('-') | |||
|
1128 | if descending: | |||
|
1129 | sortcolumn = sortcolumn[1:] | |||
|
1130 | if sortcolumn not in sortable: | |||
|
1131 | sortcolumn = "" | |||
|
1132 | ||||
|
1133 | sort = [("sort_%s" % column, | |||
|
1134 | "%s%s" % ((not descending and column == sortcolumn) | |||
|
1135 | and "-" or "", column)) | |||
|
1136 | for column in sortable] | |||
|
1137 | req.write(tmpl("index", entries=entries, | |||
|
1138 | sortcolumn=sortcolumn, descending=descending, | |||
|
1139 | **dict(sort))) |
@@ -7,10 +7,10 b'' | |||||
7 |
|
7 | |||
8 | <table> |
|
8 | <table> | |
9 | <tr> |
|
9 | <tr> | |
10 | <td>Name</td> |
|
10 | <td><a href="?sort=#sort_name#">Name</a></td> | |
11 | <td>Description</td> |
|
11 | <td><a href="?sort=#sort_description#">Description</a></td> | |
12 | <td>Contact</td> |
|
12 | <td><a href="?sort=#sort_contact#">Contact</a></td> | |
13 | <td>Last change</td> |
|
13 | <td><a href="?sort=#sort_lastchange#">Last change</a></td> | |
14 | <td> </td> |
|
14 | <td> </td> | |
15 | <tr> |
|
15 | <tr> | |
16 | #entries%indexentry# |
|
16 | #entries%indexentry# |
@@ -43,7 +43,7 b' filediffparent = \'<tr><th class="parent"' | |||||
43 | filelogparent = '<tr><th>parent #rev#:</th><td><a href="?f=#node|short#;file=#file|urlescape#">#node|short#</a></td></tr>' |
|
43 | filelogparent = '<tr><th>parent #rev#:</th><td><a href="?f=#node|short#;file=#file|urlescape#">#node|short#</a></td></tr>' | |
44 | filediffchild = '<tr><th class="child">child #rev#:</th><td class="child"><a href="?cs=#node|short#">#node|short#</a></td></tr>' |
|
44 | filediffchild = '<tr><th class="child">child #rev#:</th><td class="child"><a href="?cs=#node|short#">#node|short#</a></td></tr>' | |
45 | filelogchild = '<tr><th>child #rev#:</th><td><a href="?f=#node|short#;file=#file|urlescape#">#node|short#</a></td></tr>' |
|
45 | filelogchild = '<tr><th>child #rev#:</th><td><a href="?f=#node|short#;file=#file|urlescape#">#node|short#</a></td></tr>' | |
46 |
indexentry = '<tr class="parity#parity#"><td><a href="#url#">#name|escape#</a></td><td># |
|
46 | indexentry = '<tr class="parity#parity#"><td><a href="#url#">#name|escape#</a></td><td>#description#</td><td>#contact|obfuscate#</td><td class="age">#lastchange|age# ago</td><td class="indexlinks"><a href="#url#?cl=tip;style=rss">RSS</a> #archives%archiveentry#</td></tr>' | |
47 | index = index.tmpl |
|
47 | index = index.tmpl | |
48 | archiveentry = '<a href="#url#?ca=#node|short#;type=#type|urlescape#">#type|escape#</a> ' |
|
48 | archiveentry = '<a href="#url#?ca=#node|short#;type=#type|urlescape#">#type|escape#</a> ' | |
49 | notfound = notfound.tmpl |
|
49 | notfound = notfound.tmpl |
General Comments 0
You need to be logged in to leave comments.
Login now