Implement #37: Add avatar to navbar and profile page.
authorFredrik Nygren <frny@valteo.net>
Tue, 20 Aug 2013 19:55:31 +0000 (21:55 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Tue, 20 Aug 2013 19:55:31 +0000 (21:55 +0200)
data/templates/base.htm
data/templates/display-sidebar-history.htm
data/templates/display-sidebar-owner.htm
data/templates/user.htm
www/css/phorkie.css
www/www-header.php

index 1dcf0fc..75f9d18 100644 (file)
@@ -45,7 +45,7 @@
      <ul class="nav pull-right">
       {% if identity %}
       <li>
-       <a href="user">{{name}}</a>
+       <a href="user"><img class="avatar-tiny" src="{{htmlhelper.getIconUrl(email, 20)}}" width="20" height="20" /> {{name}}</a>
       </li>
       {% endif %}
       {% if db.adapter %}
index 6dda7e0..0e99b2f 100644 (file)
@@ -9,7 +9,7 @@
   {% endfor %}
   {% endspaceless %}
   <a class="hash" href="{{repo.getLink('revision', commit.hash)}}">{{commit.hash|slice(0, 6)}}</a>
-  <img src="{{commit.getIconUrl}}" alt="{{commit.committerName}}" title="{{commit.committerName}}" width="20"/>
+  <img class="avatar-tiny" src="{{commit.getIconUrl}}" alt="{{commit.committerName}}" title="{{commit.committerName}}" width="20" height="20"/>
   <span class="nobr" title="{{commit.committerTime|date('c')}}">
    <span class="indent visible-tablet"></span>
    {{dh.get(commit.committerTime)}}
index f84a5fa..032488d 100644 (file)
@@ -1,9 +1,9 @@
 {% set owner = repo.getOwner %}
 <div class="well well-small vcard">
  <img src="{{htmlhelper.getIconUrl(owner.email, 48)}}" alt="{{owner.name}}"
-      width="48" height="48" class="photo"
-      style="float: left; padding-right: 1ex;"/>
+      width="48" height="48" class="photo avatar-small pull-left"
+      style="margin-right: 1em;" />
  <span class="fn">{{owner.name}}</span>
  <br/><span class="muted">owner</span>
  <span class="clearfix"/>
-</div>
\ No newline at end of file
+</div>
index ab55b59..0856a6d 100644 (file)
 <h3>User profile</h3>
 <dl>
  <dt>OpenID</dt>
- <dd><code>{{ identity }}</code>
+ <dd><code>{{ identity }}</code></dd>
 
  <dt>Name</dt>
  <dd><code>{{ name }}</code></dd>
 
  <dt>Email</dt>
  <dd><code>{{ email }}</code></dd>
+
+ <dt>Avatar image</dt>
+ <dd><img class="avatar-large" src="{{htmlhelper.getIconUrl(email, 92)}}"></dd>
 </dl>
 
 <p>
  You may change this data with your OpenID provider.
+ The avatar image is loaded from <a href="http://libravatar.org/">libravatar.org</a>,
+ or perhaps from your own avatar server.
 </p>
 {% endblock %}
index 29e7d85..f752de7 100644 (file)
@@ -166,3 +166,13 @@ form label.inline {
 .nobr {
     white-space:nowrap;
 }
+
+.avatar-large {
+    border-radius: 5px;
+}
+.avatar-small {
+    border-radius: 3px;
+}
+.avatar-tiny {
+    border-radius: 2px;
+}
index 1888839..1d59b1c 100644 (file)
@@ -98,6 +98,9 @@ function render($tplname, $vars = array())
         $vars['email'] = $_SESSION['email'];
     }
     $vars['db'] = new Database();
+    if (!isset($vars['htmlhelper'])) {
+        $vars['htmlhelper'] = new HtmlHelper();
+    }
 
     $template = $GLOBALS['twig']->loadTemplate($tplname . '.htm');
     echo $template->render($vars);