Browse Source

add view to feed Antiarc's AJAX channel viewer (http://tinyurl.com/ydun45e) with data.

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
18239ecf0f
  1. 5
      pyweb/mumble/urls.py
  2. 42
      pyweb/mumble/views.py

5
pyweb/mumble/urls.py

@ -20,10 +20,15 @@ urlpatterns = patterns(
'mumble.views', 'mumble.views',
( r'djangousers', 'djangousers' ), ( r'djangousers', 'djangousers' ),
( r'(?P<server>\d+)/users', 'users' ), ( r'(?P<server>\d+)/users', 'users' ),
( r'(?P<server>\d+)/(?P<userid>\d+)/texture.png', 'showTexture' ), ( r'(?P<server>\d+)/(?P<userid>\d+)/texture.png', 'showTexture' ),
( r'(?P<server>\d+)/texture.png', 'showTexture' ), ( r'(?P<server>\d+)/texture.png', 'showTexture' ),
( r'murmur/tree/(?P<server>\d+)', 'mmng_tree' ),
( r'mobile/(?P<server>\d+)', 'mobile_show' ), ( r'mobile/(?P<server>\d+)', 'mobile_show' ),
( r'mobile/?$', 'mobile_mumbles' ), ( r'mobile/?$', 'mobile_mumbles' ),
( r'(?P<server>\d+)', 'show' ), ( r'(?P<server>\d+)', 'show' ),
( r'$', 'mumbles' ), ( r'$', 'mumbles' ),
) )

42
pyweb/mumble/views.py

@ -322,3 +322,45 @@ def djangousers( request ):
); );
def mmng_tree( request, server ):
""" JSONify the channel tree to initialize the client's tree structure. """
srv = get_object_or_404( Mumble, id=int(server) );
chanlist = []
userlist = []
for chanid in srv.channels:
channel = srv.channels[chanid]
state = None # "removed"
chanlist.append({
"type": "channel",
"id": channel.chanid,
"name": channel.name,
"parent": channel.parent and channel.parent.chanid or -1,
"position": channel.position,
"state": state == None and (channel.temporary and "temporary" or "permanent") or state
})
for sessionid in srv.players:
user = srv.players[sessionid]
userlist.append({
"type": "player",
"name": user.name,
"channel": user.channel.chanid,
"mute": user.mute or user.selfMute or user.suppress,
"deaf": user.deaf or user.selfDeaf or user.suppress,
"online": user.onlinesecs,
"state": "online" # "offline"
})
if "callback" in request.GET:
prefix = request.GET["callback"]
else:
prefix = ""
return HttpResponse(
prefix + "(" + simplejson.dumps( { 'channels': chanlist, 'users': userlist } ) + ")",
mimetype='text/javascript'
);
Loading…
Cancel
Save