Changeset - f63cc1cbce27
[Not reviewed]
beta
0 3 1
Marcin Kuzminski - 15 years ago 2011-03-19 01:07:53
marcin@python-works.com
implemented repo switcher list as dynamically loaded by xhr requestt.
fixed sorting bug and missing groups on them
4 files changed with 48 insertions and 10 deletions:
0 comments (0 inline, 0 general)
rhodecode/config/routing.py
Show inline comments
 
@@ -34,12 +34,13 @@ def make_map(config):
 
    #==========================================================================
 
    # CUSTOM ROUTES HERE
 
    #==========================================================================
 

	
 
    #MAIN PAGE
 
    routes_map.connect('home', '/', controller='home', action='index')
 
    routes_map.connect('repo_switcher', '/repos', controller='home', action='repo_switcher')
 
    routes_map.connect('bugtracker', "http://bitbucket.org/marcinkuzminski/rhodecode/issues", _static=True)
 
    routes_map.connect('gpl_license', "http://www.gnu.org/licenses/gpl.html", _static=True)
 
    routes_map.connect('rhodecode_official', "http://rhodecode.org", _static=True)
 

	
 
    #ADMIN REPOSITORY REST ROUTES
 
    with routes_map.submapper(path_prefix='/_admin', controller='admin/repos') as m:
rhodecode/controllers/home.py
Show inline comments
 
@@ -26,16 +26,18 @@
 
# MA  02110-1301, USA.
 

	
 
import logging
 
from operator import itemgetter
 

	
 
from pylons import tmpl_context as c, request
 
from paste.httpexceptions import HTTPBadRequest
 

	
 
from rhodecode.lib.auth import LoginRequired
 
from rhodecode.lib.base import BaseController, render
 

	
 

	
 
log = logging.getLogger(__name__)
 

	
 
class HomeController(BaseController):
 

	
 
    @LoginRequired()
 
    def __before__(self):
 
@@ -60,6 +62,14 @@ class HomeController(BaseController):
 
                                  reverse=True)
 
        else:
 
            c.repos_list = sorted(c.cached_repo_list, key=itemgetter(sort_key),
 
                                  reverse=False)
 

	
 
        return render('/index.html')
 

	
 
    def repo_switcher(self):
 
        if request.is_xhr:
 
            c.repos_list = sorted(c.cached_repo_list,
 
                                  key=itemgetter('name_sort'), reverse=False)
 
            return render('/repo_switcher_list.html')
 
        else:
 
            return HTTPBadRequest()
rhodecode/templates/base/base.html
Show inline comments
 
@@ -114,22 +114,34 @@
 
					<a id="repo_switcher" title="${_('Switch repository')}" href="#">
 
                    <span class="icon">
 
                        <img src="${h.url("/images/icons/database.png")}" alt="${_('Products')}" />
 
                    </span>
 
                    <span>&darr;</span>					
 
					</a>
 
					<ul class="repo_switcher">
 
                        %for repo in c.cached_repo_list:
 
                        
 
                          %if repo['dbrepo']['private']:
 
                             <li><img src="${h.url("/images/icons/lock.png")}" alt="${_('Private repository')}" class="repo_switcher_type"/>${h.link_to(repo['repo'].name,h.url('summary_home',repo_name=repo['repo'].name),class_="%s" % repo['dbrepo']['repo_type'])}</li>
 
                          %else:
 
                             <li><img src="${h.url("/images/icons/lock_open.png")}" alt="${_('Public repository')}" class="repo_switcher_type" />${h.link_to(repo['repo'].name,h.url('summary_home',repo_name=repo['repo'].name),class_="%s" % repo['dbrepo']['repo_type'])}</li>
 
                          %endif  
 
                        %endfor					
 
					</ul>			
 
					<ul id="repo_switcher_list" class="repo_switcher">
 
                        <li>
 
                            <a href="#">${_('loading...')}</a>
 
                        </li>
 
					</ul>
 
					<script type="text/javascript">
 
					   YUE.on('repo_switcher','mouseover',function(){
 
						   var loaded = YUD.hasClass('repo_switcher','loaded');
 
						   if(!loaded){
 
							   YUD.addClass('repo_switcher','loaded');
 
							   YAHOO.util.Connect.asyncRequest('GET',"${h.url('repo_switcher')}",{
 
								   success:function(o){
 
								      YUD.get('repo_switcher_list').innerHTML = o.responseText;
 
								   },
 
								   failure:function(o){
 
									   YUD.removeClass('repo_switcher','loaded');   
 
								   }
 
							   },null);
 
						   }
 
						   return false;
 
					   });
 
					</script>	
 
				</li>
 
				
 
	            <li ${is_current('summary')}>
 
	               <a title="${_('Summary')}" href="${h.url('summary_home',repo_name=c.repo_name)}">
 
	               <span class="icon">
 
	                   <img src="${h.url("/images/icons/clipboard_16.png")}" alt="${_('Summary')}" />
rhodecode/templates/repo_switcher_list.html
Show inline comments
 
new file 100644
 
## -*- coding: utf-8 -*-    
 
%for repo in c.repos_list:
 
     
 
      %if repo['dbrepo']['private']:
 
         <li>
 
             <img src="${h.url("/images/icons/lock.png")}" alt="${_('Private repository')}" class="repo_switcher_type"/>
 
             ${h.link_to(repo['name'].name,h.url('summary_home',repo_name=repo['name']),class_="%s" % repo['dbrepo']['repo_type'])}
 
          </li>
 
      %else:
 
         <li>
 
             <img src="${h.url("/images/icons/lock_open.png")}" alt="${_('Public repository')}" class="repo_switcher_type" />
 
             ${h.link_to(repo['name'],h.url('summary_home',repo_name=repo['name']),class_="%s" % repo['dbrepo']['repo_type'])}
 
         </li>
 
      %endif  
 
%endfor
 
\ No newline at end of file
0 comments (0 inline, 0 general)