Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cleaned up a bit for a more polished feel.

  • Loading branch information...
commit d5d79a1b6dc36e0f0a6486eb967f5d051751f478 1 parent 5e6566a
@ezarko authored
Showing with 51 additions and 40 deletions.
  1. +8 −0 README.txt
  2. +16 −20 coderwall.css
  3. +27 −20 coderwall2.module
View
8 README.txt
@@ -0,0 +1,8 @@
+The Coderwall module provides integration with the Coderwall service, allowing
+you to display Coderwall achievements on your site.
+
+Coderwall provides both a block, suitable for a personal website, which may be
+configured with a single, global coderwall username. This will provide badges for the configured username.
+
+In addition it provides a user profile field for a coderwall username which will
+provide the badges for each user so configured.
View
36 coderwall.css
@@ -8,46 +8,42 @@
margin: 18px 0px 0px 8px;
}
-.block-coderwall2 .content .coderwall-logo {
+.coderwall-badge {
float: left;
- margin: 14px 0px 0px 0px;
- border-radius: 5px;
- padding: 8px 10px 8px 8px;
- background: -webkit-gradient(linear, left top, left bottom, from(#6A7176), to(#4D5256));
- background: -moz-linear-gradient(-90deg, #6A7176, #4D5256);
}
-.block-coderwall2 .content .coderwall-logo:hover .coderwall-tag-name {
- color: #BED4FA;
+.coderwall-badge:hover {
+ opacity: 0.8;
}
-.block-coderwall2 .content .coderwall-badge {
+.coderwall-logo {
+ clear: both;
float: left;
+ margin: 14px 0px 0px 0px;
+ border-radius: 5px;
+ padding: 8px 10px 8px 8px;
+ background: -webkit-gradient(linear, left top, left bottom, from(#6A7176), to(#4D5256));
+ background: -moz-linear-gradient(-90deg, #6A7176, #4D5256);
}
-
-.block-coderwall2 .content .coderwall-badge:hover {
- opacity: 0.8;
-}
-
-.block-coderwall2 .content .coderwall-icon {
+.coderwall-icon {
float: left;
width: 15px;
}
-.block-coderwall2 .content .coderwall-tag-container {
+.coderwall-tag-container {
float: left;
padding-left: 8px;
margin-top: -3px;
}
-.block-coderwall2 .content .coderwall-tag-name {
+.coderwall-tag-name {
color: white;
font-weight: bold;
font-size: 20px;
text-shadow: black 0 1px 0;
}
-.block-coderwall2 .content .coderwall-tag-text {
- color: #aaa;
- font-size: 12px;
+.coderwall-logo:hover .coderwall-tag-name {
+ color: #BED4FA;
}
+
View
47 coderwall2.module
@@ -37,12 +37,6 @@ function coderwall2_block_save($delta = '', $edit = array()) {
}
}
-function _coderwall2_get_data($username) {
- $url = "http://coderwall.com/$username.json?source=jqcw";
- $response = drupal_http_request($url);
- return json_decode($response->data, TRUE);
-}
-
/**
* Implements hook_block_view().
*/
@@ -53,7 +47,8 @@ function coderwall2_block_view($delta = '') {
$username = variable_get('coderwall_username');
if (isset($username)) {
$data = _coderwall2_get_data($username);
- $block['content'] = theme('badges', $data);
+ $block['content'] = theme('badges', $data) . _coderwall2_logo();
+
return $block;
}
}
@@ -94,14 +89,18 @@ function coderwall2_user_presave(&$edit, $account, $category) {
* Implements hook_user_view().
*/
function coderwall2_user_view($account) {
- if (user_access('create blog content', $account)) {
+ if (user_access('access content')) {
if (array_key_exists('coderwall_username', $account->data)) {
$data = _coderwall2_get_data($account->data['coderwall_username']);
- $account->content['summary']['coderwall'] = array(
+ $account->content['coderwall'] = array(
+ '#type' => 'user_profile_category',
+ '#title' => '',
+ '#weight' => 15,
+ );
+ $account->content['coderwall']['badges'] = array(
'#type' => 'user_profile_item',
- '#title' => t('Coderwall'),
- // l() escapes the attributes, so we should not escape !username here.
- '#markup' => theme('badges', $data),
+ '#title' => '',
+ '#markup' => '<div>' . theme('badges', $data) . _coderwall2_logo() . '</div>',
'#attributes' => array('class' => array('blog')),
);
}
@@ -136,7 +135,7 @@ function theme_badges($variables) {
$output = '';
if (empty($badges)) {
- $output = t('No badges earned.');
+ $output .= t('No badges earned.');
}
else {
foreach ($badges as $badge) {
@@ -155,19 +154,27 @@ function theme_badges($variables) {
}
}
- $output .= "<div class='coderwall-logo'>";
- $output .= l(
+ return $output;
+}
+
+function _coderwall2_get_data($username) {
+ $url = "http://coderwall.com/$username.json?source=jqcw";
+ $response = drupal_http_request($url);
+ return json_decode($response->data, TRUE);
+}
+
+function _coderwall2_logo() {
+ return '<div class="coderwall-logo">' .
+ l(
theme('image', array(
'path' => 'http://coderwall.com/images/icon.png',
'attributes' => array('class' => 'coderwall-icon'),
)) .
- "<div class='coderwall-tag-container'><div class='coderwall-tag-name'>coderwall</div></div>",
+ '<div class="coderwall-tag-container"><div class="coderwall-tag-name">coderwall</div></div>',
'http://coderwall.com',
array('html' => TRUE)
- );
- $output .= "</div>";
-
- return $output;
+ ) .
+ '</div>';
}
?>
Please sign in to comment.
Something went wrong with that request. Please try again.