# HG changeset patch # User Marcin Kuzminski # Date 1272151161 -7200 # Node ID 5b57295601b69fc7a20158dbf63f1714024c98e1 # Parent 01d0f363f36d82b8bbcd046df271c6891b676993 Updated basic files browser with, pygments diff -r 01d0f363f36d -r 5b57295601b6 pylons_app/config/routing.py --- a/pylons_app/config/routing.py Sun Apr 25 01:18:38 2010 +0200 +++ b/pylons_app/config/routing.py Sun Apr 25 01:19:21 2010 +0200 @@ -37,7 +37,7 @@ map.connect('branches_home', '/{repo_name}/branches', controller='branches') map.connect('tags_home', '/{repo_name}/tags', controller='tags') map.connect('graph_home', '/{repo_name}/graph/{revision}', controller='graph', revision='tip') - map.connect('files_home', '/{repo_name}/files/{revision}/{path_info:.*}', controller='files', revision='tip', path_info='') + map.connect('files_home', '/{repo_name}/files/{revision}/{f_path:.*}', controller='files', revision='tip', f_path='') return map diff -r 01d0f363f36d -r 5b57295601b6 pylons_app/controllers/files.py --- a/pylons_app/controllers/files.py Sun Apr 25 01:18:38 2010 +0200 +++ b/pylons_app/controllers/files.py Sun Apr 25 01:19:21 2010 +0200 @@ -1,16 +1,27 @@ import logging -from pylons import request, response, session, tmpl_context as c, url +from pylons import request, response, session, tmpl_context as c, url, config, app_globals as g 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 FilesController(BaseController): + def __before__(self): + c.repos_prefix = config['repos_name'] + c.staticurl = g.statics + c.repo_name = get_repo_slug(request) - def index(self): - # Return a rendered template - #return render('/files.mako') - # or, return a string - return 'Hello World' + def index(self, repo_name, revision, f_path): + hg_model = HgModel() + c.repo = repo = hg_model.get_repo(c.repo_name) + c.cur_rev = revision + c.f_path = f_path + c.changeset = repo.get_changeset(repo._get_revision('tip')) + + + c.files_list = c.changeset.get_node(f_path) + + return render('/files.html') diff -r 01d0f363f36d -r 5b57295601b6 pylons_app/templates/files.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pylons_app/templates/files.html Sun Apr 25 01:19:21 2010 +0200 @@ -0,0 +1,95 @@ +<%inherit file="base/base.html"/> + +<%def name="title()"> + ${_('Repository managment')} + +<%def name="breadcrumbs()"> + ${h.link_to(u'Home',h.url('/'))} + / + ${h.link_to(c.repo_name,h.url('files_home',repo_name=c.repo_name))} + / + ${_('files')} + +<%def name="page_nav()"> +
+ +
+ + ${self.menu('files')} + +<%def name="css()"> + + + +<%def name="main()"> + + +
+

${_('File')}: ${c.repo_name}/${c.f_path}

+ %if c.files_list.is_dir(): + + + + + + + + + + + + % if c.files_list.parent: + + %endif + + <%def name="file_class(node)"> + %if node.is_file(): + browser-file + %else: + browser-dir + %endif + + + + %for cnt,node in enumerate(c.files_list): + + + + + + + + + %endfor +
${_('Name')}${_('Size')}${_('Revision')}${_('Last modified')}${_('Last commiter')}
+ ${h.link_to('..',h.url('files_home',repo_name=c.repo_name,revision=c.cur_rev,f_path=c.files_list.parent))} +
+ ${h.link_to(node.name,h.url('files_home',repo_name=c.repo_name,revision=c.cur_rev,f_path=node.path),class_='file or dir')} + + %if node.is_file(): + ${h.filesizeformat(node.size)} + %endif + + %if node.is_file(): + ${node.last_changeset.revision} + %endif + + %if node.is_file(): + ${node.last_changeset.date} + %endif + + %if node.is_file(): + ${node.last_changeset.author} + %endif + +
+ %else: +
+ ${h.pygmentize(c.files_list.content,linenos=True,anchorlinenos=True,cssclass="code-highlight")} +
+ %endif +
+ \ No newline at end of file