diff --git a/pylons_app/config/routing.py b/pylons_app/config/routing.py --- a/pylons_app/config/routing.py +++ b/pylons_app/config/routing.py @@ -25,6 +25,8 @@ def make_map(config): map.resource('repo', 'repos', path_prefix='/_admin') map.resource('user', 'users', path_prefix='/_admin') + + map.connect('hg_home', '/', controller='hg', action='index') map.connect('hg', '/{path_info:.*}', controller='hg', action="view", path_info='/') diff --git a/pylons_app/controllers/hg.py b/pylons_app/controllers/hg.py --- a/pylons_app/controllers/hg.py +++ b/pylons_app/controllers/hg.py @@ -1,11 +1,19 @@ #!/usr/bin/python # -*- coding: utf-8 -*- import logging +import os from pylons_app.lib.base import BaseController from pylons import tmpl_context as c, app_globals as g, session, request, config from pylons_app.lib import helpers as h from mako.template import Template from pylons.controllers.util import abort +from pylons_app.lib.base import BaseController, render +try: + from vcs.backends.hg import get_repositories +except ImportError: + print 'You have to import vcs module' +from mercurial.util import matchdate, Abort, makedate +from mercurial.hgweb.common import get_contact log = logging.getLogger(__name__) @@ -13,8 +21,33 @@ class HgController(BaseController): def __before__(self): c.repos_prefix = config['repos_name'] + c.staticurl = g.statics + + def index(self): + c.repos_list = [] + + def get_mtime(spath): + cl_path = os.path.join(spath, "00changelog.i") + if os.path.exists(cl_path): + return os.stat(cl_path).st_mtime + else: + return os.stat(spath).st_mtime + + for name, r in get_repositories(g.paths[0][0], g.paths[0][1]).items(): + last_change = (get_mtime(r.spath), makedate()[1]) + tmp = {} + tmp['name'] = name + tmp['desc'] = r.ui.config('web', 'description', 'Unknown', untrusted=True) + tmp['last_change'] = last_change, + tip = r.changectx('tip') + tmp['tip'] = tip.__str__(), + tmp['rev'] = tip.rev() + tmp['contact'] = get_contact(r.ui.config) + c.repos_list.append(tmp) + return render('/index.html') def view(self, *args, **kwargs): + #TODO: reimplement this not tu use hgwebdir response = g.hgapp(request.environ, self.start_response) http_accept = request.environ.get('HTTP_ACCEPT', False) diff --git a/pylons_app/lib/app_globals.py b/pylons_app/lib/app_globals.py --- a/pylons_app/lib/app_globals.py +++ b/pylons_app/lib/app_globals.py @@ -28,14 +28,15 @@ class Globals(object): self.cache = CacheManager(**parse_cache_config_options(config)) self.hgapp = wsgiapplication(self.make_web_app) - def make_web_app(self): repos = "hgwebdir.config" baseui = ui.ui() cfg = config.config() cfg.read(repos) paths = cfg.items('paths') + self.paths = paths self.check_repo_dir(paths) + self.set_statics(cfg) for k, v in cfg.items('web'): diff --git a/pylons_app/templates/index.html b/pylons_app/templates/index.html --- a/pylons_app/templates/index.html +++ b/pylons_app/templates/index.html @@ -1,161 +1,47 @@ - ## -*- coding: utf-8 -*- -<%inherit file = "base/base.html"/> - -<%def name="page_title()"> - ${_('Wire transfer')} - - -<%def name="body()"> - - - - - - -
- - - -
- -

Hello we are Luminous

-

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do -eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad -minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip -ex ea commodo consequat.


- -

What we do

- -
- - - -
-

Design

-

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do -eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad -minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip -ex ea. More »

-
- -
+## -*- coding: utf-8 -*- -
- - - -
-

Development

-

${h.secure_form('/home/make_payment',method='post',id="secure_form")} - ##Secure Form Tag for prevention of Cross-site request forgery (CSRF) attacks. - ##Generates form tags that include client-specific authorization tokens to be verified by the destined web app. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
${h.get_error('_authentication_token',c.form_errors)}
${_('Account number')}${h.text('account_number',size=44,maxlength=38)}${h.get_error('account_number',c.form_errors)}
${_('Title')}${h.textarea("title", "", cols=43, rows=5,maxlength=20)}${h.get_error('title',c.form_errors)}
${_('Recipient')}${h.select('recipient',1,c.recipients_list)}${h.get_error('recipient',c.form_errors)}
${_('Recipient address')}${h.text('recipient_address',size=44)}${h.get_error('recipient_address',c.form_errors)}
${_('Amount')}${h.text('amount',size='7')}zł${h.get_error('amount',c.form_errors)}
${h.submit('send',_('send'))}
- ${h.end_form()}More »

-
- -
- -
- - - -
-

Marketing

-

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do -eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad -minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip -ex ea. More »

-
- -
- -
- -
- +<%inherit file="base/base.html"/> +<%def name="title()"> + ${c.repos_prefix} Mercurial Repositories + +<%def name="breadcrumbs()"> +

${c.repos_prefix} Mercurial Repositories

+ +<%def name="page_nav()"> +
  • ${_('Home')}
  • +
  • ${h.link_to(u'Admin',h.url('admin_home'))}
  • - -<%def name="footer()"> - - - - +<%def name="main()"> + <%def name="get_sort(name)"> + ${name} + + + + + + + + + + %for cnt,repo in enumerate(c.repos_list): + + + + + + + + + + %endfor +
    ${get_sort(_('Name'))}${get_sort(_('Description'))}${get_sort(_('Last change'))}${get_sort(_('Tip'))}${get_sort(_('Contact'))}
    ${repo['name']}${repo['desc']}${repo['last_change']}r${repo['rev']}:${repo['tip']}${repo['contact']} + +
    +