Beispiel #1
0
    def render(self, *args, **kwargs):
        if not self.mimetype:
            self.mimetype, encoding = guess_type(self.file.name)

        if not self.size:
            self.size = path.getsize(settings.MEDIA_ROOT + self.file.name)

        ctx = {'attachment': self}

        if not 'nolink' in args:
            ctx['url'] = kwargs.get('link') or self.file.url

        if 'align' in kwargs:
            ctx['align'] = kwargs['align']

        if self.mimetype in ('image/bmp', 'image/x-windows-bmp', 'image/gif',
                             'image/jpeg', 'image/pjpeg', 'image/png',
                             'image/tiff'):
            ctx['size'] = str(kwargs['width'])
            return render_to_string('attachments/image.inc.html', ctx)
        elif self.mimetype == 'video/mp4':
            if 'bambu.jwplayer' in settings.INSTALLED_APPS:
                from bambu.jwplayer.helpers import jwplayer_code

                return jwplayer_code(self, 'file', **kwargs)
            else:
                ctx['width'] = str(kwargs['width'])
                return render_to_string('attachments/video.inc.html', ctx)
        else:
            return render_to_string('attachments/download.inc.html', ctx)
Beispiel #2
0
def jwplayer(obj, field='video', ct=None):
    player_id = ''.join(random.sample(string.letters, 10))

    code = mark_safe(
        helpers.jwplayer_code(obj, field, player_id=player_id, ct=ct))

    return code + mark_safe(
        render_to_string('jwplayer/javascript.inc.html', {'id': player_id}))
Beispiel #3
0
def jwplayer(obj, field = 'video', ct = None):
	player_id = ''.join(random.sample(string.letters, 10))
	
	code = mark_safe(
		helpers.jwplayer_code(obj, field, player_id = player_id, ct = ct)
	)
	
	return code + mark_safe(
		render_to_string(
			'jwplayer/javascript.inc.html',
			{
				'id': player_id
			}
		)
	)
Beispiel #4
0
def jwplayer_code(obj, field='video'):
    return escape(helpers.jwplayer_code(obj, field))
Beispiel #5
0
def jwplayer_code(obj, field = 'video'):
	return escape(helpers.jwplayer_code(obj, field))