changeset 205:66b20f525750

Added feed controllers, urls,and changed index page to use them.
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 23 May 2010 01:03:54 +0200
parents a8ea3ce3cdc4
children 7a6a69f3b9ec
files pylons_app/config/routing.py pylons_app/controllers/feed.py pylons_app/templates/index.html pylons_app/tests/functional/test_feed.py
diffstat 4 files changed, 38 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/pylons_app/config/routing.py	Sun May 23 00:54:22 2010 +0200
+++ b/pylons_app/config/routing.py	Sun May 23 01:03:54 2010 +0200
@@ -32,6 +32,12 @@
         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')
     
@@ -39,7 +45,7 @@
                 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')
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pylons_app/controllers/feed.py	Sun May 23 01:03:54 2010 +0200
@@ -0,0 +1,22 @@
+#!/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'
--- a/pylons_app/templates/index.html	Sun May 23 00:54:22 2010 +0200
+++ b/pylons_app/templates/index.html	Sun May 23 01:03:54 2010 +0200
@@ -20,10 +20,8 @@
 		%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>
@@ -49,10 +47,10 @@
 				%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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pylons_app/tests/functional/test_feed.py	Sun May 23 01:03:54 2010 +0200
@@ -0,0 +1,7 @@
+from pylons_app.tests import *
+
+class TestFeedController(TestController):
+
+    def test_index(self):
+        response = self.app.get(url(controller='feed', action='index'))
+        # Test response...