Forked mumble-django project from https://bitbucket.org/Svedrin/mumble-django
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.7 KiB

16 years ago
16 years ago
  1. # -*- coding: utf-8 -*-
  2. """
  3. * Copyright (C) 2009, Michael "Svedrin" Ziegler <diese-addy@funzt-halt.net>
  4. *
  5. * Mumble-Django is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This package is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. """
  15. from django import template
  16. from django.template.loader import render_to_string
  17. register = template.Library();
  18. ### FILTER: trunc -- converts "a very very extaordinary long text" to "a very very extra..."
  19. def trunc( string, maxlen = 50 ):
  20. if len(string) < maxlen:
  21. return string;
  22. return string[:(maxlen - 3)] + "...";
  23. register.filter( 'trunc', trunc );
  24. ### FILTER: chanview -- renders an mmChannel / mmPlayer object with the correct template.
  25. def chanview( obj, user = None ):
  26. if obj.is_server:
  27. return render_to_string( 'mumble/server.htm', { 'Server': obj, 'MumbleAccount': user } );
  28. elif obj.is_channel:
  29. return render_to_string( 'mumble/channel.htm', { 'Channel': obj, 'MumbleAccount': user } );
  30. elif obj.is_player:
  31. return render_to_string( 'mumble/player.htm', { 'Player': obj, 'MumbleAccount': user } );
  32. register.filter( 'chanview', chanview );
  33. ### FILTER: chanurl -- creates a connection URL and takes the user's login into account
  34. def chanurl( obj, user ):
  35. return obj.getURL( user );
  36. register.filter( 'chanurl', chanurl );