Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Brian Gonzalez
committed
Oct 21, 2011
0 parents
commit d4b7a23
Showing
251 changed files
with
16,431 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.bundle | ||
db/*.sqlite3 | ||
log/*.log | ||
tmp/ |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
source 'http://rubygems.org' | ||
|
||
gem 'rails', '3.0.5' | ||
|
||
# Bundle edge Rails instead: | ||
# gem 'rails', :git => 'git://github.com/rails/rails.git' | ||
|
||
gem 'rake' | ||
gem 'passenger' | ||
|
||
gem 'rspec' | ||
gem 'json' | ||
|
||
gem 'omniauth' | ||
gem 'haml' | ||
gem "sass" | ||
gem "compass", ">= 0.11.5" | ||
gem 'bundler' | ||
|
||
gem 'mysql2', "0.2.9" | ||
gem 'thin' | ||
|
||
gem 'yaml_db' | ||
gem 'pusher' | ||
|
||
# Geolocation-related functionality. | ||
gem 'geokit-rails3' | ||
|
||
# Jquery :) | ||
gem 'jquery-rails', '>= 1.0.12' | ||
|
||
|
||
# group :development, :test do | ||
# gem 'wirble' | ||
# end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
abstract (1.0.0) | ||
actionmailer (3.0.5) | ||
actionpack (= 3.0.5) | ||
mail (~> 2.2.15) | ||
actionpack (3.0.5) | ||
activemodel (= 3.0.5) | ||
activesupport (= 3.0.5) | ||
builder (~> 2.1.2) | ||
erubis (~> 2.6.6) | ||
i18n (~> 0.4) | ||
rack (~> 1.2.1) | ||
rack-mount (~> 0.6.13) | ||
rack-test (~> 0.5.7) | ||
tzinfo (~> 0.3.23) | ||
activemodel (3.0.5) | ||
activesupport (= 3.0.5) | ||
builder (~> 2.1.2) | ||
i18n (~> 0.4) | ||
activerecord (3.0.5) | ||
activemodel (= 3.0.5) | ||
activesupport (= 3.0.5) | ||
arel (~> 2.0.2) | ||
tzinfo (~> 0.3.23) | ||
activeresource (3.0.5) | ||
activemodel (= 3.0.5) | ||
activesupport (= 3.0.5) | ||
activesupport (3.0.5) | ||
addressable (2.2.4) | ||
arel (2.0.10) | ||
builder (2.1.2) | ||
chunky_png (1.2.0) | ||
compass (0.11.5) | ||
chunky_png (~> 1.2) | ||
fssm (>= 0.2.7) | ||
sass (~> 3.1) | ||
crack (0.1.8) | ||
daemon_controller (0.2.6) | ||
daemons (1.1.4) | ||
diff-lcs (1.1.2) | ||
erubis (2.6.6) | ||
abstract (>= 1.0.0) | ||
eventmachine (0.12.10) | ||
faraday (0.6.1) | ||
addressable (~> 2.2.4) | ||
multipart-post (~> 1.1.0) | ||
rack (< 2, >= 1.1.0) | ||
fastthread (1.0.7) | ||
fssm (0.2.7) | ||
geokit (1.5.0) | ||
geokit-rails3 (0.1.3) | ||
geokit (~> 1.5.0) | ||
rails (~> 3.0.4) | ||
haml (3.1.2) | ||
i18n (0.6.0) | ||
jquery-rails (1.0.12) | ||
railties (~> 3.0) | ||
thor (~> 0.14) | ||
json (1.5.3) | ||
mail (2.2.19) | ||
activesupport (>= 2.3.6) | ||
i18n (>= 0.4.0) | ||
mime-types (~> 1.16) | ||
treetop (~> 1.4.8) | ||
mime-types (1.16) | ||
multi_json (1.0.3) | ||
multi_xml (0.2.2) | ||
multipart-post (1.1.3) | ||
mysql2 (0.2.9) | ||
net-ldap (0.2.2) | ||
nokogiri (1.4.7) | ||
oa-basic (0.2.6) | ||
oa-core (= 0.2.6) | ||
rest-client (~> 1.6.0) | ||
oa-core (0.2.6) | ||
oa-enterprise (0.2.6) | ||
addressable (= 2.2.4) | ||
net-ldap (~> 0.2.2) | ||
nokogiri (~> 1.4.2) | ||
oa-core (= 0.2.6) | ||
pyu-ruby-sasl (~> 0.0.3.1) | ||
rubyntlm (~> 0.1.1) | ||
oa-more (0.2.6) | ||
multi_json (~> 1.0.0) | ||
oa-core (= 0.2.6) | ||
rest-client (~> 1.6.0) | ||
oa-oauth (0.2.6) | ||
faraday (~> 0.6.1) | ||
multi_json (~> 1.0.0) | ||
multi_xml (~> 0.2.2) | ||
oa-core (= 0.2.6) | ||
oauth (~> 0.4.0) | ||
oauth2 (~> 0.4.1) | ||
oa-openid (0.2.6) | ||
oa-core (= 0.2.6) | ||
rack-openid (~> 1.3.1) | ||
ruby-openid-apps-discovery (~> 1.2.0) | ||
oauth (0.4.5) | ||
oauth2 (0.4.1) | ||
faraday (~> 0.6.1) | ||
multi_json (>= 0.0.5) | ||
omniauth (0.2.6) | ||
oa-basic (= 0.2.6) | ||
oa-core (= 0.2.6) | ||
oa-enterprise (= 0.2.6) | ||
oa-more (= 0.2.6) | ||
oa-oauth (= 0.2.6) | ||
oa-openid (= 0.2.6) | ||
passenger (3.0.7) | ||
daemon_controller (>= 0.2.5) | ||
fastthread (>= 1.0.1) | ||
rack | ||
rake (>= 0.8.1) | ||
polyglot (0.3.2) | ||
pusher (0.8.2) | ||
crack (~> 0.1.0) | ||
multi_json (~> 1.0) | ||
ruby-hmac (~> 0.4.0) | ||
signature (~> 0.1.2) | ||
pyu-ruby-sasl (0.0.3.3) | ||
rack (1.2.3) | ||
rack-mount (0.6.14) | ||
rack (>= 1.0.0) | ||
rack-openid (1.3.1) | ||
rack (>= 1.1.0) | ||
ruby-openid (>= 2.1.8) | ||
rack-test (0.5.7) | ||
rack (>= 1.0) | ||
rails (3.0.5) | ||
actionmailer (= 3.0.5) | ||
actionpack (= 3.0.5) | ||
activerecord (= 3.0.5) | ||
activeresource (= 3.0.5) | ||
activesupport (= 3.0.5) | ||
bundler (~> 1.0) | ||
railties (= 3.0.5) | ||
railties (3.0.5) | ||
actionpack (= 3.0.5) | ||
activesupport (= 3.0.5) | ||
rake (>= 0.8.7) | ||
thor (~> 0.14.4) | ||
rake (0.9.2) | ||
rest-client (1.6.3) | ||
mime-types (>= 1.16) | ||
rspec (2.6.0) | ||
rspec-core (~> 2.6.0) | ||
rspec-expectations (~> 2.6.0) | ||
rspec-mocks (~> 2.6.0) | ||
rspec-core (2.6.4) | ||
rspec-expectations (2.6.0) | ||
diff-lcs (~> 1.1.2) | ||
rspec-mocks (2.6.0) | ||
ruby-hmac (0.4.0) | ||
ruby-openid (2.1.8) | ||
ruby-openid-apps-discovery (1.2.0) | ||
ruby-openid (>= 2.1.7) | ||
rubyntlm (0.1.1) | ||
sass (3.1.5) | ||
signature (0.1.2) | ||
ruby-hmac | ||
thin (1.2.11) | ||
daemons (>= 1.0.9) | ||
eventmachine (>= 0.12.6) | ||
rack (>= 1.0.0) | ||
thor (0.14.6) | ||
treetop (1.4.10) | ||
polyglot | ||
polyglot (>= 0.3.1) | ||
tzinfo (0.3.29) | ||
yaml_db (0.2.1) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
bundler | ||
compass (>= 0.11.5) | ||
geokit-rails3 | ||
haml | ||
jquery-rails (>= 1.0.12) | ||
json | ||
mysql2 (= 0.2.9) | ||
omniauth | ||
passenger | ||
pusher | ||
rails (= 3.0.5) | ||
rake | ||
rspec | ||
sass | ||
thin | ||
yaml_db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
### Sirkel | ||
|
||
Sirkel is a geolocation based chat application that won VMware's Flings Contest among all interns in the Americas. It was build in 3 weeks using Rails, Cloud Foundry & Pushr App. | ||
|
||
Because it was built in 3 weeks, there are _bugs_, so please just use this as a (very)rough reference. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Add your own tasks in files placed in lib/tasks ending in .rake, | ||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. | ||
|
||
require File.expand_path('../config/application', __FILE__) | ||
require 'rake' | ||
|
||
SirkelApp::Application.load_tasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
class ApplicationController < ActionController::Base | ||
protected | ||
helper_method( :current_user, :signed_in?, :get_active_users, :have_location, :set_user_inactive, :chat_id_hash, :poll_interval ) | ||
|
||
# HELPERS | ||
def current_user | ||
@current_user ||= User.find_by_id(session[:user_id]) | ||
end | ||
|
||
def signed_in? | ||
!!current_user | ||
end | ||
|
||
def get_active_users(id) | ||
user = User.find( id ) | ||
lat = user.latitude | ||
lng = user.longitude | ||
return User.geo_scope(:origin => [lat, lng]) | ||
#return User.where(:is_active => true) | ||
end | ||
|
||
def have_location?(id) | ||
user = User.find(id) | ||
return user.latitude || user.longitude | ||
end | ||
|
||
# Caller when logout and when user navigates away. | ||
def set_user_inactive(user) | ||
user.update_attributes(:last_seen_at => 0.0 ) | ||
user.save | ||
end | ||
|
||
|
||
|
||
def chat_id_hash( user_id, p_user_hash ) | ||
chat_ids = [] | ||
|
||
if p_user_hash | ||
p_user_hash.each do |p_user| | ||
|
||
if (p_user['id'] > user_id ) | ||
chat_id = "sirkel-" + user_id.to_s() + "-" + p_user['id'].to_s() | ||
else | ||
chat_id = "sirkel-" + p_user['id'].to_s() + "-" + user_id.to_s() | ||
end | ||
chat_ids << chat_id | ||
end | ||
end | ||
|
||
return chat_ids | ||
|
||
end | ||
|
||
|
||
def poll_interval | ||
# Is the user still alive after ___ sec.? | ||
return 8 | ||
end | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
# NON HELPERS | ||
def current_user=(user) | ||
@current_user = user | ||
session[:user_id] = user.id | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class EnvController < ApplicationController | ||
|
||
def env | ||
@env = ENV | ||
@page_title = 'Environment Variables' | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
require 'json' | ||
|
||
class GeolocateController < ApplicationController | ||
|
||
# | ||
# GETS ACTIVE USERS WITH A CERTAIN RADIUS AND SET SELF ACTIVE. | ||
# | ||
def get_active_users_within_radius_and_set_current_user_active() | ||
|
||
lat = params[:lat] | ||
lng = params[:lng] | ||
loc = { :lat => lat, :lng => lng } | ||
radius = params[:radius] | ||
|
||
# First, update the user since now we know there geolocation. | ||
user = User.find( session[:user_id] ) | ||
user.update_attributes( :latitude => lat, :longitude => lng) | ||
user.save | ||
|
||
# Grab proxime users from db. | ||
# proxime_users = User.geo_scope( :within => radius, :origin => [lat, lng]) | ||
# | ||
all_users = User.where("id != ?", session[:user_id]) | ||
all_near_users = User.geo_scope( :within => radius, :origin => [lat, lng]).where("id != ?", session[:user_id]) | ||
proxime_users = [] | ||
|
||
all_near_users.each do |user| | ||
proxime_users << user unless !( Time.now.to_f - user.last_seen_at < poll_interval ) # We're polling every 5, so if a user has | ||
end # been gone for this interval, we're ok. | ||
|
||
# Grab all users from db. | ||
# all_active_users = User.where(:is_active => true).where("id != ?", session[:user_id]) | ||
# Pusher['userActive'].trigger('update-users', {:data => all_active_users}) | ||
|
||
# Get the chat id hash that we'll use on the client side to check which user are within the radius. | ||
chat_ids = chat_id_hash( session[:user_id], proxime_users ) | ||
all_chat_ids = chat_id_hash( session[:user_id], all_users ) | ||
|
||
respond_to do |type| | ||
type.json { render :json => { proxime_users: proxime_users, | ||
self_id: session[:user_id], | ||
params: params, | ||
chat_ids: chat_ids, | ||
all_chat_ids: all_chat_ids, | ||
image_url: user.image_url, | ||
name: user.name }.to_json } | ||
end | ||
|
||
end | ||
|
||
|
||
end |
Oops, something went wrong.