Mercurial > kallithea
changeset 216:c8162373f214
Cleaned the way based was used to generate submenu for admin, now it's much more clear to use submenu. Cleaned admin and added comment to middleware
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 24 May 2010 22:20:21 +0200 |
parents | 70f645fa97cc |
children | 3a1b921ce51c |
files | pylons_app/config/middleware.py pylons_app/controllers/admin.py pylons_app/templates/admin/admin.html pylons_app/templates/admin/repos/repo_add.html pylons_app/templates/admin/repos/repo_edit.html pylons_app/templates/admin/repos/repos.html pylons_app/templates/admin/users/user_add.html pylons_app/templates/admin/users/user_edit.html pylons_app/templates/admin/users/users.html pylons_app/templates/base/base.html |
diffstat | 10 files changed, 116 insertions(+), 145 deletions(-) [+] |
line wrap: on
line diff
--- a/pylons_app/config/middleware.py Mon May 24 22:18:15 2010 +0200 +++ b/pylons_app/config/middleware.py Mon May 24 22:20:21 2010 +0200 @@ -58,7 +58,9 @@ else: app = StatusCodeRedirect(app, [400, 401, 403, 404, 500]) + #enable https redirets based on HTTP_X_URL_SCHEME set by proxy app = HttpsFixup(app) + # Establish the Registry for this application app = RegistryManager(app)
--- a/pylons_app/controllers/admin.py Mon May 24 22:18:15 2010 +0200 +++ b/pylons_app/controllers/admin.py Mon May 24 22:20:21 2010 +0200 @@ -7,7 +7,6 @@ from pylons_app.model import meta from pylons_app.model.db import UserLogs from webhelpers.paginate import Page -from pylons_app.lib.utils import check_repo, invalidate_cache from pylons_app.lib.auth import LoginRequired log = logging.getLogger(__name__) @@ -31,37 +30,5 @@ c.log_data = render('admin/admin_log.html') if request.params.get('partial'): return c.log_data - return render('admin/admin.html') - - def add_repo(self, new_repo): - #extra check it can be add since it's the command - if new_repo == '_admin': - c.msg = 'DENIED' - c.new_repo = '' - return render('admin/add.html') - - new_repo = new_repo.replace(" ", "_") - new_repo = new_repo.replace("-", "_") - - try: - self._create_repo(new_repo) - c.new_repo = new_repo - c.msg = 'added repo' - #clear our cached list for refresh with new repo - invalidate_cache('cached_repo_list') - except Exception as e: - c.new_repo = 'Exception when adding: %s' % new_repo - c.msg = str(e) - - return render('admin/add.html') - - - def _create_repo(self, repo_name): - if repo_name in [None, '', 'add']: - raise Exception('undefined repo_name of repo') - repo_path = os.path.join(g.base_path, repo_name) - if check_repo(repo_name, g.base_path): - log.info('creating repo %s in %s', repo_name, repo_path) - from vcs.backends.hg import MercurialRepository - MercurialRepository(repo_path, create=True) + return render('admin/admin.html')
--- a/pylons_app/templates/admin/admin.html Mon May 24 22:18:15 2010 +0200 +++ b/pylons_app/templates/admin/admin.html Mon May 24 22:20:21 2010 +0200 @@ -2,7 +2,7 @@ <%inherit file="/base/base.html"/> <%def name="title()"> - ${_('Repository managment')} + ${_('Administration')} </%def> <%def name="breadcrumbs()"> ${h.link_to(u'Admin',h.url('admin_home'))} @@ -10,20 +10,13 @@ </%def> <%def name="page_nav()"> ${self.menu('admin')} + ${self.submenu('')} </%def> <%def name="main()"> %if c.admin_user: - <ul class="submenu"> - <li> - ${h.link_to(u'Repos',h.url('repos'))} - </li> - <li> - ${h.link_to(u'Users',h.url('users'))} - </li> - </ul> - <br/> <div> <h2>Welcome ${c.admin_username}</h2> + ${_('Last actions')} <div id="user_log"> ${c.log_data} </div>
--- a/pylons_app/templates/admin/repos/repo_add.html Mon May 24 22:18:15 2010 +0200 +++ b/pylons_app/templates/admin/repos/repo_add.html Mon May 24 22:20:21 2010 +0200 @@ -2,39 +2,39 @@ <%inherit file="/base/base.html"/> <%def name="title()"> - ${_('Add new repository')} + ${_('Repositories administration')} </%def> - <%def name="breadcrumbs()"> ${h.link_to(u'Admin',h.url('admin_home'))} - / + / </%def> - <%def name="page_nav()"> ${self.menu('admin')} -</%def> - -<%def name="main()"> - <table cellspacing="0"> - <tr> - <td><h1>${c.msg}</h1></td> - </tr> - <tr> - <td><h2>${c.new_repo}</h2></td> - </tr> - </table> + ${self.submenu('repos')} </%def> - - - - - - - - - - - - - - +<%def name="main()"> + <div> + <h2>${_('Repositories')} - ${_('add new')}</h2> + ${h.form(url('repos'))} + <table> + <tr> + <td>${_('Name')}</td> + <td>${h.text('name',c.new_repo)}</td> + </tr> + <tr> + <td>${_('Description')}</td> + <td>${h.textarea('description',cols=23,rows=5)}</td> + </tr> + <tr> + <td>${_('Private')}</td> + <td>${h.checkbox('private')}</td> + </tr> + <tr> + <td></td> + <td>${h.submit('add','add')}</td> + </tr> + + </table> + ${h.end_form()} + </div> +</%def>
--- a/pylons_app/templates/admin/repos/repo_edit.html Mon May 24 22:18:15 2010 +0200 +++ b/pylons_app/templates/admin/repos/repo_edit.html Mon May 24 22:20:21 2010 +0200 @@ -1,25 +1,40 @@ -<%inherit file="base/base.html"/> +## -*- coding: utf-8 -*- +<%inherit file="/base/base.html"/> + <%def name="title()"> - ${_('Repository managment')} + ${_('Repositories administration')} </%def> <%def name="breadcrumbs()"> - ${h.link_to(u'Admin',h.url('admin_home'))} - / - ${h.link_to(u'Repos managment',h.url('repos'))} + ${h.link_to(u'Admin',h.url('admin_home'))} + / </%def> <%def name="page_nav()"> ${self.menu('admin')} + ${self.submenu('repos')} </%def> <%def name="main()"> - <ul class="submenu"> - <li class="current_submenu"> - ${h.link_to(u'Repos',h.url('repos'))} - </li> - <li> - ${h.link_to(u'Users',h.url('users'))} - </li> - </ul> <div> - <h2>${_('Mercurial repos')}</h2> + <h2>${_('Repositories')} - ${_('edit')}</h2> + ${h.form(url('repos'))} + <table> + <tr> + <td>${_('Name')}</td> + <td>${h.text('name',c.new_repo)}</td> + </tr> + <tr> + <td>${_('Description')}</td> + <td>${h.textarea('description',cols=23,rows=5)}</td> + </tr> + <tr> + <td>${_('Private')}</td> + <td>${h.checkbox('private')}</td> + </tr> + <tr> + <td></td> + <td>${h.submit('add','add')}</td> + </tr> + + </table> + ${h.end_form()} </div> -</%def> \ No newline at end of file +</%def>
--- a/pylons_app/templates/admin/repos/repos.html Mon May 24 22:18:15 2010 +0200 +++ b/pylons_app/templates/admin/repos/repos.html Mon May 24 22:20:21 2010 +0200 @@ -1,26 +1,20 @@ +## -*- coding: utf-8 -*- <%inherit file="/base/base.html"/> + <%def name="title()"> - ${_('Repository managment')} + ${_('Repositories administration')} </%def> <%def name="breadcrumbs()"> - ${h.link_to(u'Admin',h.url('admin_home'))} - / - ${h.link_to(u'Repos managment',h.url('repos'))} + ${h.link_to(u'Admin',h.url('admin_home'))} + / </%def> <%def name="page_nav()"> ${self.menu('admin')} + ${self.submenu('repos')} </%def> <%def name="main()"> - <ul class="submenu"> - <li> - ${h.link_to(u'Repos',h.url('repos'), class_="current_submenu")} - </li> - <li> - ${h.link_to(u'Users',h.url('users'))} - </li> - </ul> <div> - <h2>${_('Mercurial repos')}</h2> + <h2>${_('Repositories administration')}</h2> <table> %for cnt,repo in enumerate(c.repos_list): <tr class="parity${cnt%2}"> @@ -35,4 +29,4 @@ %endfor </table> </div> -</%def> \ No newline at end of file +</%def>
--- a/pylons_app/templates/admin/users/user_add.html Mon May 24 22:18:15 2010 +0200 +++ b/pylons_app/templates/admin/users/user_add.html Mon May 24 22:20:21 2010 +0200 @@ -1,24 +1,18 @@ +## -*- coding: utf-8 -*- <%inherit file="/base/base.html"/> + <%def name="title()"> - ${_('User')} - ${_('add new')} + ${_('User administration')} </%def> <%def name="breadcrumbs()"> - ${h.link_to(u'Admin',h.url('admin_home'))} - / - ${h.link_to(u'Users',h.url('users'))} + ${h.link_to(u'Admin',h.url('admin_home'))} + / </%def> <%def name="page_nav()"> ${self.menu('admin')} + ${self.submenu('users')} </%def> <%def name="main()"> - <ul class="submenu"> - <li> - ${h.link_to(u'Repos',h.url('repos'))} - </li> - <li class="current_submenu"> - ${h.link_to(u'Users',h.url('users'))} - </li> - </ul> <div> <h2>${_('User')} - ${_('add new')}</h2> ${h.form(url('users'))} @@ -41,7 +35,6 @@ </tr> </table> - ${h.end_form()} </div> </%def> \ No newline at end of file
--- a/pylons_app/templates/admin/users/user_edit.html Mon May 24 22:18:15 2010 +0200 +++ b/pylons_app/templates/admin/users/user_edit.html Mon May 24 22:20:21 2010 +0200 @@ -1,24 +1,18 @@ +## -*- coding: utf-8 -*- <%inherit file="/base/base.html"/> + <%def name="title()"> - ${_('User')} - ${c.user.username} + ${_('User administration')} </%def> <%def name="breadcrumbs()"> - ${h.link_to(u'Admin',h.url('admin_home'))} - / - ${h.link_to(u'Users',h.url('users'))} + ${h.link_to(u'Admin',h.url('admin_home'))} + / </%def> <%def name="page_nav()"> ${self.menu('admin')} + ${self.submenu('users')} </%def> <%def name="main()"> - <ul class="submenu"> - <li> - ${h.link_to(u'Repos',h.url('repos'))} - </li> - <li class="current_submenu"> - ${h.link_to(u'Users',h.url('users'))} - </li> - </ul> <div> <h2>${_('User')} - ${c.user.username}</h2> ${h.form(url('user', id=c.user.user_id),method='put')} @@ -41,7 +35,6 @@ </tr> </table> - ${h.end_form()} </div> -</%def> \ No newline at end of file +</%def> \ No newline at end of file
--- a/pylons_app/templates/admin/users/users.html Mon May 24 22:18:15 2010 +0200 +++ b/pylons_app/templates/admin/users/users.html Mon May 24 22:20:21 2010 +0200 @@ -1,24 +1,18 @@ +## -*- coding: utf-8 -*- <%inherit file="/base/base.html"/> + <%def name="title()"> - ${_('Users managment')} + ${_('Users administration')} </%def> <%def name="breadcrumbs()"> - ${h.link_to(u'Admin',h.url('admin_home'))} - / - ${h.link_to(u'Users managment',h.url('users'))} + ${h.link_to(u'Admin',h.url('admin_home'))} + / </%def> <%def name="page_nav()"> ${self.menu('admin')} + ${self.submenu('users')} </%def> <%def name="main()"> - <ul class="submenu"> - <li> - ${h.link_to(u'Repos',h.url('repos'))} - </li> - <li> - ${h.link_to(u'Users',h.url('users'), class_="current_submenu")} - </li> - </ul> <div> <h2>${_('Mercurial users')}</h2> <table> @@ -45,5 +39,4 @@ </table> <h3>${h.link_to(u'Add user',h.url('new_user'))}</h3> </div> - -</%def> \ No newline at end of file +</%def>
--- a/pylons_app/templates/base/base.html Mon May 24 22:18:15 2010 +0200 +++ b/pylons_app/templates/base/base.html Mon May 24 22:20:21 2010 +0200 @@ -5,6 +5,7 @@ <link rel="icon" href="/images/hgicon.png" type="image/png" /> <meta name="robots" content="index, nofollow"/> <title>${next.title()}</title> + ##For future use yui reset for cross browser compatability. ##<link rel="stylesheet" href="/js/yui/reset-fonts-grids/reset-fonts-grids.css" type="text/css" /> ${self.css()} ${self.js()} @@ -15,12 +16,11 @@ <div class="page-header"> <h1>${next.breadcrumbs()}</h1> ${self.page_nav()} - </div> <div id="main"> ${next.main()} </div> <div class="page-footer"> - Hg App ${c.hg_app_version} © 2010 + Hg App ${c.hg_app_version} © 2010 by Marcin Kuzminski </div> <div id="powered-by"> @@ -43,6 +43,7 @@ <%def name="page_nav()"> ${self.menu()} + ${self.submenu()} </%def> <%def name="menu(current)"> @@ -52,6 +53,7 @@ return "class='current'" %> %if current not in ['home','admin']: + ##regular menu <script type="text/javascript"> YAHOO.util.Event.onDOMReady(function(){ YAHOO.util.Event.addListener('repo_switcher','click',function(){ @@ -93,13 +95,32 @@ <li ${is_current('files')}>${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name))}</li> </ul> %else: + ##Root menu <ul class="page-nav"> <li ${is_current('home')}>${h.link_to(_('Home'),h.url('/'))}</li> <li ${is_current('admin')}>${h.link_to(_('Admin'),h.url('admin_home'))}</li> <li class="logout">${h.link_to(u'Logout',h.url('logout_home'))}</li> </ul> %endif + </div> </%def> +<%def name="submenu(current=None)"> + <% + def is_current(selected): + if selected == current: + return "class='current_submenu'" + %> + %if current != None: + <div> + <ul class="submenu"> + <li ${is_current('repos')}>${h.link_to(u'repos',h.url('repos'))}</li> + <li ${is_current('users')}>${h.link_to(u'users',h.url('users'))}</li> + </ul> + <br/> + </div> + %endif +</%def> + <%def name="css()"> <link rel="stylesheet" href="/css/monoblue_custom.css" type="text/css" />