Provide option to disable gravatars. wilson
Dan Brook [Wed, 13 Jul 2011 17:27:42 +0000 (18:27 +0100)]
Apparently this is of concern to folk who fear their stuff being leaked in
browser referer headers. Fair enough. Also centralized gravatar template bits
while I was at it for simplicity's sake.

lib/Gitalist.pm
root/fragment/ref/commit.tt2
root/fragment/repository/shortlog.tt2
root/inc/gravatar.tt2 [new file with mode: 0644]
root/ref/diff_fancy.tt2
root/repository/search.tt2
root/static/css/core.css

index 28e79ae..7ca047d 100644 (file)
@@ -217,6 +217,15 @@ C<.psgi> found under C<scripts/>:
 The Gitalist config is loaded with L<Catalyst::Plugin::ConfigLoader>
 and the available config options are:
 
+=over
+
+=item no_gravatars
+
+If true don't display gravatars. May be desirable if you are worried about
+leaking repo names via the browser referer headers.
+
+=back
+
 =head2 Model::CollectionOfRepos
 
 =over
index 29cae88..c213aea 100755 (executable)
           <p class='commit-message'>[% Commit.comment | html %]</p>
          [% INCLUDE '_refs.tt2' object = commit %]
         </td>
-       <td class='author'><a href="mailto:[% Commit.author.email %]" title="Email"><img style="float: left; padding-right: 10px" src="[% uri_for_gravatar(Commit.committer.email, 21) %]">[% Commit.author.name | html %]</a></td>
+       <td class='author'><a href="mailto:[% Commit.author.email %]" title="Email">[% INCLUDE 'inc/gravatar.tt2' email = Commit.author.email %][% Commit.author.name | html %]</a></td>
        <td class='action-list'>Author</td>
 </tr>
 <tr class="invert">
        <td></td>
        <td class='time-since'>[% time_since(Commit.committed_time) %]</td>
        <!-- spanned -->
-       <td class='author'><a href="mailto:[% Commit.committer.email %]" title="Email"><img style="float: left; padding-right: 10px" src="[% uri_for_gravatar(Commit.committer.email, 21) %]">[% Commit.committer.name %]</a></td>
+       <td class='author'><a href="mailto:[% Commit.committer.email %]" title="Email">[% INCLUDE 'inc/gravatar.tt2' email = Commit.committer.email %][% Commit.committer.name %]</a></td>
        <td class='action-list'>Committer</td>
 </tr>
 </tbody>
index 4394d76..e6d5598 100755 (executable)
@@ -28,7 +28,7 @@
           
         END;
        -%]</p>[% INCLUDE '_refs.tt2' object = line %]</td>
-       <td class='author'><img src="[% uri_for_gravatar(line.author.email, 21) %]" />[% line.author.name | html %]</td>
+       <td class='author'>[% INCLUDE 'inc/gravatar.tt2' email = line.author.email %][% line.author.name | html %]</td>
        <td class='action-list'>
                <a href="[% c.uri_for_action("/ref/commit", [Repository.name, line.sha1]) %]" title="Commit details" class="button commit">commit</a>
                <a href="[% c.uri_for_action("/ref/diff_fancy", [Repository.name, line.sha1]) %]" title="Commit difference" class="button diff">commitdiff</a>
diff --git a/root/inc/gravatar.tt2 b/root/inc/gravatar.tt2
new file mode 100644 (file)
index 0000000..973f7e7
--- /dev/null
@@ -0,0 +1 @@
+[% UNLESS c.config.no_gravatars %]<img src="[% uri_for_gravatar(email, 21) %]" class="gravatar">[% END -%]
index 312c097..6d084ab 100755 (executable)
@@ -13,7 +13,7 @@
        <td class='sha1' title='[% Commit.sha1 %]'>[% INCLUDE 'inc/chroma_hash.tt2' sha1 = Commit.sha1.substr(0, 7) %]</td>
        <td class='time-since' title='[% Commit.authored_time %]'>[% time_since(Commit.authored_time) %]</td>
        <td>[% short_cmt(Commit.comment) | html %]</td>
-       <td class='author'><img src="[% uri_for_gravatar(Commit.committer.email, 21) %]" />[% Commit.author.name | html %]</td>
+       <td class='author'>[% INCLUDE 'inc/gravatar.tt2' email = Commit.committer.email %][% Commit.author.name | html %]</td>
 </tr>
 </tbody>
 </table>
index b3f2327..5e4d446 100755 (executable)
@@ -29,7 +29,7 @@ No results found for <q>[% c.req.param('text') | html %]</q>.
        c.req.param('text'), '<span class="match">' _ c.req.param('text') _ '</span>'
      );
    %]</td>
-       <td class='author'><img src="[% uri_for_gravatar(result.author.email, 21) %]" />[% result.author.name | html %]</td>
+       <td class='author'>[% INCLUDE 'inc/gravatar.tt2' email = result.author.email %][% result.author.name | html %]</td>
        <td class='action-list'>
                <a href="[% c.uri_for_action("/ref/commit", [Repository.name, result.sha1]) %]" title="Commit details" class="button commit">commit</a>
                <a href="[% c.uri_for_action("/ref/diff_fancy", [Repository.name, result.sha1]) %]" title="Commit difference" class="button diff">commitdiff</a>
index 85543fd..cca79a3 100755 (executable)
@@ -421,6 +421,11 @@ table.listing thead {
        padding:9px 5px 9px 10px;
 }
 
+.listing .gravatar {
+    float: left;
+    padding-right: 10px;
+}
+
 /*
 
 puts the repo description on one line which gets truncated if the repo name is too long