Пример #1
0
def game_file_url_tag(context, a="", b="", c="", d="", e="", f="", varname=None):
    """
    Here "varname" is the varuiable under which to store the result, if any.
    """
    assert not isinstance(context, basestring)
    rel_path = "".join((a, b, c, d, e, f))
    full_url = real_game_file_url(rel_path)
    if varname is not None:
        assert varname, "wrong game_file_url varname %s" % varname
        context[varname] = full_url
        return ""
    else:
        return full_url
Пример #2
0
def _try_generating_thumbnail_url(rel_path, alias=None):
    """
    Falls back to original fail url if thumbnail generation fails, or if no alias is provided.
    """
    if alias:
        try:
            thumb = get_game_thumbnailer(rel_path)[
                alias]  # we enforce the GAME_FILES storage here!
            return thumb.url
        except Exception as e:
            logging.warning("Error generating game_file_img %s (alias=%s): %r",
                            rel_path, alias, e)
            pass  # fallback to plain file

    return real_game_file_url(rel_path)  # original image
Пример #3
0
def game_file_url_tag(context,
                      a="",
                      b="",
                      c="",
                      d="",
                      e="",
                      f="",
                      varname=None):
    """
    Here "varname" is the varuiable under which to store the result, if any.
    """
    assert not isinstance(context, str)
    rel_path = "".join((a, b, c, d, e, f))
    full_url = real_game_file_url(rel_path)
    if varname is not None:
        assert varname, "wrong game_file_url varname %s" % varname
        context[varname] = full_url
        return ""
    else:
        return full_url
Пример #4
0
 def _replacer(match_obj):
     rel_path = match_obj.group("path")
     fullpath = real_game_file_url(rel_path)
     return fullpath
Пример #5
0
 def _replacer(match_obj):
     rel_path = match_obj.group("path")
     fullpath = real_game_file_url(rel_path)
     return fullpath
Пример #6
0
GAME_LOCAL_TZ = config.GAME_LOCAL_TZ # real timezone object


def _try_generating_thumbnail_url(rel_path, alias=None):
    """
    Falls back to original fail url if thumbnail generation fails, or if no alias is provided.
    """
    if alias:
        try:
            thumb = get_game_thumbnailer(rel_path)[alias] # we enforce the GAME_FILES storage here!
            return thumb.url
        except Exception, e:
            logging.warning("Error generating game_file_img %s (alias=%s): %r", rel_path, alias, e)
            pass # fallback to plain file

    return real_game_file_url(rel_path) # original image



@register.simple_tag(takes_context=False)
def first_non_empty(*args):
    for arg in args:
        if arg:
            return arg
    return ""


@register.simple_tag(takes_context=False)
def random_id():
    """Tag to generate random ids in HTML tags, just to please javascript utilities."""
    return "uuid-" + str(random.randint(1000000, 1000000000))