Show More
@@ -337,7 +337,12 b' def make_map(config):' | |||||
337 | m.connect('api', '/api') |
|
337 | m.connect('api', '/api') | |
338 |
|
338 | |||
339 | #USER JOURNAL |
|
339 | #USER JOURNAL | |
340 |
rmap.connect('journal', '%s/journal' % ADMIN_PREFIX, |
|
340 | rmap.connect('journal', '%s/journal' % ADMIN_PREFIX, | |
|
341 | controller='journal', action='index') | |||
|
342 | rmap.connect('journal_rss', '%s/journal/rss' % ADMIN_PREFIX, | |||
|
343 | controller='journal', action='journal_rss') | |||
|
344 | rmap.connect('journal_atom', '%s/journal/atom' % ADMIN_PREFIX, | |||
|
345 | controller='journal', action='journal_atom') | |||
341 |
|
346 | |||
342 | rmap.connect('public_journal', '%s/public_journal' % ADMIN_PREFIX, |
|
347 | rmap.connect('public_journal', '%s/public_journal' % ADMIN_PREFIX, | |
343 | controller='journal', action="public_journal") |
|
348 | controller='journal', action="public_journal") |
@@ -49,8 +49,6 b' class JournalController(BaseController):' | |||||
49 |
|
49 | |||
50 | def __before__(self): |
|
50 | def __before__(self): | |
51 | super(JournalController, self).__before__() |
|
51 | super(JournalController, self).__before__() | |
52 | self.rhodecode_user = self.rhodecode_user |
|
|||
53 | self.title = _('%s public journal %s feed') % (c.rhodecode_name, '%s') |
|
|||
54 | self.language = 'en-us' |
|
52 | self.language = 'en-us' | |
55 | self.ttl = "5" |
|
53 | self.ttl = "5" | |
56 | self.feed_nr = 20 |
|
54 | self.feed_nr = 20 | |
@@ -84,6 +82,28 b' class JournalController(BaseController):' | |||||
84 | return c.journal_data |
|
82 | return c.journal_data | |
85 | return render('journal/journal.html') |
|
83 | return render('journal/journal.html') | |
86 |
|
84 | |||
|
85 | @LoginRequired(api_access=True) | |||
|
86 | def journal_atom(self): | |||
|
87 | """ | |||
|
88 | Produce an atom-1.0 feed via feedgenerator module | |||
|
89 | """ | |||
|
90 | following = self.sa.query(UserFollowing)\ | |||
|
91 | .filter(UserFollowing.user_id == self.rhodecode_user.user_id)\ | |||
|
92 | .options(joinedload(UserFollowing.follows_repository))\ | |||
|
93 | .all() | |||
|
94 | return self._atom_feed(following, public=False) | |||
|
95 | ||||
|
96 | @LoginRequired(api_access=True) | |||
|
97 | def journal_rss(self): | |||
|
98 | """ | |||
|
99 | Produce an rss feed via feedgenerator module | |||
|
100 | """ | |||
|
101 | following = self.sa.query(UserFollowing)\ | |||
|
102 | .filter(UserFollowing.user_id == self.rhodecode_user.user_id)\ | |||
|
103 | .options(joinedload(UserFollowing.follows_repository))\ | |||
|
104 | .all() | |||
|
105 | return self._rss_feed(following, public=False) | |||
|
106 | ||||
87 | def _get_daily_aggregate(self, journal): |
|
107 | def _get_daily_aggregate(self, journal): | |
88 | groups = [] |
|
108 | groups = [] | |
89 | for k, g in groupby(journal, lambda x: x.action_as_day): |
|
109 | for k, g in groupby(journal, lambda x: x.action_as_day): | |
@@ -173,6 +193,80 b' class JournalController(BaseController):' | |||||
173 | return c.journal_data |
|
193 | return c.journal_data | |
174 | return render('journal/public_journal.html') |
|
194 | return render('journal/public_journal.html') | |
175 |
|
195 | |||
|
196 | def _atom_feed(self, repos, public=True): | |||
|
197 | journal = self._get_journal_data(repos) | |||
|
198 | if public: | |||
|
199 | _link = url('public_journal_atom', qualified=True) | |||
|
200 | _desc = '%s %s %s' % (c.rhodecode_name, _('public journal'), | |||
|
201 | 'atom feed') | |||
|
202 | else: | |||
|
203 | _link = url('journal_atom', qualified=True) | |||
|
204 | _desc = '%s %s %s' % (c.rhodecode_name, _('journal'), 'atom feed') | |||
|
205 | ||||
|
206 | feed = Atom1Feed(title=_desc, | |||
|
207 | link=_link, | |||
|
208 | description=_desc, | |||
|
209 | language=self.language, | |||
|
210 | ttl=self.ttl) | |||
|
211 | ||||
|
212 | for entry in journal[:self.feed_nr]: | |||
|
213 | action, action_extra, ico = h.action_parser(entry, feed=True) | |||
|
214 | title = "%s - %s %s" % (entry.user.short_contact, action(), | |||
|
215 | entry.repository.repo_name) | |||
|
216 | desc = action_extra() | |||
|
217 | _url = None | |||
|
218 | if entry.repository is not None: | |||
|
219 | _url = url('changelog_home', | |||
|
220 | repo_name=entry.repository.repo_name, | |||
|
221 | qualified=True) | |||
|
222 | ||||
|
223 | feed.add_item(title=title, | |||
|
224 | pubdate=entry.action_date, | |||
|
225 | link=_url or url('', qualified=True), | |||
|
226 | author_email=entry.user.email, | |||
|
227 | author_name=entry.user.full_contact, | |||
|
228 | description=desc) | |||
|
229 | ||||
|
230 | response.content_type = feed.mime_type | |||
|
231 | return feed.writeString('utf-8') | |||
|
232 | ||||
|
233 | def _rss_feed(self, repos, public=True): | |||
|
234 | journal = self._get_journal_data(repos) | |||
|
235 | if public: | |||
|
236 | _link = url('public_journal_atom', qualified=True) | |||
|
237 | _desc = '%s %s %s' % (c.rhodecode_name, _('public journal'), | |||
|
238 | 'rss feed') | |||
|
239 | else: | |||
|
240 | _link = url('journal_atom', qualified=True) | |||
|
241 | _desc = '%s %s %s' % (c.rhodecode_name, _('journal'), 'rss feed') | |||
|
242 | ||||
|
243 | feed = Rss201rev2Feed(title=_desc, | |||
|
244 | link=_link, | |||
|
245 | description=_desc, | |||
|
246 | language=self.language, | |||
|
247 | ttl=self.ttl) | |||
|
248 | ||||
|
249 | for entry in journal[:self.feed_nr]: | |||
|
250 | action, action_extra, ico = h.action_parser(entry, feed=True) | |||
|
251 | title = "%s - %s %s" % (entry.user.short_contact, action(), | |||
|
252 | entry.repository.repo_name) | |||
|
253 | desc = action_extra() | |||
|
254 | _url = None | |||
|
255 | if entry.repository is not None: | |||
|
256 | _url = url('changelog_home', | |||
|
257 | repo_name=entry.repository.repo_name, | |||
|
258 | qualified=True) | |||
|
259 | ||||
|
260 | feed.add_item(title=title, | |||
|
261 | pubdate=entry.action_date, | |||
|
262 | link=_url or url('', qualified=True), | |||
|
263 | author_email=entry.user.email, | |||
|
264 | author_name=entry.user.full_contact, | |||
|
265 | description=desc) | |||
|
266 | ||||
|
267 | response.content_type = feed.mime_type | |||
|
268 | return feed.writeString('utf-8') | |||
|
269 | ||||
176 | @LoginRequired(api_access=True) |
|
270 | @LoginRequired(api_access=True) | |
177 | def public_journal_atom(self): |
|
271 | def public_journal_atom(self): | |
178 | """ |
|
272 | """ | |
@@ -183,28 +277,7 b' class JournalController(BaseController):' | |||||
183 | .options(joinedload(UserFollowing.follows_repository))\ |
|
277 | .options(joinedload(UserFollowing.follows_repository))\ | |
184 | .all() |
|
278 | .all() | |
185 |
|
279 | |||
186 |
|
|
280 | return self._atom_feed(c.following) | |
187 |
|
||||
188 | feed = Atom1Feed(title=self.title % 'atom', |
|
|||
189 | link=url('public_journal_atom', qualified=True), |
|
|||
190 | description=_('Public journal'), |
|
|||
191 | language=self.language, |
|
|||
192 | ttl=self.ttl) |
|
|||
193 |
|
||||
194 | for entry in journal[:self.feed_nr]: |
|
|||
195 | action, action_extra, ico = h.action_parser(entry, feed=True) |
|
|||
196 | title = "%s - %s %s" % (entry.user.short_contact, action(), |
|
|||
197 | entry.repository.repo_name) |
|
|||
198 | desc = action_extra() |
|
|||
199 | feed.add_item(title=title, |
|
|||
200 | pubdate=entry.action_date, |
|
|||
201 | link=url('', qualified=True), |
|
|||
202 | author_email=entry.user.email, |
|
|||
203 | author_name=entry.user.full_contact, |
|
|||
204 | description=desc) |
|
|||
205 |
|
||||
206 | response.content_type = feed.mime_type |
|
|||
207 | return feed.writeString('utf-8') |
|
|||
208 |
|
281 | |||
209 | @LoginRequired(api_access=True) |
|
282 | @LoginRequired(api_access=True) | |
210 | def public_journal_rss(self): |
|
283 | def public_journal_rss(self): | |
@@ -216,25 +289,4 b' class JournalController(BaseController):' | |||||
216 | .options(joinedload(UserFollowing.follows_repository))\ |
|
289 | .options(joinedload(UserFollowing.follows_repository))\ | |
217 | .all() |
|
290 | .all() | |
218 |
|
291 | |||
219 |
|
|
292 | return self._rss_feed(c.following) | |
220 |
|
||||
221 | feed = Rss201rev2Feed(title=self.title % 'rss', |
|
|||
222 | link=url('public_journal_rss', qualified=True), |
|
|||
223 | description=_('Public journal'), |
|
|||
224 | language=self.language, |
|
|||
225 | ttl=self.ttl) |
|
|||
226 |
|
||||
227 | for entry in journal[:self.feed_nr]: |
|
|||
228 | action, action_extra, ico = h.action_parser(entry, feed=True) |
|
|||
229 | title = "%s - %s %s" % (entry.user.short_contact, action(), |
|
|||
230 | entry.repository.repo_name) |
|
|||
231 | desc = action_extra() |
|
|||
232 | feed.add_item(title=title, |
|
|||
233 | pubdate=entry.action_date, |
|
|||
234 | link=url('', qualified=True), |
|
|||
235 | author_email=entry.user.email, |
|
|||
236 | author_name=entry.user.full_contact, |
|
|||
237 | description=desc) |
|
|||
238 |
|
||||
239 | response.content_type = feed.mime_type |
|
|||
240 | return feed.writeString('utf-8') |
|
@@ -17,8 +17,13 b'' | |||||
17 | <h5>${_('Journal')}</h5> |
|
17 | <h5>${_('Journal')}</h5> | |
18 | <ul class="links"> |
|
18 | <ul class="links"> | |
19 | <li> |
|
19 | <li> | |
20 | <span><a id="refresh" href="${h.url('journal')}"><img class="icon" title="${_('Refresh')}" alt="${_('Refresh')}" src="${h.url('/images/icons/arrow_refresh.png')}"/> |
|
20 | <span><a id="refresh" href="${h.url('journal')}"><img class="icon" title="${_('Refresh')}" alt="${_('Refresh')}" src="${h.url('/images/icons/arrow_refresh.png')}"/></a></span> | |
21 |
|
|
21 | </li> | |
|
22 | <li> | |||
|
23 | <span><a href="${h.url('journal_rss')}"><img class="icon" title="${_('RSS feed')}" alt="${_('RSS feed')}" src="${h.url('/images/icons/atom.png')}"/></a></span> | |||
|
24 | </li> | |||
|
25 | <li> | |||
|
26 | <span><a href="${h.url('journal_atom')}"><img class="icon" title="${_('ATOM feed')}" alt="${_('ATOM feed')}" src="${h.url('/images/icons/rss_16.png')}"/></a></span> | |||
22 | </li> |
|
27 | </li> | |
23 | </ul> |
|
28 | </ul> | |
24 | </div> |
|
29 | </div> |
@@ -17,12 +17,11 b'' | |||||
17 | <h5>${_('Public Journal')}</h5> |
|
17 | <h5>${_('Public Journal')}</h5> | |
18 | <ul class="links"> |
|
18 | <ul class="links"> | |
19 | <li> |
|
19 | <li> | |
20 | <span>${h.link_to(_('RSS'),h.url('public_journal_rss'),class_='rss_icon')}</span> |
|
20 | <span><a href="${h.url('public_journal_rss')}"><img class="icon" title="${_('RSS feed')}" alt="${_('RSS feed')}" src="${h.url('/images/icons/atom.png')}"/></a></span> | |
21 |
|
|
21 | </li> | |
22 |
|
|
22 | <li> | |
23 | <span>${h.link_to(_('Atom'),h.url('public_journal_atom'),class_='atom_icon')}</span> |
|
23 | <span><a href="${h.url('public_journal_atom')}"><img class="icon" title="${_('ATOM feed')}" alt="${_('ATOM feed')}" src="${h.url('/images/icons/rss_16.png')}"/></a></span> | |
24 |
|
|
24 | </li> | |
25 |
|
||||
26 | </ul> |
|
25 | </ul> | |
27 |
|
26 | |||
28 | </div> |
|
27 | </div> |
General Comments 0
You need to be logged in to leave comments.
Login now