Show More
@@ -73,49 +73,58 b' class hgwebdir(object):' | |||
|
73 | 73 | |
|
74 | 74 | try: |
|
75 | 75 | try: |
|
76 | ||
|
76 | 77 | virtual = req.env.get("PATH_INFO", "").strip('/') |
|
77 | if virtual.startswith('static/'): | |
|
78 | ||
|
79 | # a static file | |
|
80 | if virtual.startswith('static/') or 'static' in req.form: | |
|
78 | 81 | static = os.path.join(templater.templatepath(), 'static') |
|
79 |
f |
|
|
82 | if virtual.startswith('static/'): | |
|
83 | fname = virtual[7:] | |
|
84 | else: | |
|
85 | fname = req.form['static'][0] | |
|
80 | 86 | req.write(staticfile(static, fname, req)) |
|
81 |
|
|
|
82 | repos = dict(self.repos) | |
|
83 |
|
|
|
84 |
|
|
|
85 |
|
|
|
86 | req.env['REPO_NAME'] = virtual | |
|
87 |
|
|
|
88 | repo = hg.repository(self.parentui, real) | |
|
89 | hgweb(repo).run_wsgi(req) | |
|
90 | return | |
|
91 | except IOError, inst: | |
|
92 | raise ErrorResponse(500, inst.strerror) | |
|
93 | except hg.RepoError, inst: | |
|
94 | raise ErrorResponse(500, str(inst)) | |
|
87 | return | |
|
88 | ||
|
89 | # top-level index | |
|
90 | elif not virtual: | |
|
91 | tmpl = self.templater(req) | |
|
92 | self.makeindex(req, tmpl) | |
|
93 | return | |
|
95 | 94 | |
|
96 | # browse subdirectories | |
|
97 | subdir = virtual + '/' | |
|
98 | if [r for r in repos if r.startswith(subdir)]: | |
|
99 | tmpl = self.templater(req) | |
|
100 | self.makeindex(req, tmpl, subdir) | |
|
95 | # nested indexes and hgwebs | |
|
96 | repos = dict(self.repos) | |
|
97 | while virtual: | |
|
98 | real = repos.get(virtual) | |
|
99 | if real: | |
|
100 | req.env['REPO_NAME'] = virtual | |
|
101 | try: | |
|
102 | repo = hg.repository(self.parentui, real) | |
|
103 | hgweb(repo).run_wsgi(req) | |
|
101 | 104 | return |
|
102 | ||
|
103 | up = virtual.rfind('/') | |
|
104 |
|
|
|
105 |
|
|
|
106 | virtual = virtual[:up] | |
|
105 | except IOError, inst: | |
|
106 | raise ErrorResponse(500, inst.strerror) | |
|
107 | except hg.RepoError, inst: | |
|
108 | raise ErrorResponse(500, str(inst)) | |
|
107 | 109 | |
|
108 | tmpl = self.templater(req) | |
|
109 | req.respond(404, tmpl("notfound", repo=virtual)) | |
|
110 | else: | |
|
111 | if req.form.has_key('static'): | |
|
112 | static = os.path.join(templater.templatepath(), "static") | |
|
113 | fname = req.form['static'][0] | |
|
114 | req.write(staticfile(static, fname, req)) | |
|
115 | else: | |
|
110 | # browse subdirectories | |
|
111 | subdir = virtual + '/' | |
|
112 | if [r for r in repos if r.startswith(subdir)]: | |
|
116 | 113 | tmpl = self.templater(req) |
|
117 | self.makeindex(req, tmpl) | |
|
114 | self.makeindex(req, tmpl, subdir) | |
|
115 | return | |
|
116 | ||
|
117 | up = virtual.rfind('/') | |
|
118 | if up < 0: | |
|
119 | break | |
|
120 | virtual = virtual[:up] | |
|
121 | ||
|
122 | # prefixes not found | |
|
123 | tmpl = self.templater(req) | |
|
124 | req.respond(404, tmpl("notfound", repo=virtual)) | |
|
125 | ||
|
118 | 126 | except ErrorResponse, err: |
|
127 | tmpl = self.templater(req) | |
|
119 | 128 | req.respond(err.code, tmpl('error', error=err.message or '')) |
|
120 | 129 | finally: |
|
121 | 130 | tmpl = None |
General Comments 0
You need to be logged in to leave comments.
Login now