Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/hgweb_mod.py @ 3270:a7370503d800
hgweb: provide means for handling query parameters
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Thu, 05 Oct 2006 14:27:14 -0700 |
parents | b4f16bf59a5d |
children | 10277edf7e5b |
comparison
equal
deleted
inserted
replaced
3269:6901d3545021 | 3270:a7370503d800 |
---|---|
9 import os | 9 import os |
10 import os.path | 10 import os.path |
11 import mimetypes | 11 import mimetypes |
12 from mercurial.demandload import demandload | 12 from mercurial.demandload import demandload |
13 demandload(globals(), "re zlib ConfigParser mimetools cStringIO sys tempfile") | 13 demandload(globals(), "re zlib ConfigParser mimetools cStringIO sys tempfile") |
14 demandload(globals(), 'urllib') | |
14 demandload(globals(), "mercurial:mdiff,ui,hg,util,archival,streamclone,patch") | 15 demandload(globals(), "mercurial:mdiff,ui,hg,util,archival,streamclone,patch") |
15 demandload(globals(), "mercurial:templater") | 16 demandload(globals(), "mercurial:templater") |
16 demandload(globals(), "mercurial.hgweb.common:get_mtime,staticfile") | 17 demandload(globals(), "mercurial.hgweb.common:get_mtime,staticfile") |
17 from mercurial.node import * | 18 from mercurial.node import * |
18 from mercurial.i18n import gettext as _ | 19 from mercurial.i18n import gettext as _ |
715 ext = spec[2] | 716 ext = spec[2] |
716 if fn.endswith(ext): | 717 if fn.endswith(ext): |
717 req.form['node'] = [fn[:-len(ext)]] | 718 req.form['node'] = [fn[:-len(ext)]] |
718 req.form['type'] = [type_] | 719 req.form['type'] = [type_] |
719 | 720 |
721 def queryprefix(**map): | |
722 return req.url[-1] == '?' and ';' or '?' | |
723 | |
724 def getentries(**map): | |
725 fields = {} | |
726 if req.form.has_key('style'): | |
727 style = req.form['style'][0] | |
728 if style != self.repo.ui.config('web', 'style', ''): | |
729 fields['style'] = style | |
730 | |
731 if fields: | |
732 fields = ['%s=%s' % (k, urllib.quote(v)) | |
733 for k, v in fields.iteritems()] | |
734 yield '%s%s' % (queryprefix(), ';'.join(fields)) | |
735 else: | |
736 yield '' | |
737 | |
720 self.refresh() | 738 self.refresh() |
721 | 739 |
722 expand_form(req.form) | 740 expand_form(req.form) |
723 rewrite_request(req) | 741 rewrite_request(req) |
724 | 742 |
749 defaults={"url": req.url, | 767 defaults={"url": req.url, |
750 "repo": self.reponame, | 768 "repo": self.reponame, |
751 "header": header, | 769 "header": header, |
752 "footer": footer, | 770 "footer": footer, |
753 "rawfileheader": rawfileheader, | 771 "rawfileheader": rawfileheader, |
772 "queryprefix": queryprefix, | |
773 "getentries": getentries | |
754 }) | 774 }) |
755 | 775 |
756 if not req.form.has_key('cmd'): | 776 if not req.form.has_key('cmd'): |
757 req.form['cmd'] = [self.t.cache['default'],] | 777 req.form['cmd'] = [self.t.cache['default'],] |
758 | 778 |