---
+++
@@ -140,6 +140,7 @@
COMMIT_AUTHOR_RE = re.compile('(.*) <(.*)>')
def _parse_author(self, author_str):
+ author_str = author_str.decode('utf-8')
m = self.COMMIT_AUTHOR_RE.match(author_str)
if m:
author = m.group(1)
@@ -151,20 +152,21 @@
def get_commit(self, commit_id):
commit = self.repo[commit_id]
- short_message = commit.message.splitlines()
+ message = commit.message.decode('utf-8')
+ short_message = message.splitlines()
if len(short_message):
short_message = short_message[0]
else:
short_message = ''
if len(short_message) > 79:
- short_message = u'%s…' % short_message[:79].decode('utf-8')
+ short_message = u'%s…' % short_message[:79]
author = self._parse_author(commit.author)
committer = self._parse_author(commit.committer)
c = {
'commit': commit.id,
- 'message': commit.message,
+ 'message': message,
'author': author[0],
'committer': committer[0],
'date': datetime.fromtimestamp(commit.author_time),
---
+++
@@ -1,16 +1,28 @@
+from feedgenerator.django.utils.feedgenerator import rfc2822_date
+from cgi import escape
+
from ..tab import Tab
from ...git import Git
-from ...pages.paginate_tmpl import PaginateTmpl
+from ...pages.rss_page import RSSPage
from .commit_page import CommitPage
from .dir_page import DirPage
from .file_page import FilePage
-class RepositoryTab(Tab, PaginateTmpl):
+class RepositoryTab(Tab, RSSPage):
JSON_ATTRS = ['commits', 'heads', 'tags']
+ RSS_TITLE = 'Revisions history'
+ RSS_DESCRIPTION = 'Latest commits history'
+ RSS_FIELD_DESC = {
+ 'date': 'date',
+ 'title': 'short_message',
+ 'description': 'summary',
+ 'link': 'url',
+ }
+ RSS_SORT = False
def __init__(self, name, parent, *args, **kw):
- PaginateTmpl.__init__(self, name, parent, 'commit_tree.html', *args, **kw)
+ RSSPage.__init__(self, name, parent, 'commit_tree.html', *args, **kw)
Tab.__init__(self)
self.repo = Git(self.page_conf.get('path'))
@@ -21,6 +33,7 @@
self.new_commits = []
self.new_commits_calculated = False
self.pagination = 30
+ self.rss_entries = 30
self.page_conf['http_dyn_url'] = False
@@ -114,6 +127,20 @@
commits.append(commit)
for commit in commits:
+ if self.rss_entries:
+ commit_date = rfc2822_date(commit['date'])
+ if commit_date.endswith(' -0000'):
+ commit_date = commit_date[:-6]
+ summary = 'Commit: %s\nAuthor: %s\nDate: %s\n' % \
+ (commit['commit'], commit['author'], commit_date)
+ if commit['new_tickets']:
+ summary += '%i ticket(s) opened\n' % commit['new_tickets']
+ if commit['closed_tickets']:
+ summary += '%i ticket(s) closed\n' % commit['closed_tickets']
+ summary += '\n%s' % commit['message']
+ summary = escape(summary)
+ commit['summary'] = '<pre>%s</pre>' % summary
+
self.commits[commit['commit']] = commit
namespace = {
---
+++
@@ -36,13 +36,15 @@
self.changed = False
def init(self, commit_id):
+ date = datetime.fromtimestamp(self.repo.repo[commit_id].author_time)
self.set_meta(commit_id, 'Status', 'Open')
self.set_meta(commit_id, 'Subject', '%s' % self.name)
self.set_meta(commit_id, 'Initial commit', commit_id)
self.set_meta(commit_id, 'Initial commit url', self.repo_tab.get_relative_url(self, 'commits/%s/%s.html' % (commit_id[:2], commit_id[2:])))
- self.set_meta(commit_id, 'Last changed', datetime.fromtimestamp(self.repo.repo[commit_id].author_time), history=False)
+ self.set_meta(commit_id, 'Last changed', date, history=False)
self.set_meta(commit_id, 'Content', '')
self.set_meta(commit_id, 'Id', self.name.split('/', 1)[1])
+ self.set_meta(commit_id, 'Creation date', date)
def load(self):
TemplatePage.load(self)
@@ -148,3 +150,23 @@
def get_meta_keys(self):
return self.meta_keys
+
+ @property
+ def date(self):
+ return self.meta['Creation date']
+
+ @property
+ def subject(self):
+ return self.meta['Subject']
+
+ @property
+ def content(self):
+ content = '<ul>'
+ for meta in ('Subject', 'Initial commit', 'Created by', 'Creation date'):
+ content += '<li><b>%s</b>: %s<br/></li>' % (meta, self.meta[meta])
+ content += '<ul/>'
+ return content + self.meta['Content']
+
+ @property
+ def link(self):
+ return self.get_url()
---
+++
@@ -3,13 +3,30 @@
from ...template import Template
from ...pages.page import Page
from ...pages.template_page import TemplatePage
-from ...pages.paginate_tmpl import PaginateTmpl
+from ...pages.rss_page import RSSPage
from ..tab import Tab
from ..repository.repository import RepositoryTab
from .comments_ticket import CommentsTicket
from .files_ticket import FilesTicket
from .ticket import Ticket
+
+class TrackerCategory(Tab, RSSPage):
+ RSS_FIELD_DESC = {
+ 'date': 'date',
+ 'title': 'subject',
+ 'description': 'content',
+ 'link': 'link',
+ }
+ RSS_SORT = False
+
+ def __init__(self, category, *args, **kw):
+ RSSPage.__init__(self, *args, **kw)
+ self.pagination = 20
+ self.rss_entries = 30
+ self.category = category.title()
+ self.RSS_TITLE = '%s tracker' % category
+ self.RSS_DESCRIPTION = '%s tickets tracker' % category
class TrackerTab(Tab, Page):
DEPENDS_ON = [RepositoryTab]
@@ -260,8 +277,9 @@
if sort_name != '':
page_name += '_' + sort_name
page_name += '.html'
- tracker_page = PaginateTmpl(page_name, self, 'tickets_list.html')
- tracker_page.pagination = 20
+
+ # FIXME: the rss feed will be regenerated for each page sort
+ tracker_page = TrackerCategory(category, page_name, self, 'tickets_list.html')
tracker_page.render_paginate('tickets', __namespace)
if create_ticket:
---
+++
@@ -23,6 +23,9 @@
</div>
<h4>History</h4>
+#if $varExists('rss_url')
+<div style="vertical-align: middle"><a href="$rss_url"><img src="${base_url}static/rss.png" alt="Feed">RSS</img></a></div>
+#end if
#set $color = {}
#set $color[0] = "#f00"
#set $color[1] = "#00f"
---
+++
@@ -30,6 +30,9 @@
#end for
</ul>
+#if $varExists('rss_url')
+<div style="vertical-align: middle"><a href="$rss_url"><img src="${base_url}static/rss.png" alt="Feed">RSS</img></a></div>
+#end if
#if $create_ticket:
<a class="button" href="$new_ticket_url">New ticket</a>
#end if
Generated with KisssPM