Skip to content

Commit 7b74f61

Browse files
committed
Merge pull request #101 from dnschnur/new-css
Added gravatars for plugin authors & maintainers.
2 parents 585b484 + 465f736 commit 7b74f61

File tree

3 files changed

+59
-14
lines changed

3 files changed

+59
-14
lines changed

themes/plugins.jquery.com/functions.php

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,39 @@ function jq_release_manifest( $id = null ) {
132132
return json_decode( get_post_meta( $id, 'manifest', true ) );
133133
}
134134

135-
function person( $person, $avatar ) {
136-
$ret = htmlspecialchars( $person->name );
137-
if ( !empty( $person->url ) ) {
138-
$url = htmlspecialchars( $person->url );
139-
$ret = "<a href='$url'>$ret</a>";
135+
//////////////////////////////////////////////////////////////////////////////
136+
// Produces a block of markup describing the given person, optionally with
137+
// a gravatar image at the given size.
138+
139+
function person( $person, $avatar, $size = 96 ) {
140+
141+
$name = htmlspecialchars( $person->name );
142+
143+
// If an avatar is requested, build a little gravatar tile; otherwise
144+
// just use the name by itself.
145+
146+
if ( $avatar ) {
147+
if (!empty( $person->email )) {
148+
$content = get_avatar( $person->email, $size );
149+
} else {
150+
$content = get_avatar( null, $size );
151+
}
152+
$content = $content . $name;
153+
} else {
154+
$content = $name;
140155
}
141-
if ( $avatar && !empty( $person->email ) ) {
142-
$ret = get_avatar( $person->email, '80' ) . $ret;
156+
157+
// Wrap the content in a link to the person's page or email address
158+
159+
if (!empty( $person->url )) {
160+
$url = htmlspecialchars( $person->url );
161+
return "<a href='$url'>$content</a>";
162+
} elseif (!empty( $person->email )) {
163+
$email = htmlspecialchars( $person->email );
164+
return "<a href='mailto:$email'>$content</a>";
165+
} else {
166+
return $content;
143167
}
144-
return $ret;
145168
}
146169

147170
function jq_release_download_url() {
@@ -184,7 +207,7 @@ function jq_release_licenses() {
184207
return $ret;
185208
}
186209

187-
function jq_release_maintainers( $options = array('avatar' => false) ) {
210+
function jq_release_maintainers( $options = array('avatar' => false, 'size' => 48) ) {
188211
$pkg = jq_release_manifest();
189212

190213
if ( empty( $pkg->maintainers ) ) {
@@ -193,15 +216,15 @@ function jq_release_maintainers( $options = array('avatar' => false) ) {
193216

194217
$ret = '<ul>';
195218
foreach( $pkg->maintainers as $maintainer ) {
196-
$ret .= '<li>' . person( $maintainer, $options['avatar'] ) . '</li>';
219+
$ret .= '<li>' . person( $maintainer, $options['avatar'], $options['size'] ) . '</li>';
197220
}
198221
$ret .= '</ul>';
199222
return $ret;
200223
}
201224

202-
function jq_release_author( $options = array('avatar' => false) ) {
225+
function jq_release_author( $options = array('avatar' => false, 'size' => 48) ) {
203226
$pkg = jq_release_manifest();
204-
return person( $pkg->author, $options['avatar'] );
227+
return person( $pkg->author, $options['avatar'], $options['size'] );
205228
}
206229

207230
function jq_release_dependencies() {

themes/plugins.jquery.com/sidebar-jquery_plugin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@
5151
<div class="block author-info">
5252
<h3><span class="icon-user"></span>Author</h3>
5353
<ul>
54-
<li><?php echo jq_release_author(); ?></li>
54+
<li><?php echo jq_release_author(array('avatar' => true, 'size' => 80)); ?></li>
5555
</ul>
5656
</div> <!-- /.author-info -->
5757

58-
<?php if ( $maintainers = jq_release_maintainers() ) { ?>
58+
<?php if ( $maintainers = jq_release_maintainers(array('avatar' => true, 'size' => 48)) ) { ?>
5959
<div class="block maintainer-info">
6060
<h3><span class="icon-wrench"></span>Maintainers</h3>
6161
<?php echo $maintainers; ?>

themes/plugins.jquery.com/style.css

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,28 @@ p.info {
390390
letter-spacing: 1px;
391391
}
392392

393+
#sidebar.jquery-plugin .author-info li {
394+
background: none;
395+
font-size: 18px;
396+
}
397+
398+
#sidebar.jquery-plugin .maintainer-info li {
399+
background: none;
400+
font-size: 16px;
401+
}
402+
403+
#sidebar.jquery-plugin .avatar {
404+
margin-right: 10px;
405+
}
406+
407+
#sidebar.jquery-plugin .avatar-80 {
408+
border-radius: 8px;
409+
}
410+
411+
#sidebar.jquery-plugin .avatar-48 {
412+
border-radius: 4px;
413+
}
414+
393415
/*----------[ Individual plugin page sidebar toolbox ]----------------------*/
394416

395417
.jquery-plugin .toolbox {

0 commit comments

Comments
 (0)