Ejemplo n.º 1
0
def experimental_editor_tag(bundle_name):
    # somewhat hacky code to handle the experimental editor
    if not settings.STATIC_MEDIA_USES_S3:
        raise AssertionError("Can't use the experimental editor "
                             "without STATIC_MEDIA_USES_S3 set")
    if bundle_name == 'editor.js':
        url = "{}experimental/js/editor.js".format(utils.static_url())
        return format_html('<script src="{}"></script>', url)
    elif bundle_name == 'editor.css':
        url = "{}experimental/css/editor.css".format(utils.static_url())
        return '<link href="{}" rel="stylesheet" type="text/css" />'.format(
            url)
    else:
        raise ValueError("Unkown bundle name: {}").format(bundle_name)
Ejemplo n.º 2
0
def js_i18n_catalog(context):
    if settings.STATIC_MEDIA_USES_S3:
        locale = to_locale(context['LANGUAGE_CODE'])
        src = utils.static_url() + 'jsi18catalog/{}.js'.format(locale)
    else:
        src = reverse('staticmedia:js_i18n_catalog')
    return '<script type="text/javascript" src="{}"></script>'.format(src)
Ejemplo n.º 3
0
def js_language_data(context):
    locale = to_locale(context['LANGUAGE_CODE'])
    if settings.STATIC_MEDIA_USES_S3:
        src = utils.static_url() + 'jslanguagedata/{}.js'.format(locale)
    else:
        src = reverse('staticmedia:js_language_data', args=(locale, ))
    return '<script type="text/javascript" src="{}"></script>'.format(src)
Ejemplo n.º 4
0
def staticmedia(request):
    """Add media-related context variables to the context."""
    return {
        'MEDIA_URL': settings.MEDIA_URL,
        'STATIC_URL': utils.static_url(),
        'LOGO_URL': settings.LOGO_URL,
        'PCF_LOGO_URL': settings.PCF_LOGO_URL,
    }
Ejemplo n.º 5
0
def language_list(video):
    video.prefetch_languages(with_public_tips=True, with_private_tips=True)
    return render_to_string(
        'videos/_language-list.html', {
            'video': video,
            'language_list': LanguageList(video),
            'STATIC_URL': utils.static_url(),
        })
Ejemplo n.º 6
0
def js_code():
    """Build the JS for the old embed.js file """
    bundle = bundles.get_bundle('unisubs-offsite-compiled.js')
    context = {
        'current_site': Site.objects.get_current(),
        'STATIC_URL': utils.static_url(),
        "js_file": bundle.get_url(),
    }
    return render_to_string('widget/embed.js', context)
Ejemplo n.º 7
0
def language_list(video):
    cached = video.cache.get('language-list')
    if cached is not None:
        return cached
    video.prefetch_languages(with_public_tips=True, with_private_tips=True)
    content = render_to_string(
        'videos/_language-list.html', {
            'video': video,
            'language_list': LanguageList(video),
            'STATIC_URL': utils.static_url(),
        })
    video.cache.set('language-list', content)
    return content
Ejemplo n.º 8
0
def static_url():
    return utils.static_url()
Ejemplo n.º 9
0
 def get_s3_url(self):
     return "%s%s/%s" % (utils.static_url(), self.bundle_type, self.name)
Ejemplo n.º 10
0
 def generate_amara_conf(self):
     return render_to_string('staticmedia/amara-conf.js', {
         'base_url': settings.HOSTNAME,
         'static_url': utils.static_url(),
     })
Ejemplo n.º 11
0
 def generate_amara_conf(self):
     return render_to_string(
         'staticmedia/amara-conf.js', {
             'base_url': Site.objects.get_current().domain,
             'static_url': utils.static_url(),
         })
Ejemplo n.º 12
0
def static(path):
    return utils.static_url() + path
Ejemplo n.º 13
0
 def ready(self):
     settings.STATIC_URL = utils.static_url()
Ejemplo n.º 14
0
# Amara, universalsubtitles.org
#
# Copyright (C) 2014 Participatory Culture Foundation
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see
# http://www.gnu.org/licenses/agpl-3.0.html.

from django.conf import settings

from staticmedia import utils

settings.STATIC_URL = utils.static_url()