From e57b081b0e1733ef5e7617dc3ac4b8eeff34368f Mon Sep 17 00:00:00 2001 From: Ryan Lerch Date: Oct 20 2016 14:22:25 +0000 Subject: [PATCH 1/4] Add a link to the user on the commit list This adds a link to the user on the commit list. It required a little more playing than just adding the link, as the previous iteration had a single tag that just wrapped everything. So we had to pull this out, and add a link to the user on the username text. --- diff --git a/pagure/static/pagure.css b/pagure/static/pagure.css index b7a79c6..04be8fd 100644 --- a/pagure/static/pagure.css +++ b/pagure/static/pagure.css @@ -406,6 +406,10 @@ a.notblue { text-decoration:none; } +a.notblue:hover { + color: #888; +} + #headerSearch .selectize-control.single .selectize-input::after { content: "\e08f"; diff --git a/pagure/templates/commits.html b/pagure/templates/commits.html index 131c552..fd52698 100644 --- a/pagure/templates/commits.html +++ b/pagure/templates/commits.html @@ -121,12 +121,7 @@
{% for commit in last_commits %} - {% if diff_commits and commit.oid.hex in diff_commits %} @@ -138,19 +133,25 @@
{% endif %}
- {{ commit.message.split('\n')[0] }} -
- - {{ commit.commit_time|humanize }} - -
+
+ {{ commit.message.split('\n')[0] }} +
+ + {{ commit.commit_time|humanize }} + +
+
- {{ commit.author | author2avatar(20) | safe }} {{ commit.author.name }} + {{commit.author|author2user(cssclass="notblue")|safe}}
{{ commit.hex|short }}
- + {% endfor %} diff --git a/pagure/ui/filters.py b/pagure/ui/filters.py index 024730a..b84a94b 100644 --- a/pagure/ui/filters.py +++ b/pagure/ui/filters.py @@ -331,7 +331,7 @@ def patch_to_diff(patch): @APP.template_filter('author2user') -def author_to_user(author, size=16): +def author_to_user(author, size=16, cssclass=None): """ Template filter transforming a pygit2 Author object into a text either with just the username or linking to the user in pagure. """ @@ -340,11 +340,19 @@ def author_to_user(author, size=16): return output user = pagure.lib.search_user(SESSION, email=author.email) if user: - output = "%s %s" % ( - avatar(user.default_email, size), - flask.url_for('view_user', username=user.username), - author.name, - ) + if cssclass: + output = "%s %s" % ( + avatar(user.default_email, size), + flask.url_for('view_user', username=user.username), + cssclass, + author.name, + ) + else: + output = "%s %s" % ( + avatar(user.default_email, size), + flask.url_for('view_user', username=user.username), + author.name, + ) return output From c1b151e950be08559622328d794502380818850f Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Oct 20 2016 14:22:25 +0000 Subject: [PATCH 2/4] Simplify a little how the css class is added to the user link on the commit list --- diff --git a/pagure/ui/filters.py b/pagure/ui/filters.py index b84a94b..944a7c1 100644 --- a/pagure/ui/filters.py +++ b/pagure/ui/filters.py @@ -340,19 +340,13 @@ def author_to_user(author, size=16, cssclass=None): return output user = pagure.lib.search_user(SESSION, email=author.email) if user: - if cssclass: - output = "%s %s" % ( - avatar(user.default_email, size), - flask.url_for('view_user', username=user.username), - cssclass, - author.name, - ) - else: - output = "%s %s" % ( - avatar(user.default_email, size), - flask.url_for('view_user', username=user.username), - author.name, - ) + output = "%s %s" % ( + avatar(user.default_email, size), + flask.url_for('view_user', username=user.username), + ('class="%s"' % cssclass) if cssclass else '', + author.name, + ) + return output From 50542f52041559f0bd6c11e0145167b10f233adc Mon Sep 17 00:00:00 2001 From: Ryan Lerch Date: Oct 20 2016 14:22:25 +0000 Subject: [PATCH 3/4] remove the blue links on the commit page --- diff --git a/pagure/static/pagure.css b/pagure/static/pagure.css index 04be8fd..3f56485 100644 --- a/pagure/static/pagure.css +++ b/pagure/static/pagure.css @@ -407,7 +407,8 @@ a.notblue { } a.notblue:hover { - color: #888; + color: #444; + text-decoration:underline; } #headerSearch .selectize-control.single .selectize-input::after diff --git a/pagure/templates/commits.html b/pagure/templates/commits.html index fd52698..8d6dd34 100644 --- a/pagure/templates/commits.html +++ b/pagure/templates/commits.html @@ -137,7 +137,8 @@ repo=repo.name, username=username, namespace=repo.namespace, - commitid=commit.hex, branch=branchname) }}"> + commitid=commit.hex, branch=branchname) }}" + class="notblue"> {{ commit.message.split('\n')[0] }}
Date: Oct 20 2016 14:22:26 +0000 Subject: [PATCH 4/4] Create a dedicated jinja filter for showing the author in the commit list This creates two links on the author's info: * one link on the avatar pointing to the user's generic info page * one link on the user's name filtering the list of commits for this user --- diff --git a/pagure/templates/commits.html b/pagure/templates/commits.html index 8d6dd34..d0013da 100644 --- a/pagure/templates/commits.html +++ b/pagure/templates/commits.html @@ -148,7 +148,14 @@
- {{commit.author|author2user(cssclass="notblue")|safe}} + {{commit.author|author2user_commits( + link=url_for('view_commits', + repo=repo.name, + branchname=branchname, + username=username, + namespace=repo.namespace, + author=commit.author.email), + cssclass="notblue")|safe}}
{{ commit.hex|short }}
diff --git a/pagure/ui/filters.py b/pagure/ui/filters.py index 944a7c1..b05b17d 100644 --- a/pagure/ui/filters.py +++ b/pagure/ui/filters.py @@ -359,6 +359,26 @@ def author_to_avatar(author, size=32): return avatar(output.encode('utf-8'), size) +@APP.template_filter('author2user_commits') +def author_to_user_commits(author, link, size=16, cssclass=None): + """ Template filter transforming a pygit2 Author object into a text + either with just the username or linking to the user in pagure. + """ + output = author.name + if not author.email: + return output + user = pagure.lib.search_user(SESSION, email=author.email) + if user: + output = "%s %s" % ( + flask.url_for('view_user', username=user.username), + avatar(user.default_email, size), + link, + ('class="%s"' % cssclass) if cssclass else '', + author.name, + ) + + return output + @APP.template_filter('InsertDiv') def insert_div(content): """ Template filter inserting an opening
and closing