Navigation Menu

Skip to content

Commit

Permalink
Builder: Feed cleanup
Browse files Browse the repository at this point in the history
Subject lines are truncated only at whitespace. Also, the RSS feed will only
show a maximum of 100 latest commits (XML feed has all commits).
  • Loading branch information
skyjake committed Jan 1, 2012
1 parent b998cb8 commit f68e1f5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
19 changes: 16 additions & 3 deletions distrib/builder/changes.py
@@ -1,5 +1,6 @@
# coding=utf-8
import os
import string
import utils
from event import Event
import config
Expand Down Expand Up @@ -31,8 +32,11 @@ def setSubject(self, subject):
# Check that the subject lines are not too long.
MAX_SUBJECT = 100
if len(utils.collated(subject)) > MAX_SUBJECT:
self.extra = '...' + subject[MAX_SUBJECT:] + ' '
subject = subject[:MAX_SUBJECT] + '...'
# Find a suitable spot the break the subject line.
pos = MAX_SUBJECT
while subject[pos] not in string.whitespace: pos -= 1
self.extra = '...' + subject[pos+1:] + ' '
subject = subject[:pos] + '...'
else:
# If there is a single dot at the end of the subject, remove it.
if subject[-1] == '.' and subject[-2] != '.':
Expand Down Expand Up @@ -127,10 +131,19 @@ def generate(self, format):

if format == 'html':
out = file(Event(toTag).file_path('changes.html'), 'wt')

MAX_COMMITS = 100
entries = self.entries[:MAX_COMMITS]

if len(self.entries) > MAX_COMMITS:
print >> out, '<p>Showing %i of %i commits.' % (MAX_COMMITS, len(self.entries))
print >> out, 'The <a href="%s">oldest commit</a> is dated %s.</p>' % \
(self.entries[-1].link, self.entries[-1].date)

print >> out, '<ol>'

# Write a list entry for each commit.
for entry in self.entries:
for entry in entries:
print >> out, '<li><b>%s</b><br/>' % entry.subject
print >> out, 'by <i>%s</i> on %s' % (entry.author, entry.date)
print >> out, '<a href="%s">(show in repository)</a>' % entry.link
Expand Down
4 changes: 3 additions & 1 deletion distrib/builder/event.py
Expand Up @@ -135,7 +135,9 @@ def text_summary(self):
if os.path.exists(changesName):
commitCount = utils.count_word('<li>', file(changesName).read())
if commitCount:
msg += " contains %i commits and" % commitCount
moreThan = ''
if commitCount == 100: moreThan = 'more than '
msg += " contains %s%i commits and" % (moreThan, commitCount)

msg += " produced %i installable binary package%s." % \
(pkgCount, 's' if (pkgCount != 1) else '')
Expand Down

0 comments on commit f68e1f5

Please sign in to comment.