Mercurial > kallithea
changeset 107:5e2470ebdbc6
Added repo switcher, in base and long term caching for this.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 26 Apr 2010 00:38:53 +0200 |
parents | a86c8de926b4 |
children | 68e574905860 |
files | development.ini production.ini pylons_app/config/environment.py pylons_app/controllers/summary.py pylons_app/lib/base.py pylons_app/public/css/monoblue_custom.css pylons_app/templates/base/base.html |
diffstat | 7 files changed, 59 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/development.ini Sun Apr 25 23:26:14 2010 +0200 +++ b/development.ini Mon Apr 26 00:38:53 2010 +0200 @@ -45,10 +45,12 @@ #################################### beaker.cache.data_dir=/tmp/cache/data beaker.cache.lock_dir=/tmp/cache/lock -beaker.cache.regions=short_term +beaker.cache.regions=short_term,long_term +beaker.cache.short_term.type=file +beaker.cache.short_term.expire=3600 beaker.cache.short_term.type=memory beaker.cache.short_term.expire=60 - + ################################################################################ ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ## ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
--- a/production.ini Sun Apr 25 23:26:14 2010 +0200 +++ b/production.ini Mon Apr 26 00:38:53 2010 +0200 @@ -45,9 +45,11 @@ #################################### beaker.cache.data_dir=/tmp/cache/data beaker.cache.lock_dir=/tmp/cache/lock -beaker.cache.regions=short_term +beaker.cache.regions=short_term,long_term +beaker.cache.short_term.type=file +beaker.cache.short_term.expire=3600 beaker.cache.short_term.type=memory -beaker.cache.short_term.expire=3600 +beaker.cache.short_term.expire=60 ################################################################################ ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
--- a/pylons_app/config/environment.py Sun Apr 25 23:26:14 2010 +0200 +++ b/pylons_app/config/environment.py Mon Apr 26 00:38:53 2010 +0200 @@ -48,7 +48,7 @@ imports=['from webhelpers.html import escape']) #sets the c attribute access when don't existing attribute ar accessed - config['pylons.strict_tmpl_context'] = False + config['pylons.strict_tmpl_context'] = True #MULTIPLE DB configs # Setup the SQLAlchemy database engine
--- a/pylons_app/controllers/summary.py Sun Apr 25 23:26:14 2010 +0200 +++ b/pylons_app/controllers/summary.py Mon Apr 26 00:38:53 2010 +0200 @@ -27,6 +27,6 @@ '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) + c.repo_tags = []#c.repo_info.get_tags(limit=10) + c.repo_branches = []#c.repo_info.get_branches(limit=10) return render('/summary.html')
--- a/pylons_app/lib/base.py Sun Apr 25 23:26:14 2010 +0200 +++ b/pylons_app/lib/base.py Mon Apr 26 00:38:53 2010 +0200 @@ -5,14 +5,25 @@ from pylons.controllers import WSGIController from pylons.templating import render_mako as render from pylons_app.model import meta +from beaker.cache import cache_region +from pylons import tmpl_context as c +from pylons_app.model.hg_model import HgModel class BaseController(WSGIController): - + def _load_repos(self): + + @cache_region('long_term', 'repo_list_2') + def _get_repos(): + return [rep['name'] for rep in HgModel().get_repos()] + + c.repo_list = _get_repos() + def __call__(self, environ, start_response): """Invoke the Controller""" # WSGIController.__call__ dispatches to the Controller method # the request is routed to. This routing information is # available in environ['pylons.routes_dict'] + self._load_repos() try: return WSGIController.__call__(self, environ, start_response) finally:
--- a/pylons_app/public/css/monoblue_custom.css Sun Apr 25 23:26:14 2010 +0200 +++ b/pylons_app/public/css/monoblue_custom.css Mon Apr 26 00:38:53 2010 +0200 @@ -43,7 +43,7 @@ margin: 10px 0 30px; font-size: 1.8em; font-weight: bold; - font-family: osaka,'MS P Gothic', Georgia, serif; + font-family: sans-serif; letter-spacing: 1px; color: #DDD; } @@ -91,18 +91,21 @@ ul.page-nav li { margin: 0 2px 0 0; float: left; - width: 80px; height: 24px; font-size: 1.1em; line-height: 24px; - text-align: center; + text-align: center; } ul.page-nav li.current { background: #FFF; + padding-right:5px; + padding-left:5px; } ul.page-nav li a { height: 24px; color: #666; + padding-right:5px; + padding-left:5px; background: #DDD; display: block; text-decoration: none;
--- a/pylons_app/templates/base/base.html Sun Apr 25 23:26:14 2010 +0200 +++ b/pylons_app/templates/base/base.html Mon Apr 26 00:38:53 2010 +0200 @@ -51,7 +51,36 @@ <%def name="menu(current)"> <ul class="page-nav"> - + <script> + YAHOO.util.Event.onDOMReady(function(){ + YAHOO.util.Event.addListener('repo_switcher','click',function(){ + if(YAHOO.util.Dom.hasClass('repo_switcher','selected')){ + YAHOO.util.Dom.setStyle('switch_repos','display','none'); + YAHOO.util.Dom.removeClass('repo_switcher','selected'); + } + else{ + YAHOO.util.Dom.setStyle('switch_repos','display',''); + YAHOO.util.Dom.addClass('repo_switcher','selected'); + } + }); + YAHOO.util.Event.addListener('repos_list','change',function(e){ + var wa = YAHOO.util.Dom.get('repos_list').value; + + var url = "${h.url('summary_home',repo_name='__REPLACE__')}".replace('__REPLACE__',wa); + window.location = url; + }) + }); + </script> + <li> + <a id="repo_switcher" title="${_('Switch repository')}" href="#">↓</a> + <div id="switch_repos" style="display:none;position: absolute;width: 150px;height: 25px;background-color: #DDDDDD"> + <select id="repos_list"> + %for repo in c.repo_list: + <option value="${repo}">${repo}</option> + %endfor + </select> + </div> + </li> <li %if current=='summary': class='current'