diff --git a/progit/__init__.py b/progit/__init__.py index 9af0e3c..2bbb6a1 100644 --- a/progit/__init__.py +++ b/progit/__init__.py @@ -237,13 +237,20 @@ def rst2html(rst_string): @APP.template_filter('format_loc') -def format_loc(loc, commit=None): +def format_loc(loc, commit=None, prequest=None): """ Template filter putting the provided lines of code into a table """ output = [ '
', '' ] + + comments = {} + if prequest: + for com in prequest.comments: + if commit and com.commit_id == commit.oid.hex: + comments[com.line] = com + cnt = 1 for line in loc.split('\n'): if commit: @@ -279,6 +286,26 @@ def format_loc(loc, commit=None): line = line.split('
')[1]
         output.append('
' % line) output.append('') + + if cnt - 1 in comments: + output.append( + '' + '' % ( + { + 'url': flask.url_for( + 'view_user', username=comments[cnt -1].user.user), + 'user': comments[cnt -1].user.user, + 'date': comments[cnt -1].date_created.strftime( + '%b %d %Y %H:%M:%S'), + 'comment': comments[cnt -1].comment, + } + ) + ) + output.append('
%s
' + '' + '' + '' + '
%(user)s%(date)s
%(comment)s
') return '\n'.join(output)