##// END OF EJS Templates
hgweb: use modern response type for index generation...
Gregory Szorc -
r36921:93717f08 default
parent child Browse files
Show More
@@ -16,7 +16,6 b' from ..i18n import _'
16 from .common import (
16 from .common import (
17 ErrorResponse,
17 ErrorResponse,
18 HTTP_NOT_FOUND,
18 HTTP_NOT_FOUND,
19 HTTP_OK,
20 HTTP_SERVER_ERROR,
19 HTTP_SERVER_ERROR,
21 cspvalues,
20 cspvalues,
22 get_contact,
21 get_contact,
@@ -400,16 +399,14 b' class hgwebdir(object):'
400 repos = dict(self.repos)
399 repos = dict(self.repos)
401
400
402 if (not virtual or virtual == 'index') and virtual not in repos:
401 if (not virtual or virtual == 'index') and virtual not in repos:
403 wsgireq.respond(HTTP_OK, ctype)
402 return self.makeindex(req, res, tmpl)
404 return self.makeindex(req, tmpl)
405
403
406 # nested indexes and hgwebs
404 # nested indexes and hgwebs
407
405
408 if virtual.endswith('/index') and virtual not in repos:
406 if virtual.endswith('/index') and virtual not in repos:
409 subdir = virtual[:-len('index')]
407 subdir = virtual[:-len('index')]
410 if any(r.startswith(subdir) for r in repos):
408 if any(r.startswith(subdir) for r in repos):
411 wsgireq.respond(HTTP_OK, ctype)
409 return self.makeindex(req, res, tmpl, subdir)
412 return self.makeindex(req, tmpl, subdir)
413
410
414 def _virtualdirs():
411 def _virtualdirs():
415 # Check the full virtual path, each parent, and the root ('')
412 # Check the full virtual path, each parent, and the root ('')
@@ -442,8 +439,7 b' class hgwebdir(object):'
442 # browse subdirectories
439 # browse subdirectories
443 subdir = virtual + '/'
440 subdir = virtual + '/'
444 if [r for r in repos if r.startswith(subdir)]:
441 if [r for r in repos if r.startswith(subdir)]:
445 wsgireq.respond(HTTP_OK, ctype)
442 return self.makeindex(req, res, tmpl, subdir)
446 return self.makeindex(req, tmpl, subdir)
447
443
448 # prefixes not found
444 # prefixes not found
449 wsgireq.respond(HTTP_NOT_FOUND, ctype)
445 wsgireq.respond(HTTP_NOT_FOUND, ctype)
@@ -455,7 +451,7 b' class hgwebdir(object):'
455 finally:
451 finally:
456 tmpl = None
452 tmpl = None
457
453
458 def makeindex(self, req, tmpl, subdir=""):
454 def makeindex(self, req, res, tmpl, subdir=""):
459 self.refresh()
455 self.refresh()
460 sortable = ["name", "description", "contact", "lastchange"]
456 sortable = ["name", "description", "contact", "lastchange"]
461 sortcolumn, descending = None, False
457 sortcolumn, descending = None, False
@@ -478,10 +474,16 b' class hgwebdir(object):'
478 self.stripecount, sortcolumn=sortcolumn,
474 self.stripecount, sortcolumn=sortcolumn,
479 descending=descending, subdir=subdir)
475 descending=descending, subdir=subdir)
480
476
481 return tmpl("index", entries=entries, subdir=subdir,
477 res.setbodygen(tmpl(
482 pathdef=hgweb_mod.makebreadcrumb('/' + subdir, self.prefix),
478 'index',
483 sortcolumn=sortcolumn, descending=descending,
479 entries=entries,
484 **dict(sort))
480 subdir=subdir,
481 pathdef=hgweb_mod.makebreadcrumb('/' + subdir, self.prefix),
482 sortcolumn=sortcolumn,
483 descending=descending,
484 **dict(sort)))
485
486 return res.sendresponse()
485
487
486 def templater(self, wsgireq, nonce):
488 def templater(self, wsgireq, nonce):
487
489
General Comments 0
You need to be logged in to leave comments. Login now