Show More
@@ -90,8 +90,12 b' class hgwebdir(object):' | |||
|
90 | 90 | url = req.env['REQUEST_URI'].split('?')[0] |
|
91 | 91 | if not url.endswith('/'): |
|
92 | 92 | url += '/' |
|
93 | pathinfo = req.env.get('PATH_INFO', '').strip('/') + '/' | |
|
94 | base = url[:len(url) - len(pathinfo)] | |
|
95 | if not base.endswith('/'): | |
|
96 | base += '/' | |
|
93 | 97 | |
|
94 |
staticurl = config('web', 'staticurl') or |
|
|
98 | staticurl = config('web', 'staticurl') or base + 'static/' | |
|
95 | 99 | if not staticurl.endswith('/'): |
|
96 | 100 | staticurl += '/' |
|
97 | 101 | |
@@ -118,7 +122,7 b' class hgwebdir(object):' | |||
|
118 | 122 | yield {"type" : i[0], "extension": i[1], |
|
119 | 123 | "node": nodeid, "url": url} |
|
120 | 124 | |
|
121 | def entries(sortcolumn="", descending=False, **map): | |
|
125 | def entries(sortcolumn="", descending=False, subdir="", **map): | |
|
122 | 126 | def sessionvars(**map): |
|
123 | 127 | fields = [] |
|
124 | 128 | if req.form.has_key('style'): |
@@ -134,6 +138,9 b' class hgwebdir(object):' | |||
|
134 | 138 | rows = [] |
|
135 | 139 | parity = paritygen(self.stripecount) |
|
136 | 140 | for name, path in self.repos: |
|
141 | if not name.startswith(subdir): | |
|
142 | continue | |
|
143 | ||
|
137 | 144 | u = ui.ui(parentui=parentui) |
|
138 | 145 | try: |
|
139 | 146 | u.readconfig(os.path.join(path, '.hg', 'hgrc')) |
@@ -145,7 +152,7 b' class hgwebdir(object):' | |||
|
145 | 152 | if u.configbool("web", "hidden", untrusted=True): |
|
146 | 153 | continue |
|
147 | 154 | |
|
148 | url = ('/'.join([req.env["REQUEST_URI"].split('?')[0], name]) | |
|
155 | url = ('/'.join([req.env["REQUEST_URI"].split('?')[0], name[len(subdir):]]) | |
|
149 | 156 | .replace("//", "/")) + '/' |
|
150 | 157 | |
|
151 | 158 | # update time with local timezone |
@@ -185,6 +192,25 b' class hgwebdir(object):' | |||
|
185 | 192 | row['parity'] = parity.next() |
|
186 | 193 | yield row |
|
187 | 194 | |
|
195 | def makeindex(req, subdir=""): | |
|
196 | sortable = ["name", "description", "contact", "lastchange"] | |
|
197 | sortcolumn, descending = self.repos_sorted | |
|
198 | if req.form.has_key('sort'): | |
|
199 | sortcolumn = req.form['sort'][0] | |
|
200 | descending = sortcolumn.startswith('-') | |
|
201 | if descending: | |
|
202 | sortcolumn = sortcolumn[1:] | |
|
203 | if sortcolumn not in sortable: | |
|
204 | sortcolumn = "" | |
|
205 | ||
|
206 | sort = [("sort_%s" % column, | |
|
207 | "%s%s" % ((not descending and column == sortcolumn) | |
|
208 | and "-" or "", column)) | |
|
209 | for column in sortable] | |
|
210 | req.write(tmpl("index", entries=entries, subdir=subdir, | |
|
211 | sortcolumn=sortcolumn, descending=descending, | |
|
212 | **dict(sort))) | |
|
213 | ||
|
188 | 214 | try: |
|
189 | 215 | virtual = req.env.get("PATH_INFO", "").strip('/') |
|
190 | 216 | if virtual.startswith('static/'): |
@@ -211,7 +237,11 b' class hgwebdir(object):' | |||
|
211 | 237 | except hg.RepoError, inst: |
|
212 | 238 | req.write(tmpl("error", error=str(inst))) |
|
213 | 239 | else: |
|
214 | req.write(tmpl("notfound", repo=virtual)) | |
|
240 | subdir=req.env.get("PATH_INFO", "").strip('/') + '/' | |
|
241 | if [r for r in self.repos if r[0].startswith(subdir)]: | |
|
242 | makeindex(req, subdir) | |
|
243 | else: | |
|
244 | req.write(tmpl("notfound", repo=virtual)) | |
|
215 | 245 | else: |
|
216 | 246 | if req.form.has_key('static'): |
|
217 | 247 | static = os.path.join(templater.templatepath(), "static") |
@@ -219,22 +249,6 b' class hgwebdir(object):' | |||
|
219 | 249 | req.write(staticfile(static, fname, req) |
|
220 | 250 | or tmpl("error", error="%r not found" % fname)) |
|
221 | 251 | else: |
|
222 | sortable = ["name", "description", "contact", "lastchange"] | |
|
223 | sortcolumn, descending = self.repos_sorted | |
|
224 | if req.form.has_key('sort'): | |
|
225 | sortcolumn = req.form['sort'][0] | |
|
226 | descending = sortcolumn.startswith('-') | |
|
227 | if descending: | |
|
228 | sortcolumn = sortcolumn[1:] | |
|
229 | if sortcolumn not in sortable: | |
|
230 | sortcolumn = "" | |
|
231 | ||
|
232 | sort = [("sort_%s" % column, | |
|
233 | "%s%s" % ((not descending and column == sortcolumn) | |
|
234 | and "-" or "", column)) | |
|
235 | for column in sortable] | |
|
236 | req.write(tmpl("index", entries=entries, | |
|
237 | sortcolumn=sortcolumn, descending=descending, | |
|
238 | **dict(sort))) | |
|
252 | makeindex(req) | |
|
239 | 253 | finally: |
|
240 | 254 | tmpl = None |
General Comments 0
You need to be logged in to leave comments.
Login now