Changeset - 66b20f525750
[Not reviewed]
default
0 2 2
Marcin Kuzminski - 15 years ago 2010-05-23 01:03:54
marcin@python-works.com
Added feed controllers, urls,and changed index page to use them.
4 files changed with 38 insertions and 5 deletions:
0 comments (0 inline, 0 general)
pylons_app/config/routing.py
Show inline comments
 
@@ -23,32 +23,38 @@ def make_map(config):
 
    
 
    
 
    #REST controllers
 
    map.resource('repo', 'repos', path_prefix='/_admin')
 
    map.resource('user', 'users', path_prefix='/_admin')
 
    
 
    #ADMIN
 
    with map.submapper(path_prefix='/_admin', controller='admin') as m:
 
        m.connect('admin_home', '/', action='index')#main page
 
        m.connect('admin_add_repo', '/add_repo/{new_repo:[a-z0-9\. _-]*}',
 
                  action='add_repo')
 
    
 
    #FEEDS
 
    map.connect('rss_feed_home', '/{repo_name}/feed/rss',
 
                controller='feed', action='rss')
 
    map.connect('atom_feed_home', '/{repo_name}/feed/atom',
 
                controller='feed', action='atom')
 
    
 
    map.connect('login_home', '/login', controller='login')
 
    map.connect('logout_home', '/logout', controller='login', action='logout')
 
    
 
    map.connect('changeset_home', '/{repo_name}/changeset/{revision}',
 
                controller='changeset', revision='tip')
 
    map.connect('summary_home', '/{repo_name}/summary',
 
                controller='summary')
 
    map.connect('shortlog_home', '/{repo_name}/shortlog/',
 
    map.connect('shortlog_home', '/{repo_name}/shortlog',
 
                controller='shortlog')
 
    map.connect('branches_home', '/{repo_name}/branches',
 
                controller='branches')
 
    map.connect('tags_home', '/{repo_name}/tags',
 
                controller='tags')
 
    map.connect('changelog_home', '/{repo_name}/changelog',
 
                controller='changelog')    
 
    map.connect('files_home', '/{repo_name}/files/{revision}/{f_path:.*}',
 
                controller='files', revision='tip', f_path='')
 
    map.connect('files_diff_home', '/{repo_name}/diff/{f_path:.*}',
 
                controller='files', action='diff', revision='tip', f_path='')
 
    map.connect('files_raw_home', '/{repo_name}/rawfile/{revision}/{f_path:.*}',
pylons_app/controllers/feed.py
Show inline comments
 
new file 100644
 
#!/usr/bin/python
 
# -*- coding: utf-8 -*-
 
import logging
 
from operator import itemgetter
 
from pylons import tmpl_context as c, request, config
 
from pylons_app.lib.base import BaseController, render
 
from pylons_app.lib.utils import get_repo_slug
 
from pylons_app.model.hg_model import HgModel
 
from pylons_app.lib.auth import LoginRequired
 
log = logging.getLogger(__name__)
 

	
 
class FeedController(BaseController):
 
    
 
    #secure it or not ?
 
    def __before__(self):
 
        super(FeedController, self).__before__()
 
        
 
    def atom(self):
 
        return 'Hello Atom'
 
    
 
    def rss(self):
 
        return 'Hello rss'
pylons_app/templates/index.html
Show inline comments
 
@@ -11,28 +11,26 @@ from pylons_app.lib import filters
 
</%def>
 
<%def name="page_nav()">
 
	${self.menu('home')}
 
</%def>
 
<%def name="main()">
 
	<%def name="get_sort(name)">
 
		<%name_slug = name.lower().replace(' ','_') %>
 
		%if name_slug == c.cs_slug:
 
			<span style="font-weight: bold;color:#006699">${name}</span>
 
		%else:
 
			<span style="font-weight: bold">${name}</span>
 
		%endif
 
		
 
		<a href="?sort=${name_slug}">&darr;</a>
 
		<a href="?sort=-${name_slug}">&uarr;</a>
 
		
 
	</%def>
 
	<table>
 
	  <tr>
 
	    <td>${get_sort(_('Name'))}</td>
 
	    <td>${get_sort(_('Description'))}</td>
 
	    <td>${get_sort(_('Last change'))}</td>
 
	    <td>${get_sort(_('Tip'))}</td>
 
	    <td>${get_sort(_('Contact'))}</td>
 
	    <td></td>
 
	    <td></td>
 
	    <td></td>
 
	  </tr>	
 
@@ -40,21 +38,21 @@ from pylons_app.lib import filters
 
 		<tr class="parity${cnt%2}">
 
		    <td>${h.link(repo['name'],h.url('summary_home',repo_name=repo['name']))}</td>
 
		    <td>${repo['description']}</td>
 
	        <td>${repo['last_change']|n,filters.age}</td>
 
	        <td>r${repo['rev']}:<a href="/${repo['name']}/rev/${repo['tip']}/">${repo['tip']}</a></td>
 
	        <td>${repo['contact']}</td>
 
	        <td class="indexlinks">
 
	        	%for archive in repo['repo_archives']:
 
					<a href="/${repo['name']}/archive/${archive['node']}${archive['extension']}">${archive['type']}</a>
 
				%endfor
 
	        </td>
 
			<td>
 
				<a  class="rss_logo" href="/${repo['name']}/rss-log">RSS</a>
 
				${h.link_to(_('RSS'),h.url('rss_feed_home',repo_name=repo['name']),class_='rss_logo')}
 
			</td>        
 
			<td>
 
				<a  class="atom_logo" href="/${repo['name']}/atom-log">Atom</a>
 
				${h.link_to(_('Atom'),h.url('rss_feed_home',repo_name=repo['name']),class_='atom_logo')}
 
			</td>
 
		</tr>
 
	%endfor
 
	</table>
 
</%def>    
pylons_app/tests/functional/test_feed.py
Show inline comments
 
new file 100644
 
from pylons_app.tests import *
 

	
 
class TestFeedController(TestController):
 

	
 
    def test_index(self):
 
        response = self.app.get(url(controller='feed', action='index'))
 
        # Test response...
0 comments (0 inline, 0 general)