##// END OF EJS Templates
hgweb: accept NewWebInterface URLs
Brendan Cully -
r3260:1f1af9b2 default
parent child Browse files
Show More
@@ -54,9 +54,9 b' class hgweb(object):'
54
54
55 def archivelist(self, nodeid):
55 def archivelist(self, nodeid):
56 allowed = self.repo.ui.configlist("web", "allow_archive")
56 allowed = self.repo.ui.configlist("web", "allow_archive")
57 for i in self.archives:
57 for i, spec in self.archive_specs.iteritems():
58 if i in allowed or self.repo.ui.configbool("web", "allow" + i):
58 if i in allowed or self.repo.ui.configbool("web", "allow" + i):
59 yield {"type" : i, "node" : nodeid, "url": ""}
59 yield {"type" : i, "extension" : spec[2], "node" : nodeid}
60
60
61 def listfiles(self, files, mf):
61 def listfiles(self, files, mf):
62 for f in files[:self.maxfiles]:
62 for f in files[:self.maxfiles]:
@@ -645,9 +645,53 b' class hgweb(object):'
645 form[name] = value
645 form[name] = value
646 del form[k]
646 del form[k]
647
647
648 def rewrite_request(req):
649 '''translate new web interface to traditional format'''
650
651 if req.form.has_key('cmd'):
652 # old style
653 return
654 if req.env.has_key('SCRIPT_URL'):
655 # run through web server
656 base = req.env['SCRIPT_URL']
657 # strip repo and leading '/' or '?'
658 query = req.env['REQUEST_URI'][len(base)+1:]
659 else:
660 query = req.env['PATH_INFO'][1:]
661
662 args = query.split('/', 2)
663 if not args or not args[0]:
664 return
665
666 cmd = args.pop(0)
667 if cmd == 'raw':
668 req.form['style'] = ['raw']
669 cmd = 'rev'
670 elif cmd == 'rawdiff':
671 req.form['style'] = ['raw']
672 cmd = 'diff'
673 req.form['cmd'] = [cmd]
674
675 if args and args[0]:
676 node = args.pop(0)
677 req.form['node'] = [node]
678 if args:
679 req.form['file'] = args
680
681 if cmd == 'static':
682 req.form['file'] = req.form['node']
683 elif cmd == 'archive':
684 fn = req.form['node'][0]
685 for type_, spec in self.archive_specs.iteritems():
686 ext = spec[2]
687 if fn.endswith(ext):
688 req.form['node'] = [fn[:-len(ext)]]
689 req.form['type'] = [type_]
690
648 self.refresh()
691 self.refresh()
649
692
650 expand_form(req.form)
693 expand_form(req.form)
694 rewrite_request(req)
651
695
652 m = os.path.join(self.templatepath, "map")
696 m = os.path.join(self.templatepath, "map")
653 style = self.repo.ui.config("web", "style", "")
697 style = self.repo.ui.config("web", "style", "")
@@ -723,6 +767,30 b' class hgweb(object):'
723 else:
767 else:
724 return 0
768 return 0
725
769
770 def do_log(self, req):
771 if req.form.has_key('file') and req.form['file'][0]:
772 self.do_filelog(req)
773 else:
774 self.do_changelog(req)
775
776 def do_rev(self, req):
777 self.do_changeset(req)
778
779 def do_file(self, req):
780 path = req.form.get('file', [''])[0]
781 if path:
782 try:
783 req.write(self.filerevision(self.filectx(req)))
784 return
785 except hg.RepoError:
786 pass
787 path = self.cleanpath(path)
788
789 req.write(self.manifest(self.changectx(req), '/' + path))
790
791 def do_diff(self, req):
792 self.do_filediff(req)
793
726 def do_changelog(self, req, shortlog = False):
794 def do_changelog(self, req, shortlog = False):
727 if req.form.has_key('node'):
795 if req.form.has_key('node'):
728 ctx = self.changectx(req)
796 ctx = self.changectx(req)
@@ -759,9 +827,6 b' class hgweb(object):'
759 def do_filediff(self, req):
827 def do_filediff(self, req):
760 req.write(self.filediff(self.filectx(req)))
828 req.write(self.filediff(self.filectx(req)))
761
829
762 def do_file(self, req):
763 req.write(self.filerevision(self.filectx(req)))
764
765 def do_annotate(self, req):
830 def do_annotate(self, req):
766 req.write(self.fileannotate(self.filectx(req)))
831 req.write(self.fileannotate(self.filectx(req)))
767
832
General Comments 0
You need to be logged in to leave comments. Login now