Skip to content

Feature: Change icon for commented changesets #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions code_comments/htdocs/code-comments.css
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,9 @@ button#subscribe {
float: right;
margin: 5px 0 5px 5px;
}

/* Highlight links to commented revisions */
.chglist td.rev a.chgset.chgset-commented {
background-image: url(jquery-ui/images/ui-icons_4b954f_256x240.png);
background-position: -131px -98px;
}
18 changes: 18 additions & 0 deletions code_comments/htdocs/log-view-enhancer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
$(document).ready(function($){
function isLinkToCommentedRevision($link) {
const href = $link.attr('href');
const match = href && href.match(/^\/changeset\/([^/]+)\/.*$/);
if (!match) {
return false;
}
const targetRevision = match[1];
return CodeCommentsCommentedRevisions.includes(targetRevision);
}
const $changesetLinks = jQuery('td.rev a.chgset')
$changesetLinks.each(function(){
$link = $(this)
if (isLinkToCommentedRevision($link)) {
$link.addClass('chgset-commented');
}
});
});
27 changes: 27 additions & 0 deletions code_comments/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,30 @@ def match_request(self, req):
def process_request(self, req):
html = format_to_html(req, self.env, req.args.get('text', ''))
req.send(html.encode('utf-8'))


class HighlightCommentedRevisions(Component):
implements(IRequestFilter)

# IRequestFilter methods
def pre_process_request(self, req, handler):
return handler

def post_process_request(self, req, template, data, metadata):
if not re.match(r'^\/log\/\w+', req.path_info):
return template, data, metadata

query_params = {
'type': 'changeset',
'reponame': data['reponame'],
}
revisions_with_comments = []
for revision in data['changes']:
query_params['revision'] = revision
has_comments = bool(Comments(None, self.env).count(query_params))
if has_comments:
revisions_with_comments.append(revision)

add_script_data(req, {'CodeCommentsCommentedRevisions': revisions_with_comments})
add_script(req, 'code-comments/log-view-enhancer.js')
return template, data, metadata