# HG changeset patch # User Marcin Kuzminski # Date 1271543518 -7200 # Node ID 670713507d03007ef4d888c35da696f8d6c0a9ab # Parent c2f27b9b81bcd97499331b5c44ac41ecd81bfa24 Moved summary to seperate controller, little cleanups in templates. added archives to summary diff -r c2f27b9b81bc -r 670713507d03 pylons_app/config/routing.py --- a/pylons_app/config/routing.py Sat Apr 17 22:24:08 2010 +0200 +++ b/pylons_app/config/routing.py Sun Apr 18 00:31:58 2010 +0200 @@ -30,7 +30,7 @@ m.connect('admin_add_repo', '/add_repo/{new_repo:[a-z0-9\. _-]*}', action='add_repo') - map.connect('summary_home', '/{repo_name}/_summary', controller='hg', action='view') + map.connect('summary_home', '/{repo_name}/_summary', controller='summary') map.connect('hg', '/{path_info:.*}', controller='hg', action="view", path_info='/') diff -r c2f27b9b81bc -r 670713507d03 pylons_app/controllers/hg.py --- a/pylons_app/controllers/hg.py Sat Apr 17 22:24:08 2010 +0200 +++ b/pylons_app/controllers/hg.py Sun Apr 18 00:31:58 2010 +0200 @@ -6,7 +6,7 @@ from pylons_app.lib.base import BaseController, render from mako.template import Template from pylons.controllers.util import abort - +from pylons_app.lib.utils import get_repo_slug from operator import itemgetter from pylons_app.model.hg_model import HgModel log = logging.getLogger(__name__) @@ -16,7 +16,8 @@ def __before__(self): c.repos_prefix = config['repos_name'] c.staticurl = g.statics - + c.repo_name = get_repo_slug(request) + def index(self): hg_model = HgModel() c.repos_list = list(hg_model.get_repos()) @@ -37,13 +38,7 @@ def view(self, *args, **kwargs): #TODO: reimplement this not tu use hgwebdir - - #patch for replacing mercurial servings with hg_app servings - vcs_impl = self._get_vcs_impl(request.environ) - if vcs_impl: - return vcs_impl - - + response = g.hgapp(request.environ, self.start_response) http_accept = request.environ.get('HTTP_ACCEPT', False) @@ -68,21 +63,3 @@ return template.render(g=g, c=c, session=session, h=h) - - - - - def _get_vcs_impl(self, environ): - path_info = environ['PATH_INFO'] - c.repo_name = path_info.split('/')[-2] - action = path_info.split('/')[-1] - if not action.startswith('_'): - return False - else: - hg_model = HgModel() - c.repo_info = hg_model.get_repo(c.repo_name) - c.repo_changesets = c.repo_info.get_changesets(10) -# c.repo_tags = c.repo_info.get_tags(limit=10) -# c.repo_branches = c.repo_info.get_branches(limit=10) - return render('/summary.html') - diff -r c2f27b9b81bc -r 670713507d03 pylons_app/controllers/summary.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pylons_app/controllers/summary.py Sun Apr 18 00:31:58 2010 +0200 @@ -0,0 +1,32 @@ +import logging + +from pylons import tmpl_context as c, app_globals as g, session, request, config, url +from pylons.controllers.util import abort, redirect + +from pylons_app.lib.base import BaseController, render +from pylons_app.lib.utils import get_repo_slug +from pylons_app.model.hg_model import HgModel +log = logging.getLogger(__name__) + +class SummaryController(BaseController): + def __before__(self): + c.repos_prefix = config['repos_name'] + c.staticurl = g.statics + c.repo_name = get_repo_slug(request) + + def index(self): + hg_model = HgModel() + c.repo_info = hg_model.get_repo(c.repo_name) + c.repo_changesets = c.repo_info.get_changesets(10) + + e = request.environ + uri = r'%(protocol)s://%(user)s@%(host)s/%(repo_name)s' % { + 'protocol': e.get('wsgi.url_scheme'), + 'user':e.get('REMOTE_USER'), + 'host':e.get('HTTP_HOST'), + 'repo_name':c.repo_name, + } + c.clone_repo_url = url(uri) + #c.repo_tags = c.repo_info.get_tags(limit=10) + #c.repo_branches = c.repo_info.get_branches(limit=10) + return render('/summary.html') diff -r c2f27b9b81bc -r 670713507d03 pylons_app/lib/utils.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pylons_app/lib/utils.py Sun Apr 18 00:31:58 2010 +0200 @@ -0,0 +1,7 @@ + +def get_repo_slug(request): + path_info = request.environ.get('PATH_INFO') + repo_name = path_info.split('/')[-2] + action = path_info.split('/')[-1] + + return repo_name diff -r c2f27b9b81bc -r 670713507d03 pylons_app/model/hg_model.py --- a/pylons_app/model/hg_model.py Sat Apr 17 22:24:08 2010 +0200 +++ b/pylons_app/model/hg_model.py Sun Apr 18 00:31:58 2010 +0200 @@ -49,7 +49,7 @@ tmp_d['rev'] = tip.rev() tmp_d['contact'] = mercurial_repo.contact tmp_d['contact_sort'] = tmp_d['contact'] - tmp_d['repo_archives'] = mercurial_repo._get_archive_list() + tmp_d['repo_archives'] = mercurial_repo._get_archives() yield tmp_d diff -r c2f27b9b81bc -r 670713507d03 pylons_app/templates/summary.html --- a/pylons_app/templates/summary.html Sat Apr 17 22:24:08 2010 +0200 +++ b/pylons_app/templates/summary.html Sun Apr 18 00:31:58 2010 +0200 @@ -11,8 +11,7 @@ ${_('summary')} <%def name="page_nav()"> -
- {sessionvars%hiddenformentry} +