##// END OF EJS Templates
Added simple forks page, resolves issue #179
marcink -
r1301:7e75af30 beta
parent child Browse files
Show More
@@ -0,0 +1,56 b''
1 # -*- coding: utf-8 -*-
2 """
3 rhodecode.controllers.forks
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
6 forks controller for rhodecode
7
8 :created_on: Apr 23, 2011
9 :author: marcink
10 :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com>
11 :license: GPLv3, see COPYING for more details.
12 """
13 # This program is free software: you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation, either version 3 of the License, or
16 # (at your option) any later version.
17 #
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25 import logging
26
27 from pylons import tmpl_context as c, request
28
29 from rhodecode.lib.helpers import Page
30 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
31 from rhodecode.lib.base import BaseRepoController, render
32 from rhodecode.model.db import Repository, User, UserFollowing
33
34 log = logging.getLogger(__name__)
35
36
37 class ForksController(BaseRepoController):
38
39 @LoginRequired()
40 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
41 'repository.admin')
42 def __before__(self):
43 super(ForksController, self).__before__()
44
45 def forks(self, repo_name):
46 p = int(request.params.get('page', 1))
47 repo_id = Repository.by_repo_name(repo_name).repo_id
48 d = Repository.get_repo_forks(repo_id)
49 c.forks_pager = Page(d, page=p, items_per_page=20)
50
51 c.forks_data = render('/forks/forks_data.html')
52
53 if request.params.get('partial'):
54 return c.forks_data
55
56 return render('/forks/forks.html')
@@ -0,0 +1,32 b''
1 ## -*- coding: utf-8 -*-
2 <%inherit file="/base/base.html"/>
3
4 <%def name="title()">
5 ${c.repo_name} ${_('Forks')} - ${c.rhodecode_name}
6 </%def>
7
8 <%def name="breadcrumbs_links()">
9 ${h.link_to(u'Home',h.url('/'))}
10 &raquo;
11 ${h.link_to(c.repo_name,h.url('summary_home',repo_name=c.repo_name))}
12 &raquo;
13 ${_('forks')}
14 </%def>
15
16 <%def name="page_nav()">
17 ${self.menu('forks')}
18 </%def>
19 <%def name="main()">
20 <div class="box">
21 <!-- box / title -->
22 <div class="title">
23 ${self.breadcrumbs()}
24 </div>
25 <!-- end box / title -->
26 <div class="table">
27 <div id="forks">
28 ${c.forks_data}
29 </div>
30 </div>
31 </div>
32 </%def> No newline at end of file
@@ -0,0 +1,40 b''
1 ## -*- coding: utf-8 -*-
2
3 % for f in c.forks_pager:
4 <div>
5 <div class="fork_user">
6 <div class="gravatar">
7 <img alt="gravatar" src="${h.gravatar_url(f.user.email,24)}"/>
8 </div>
9 <span style="font-size: 20px">
10 <b>${f.user.username}</b> (${f.user.name} ${f.user.lastname}) /
11 ${h.link_to(f.repo_name,h.url('summary_home',repo_name=f.repo_name))}
12 </span>
13 <div style="padding:5px 3px 3px 42px;">${f.description}</div>
14 </div>
15 <div style="clear:both;padding-top: 10px"></div>
16 <div class="follower_date">${_('forked')} -
17 <span class="tooltip" title="${f.created_on}"> ${h.age(f.created_on)}</span></div>
18 <div style="border-bottom: 1px solid #DDD;margin:10px 0px 10px 0px"></div>
19 </div>
20 % endfor
21
22 <div class="pagination-wh pagination-left">
23 <script type="text/javascript">
24 var data_div = 'forks';
25 YAHOO.util.Event.onDOMReady(function(){
26 YAHOO.util.Event.addListener(
27 YUD.getElementsByClassName('pager_link'),"click",
28 function(){
29 YAHOO.util.Dom.setStyle(data_div,'opacity','0.3');
30 });
31 });
32 </script>
33
34 ${c.forks_pager.pager('$link_previous ~2~ $link_next',
35 onclick="""YAHOO.util.Connect.asyncRequest('GET','$partial_url',{
36 success:function(o){YAHOO.util.Dom.get(data_div).innerHTML=o.responseText;
37 YUE.on(YAHOO.util.Dom.getElementsByClassName('pager_link'),"click",function(){
38 YAHOO.util.Dom.setStyle(data_div,'opacity','0.3');});
39 YAHOO.util.Dom.setStyle(data_div,'opacity','1');}},null); return false;""")}
40 </div> No newline at end of file
@@ -341,4 +341,8 b' def make_map(config):'
341 rmap.connect('repo_followers_home', '/{repo_name:.*}/followers',
341 rmap.connect('repo_followers_home', '/{repo_name:.*}/followers',
342 controller='followers', action='followers',
342 controller='followers', action='followers',
343 conditions=dict(function=check_repo))
343 conditions=dict(function=check_repo))
344
345 rmap.connect('repo_forks_home', '/{repo_name:.*}/forks',
346 controller='forks', action='forks',
347 conditions=dict(function=check_repo))
344 return rmap
348 return rmap
@@ -44,7 +44,7 b' class FollowersController(BaseRepoContro'
44
44
45 def followers(self, repo_name):
45 def followers(self, repo_name):
46 p = int(request.params.get('page', 1))
46 p = int(request.params.get('page', 1))
47 repo_id = getattr(Repository.by_repo_name(repo_name), 'repo_id')
47 repo_id = Repository.by_repo_name(repo_name).repo_id
48 d = UserFollowing.get_repo_followers(repo_id)\
48 d = UserFollowing.get_repo_followers(repo_id)\
49 .order_by(UserFollowing.follows_from)
49 .order_by(UserFollowing.follows_from)
50 c.followers_pager = Page(d, page=p, items_per_page=20)
50 c.followers_pager = Page(d, page=p, items_per_page=20)
@@ -237,6 +237,8 b' class Repository(Base):'
237 enable_statistics = Column("statistics", Boolean(), nullable=True, unique=None, default=True)
237 enable_statistics = Column("statistics", Boolean(), nullable=True, unique=None, default=True)
238 enable_downloads = Column("downloads", Boolean(), nullable=True, unique=None, default=True)
238 enable_downloads = Column("downloads", Boolean(), nullable=True, unique=None, default=True)
239 description = Column("description", String(length=10000, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
239 description = Column("description", String(length=10000, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
240 created_on = Column('created_on', DateTime(timezone=False), nullable=True, unique=None, default=datetime.datetime.now)
241
240 fork_id = Column("fork_id", Integer(), ForeignKey('repositories.repo_id'), nullable=True, unique=False, default=None)
242 fork_id = Column("fork_id", Integer(), ForeignKey('repositories.repo_id'), nullable=True, unique=False, default=None)
241 group_id = Column("group_id", Integer(), ForeignKey('groups.group_id'), nullable=True, unique=False, default=None)
243 group_id = Column("group_id", Integer(), ForeignKey('groups.group_id'), nullable=True, unique=False, default=None)
242
244
@@ -260,6 +262,11 b' class Repository(Base):'
260 def by_repo_name(cls, repo_name):
262 def by_repo_name(cls, repo_name):
261 return Session.query(cls).filter(cls.repo_name == repo_name).one()
263 return Session.query(cls).filter(cls.repo_name == repo_name).one()
262
264
265
266 @classmethod
267 def get_repo_forks(cls, repo_id):
268 return Session.query(cls).filter(Repository.fork_id == repo_id)
269
263 @property
270 @property
264 def just_name(self):
271 def just_name(self):
265 return self.repo_name.split(os.sep)[-1]
272 return self.repo_name.split(os.sep)[-1]
@@ -298,7 +298,7 b''
298 </a>
298 </a>
299 </li>
299 </li>
300 <li>
300 <li>
301 <a title="${_('Forks')}" href="#">
301 <a title="${_('Forks')}" href="${h.url('repo_forks_home',repo_name=c.repo_name)}">
302 <span class="icon_short">
302 <span class="icon_short">
303 <img src="${h.url("/images/icons/arrow_divide.png")}" alt="${_('Forks')}" />
303 <img src="${h.url("/images/icons/arrow_divide.png")}" alt="${_('Forks')}" />
304 </span>
304 </span>
General Comments 0
You need to be logged in to leave comments. Login now