Mercurial > kallithea
annotate pylons_app/controllers/feed.py @ 207:8bdec09436cb rhodecode-0.0.0.7.1
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 23 May 2010 02:07:56 +0200 |
parents | 66b20f525750 |
children | a83a1799480c |
rev | line source |
---|---|
205
66b20f525750
Added feed controllers, urls,and changed index page to use them.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
1 #!/usr/bin/python |
66b20f525750
Added feed controllers, urls,and changed index page to use them.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
66b20f525750
Added feed controllers, urls,and changed index page to use them.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
3 import logging |
66b20f525750
Added feed controllers, urls,and changed index page to use them.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
4 from operator import itemgetter |
207
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
5 from pylons import tmpl_context as c, request, config, url, response |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
6 from pylons_app.lib.base import BaseController, render, _full_changelog_cached |
205
66b20f525750
Added feed controllers, urls,and changed index page to use them.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
7 from pylons_app.lib.utils import get_repo_slug |
66b20f525750
Added feed controllers, urls,and changed index page to use them.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 from pylons_app.model.hg_model import HgModel |
66b20f525750
Added feed controllers, urls,and changed index page to use them.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 from pylons_app.lib.auth import LoginRequired |
207
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
10 from webhelpers.feedgenerator import Atom1Feed, Rss201rev2Feed |
205
66b20f525750
Added feed controllers, urls,and changed index page to use them.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 log = logging.getLogger(__name__) |
66b20f525750
Added feed controllers, urls,and changed index page to use them.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 |
66b20f525750
Added feed controllers, urls,and changed index page to use them.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
13 class FeedController(BaseController): |
66b20f525750
Added feed controllers, urls,and changed index page to use them.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 |
66b20f525750
Added feed controllers, urls,and changed index page to use them.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
15 #secure it or not ? |
66b20f525750
Added feed controllers, urls,and changed index page to use them.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
16 def __before__(self): |
66b20f525750
Added feed controllers, urls,and changed index page to use them.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 super(FeedController, self).__before__() |
207
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
18 #common values for feeds |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
19 self.description = 'Changes on %s repository' |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
20 self.title = "%s feed" |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
21 self.language = 'en-us' |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
22 self.ttl = "5" |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
23 self.feed_nr = 10 |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
24 |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
25 def atom(self, repo_name): |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
26 """Produce an atom-1.0 feed via feedgenerator module""" |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
27 feed = Atom1Feed(title=self.title % repo_name, |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
28 link=url('summary_home', repo_name=repo_name, qualified=True), |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
29 description=self.description % repo_name, |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
30 language=self.language, |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
31 ttl=self.ttl) |
205
66b20f525750
Added feed controllers, urls,and changed index page to use them.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
32 |
207
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
33 |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
34 for cnt, cs in enumerate(_full_changelog_cached(repo_name)): |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
35 if cnt > self.feed_nr: |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
36 break |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
37 feed.add_item(title=cs.message, |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
38 link=url('changeset_home', repo_name=repo_name, revision=cs.raw_id, qualified=True), |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
39 description=str(cs.date)) |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
40 |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
41 response.content_type = feed.mime_type |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
42 return feed.writeString('utf-8') |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
43 |
205
66b20f525750
Added feed controllers, urls,and changed index page to use them.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
44 |
207
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
45 def rss(self, repo_name): |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
46 """Produce an rss2 feed via feedgenerator module""" |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
47 feed = Rss201rev2Feed(title=self.title % repo_name, |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
48 link=url('summary_home', repo_name=repo_name, qualified=True), |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
49 description=self.description % repo_name, |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
50 language=self.language, |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
51 ttl=self.ttl) |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
52 |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
53 for cnt, cs in enumerate(_full_changelog_cached(repo_name)): |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
54 if cnt > self.feed_nr: |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
55 break |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
56 feed.add_item(title=cs.message, |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
57 link=url('changeset_home', repo_name=repo_name, revision=cs.raw_id, qualified=True), |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
58 description=str(cs.date)) |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
59 |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
60 response.content_type = feed.mime_type |
8bdec09436cb
bumped version to 0.7.1 added atom and rss feeds. Moved https Fixud middleware before error middleware to proper generate debug page (static imports)
Marcin Kuzminski <marcin@python-works.com>
parents:
205
diff
changeset
|
61 return feed.writeString('utf-8') |