Skip to content

Commit

Permalink
Merge pull request #214 from fusion94/kandan-198
Browse files Browse the repository at this point in the history
Adds badging to admins Fixes #198
  • Loading branch information
gabceb committed Mar 14, 2013
2 parents fc93ad8 + 5a99802 commit 989d673
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 4 deletions.
7 changes: 6 additions & 1 deletion app/assets/javascripts/backbone/plugins/user_list.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ class Kandan.Plugins.UserList
@pluginNamespace: "Kandan.Plugins.UserList"

@template: _.template '''
<div class="user clearfix">
<div class="user clearfix">
<img class="avatar" src="<%= avatarUrl %>"/>
<span class="name"><%= name %></span>
<% if(admin){ %>
&nbsp;<span class="badge badge-important">Admin</span>
<% } %>
</div>
'''

Expand All @@ -19,9 +22,11 @@ class Kandan.Plugins.UserList
displayName = null
displayName = user.username # Defaults to username
displayName ||= user.email # Revert to user email address if that's all we have
isAdmin = user.is_admin

$users.append @template({
name: displayName,
admin: isAdmin,
avatarUrl: Kandan.Helpers.Avatars.urlFor(user, {size: 25})
})
$el.html($users)
Expand Down
105 changes: 105 additions & 0 deletions app/assets/stylesheets/lib/font-awesome.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,108 @@
.label,
.badge {
display: inline-block;
margin-top: 2.5px;
margin-left: 5px;
padding: 2px 4px;
font-size: 12px;
font-weight: bold;
line-height: 12px;
color: #ffffff;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
white-space: nowrap;
vertical-align: baseline;
background-color: #999999;
}

.label {
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}

.badge {
padding-right: 9px;
padding-left: 9px;
-webkit-border-radius: 9px;
-moz-border-radius: 9px;
border-radius: 9px;
}

.label:empty,
.badge:empty {
display: none;
}

a.label:hover,
a.label:focus,
a.badge:hover,
a.badge:focus {
color: #ffffff;
text-decoration: none;
cursor: pointer;
}

.label-important,
.badge-important {
background-color: #b94a48;
}

.label-important[href],
.badge-important[href] {
background-color: #953b39;
}

.label-warning,
.badge-warning {
background-color: #f89406;
}

.label-warning[href],
.badge-warning[href] {
background-color: #c67605;
}

.label-success,
.badge-success {
background-color: #468847;
}

.label-success[href],
.badge-success[href] {
background-color: #356635;
}

.label-info,
.badge-info {
background-color: #3a87ad;
}

.label-info[href],
.badge-info[href] {
background-color: #2d6987;
}

.label-inverse,
.badge-inverse {
background-color: #333333;
}

.label-inverse[href],
.badge-inverse[href] {
background-color: #1a1a1a;
}

.btn .label,
.btn .badge {
position: relative;
top: -1px;
}

.btn-mini .label,
.btn-mini .badge {
top: 0;
}

/*!
* Font Awesome 3.0.2
* the iconic font designed for use with Twitter Bootstrap
Expand Down
4 changes: 2 additions & 2 deletions app/models/activity_observer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def after_save(activity)
def message_broadcast_data(activity)
faye_channel = "/channels/#{activity.channel.to_param}"
broadcast_data = activity.attributes.merge({
:user => activity.user.as_json(:only => [:id, :email, :first_name, :last_name, :gravatar_hash, :active, :locale, :username]),
:user => activity.user.as_json(:only => [:id, :email, :first_name, :last_name, :gravatar_hash, :active, :locale, :username, :is_admin]),
:channel => activity.channel.attributes
})
[faye_channel, broadcast_data]
Expand All @@ -22,7 +22,7 @@ def upload_broadcast_data(activity)
broadcast_data = {
:event => "attachment#upload",
:entity => activity.attributes.merge({
:user => activity.user.as_json(:only => [:id, :email, :first_name, :last_name, :gravatar_hash, :active, :locale, :username]),
:user => activity.user.as_json(:only => [:id, :email, :first_name, :last_name, :gravatar_hash, :active, :locale, :username, :is_admin]),
:channel => activity.channel.attributes
}),
:extra => {
Expand Down
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@
add_index "users", ["authentication_token"], :name => "index_users_on_authentication_token", :unique => true
add_index "users", ["email"], :name => "index_users_on_email", :unique => true

end
end

0 comments on commit 989d673

Please sign in to comment.