Exemple #1
0
def html_for_media(filename):
    media_type = get_media_type(filename)
    url = relative_url_for("posts_bp.get_media", filename=filename)
    if media_type == MediaType.image:
        return html_for_image(filename)
    if media_type == MediaType.video:
        basename, ext = os.path.splitext(filename)
        fname_mp4, fname_webm = basename + ".mp4", basename + ".webm"
        fname_poster = poster_filename_for(filename)
        url_mp4 = relative_url_for("posts_bp.get_media", filename=fname_mp4)
        url_webm = relative_url_for("posts_bp.get_media", filename=fname_webm)
        poster_url = relative_url_for("posts_bp.get_media",
                                      filename=fname_poster)
        return videojs_template.format(
            id=filename, mp4=url_mp4, webm=url_webm, 
            poster_url=poster_url)

    return "<p>Unknown media type: '{}'</p>".format(filename)
Exemple #2
0
def uri(path: str) -> str:
    """Handle the relative path and URIs."""
    if not path:
        return ""
    u = urlparse(path)
    if all((u.scheme, u.netloc, u.path)):
        return path
    if app.config.get('FREEZER_RELATIVE_URLS', False):
        return relative_url_for('static', filename=path)
    else:
        return url_for('static', filename=path)
Exemple #3
0
def yasifipo_url_for(target, **values):

	if yasifipo_is_server() and ('yasifipo_subdirectory' in app.yasifipo['config'].keys() and app.yasifipo['config']['yasifipo_subdirectory'] != ''):
		if 'path' in values.keys():
			if values['path'] != "/":
				values['path'] = app.yasifipo['config']['yasifipo_subdirectory'] + '/' + values['path']
			else:
				values['path'] = app.yasifipo['config']['yasifipo_subdirectory']
				target = 'render_file'
	if yasifipo_is_server() == False:
		return relative_url_for(target, **values)
	else:
		return url_for(target, **values)
Exemple #4
0
 def get_url(self):
     return relative_url_for(self.endpoint, **self.url_for_kwargs)
def path_helper(path, **kwargs):
    """
    Helper function for getting preview URLs
    """
    return relative_url_for('preview', path=path, **kwargs)
Exemple #6
0
def html_for_image(filename):
    url = relative_url_for("posts_bp.get_media", filename=filename)
    classes = "img-responsive img-rounded"
    img_tag = '<img class="{}" src="{}">'.format(
            classes, url)
    return '<a href="{}">{}</a>'.format(url, img_tag)