Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'master' of github.com:mbarton/musictionary

  • Loading branch information...
commit 6d366821c3420751f8d6abf9292d2a33b28ebf10 2 parents 696cfd9 + c1e634e
Kiril Piskunov authored September 21, 2012
10  server.py
@@ -18,6 +18,7 @@
18 18
 	 "triggers": [False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False],
19 19
 	 "notes": ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""], "editing": True}
20 20
 ]
  21
+app.users = {}
21 22
 
22 23
 def randomRoomName():
23 24
 	return "%s%d" % (random.choice(app.words), random.randint(1, 99))
@@ -53,10 +54,14 @@ def player(room, facebook_id):
53 54
 	#Add or remove a player from a room
54 55
 	if request.method == 'POST':
55 56
 		print "adding player {0} to room {1}".format(facebook_id, room)
  57
+		app.p[room].trigger('presence', {"state": "add","facebook_id": facebook_id})
  58
+		app.users[room].append(facebook_id)
56 59
 	elif request.method == 'DELETE':
57 60
 		print "removing player {0} to room {1}".format(facebook_id, room)
  61
+		app.p[room].trigger('presence', {"state": "del","facebook_id": facebook_id})
  62
+		app.users[room].remove(facebook_id)
58 63
 	else:
59  
-		return json.dumps({'0': 681421705, '1': 100004387927649})
  64
+		return json.dumps(app.users[room])
60 65
 
61 66
 	return "Done"
62 67
 
@@ -68,6 +73,7 @@ def room(room):
68 73
 
69 74
 	if not room in app.rooms:
70 75
 		app.rooms[room] = copy.deepcopy(app.default_matrix)
  76
+		app.users[str(room)] = []
71 77
 	return render_template('room.html', matrix=json.dumps(app.rooms[room]), room=room)
72 78
 
73 79
 @app.route("/")
@@ -76,6 +82,8 @@ def index():
76 82
 	room = randomRoomName()
77 83
 	while room in app.rooms:
78 84
 		room = randomRoomName()
  85
+	
  86
+	app.users[str(room)] = []
79 87
 
80 88
 	# Build a list of random existing rooms
81 89
 	max_room_links = 10 if len(app.rooms) > 10 else len(app.rooms)
BIN  static/img/share.jpg
6  static/js/fb.js
@@ -29,7 +29,9 @@ MusictionaryFacebook = function(secret) {
29 29
     */
30 30
 
31 31
      FB.ui({ method: 'feed', 
32  
-            message: 'Facebook for Websites is super-cool'});
  32
+             name: 'Join my realtime Musictionary game!',
  33
+             description: 'Follow the link and guess the song',
  34
+             link: document.location.href });
33 35
 
34 36
   }
35 37
 
@@ -73,6 +75,7 @@ MusictionaryFacebook = function(secret) {
73 75
           $.ajax(url, {type: "DELETE"});
74 76
         }
75 77
         app.currentUserId = null;
  78
+        $('#share-button').hide();
76 79
         return;
77 80
       }
78 81
 
@@ -92,6 +95,7 @@ MusictionaryFacebook = function(secret) {
92 95
 
93 96
           $.ajax(url, {type: "POST"});
94 97
           $.getJSON(url, refresh_connected_users);
  98
+          $('#share-button').show();
95 99
         }
96 100
       );
97 101
     };
2  templates/room.html
@@ -30,7 +30,7 @@
30 30
         	<a class="brand error_report">
31 31
         	</a>
32 32
           <ul class="nav pull-right">
33  
-            <li> <button id='share-button' class='btn'>Share </button> </li>
  33
+            <li> <img class='brand' src='static/img/share.jpg' id='share-button' style='width: 80px; height: 25px; cursor: pointer;display:none'/> </li>
34 34
             <li> <a id="user_info"></a> </li>
35 35
             <li> <div class="fb-login-button brand" autologoutlink="true"/> </li>
36 36
           </ul>

0 notes on commit 6d36682

Please sign in to comment.
Something went wrong with that request. Please try again.