Show More
@@ -90,8 +90,12 b' class hgwebdir(object):' | |||||
90 | url = req.env['REQUEST_URI'].split('?')[0] |
|
90 | url = req.env['REQUEST_URI'].split('?')[0] | |
91 | if not url.endswith('/'): |
|
91 | if not url.endswith('/'): | |
92 | url += '/' |
|
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 | if not staticurl.endswith('/'): |
|
99 | if not staticurl.endswith('/'): | |
96 | staticurl += '/' |
|
100 | staticurl += '/' | |
97 |
|
101 | |||
@@ -118,7 +122,7 b' class hgwebdir(object):' | |||||
118 | yield {"type" : i[0], "extension": i[1], |
|
122 | yield {"type" : i[0], "extension": i[1], | |
119 | "node": nodeid, "url": url} |
|
123 | "node": nodeid, "url": url} | |
120 |
|
124 | |||
121 | def entries(sortcolumn="", descending=False, **map): |
|
125 | def entries(sortcolumn="", descending=False, subdir="", **map): | |
122 | def sessionvars(**map): |
|
126 | def sessionvars(**map): | |
123 | fields = [] |
|
127 | fields = [] | |
124 | if req.form.has_key('style'): |
|
128 | if req.form.has_key('style'): | |
@@ -134,6 +138,9 b' class hgwebdir(object):' | |||||
134 | rows = [] |
|
138 | rows = [] | |
135 | parity = paritygen(self.stripecount) |
|
139 | parity = paritygen(self.stripecount) | |
136 | for name, path in self.repos: |
|
140 | for name, path in self.repos: | |
|
141 | if not name.startswith(subdir): | |||
|
142 | continue | |||
|
143 | ||||
137 | u = ui.ui(parentui=parentui) |
|
144 | u = ui.ui(parentui=parentui) | |
138 | try: |
|
145 | try: | |
139 | u.readconfig(os.path.join(path, '.hg', 'hgrc')) |
|
146 | u.readconfig(os.path.join(path, '.hg', 'hgrc')) | |
@@ -145,7 +152,7 b' class hgwebdir(object):' | |||||
145 | if u.configbool("web", "hidden", untrusted=True): |
|
152 | if u.configbool("web", "hidden", untrusted=True): | |
146 | continue |
|
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 | .replace("//", "/")) + '/' |
|
156 | .replace("//", "/")) + '/' | |
150 |
|
157 | |||
151 | # update time with local timezone |
|
158 | # update time with local timezone | |
@@ -185,6 +192,25 b' class hgwebdir(object):' | |||||
185 | row['parity'] = parity.next() |
|
192 | row['parity'] = parity.next() | |
186 | yield row |
|
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 | try: |
|
214 | try: | |
189 | virtual = req.env.get("PATH_INFO", "").strip('/') |
|
215 | virtual = req.env.get("PATH_INFO", "").strip('/') | |
190 | if virtual.startswith('static/'): |
|
216 | if virtual.startswith('static/'): | |
@@ -211,7 +237,11 b' class hgwebdir(object):' | |||||
211 | except hg.RepoError, inst: |
|
237 | except hg.RepoError, inst: | |
212 | req.write(tmpl("error", error=str(inst))) |
|
238 | req.write(tmpl("error", error=str(inst))) | |
213 | else: |
|
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 | else: |
|
245 | else: | |
216 | if req.form.has_key('static'): |
|
246 | if req.form.has_key('static'): | |
217 | static = os.path.join(templater.templatepath(), "static") |
|
247 | static = os.path.join(templater.templatepath(), "static") | |
@@ -219,22 +249,6 b' class hgwebdir(object):' | |||||
219 | req.write(staticfile(static, fname, req) |
|
249 | req.write(staticfile(static, fname, req) | |
220 | or tmpl("error", error="%r not found" % fname)) |
|
250 | or tmpl("error", error="%r not found" % fname)) | |
221 | else: |
|
251 | else: | |
222 | sortable = ["name", "description", "contact", "lastchange"] |
|
252 | makeindex(req) | |
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))) |
|
|||
239 | finally: |
|
253 | finally: | |
240 | tmpl = None |
|
254 | tmpl = None |
General Comments 0
You need to be logged in to leave comments.
Login now