Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Bushido/Kandan
Browse files Browse the repository at this point in the history
  • Loading branch information
kevzettler committed Apr 2, 2012
2 parents ed2bbb2 + 2d34402 commit 3f92f32
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 30 deletions.
Binary file added app/assets/images/search_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions app/assets/javascripts/backbone/kandan.js.coffee
Expand Up @@ -71,8 +71,18 @@ window.Kandan =
Kandan.initTabs()
Kandan.Widgets.initAll()

setCurrentUser: ()->
template = _.template '''
<img src="http://gravatar.com/avatar/<%= gravatar_hash %>?s=25&d=http://bushi.do/images/profile.png"/> <%= name %>
'''
currentUser = Kandan.Helpers.Users.currentUser()
$(".header .user").html template({
gravatar_hash: currentUser.gravatar_hash,
name: "#{currentUser.first_name} #{currentUser.last_name}"
})

init: ->
@setCurrentUser()
channels = new Kandan.Collections.Channels()
channels.fetch({success: (channelsCollection)=>
@initBroadcasterAndSubscribe()
Expand Down
Expand Up @@ -42,7 +42,7 @@ class Kandan.Plugins.Attachments

@fileIcon: (fileName)->
fileExtension = fileName.split(".").pop()
return "/assets/img_icon.png" if fileExtension.match(/(png|jpeg|gif)/i)
return "/assets/img_icon.png" if fileExtension.match(/(png|jpeg|jpg|gif)/i)
return "/assets/video_icon.png" if fileExtension.match(/(mp3|wav)/i)
return "/assets/audio_icon.png" if fileExtension.match(/(mov|mpg|mpeg|mp4)/i)
return "/assets/file_icon.png"
Expand Down
3 changes: 1 addition & 2 deletions app/assets/stylesheets/_base.sass
Expand Up @@ -24,8 +24,7 @@ html
+full-height

body
background: $page-bg
background-image: url("/assets/page_bg.png")
background: $page-bg url(image_path('page_bg.png')) repeat
height: 100%
min-height: 100%
font-size: 13px
Expand Down
3 changes: 1 addition & 2 deletions app/assets/stylesheets/_chat_area.sass
Expand Up @@ -57,8 +57,7 @@ a.ui-icon-close

.ui-widget-content
+full-height
background: $panel-bg
background-image: url("/assets/page_bg.png")
background: $panel-bg url(image_path('page_bg.png')) repeat
font-size: 13px

.paginated-activities
Expand Down
16 changes: 14 additions & 2 deletions app/assets/stylesheets/_sidebar.sass
Expand Up @@ -56,12 +56,24 @@


.search
width: 200px
min-width: 100px
float: right
text-align: right
input
+border-radius(20px)
background: $search-bg url(image_path('search_icon.png')) no-repeat
background-position: 95% center
width: 100%
background: $search-bg
color: $search-color
border: 2px solid darken($search-bg, 10%)
padding-right: 15%

.header .user
float: right
color: #CCC
padding-left: 10px
padding-right: 10px
img
vertical-align: middle
width: 20px
height: 20px
1 change: 1 addition & 0 deletions app/assets/stylesheets/plugins/_attachments.sass
Expand Up @@ -12,6 +12,7 @@
color: #585D5F
img
width: 14px
height: 12px
margin-right: 10px
a
text-decoration: none
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/apis_controller.rb
Expand Up @@ -4,7 +4,7 @@ class ApisController < ApplicationController

def active_users
respond_to do |format|
format.js { render :json => ActiveUsers.all }
format.json { render :json => ActiveUsers.all }
end
end
end
3 changes: 2 additions & 1 deletion app/views/layouts/application.html.erb
Expand Up @@ -17,7 +17,8 @@
:id => current_user.id,
:first_name => current_user.first_name,
:last_name => current_user.last_name,
:auth_token => current_user.authentication_token
:auth_token => current_user.authentication_token,
:gravatar_hash => current_user.gravatar_hash
}
%>
$.data(document, 'current_user', <%= current_user_data.to_json.html_safe %>);
Expand Down
2 changes: 1 addition & 1 deletion app/views/main/index.html.erb
Expand Up @@ -10,12 +10,12 @@
<div class="header">
<%= image_tag "logo.png", :class=>"logo" %>

<div class="user"></div>
<div class="search">
<form method="get" action="/search" target="_blank">
<input type="text" class="query" name="query"/>
</form>
</div>
<div class="user"></div>
</div>

<div id="app_body">
Expand Down
19 changes: 19 additions & 0 deletions spec/controllers/apis_controller_spec.rb
@@ -0,0 +1,19 @@
require "spec_helper"

describe ApisController do

before :each do
@user = Factory :user
request.env['warden'].stub :authenticate! => @user
controller.stub :current_user => @user
end


describe "active_users" do
it "should return json" do
get :active_users, :format => :json
ActiveUsers.stub!(:all).and_return([])
JSON(response.body).should be_kind_of(Array)
end
end
end
11 changes: 7 additions & 4 deletions spec/controllers/channels_controller_spec.rb
Expand Up @@ -4,20 +4,23 @@

before :all do
@channel = Factory :channel
# @sample_activity = @channel.activities.build :action => "message"
end

before :each do
@user = Factory :user
request.env['warden'].stub :authenticate! => @user
controller.stub :current_user => @user
end

describe "GET index" do
it "should return list of channels in JSON" do
get :index, :format => :json
JSON(response.body).should be_kind_of(Array)
JSON(response.body).first.should have_key("activities")
JSON(response.body) # parse to validate json
end

it "should have an array for activities in the JSON response" do
get :index, :format => :json
puts JSON(response.body).first["activities"].should be_kind_of(Array)
end
end

Expand Down
32 changes: 17 additions & 15 deletions spec/factories.rb
@@ -1,18 +1,20 @@
Factory.sequence :ido_id do |n|
"abc-#{ n }"
end
FactoryGirl.define do
sequence :ido_id do |n|
"abc-#{n}"
end

Factory.sequence :email do |n|
"email#{ n }@factory.com"
end
sequence :email do |n|
"email#{n}@example.com"
end

Factory.define :channel do |f|
f.name "Test channel"
end
factory :channel do |f|
f.name "Test channel"
end

Factory.define :user do |f|
f.first_name "Test"
f.last_name "User"
f.email { Factory.next(:email) }
f.ido_id { Factory.next(:ido_id) }
end
factory :user do |f|
f.first_name "Test"
f.last_name "User"
f.email { Factory.next(:email) }
f.ido_id { Factory.next(:ido_id) }
end
end
3 changes: 2 additions & 1 deletion spec/spec_helper.rb
@@ -1,8 +1,9 @@
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
ENV["RAILS_ENV"] = 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require "#{Rails.root}/lib/active_users.rb"

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Expand Down

0 comments on commit 3f92f32

Please sign in to comment.