From 465f736852ee353b2374c7bd7c95729dd3c357bc Mon Sep 17 00:00:00 2001 From: David Schnur Date: Tue, 16 Oct 2012 16:32:23 -0400 Subject: [PATCH] Added gravatars for plugin authors & maintainers. Replaced the author and list of maintainers with gravatar tiles, using the email field of their manifest entries. If the email has no gravatar, the standard 'unknown person' image is used instead. Gave jq_release_author, jq_release_maintainers and the underlying person function a way to specify the size of the gravatar image they produce. The author and maintainers sections no longer appear as bulleted lists. --- themes/plugins.jquery.com/functions.php | 47 ++++++++++++++----- .../sidebar-jquery_plugin.php | 4 +- themes/plugins.jquery.com/style.css | 22 +++++++++ 3 files changed, 59 insertions(+), 14 deletions(-) diff --git a/themes/plugins.jquery.com/functions.php b/themes/plugins.jquery.com/functions.php index 91f2e8db..02ba57f8 100644 --- a/themes/plugins.jquery.com/functions.php +++ b/themes/plugins.jquery.com/functions.php @@ -132,16 +132,39 @@ function jq_release_manifest( $id = null ) { return json_decode( get_post_meta( $id, 'manifest', true ) ); } -function person( $person, $avatar ) { - $ret = htmlspecialchars( $person->name ); - if ( !empty( $person->url ) ) { - $url = htmlspecialchars( $person->url ); - $ret = "$ret"; +////////////////////////////////////////////////////////////////////////////// +// Produces a block of markup describing the given person, optionally with +// a gravatar image at the given size. + +function person( $person, $avatar, $size = 96 ) { + + $name = htmlspecialchars( $person->name ); + + // If an avatar is requested, build a little gravatar tile; otherwise + // just use the name by itself. + + if ( $avatar ) { + if (!empty( $person->email )) { + $content = get_avatar( $person->email, $size ); + } else { + $content = get_avatar( null, $size ); + } + $content = $content . $name; + } else { + $content = $name; } - if ( $avatar && !empty( $person->email ) ) { - $ret = get_avatar( $person->email, '80' ) . $ret; + + // Wrap the content in a link to the person's page or email address + + if (!empty( $person->url )) { + $url = htmlspecialchars( $person->url ); + return "$content"; + } elseif (!empty( $person->email )) { + $email = htmlspecialchars( $person->email ); + return "$content"; + } else { + return $content; } - return $ret; } function jq_release_download_url() { @@ -184,7 +207,7 @@ function jq_release_licenses() { return $ret; } -function jq_release_maintainers( $options = array('avatar' => false) ) { +function jq_release_maintainers( $options = array('avatar' => false, 'size' => 48) ) { $pkg = jq_release_manifest(); if ( empty( $pkg->maintainers ) ) { @@ -193,15 +216,15 @@ function jq_release_maintainers( $options = array('avatar' => false) ) { $ret = ''; return $ret; } -function jq_release_author( $options = array('avatar' => false) ) { +function jq_release_author( $options = array('avatar' => false, 'size' => 48) ) { $pkg = jq_release_manifest(); - return person( $pkg->author, $options['avatar'] ); + return person( $pkg->author, $options['avatar'], $options['size'] ); } function jq_release_dependencies() { diff --git a/themes/plugins.jquery.com/sidebar-jquery_plugin.php b/themes/plugins.jquery.com/sidebar-jquery_plugin.php index 042e4cb1..b6cd4906 100644 --- a/themes/plugins.jquery.com/sidebar-jquery_plugin.php +++ b/themes/plugins.jquery.com/sidebar-jquery_plugin.php @@ -51,11 +51,11 @@

Author

- + true, 'size' => 48)) ) { ?>

Maintainers

diff --git a/themes/plugins.jquery.com/style.css b/themes/plugins.jquery.com/style.css index 5173fee6..5fc6227c 100755 --- a/themes/plugins.jquery.com/style.css +++ b/themes/plugins.jquery.com/style.css @@ -390,6 +390,28 @@ p.info { letter-spacing: 1px; } +#sidebar.jquery-plugin .author-info li { + background: none; + font-size: 18px; +} + +#sidebar.jquery-plugin .maintainer-info li { + background: none; + font-size: 16px; +} + +#sidebar.jquery-plugin .avatar { + margin-right: 10px; +} + +#sidebar.jquery-plugin .avatar-80 { + border-radius: 8px; +} + +#sidebar.jquery-plugin .avatar-48 { + border-radius: 4px; +} + /*----------[ Individual plugin page sidebar toolbox ]----------------------*/ .jquery-plugin .toolbox {