diff --git a/htdocs/templatestyle.css b/htdocs/templatestyle.css index 03069d4..15d6127 100644 --- a/htdocs/templatestyle.css +++ b/htdocs/templatestyle.css @@ -6,6 +6,16 @@ border: 2px solid grey; } +#mobilecontent { + background-color: white; + width: 90%; + margin: 25px auto; + border: 2px solid grey; + padding: 0; + padding-top: 10px; + padding-bottom: 10px; +} + #headpanel { position: relative; padding: 45px 2em 1em 20px; diff --git a/pyweb/mumble/urls.py b/pyweb/mumble/urls.py index fea6e82..c26be74 100644 --- a/pyweb/mumble/urls.py +++ b/pyweb/mumble/urls.py @@ -18,10 +18,12 @@ from django.conf.urls.defaults import * urlpatterns = patterns( 'mumble.views', - ( r'djangousers', 'djangousers' ), - ( r'(?P\d+)/users', 'users' ), - ( r'(?P\d+)/(?P\d+)/texture.png', 'showTexture' ), - ( r'(?P\d+)/texture.png', 'showTexture' ), - ( r'(?P\d+)', 'show' ), - ( r'$', 'mumbles' ), + ( r'djangousers', 'djangousers' ), + ( r'(?P\d+)/users', 'users' ), + ( r'(?P\d+)/(?P\d+)/texture.png', 'showTexture' ), + ( r'(?P\d+)/texture.png', 'showTexture' ), + ( r'mobile/(?P\d+)', 'mobile_show' ), + ( r'mobile/?$', 'mobile_mumbles' ), + ( r'(?P\d+)', 'show' ), + ( r'$', 'mumbles' ), ) diff --git a/pyweb/mumble/views.py b/pyweb/mumble/views.py index 7de2ae9..c906e42 100644 --- a/pyweb/mumble/views.py +++ b/pyweb/mumble/views.py @@ -35,7 +35,10 @@ from mmobjects import * def redir( request ): """ Redirect to the servers list. """ - return HttpResponseRedirect( reverse( mumbles ) ); + if request.META['HTTP_USER_AGENT'].startswith( 'BlackBerry' ): + return HttpResponseRedirect( reverse( mobile_mumbles ) ); + else: + return HttpResponseRedirect( reverse( mumbles ) ); def mumbles( request ): """ Display a list of all configured Mumble servers, or redirect if only one configured. """ @@ -53,6 +56,22 @@ def mumbles( request ): context_instance = RequestContext(request) ); +def mobile_mumbles( request ): + """ Display a list of all configured Mumble servers, or redirect if only one configured. """ + mumbles = get_list_or_404( Mumble ); + + if len(mumbles) == 1: + return HttpResponseRedirect( reverse( mobile_show, kwargs={ 'server': mumbles[0].id, } ) ); + + return render_to_response( + 'mumble/mobile_list.htm', + { 'MumbleObjects': mumbles, + 'MumbleActive': True, + 'MEDIA_URL': settings.MEDIA_URL, + }, + context_instance = RequestContext(request) + ); + def show( request, server ): """Display the channel list for the given Server ID. @@ -169,6 +188,31 @@ def show( request, server ): context_instance = RequestContext(request) ); +def mobile_show( request, server ): + """ Display the channel list for the given Server ID. """ + + srv = get_object_or_404( Mumble, id=server ); + + user = None; + if request.user.is_authenticated(): + try: + user = MumbleUser.objects.get( server=srv, owner=request.user ); + except MumbleUser.DoesNotExist: + pass; + + return render_to_response( + 'mumble/mobile_mumble.htm', + { + 'MEDIA_URL': settings.MEDIA_URL, + 'DBaseObject': srv, + 'MumbleActive': True, + 'MumbleAccount':user, + }, + context_instance = RequestContext(request) + ); + + + def showTexture( request, server, userid = None ): """ Pack the given user's texture into an HttpResponse. diff --git a/template/mobile_index.htm b/template/mobile_index.htm new file mode 100644 index 0000000..539ef6b --- /dev/null +++ b/template/mobile_index.htm @@ -0,0 +1,24 @@ + + + Mumble Administration + + + + + + + + {% block HeadTag %} + {% endblock %} + + +
+ {% block LeftColumn %} + {% endblock %} +
+ + + + diff --git a/template/mumble/mobile_list.htm b/template/mumble/mobile_list.htm new file mode 100644 index 0000000..87f4e98 --- /dev/null +++ b/template/mumble/mobile_list.htm @@ -0,0 +1,14 @@ +{% extends "mobile_index.htm" %} +{% load mumble_extras %} +{% block Headline %} +Configured Mumble Servers +{% endblock %} +{% block Content %} +
+ +
+{% endblock %} \ No newline at end of file diff --git a/template/mumble/mobile_mumble.htm b/template/mumble/mobile_mumble.htm new file mode 100644 index 0000000..3bcdaf1 --- /dev/null +++ b/template/mumble/mobile_mumble.htm @@ -0,0 +1,9 @@ +{% extends "mobile_index.htm" %} +{% load mumble_extras %} +{% load i18n %} +{% block Headline %} + {{ DBaseObject.name }} +{% endblock %} +{% block LeftColumn %} + {{ DBaseObject|chanview:MumbleAccount }} +{% endblock %}