예제 #1
0
def static(context, path):
    lang = context['request'].session.get('_language', 'ru')
    res = ''
    if should_i18n(path):
        if lang != 'ru':
            real_path = path.split('?', 1)[0]
            decomposed = map(lambda x: lang + '.' + x if x == 'js' else x,
                             real_path.split('/'))
            composed = '/'.join(decomposed)
            res = _static(composed)
    if not res:
        res = _static(path)
    return mark_safe(res + '?v={}'.format(VERSION))
예제 #2
0
def icon(value,icontype):
    txt=""
    if icontype=="league":
        if value!=None:
            txt='<img src="'
            txt+=_static(value+"icon.png")+'">'
        else:
            txt="?"
    if icontype=="race":
        if value!=None:
            txt='<img src="'+_static(value+"icon_small.png")+'">'
        else:
            txt="?"
    return mark_safe(txt)
예제 #3
0
def static(path):
    warnings.warn(
        'django.contrib.staticfiles.templatetags.static() is deprecated in '
        'favor of django.templatetags.static.static().',
        RemovedInDjango30Warning,
        stacklevel=2,
    )
    return _static(path)
예제 #4
0
def static(path):
    warnings.warn(
        'django.contrib.staticfiles.templatetags.data() is deprecated in '
        'favor of django.templatetags.data.data().',
        RemovedInDjango30Warning,
        stacklevel=2,
    )
    return _static(path)
예제 #5
0
def static(path):
    warnings.warn(
        "django.contrib.staticfiles.templatetags.static() is deprecated in "
        "favor of django.templatetags.static.static().",
        RemovedInDjango30Warning,
        stacklevel=2,
    )
    return _static(path)
예제 #6
0
def static(path):
    global _static
    if _static is None:
        # if apps.is_installed('django.contrib.staticfiles'):
        #     from django.contrib.staticfiles.templatetags.staticfiles import static as _static
        # else:
        from django.templatetags.static import static as _static
    return _static(path)
예제 #7
0
def static(path):
    global _static
    if _static is None:
        if apps.is_installed('django-contrib.staticfiles'):
            from django.contrib.staticfiles.templatetags.staticfiles import static as _static
        else:
            from django.templatetags.static import static as _static
    if django.VERSION >= (1, 9) and path == 'admin/img/icon-unknown.gif':
        path = 'admin/img/icon-unknown.svg'
    return _static(path)
예제 #8
0
def tag_babeljs(context, version=settings.VERSION, minified=MINIFIED):
    return mark_safe("""<script type="text/javascript" src="{babel}"></script>""".format(
        babel=_static(iri_to_uri(
            "babeljs/{script}-{version}{minified}.js".format(
                script="browser",
                version=version,
                minified=minified,
            )
        )),
    ))
예제 #9
0
 def static(path):
     sp = _static(path)
     if not settings.MEDIA_URL.startswith("/") and sp.startswith("/"):
         domain = get_domain(object.organizer if isinstance(object, Event) else object)
         if domain:
             siteurlsplit = urlsplit(settings.SITE_URL)
             if siteurlsplit.port and siteurlsplit.port not in (80, 443):
                 domain = '%s:%d' % (domain, siteurlsplit.port)
             sp = urljoin('%s://%s' % (siteurlsplit.scheme, domain), sp)
         else:
             sp = urljoin(settings.SITE_URL, sp)
     return '"{}"'.format(sp)
예제 #10
0
 def static(path):
     sp = _static(path)
     if not settings.MEDIA_URL.startswith("/") and sp.startswith("/"):
         domain = get_domain(object.organizer if isinstance(object, Event) else object)
         if domain:
             siteurlsplit = urlsplit(settings.SITE_URL)
             if siteurlsplit.port and siteurlsplit.port not in (80, 443):
                 domain = '%s:%d' % (domain, siteurlsplit.port)
             sp = urljoin('%s://%s' % (siteurlsplit.scheme, domain), sp)
         else:
             sp = urljoin(settings.SITE_URL, sp)
     return '"{}"'.format(sp)
예제 #11
0
def static(path, site_id=None):
    url = _static(path)

    if url.startswith("http"):
        return url

    if site_id is None:
        site = base.get_current()
    else:
        site = base.get_by_id(site_id)

    return get_absolute_url_for_site(url, site)
예제 #12
0
def static(path):
    warnings.warn(
        '{% load admin_static %} is deprecated in favor of {% load static %}.',
        RemovedInDjango30Warning,
    )
    return _static(path)
예제 #13
0
def static(path):
    # Backwards compatibility alias for django.templatetags.static.static().
    # Deprecation should start in Django 2.0.
    return _static(path)
예제 #14
0
def static(path):
    return _static(path)
예제 #15
0
파일: staticfiles.py 프로젝트: nbsky/django
def static(path):
    # Backwards compatibility alias for django.templatetags.static.static().
    # Deprecation should start in Django 2.0.
    return _static(path)
예제 #16
0
def _get_default_avatar_image(request, query, is_secure=False):
    if settings.DEFAULT_IMAGE:
        query["d"] = request.build_absolute_uri(_static(
            settings.DEFAULT_IMAGE))