Show More
@@ -172,53 +172,56 b' class hgwebdir(object):' | |||||
172 | parity = 1 - parity |
|
172 | parity = 1 - parity | |
173 | yield row |
|
173 | yield row | |
174 |
|
174 | |||
175 | virtual = req.env.get("PATH_INFO", "").strip('/') |
|
175 | try: | |
176 | if virtual.startswith('static/'): |
|
176 | virtual = req.env.get("PATH_INFO", "").strip('/') | |
177 | static = os.path.join(templater.templatepath(), 'static') |
|
177 | if virtual.startswith('static/'): | |
178 | fname = virtual[7:] |
|
178 | static = os.path.join(templater.templatepath(), 'static') | |
179 | req.write(staticfile(static, fname, req) or |
|
179 | fname = virtual[7:] | |
180 | tmpl('error', error='%r not found' % fname)) |
|
180 | req.write(staticfile(static, fname, req) or | |
181 | elif virtual: |
|
181 | tmpl('error', error='%r not found' % fname)) | |
182 |
|
|
182 | elif virtual: | |
183 |
|
|
183 | while virtual: | |
|
184 | real = dict(self.repos).get(virtual) | |||
|
185 | if real: | |||
|
186 | break | |||
|
187 | up = virtual.rfind('/') | |||
|
188 | if up < 0: | |||
|
189 | break | |||
|
190 | virtual = virtual[:up] | |||
184 | if real: |
|
191 | if real: | |
185 |
|
|
192 | req.env['REPO_NAME'] = virtual | |
186 |
|
|
193 | try: | |
187 | if up < 0: |
|
194 | repo = hg.repository(parentui, real) | |
188 |
|
|
195 | hgweb(repo).run_wsgi(req) | |
189 | virtual = virtual[:up] |
|
196 | except IOError, inst: | |
190 | if real: |
|
197 | req.write(tmpl("error", error=inst.strerror)) | |
191 | req.env['REPO_NAME'] = virtual |
|
198 | except hg.RepoError, inst: | |
192 | try: |
|
199 | req.write(tmpl("error", error=str(inst))) | |
193 | repo = hg.repository(parentui, real) |
|
200 | else: | |
194 | hgweb(repo).run_wsgi(req) |
|
201 | req.write(tmpl("notfound", repo=virtual)) | |
195 | except IOError, inst: |
|
|||
196 | req.write(tmpl("error", error=inst.strerror)) |
|
|||
197 | except hg.RepoError, inst: |
|
|||
198 | req.write(tmpl("error", error=str(inst))) |
|
|||
199 | else: |
|
202 | else: | |
200 | req.write(tmpl("notfound", repo=virtual)) |
|
203 | if req.form.has_key('static'): | |
201 | else: |
|
204 | static = os.path.join(templater.templatepath(), "static") | |
202 |
|
|
205 | fname = req.form['static'][0] | |
203 | static = os.path.join(templater.templatepath(), "static") |
|
206 | req.write(staticfile(static, fname, req) | |
204 | fname = req.form['static'][0] |
|
207 | or tmpl("error", error="%r not found" % fname)) | |
205 | req.write(staticfile(static, fname, req) |
|
208 | else: | |
206 | or tmpl("error", error="%r not found" % fname)) |
|
209 | sortable = ["name", "description", "contact", "lastchange"] | |
207 | else: |
|
210 | sortcolumn, descending = self.repos_sorted | |
208 | sortable = ["name", "description", "contact", "lastchange"] |
|
211 | if req.form.has_key('sort'): | |
209 |
sortcolumn |
|
212 | sortcolumn = req.form['sort'][0] | |
210 | if req.form.has_key('sort'): |
|
213 | descending = sortcolumn.startswith('-') | |
211 | sortcolumn = req.form['sort'][0] |
|
214 | if descending: | |
212 |
|
|
215 | sortcolumn = sortcolumn[1:] | |
213 |
if |
|
216 | if sortcolumn not in sortable: | |
214 |
sortcolumn = |
|
217 | sortcolumn = "" | |
215 | if sortcolumn not in sortable: |
|
|||
216 | sortcolumn = "" |
|
|||
217 |
|
218 | |||
218 | sort = [("sort_%s" % column, |
|
219 | sort = [("sort_%s" % column, | |
219 | "%s%s" % ((not descending and column == sortcolumn) |
|
220 | "%s%s" % ((not descending and column == sortcolumn) | |
220 | and "-" or "", column)) |
|
221 | and "-" or "", column)) | |
221 | for column in sortable] |
|
222 | for column in sortable] | |
222 | req.write(tmpl("index", entries=entries, |
|
223 | req.write(tmpl("index", entries=entries, | |
223 | sortcolumn=sortcolumn, descending=descending, |
|
224 | sortcolumn=sortcolumn, descending=descending, | |
224 | **dict(sort))) |
|
225 | **dict(sort))) | |
|
226 | finally: | |||
|
227 | tmpl = None |
General Comments 0
You need to be logged in to leave comments.
Login now