Navigation Menu

Skip to content

Commit

Permalink
rackup
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Choi committed Jun 23, 2013
1 parent 19475b6 commit 5c6a398
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -10,9 +10,9 @@ Create the database

Run the Sintra app

ruby app.rb
rackup -s thin

A test change
Open the app on localhost:9292

![readme](./img/geogossip.png)

Expand Down
5 changes: 3 additions & 2 deletions app.rb
Expand Up @@ -40,7 +40,7 @@ class Membership < ActiveRecord::Base
end

get '/channels' do
Channel.all.map {|channel|
Channel.order("updated desc").all.map {|channel|
channel.attributes.merge(
users: channel.users,
messages: channel.messages.limit(20),
Expand Down Expand Up @@ -86,7 +86,7 @@ class Membership < ActiveRecord::Base

post '/memberships' do
payload = JSON.parse(request.body.read)
user = User.find payload
user = find_user payload
channel_id = payload["channel_id"]
# expire all current memberships
user.memberships.each {|x| x.update_attributes(terminated: Time.now)}
Expand All @@ -112,6 +112,7 @@ class Membership < ActiveRecord::Base
end

def find_user payload
puts "find_user from payload: #{payload.to_json}"
User.find(payload['user_id']) # may change this impl later
end

3 changes: 3 additions & 0 deletions config.ru
@@ -0,0 +1,3 @@

require './app'
run Sinatra::Application
15 changes: 10 additions & 5 deletions public/js/chatui.js
Expand Up @@ -101,7 +101,8 @@ function ChatUICtrl ($scope, $http) {
.success(function(data){
console.log(data);
});
console.log("active channel is: " + $scope.activeChannel.topic);
/* this highlights map circle if channel on map */
$scope.populateMap();
};

$scope.postMessage = function(msg){
Expand Down Expand Up @@ -163,15 +164,19 @@ function ChatUICtrl ($scope, $http) {
svg.selectAll("circle")
.data(xs)
.enter().append("circle")
.attr('class', 'geoChatCircle')
.attr('class', function(d) {
var cn = d.channel_id === $scope.activeChannel.channel_id ? "active" : null;
return cn;
})
.attr("cx", function(d) {
console.log(d.latLng);
console.log(project(d.latLng));
return (project(d.latLng)[0]);
})
.attr("cy", function(d) {return (project(d.latLng)[1])})
.attr("r", 12)
.style("fill", "#f03")
.style("fill", function(d) {
var f = d.channel_id === $scope.activeChannel.channel_id ? "yellow" : "#f03";
return f;
})
.style('fill-opacity', 0.3)
.style("stroke", "red")
.style("stroke-opacity", 1)
Expand Down

0 comments on commit 5c6a398

Please sign in to comment.