From: Paul J R Date: Wed, 19 Sep 2012 01:33:55 +0000 (+1000) Subject: added gravatar to repo view commit logs - sweet X-Git-Url: http://git.pjr.cc/?a=commitdiff_plain;h=75cc0009dc451b541228e9222e19b4b6d5659065;p=gwvp-mini.git added gravatar to repo view commit logs - sweet --- diff --git a/gwvpmini/gwvpmini_view.php b/gwvpmini/gwvpmini_view.php index 96ee359..3703a72 100644 --- a/gwvpmini/gwvpmini_view.php +++ b/gwvpmini/gwvpmini_view.php @@ -76,19 +76,23 @@ function gwvpmini_RepoViewPageBody() echo ""; echo ""; foreach($commitids as $ids) { - $rs = popen("git --git-dir=$repo_base/$repo_view_call.git log --pretty=format:\"%at%n%ce%n%s\" $ids -1", "r"); + $rs = popen("git --git-dir=$repo_base/$repo_view_call.git log --pretty=format:\"%at%n%ce%n%an%n%s\" $ids -1", "r"); if($rs) { $flin1 = trim(fgets($rs)); - $flin2 = gwvpmini_emailToUserLink(trim(fgets($rs))); + $flin2 = trim(fgets($rs)); + $flin3 = trim(fgets($rs)); while(!feof($rs)) { - $flin3 = fread($rs, 8192); + $flin4 = fread($rs, 8192); + } + $flon = gwvpmini_emailToUserLink($flin2); + if(!$flon) { + $flon = "$flin3 (external)"; } } - echo ""; + echo ""; } echo "
Committed ByDateCommit Log Entry
$flin2$flin1$flin3
".get_gravatar($flin2, 18, 'mm', 'g', true)."$flon$flin1$flin4
"; } - } diff --git a/gwvpmini/gwvpmini_web.php b/gwvpmini/gwvpmini_web.php index f6b6665..54b34a4 100644 --- a/gwvpmini/gwvpmini_web.php +++ b/gwvpmini/gwvpmini_web.php @@ -231,12 +231,12 @@ function gwvpmini_emailToUserLink($email) { global $BASE_URL; - $username = gwvpmini_GetUserNameFromEmail($username); + $username = gwvpmini_GetUserNameFromEmail($email); if($username !== false) { return "$username"; } else { - return "Uknown"; + return false; } } @@ -253,5 +253,30 @@ function gwvpmini_fourZeroFour() } +/** + * Get either a Gravatar URL or complete image tag for a specified email address. + * + * @param string $email The email address + * @param string $s Size in pixels, defaults to 80px [ 1 - 2048 ] + * @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ] + * @param string $r Maximum rating (inclusive) [ g | pg | r | x ] + * @param boole $img True to return a complete IMG tag False for just the URL + * @param array $atts Optional, additional key/value attributes to include in the IMG tag + * @return String containing either just a URL or a complete image tag + * @source http://gravatar.com/site/implement/images/php/ + */ +function get_gravatar( $email, $s = 80, $d = 'mm', $r = 'g', $img = false, $atts = array() ) { + $url = 'http://en.gravatar.com/avatar/'; + $url .= md5( strtolower( trim( $email ) ) ); + $url .= "?s=$s&d=$d&r=$r"; + if ( $img ) { + $url = ' $val ) + $url .= ' ' . $key . '="' . $val . '"'; + $url .= ' />'; + } + return $url; +} + ?> \ No newline at end of file