예제 #1
0
def media_files(request):
    media = Media()
    media.add_css({
        'all': (
            'libs/yaml/base.css',
            'libs/jquery-ui/jquery-ui.css',
            'libs/crispy-forms/uni-form.css',
            'libs/crispy-forms/default.uni-form.css',
            'libs/chosen/chosen.css',
            'libs/tipsy/tipsy.css',
            'libs/jTour/jquery-jtour-2.0.2.css',

            'css/hlist.css',
            'css/tabs.css',
            'css/gray-theme.css',
            'css/typography.css',
            'css/deco.css',
            'css/style.css',
        ),
    })

    if settings.DEBUG:
        js = (
            'libs/jquery.js',
            'libs/jquery-ui/jquery-ui.js',
            'libs/openapi.js',
        )
    else:
        js = (
            'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js',
            'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js',
            'http://userapi.com/js/api/openapi.js?49', # VKontakte
        )

    js += (
        'libs/underscore.js',
        'libs/json2.js',
        'libs/backbone.js',
        'libs/chosen/chosen.jquery.min.js',
        'libs/jquery.placeholder.min.js',
        'libs/jquery.autosize.js',
        reverse('code_data') if settings.DEBUG else 'js/code_data.js',
        'js/main.js',
        'js/resources.js',
        'js/resources_form.js',
        'js/comments.js',
        'js/locations.js',
    )
    media.add_js(js)

    bottom_media = Media()
    bottom_media.add_js((
        'libs/tipsy/jquery.tipsy.js',
        'libs/mustache.js',
        'libs/crispy-forms/uni-form.jquery.js', # TODO: currently doesn't work
        'libs/jTour/jquery-jtour-2.0.2.min.js',
        'js/tour.js',
    ))

    return {'media_files': media, 'bottom_media_files': bottom_media}
def grakon_media(request):
    media = Media()
    media.add_css({
        'all': (
            'libs/yaml/base.css',
            'css/hlist.css',
            'libs/jquery-ui/jquery-ui.css',
            'css/layout.css',
            'css/typography.css',
            'css/style.css',
            'libs/tipsy/tipsy.css',
            'css/julia_style.css',
        ),
    })

    if settings.DEBUG:
        js = ('libs/jquery.js', 'libs/jquery-ui/jquery-ui.js')
    else:
        js = ('https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js',
                'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js')

    js += (
        'libs/underscore.js',
        'libs/tipsy/jquery.tipsy.js',
        'libs/backbone.js',
        'http://userapi.com/js/api/openapi.js?47', # VKontakte
        'http://loginza.ru/js/widget.js',
        'js/main.js',
    )
    media.add_js(js)
    return {'grakon_media': media}
예제 #3
0
 def _get_common_media(self):
     config = getattr(settings, 'ARCTIC_COMMON_MEDIA_ASSETS', [])
     media = Media()
     if 'css' in config:
         media.add_css(config['css'])
     if 'js' in config:
         media.add_js(config['js'])
     return media
예제 #4
0
def media_files(request):
    media = Media()
    media.add_css(
        {
            "all": (
                "libs/yaml/base.css",
                "libs/jquery-ui/jquery-ui.css",
                "libs/crispy-forms/uni-form.css",
                "libs/crispy-forms/default.uni-form.css",
                "libs/chosen/chosen.css",
                "libs/tipsy/tipsy.css",
                "css/hlist.css",
                "css/layout.css",
                "css/typography.css",
                "css/style.css",
                "css/julia_style.css",
            )
        }
    )

    if settings.DEBUG:
        js = ("libs/jquery.js", "libs/jquery-ui/jquery-ui.js", "libs/openapi.js")
    else:
        js = (
            "https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js",
            "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js",
            "http://userapi.com/js/api/openapi.js?49",  # VKontakte
        )

    js += (
        "libs/underscore.js",
        "libs/tipsy/jquery.tipsy.js",
        "libs/json2.js",
        "libs/backbone.js",
        "libs/chosen/chosen.jquery.min.js",
        "libs/jquery.placeholder.min.js",
        "libs/jquery.autosize.js",
        reverse("code_data") if settings.DEBUG else "js/code_data.js",
        "js/main.js",
        "js/comments.js",
        "js/locations.js",
    )
    media.add_js(js)

    bottom_media = Media()
    bottom_media.add_js(
        (
            "libs/tipsy/jquery.tipsy.js",
            "libs/mustache.js",
            "libs/crispy-forms/uni-form.jquery.js",  # TODO: currently doesn't work
            #'libs/jTour/jquery-jtour-2.0.2.min.js',
            #'js/tour.js',
        )
    )

    return {"media_files": media, "bottom_media_files": bottom_media}
def uni_form_media(request):
    media = Media()
    media.add_css({
        'all': (
            'libs/uni-form/uni-form.css',
            'libs/uni-form/default.uni-form.css'
        )
    })
    media.add_js((
        'libs/uni-form/uni-form.jquery.js',
    ))
    return {'uni_form_media': media}
예제 #6
0
 def _get_view_media(self):
     """
     Gather view-level media assets
     """
     media = Media()
     try:
         media.add_css(self.Media.css)
     except AttributeError:
         pass
     try:
         media.add_js(self.Media.js)
     except AttributeError:
         pass
     return media
예제 #7
0
    def test_media_monkey_patch(self):
        media = Media()
        media.add_js((
            '/admin/test1.js',
            'admin/test2.js',
            'http://example.com/admin/test3.js',
            '//example.com/admin/test3.js'
        ))
        media.add_css({
            'all': (
                '/admin/test1.css',
                'admin/test2.css',
                'http://example.com/admin/test2.css',
                '//example.com/admin/test2.css'
            )
        })

        no_monkey = """
<link href="/admin/test1.css" type="text/css" media="all" rel="stylesheet" />
<link href="/static/admin/test2.css" type="text/css" media="all" rel="stylesheet" />
<link href="http://example.com/admin/test2.css" type="text/css" media="all" rel="stylesheet" />
<link href="//example.com/admin/test2.css" type="text/css" media="all" rel="stylesheet" />
<script type="text/javascript" src="/admin/test1.js"></script>
<script type="text/javascript" src="/static/admin/test2.js"></script>
<script type="text/javascript" src="http://example.com/admin/test3.js"></script>
<script type="text/javascript" src="//example.com/admin/test3.js"></script>
        """.strip()
        monkey = """
<link href="/admin/test1.css" type="text/css" media="all" rel="stylesheet" />
<link href="http://this.com/static/admin/test2.css" type="text/css" media="all" rel="stylesheet" />
<link href="http://example.com/admin/test2.css" type="text/css" media="all" rel="stylesheet" />
<link href="//example.com/admin/test2.css" type="text/css" media="all" rel="stylesheet" />
<script type="text/javascript" src="/admin/test1.js"></script>
<script type="text/javascript" src="http://this.com/static/admin/test2.js"></script>
<script type="text/javascript" src="http://example.com/admin/test3.js"></script>
<script type="text/javascript" src="//example.com/admin/test3.js"></script>
        """.strip()

        with self.settings(STATIC_URL='/static/'):
            self.assertEqual(media.render(), no_monkey)

        with self.settings(
            STATIC_URL=CloudFrontURLs('http://notthis.com/', patterns={
                '^admin': 'http://this.com/static/'
            })
        ):
            self.assertEqual(media.render(), monkey)
예제 #8
0
    def test_media_monkey_patch(self):
        media = Media()
        media.add_js((
            '/admin/test1.js',
            'admin/test2.js',
            'http://example.com/admin/test3.js',
            '//example.com/admin/test3.js'
        ))
        media.add_css({
            'all': (
                '/admin/test1.css',
                'admin/test2.css',
                'http://example.com/admin/test2.css',
                '//example.com/admin/test2.css'
            )
        })

        no_monkey = """
<link href="/admin/test1.css" type="text/css" media="all" rel="stylesheet" />
<link href="/static/admin/test2.css" type="text/css" media="all" rel="stylesheet" />
<link href="http://example.com/admin/test2.css" type="text/css" media="all" rel="stylesheet" />
<link href="//example.com/admin/test2.css" type="text/css" media="all" rel="stylesheet" />
<script type="text/javascript" src="/admin/test1.js"></script>
<script type="text/javascript" src="/static/admin/test2.js"></script>
<script type="text/javascript" src="http://example.com/admin/test3.js"></script>
<script type="text/javascript" src="//example.com/admin/test3.js"></script>
        """.strip()
        monkey = """
<link href="/admin/test1.css" type="text/css" media="all" rel="stylesheet" />
<link href="http://this.com/static/admin/test2.css" type="text/css" media="all" rel="stylesheet" />
<link href="http://example.com/admin/test2.css" type="text/css" media="all" rel="stylesheet" />
<link href="//example.com/admin/test2.css" type="text/css" media="all" rel="stylesheet" />
<script type="text/javascript" src="/admin/test1.js"></script>
<script type="text/javascript" src="http://this.com/static/admin/test2.js"></script>
<script type="text/javascript" src="http://example.com/admin/test3.js"></script>
<script type="text/javascript" src="//example.com/admin/test3.js"></script>
        """.strip()

        with self.settings(STATIC_URL='/static/'):
            self.assertEqual(media.render(), no_monkey)

        with self.settings(
            STATIC_URL=CloudFrontURLs('http://notthis.com/', patterns={
                '^admin': 'http://this.com/static/'
            })
        ):
            self.assertEqual(media.render(), monkey)
예제 #9
0
 def media(self):
     """
     Return all media required to render this view, including forms.
     """
     media = Media()
     try:
         media.add_css(self.Media.css)
     except AttributeError:
         pass
     try:
         media.add_js(self.Media.js)
     except AttributeError:
         pass
     forms = self._forms()
     for form in forms:
         media = media + getattr(self, form)().media
     return media
예제 #10
0
    def media(self):

        if not USE_BOOTSTRAP_ACE:
            media_obj = super(SmartSnippetPlugin, self).media
        else:
            media_obj = WidgetsMedia(
                js=((
                    static('admin/js/core.js'),
                    static('admin/js/admin/RelatedObjectLookups.js'),
                    static('libs/jquery-2.1.1.min.js'),
                    static('libs/bootstrap/js/bootstrap.min.js'),
                    static('admin/js/custom.js'),
                )),
                css={
                    'all': (
                        '//fonts.googleapis.com/css?family=Open+Sans:400,300',
                        static('libs/bootstrap/css/bootstrap.css'),
                        static('libs/ace/css/ace.min.css'),
                        static('admin/css/custom.css'),
                    )
                })

        media_obj.add_js(
            (reverse('admin:jsi18n'), static('admin/js/SmartSnippetLib.js'),
             static('admin/js/jquery.init.js'),
             static('admin/js/default.jQuery.init.js')))

        if not USE_BOOTSTRAP_ACE:
            media_obj.add_css({
                'all': (
                    static('admin/css/forms.css'),
                    static('admin/css/base.css'),
                    static('css/tipTip.css'),
                    static('admin/css/snippet_plugin_default.css'),
                )
            })
            media_obj.add_js((
                static('js/jquery.tipTip.minified.js'),
                static('admin/js/snippet_plugin_default.js'),
            ))
        return media_obj
예제 #11
0
    def media(self):

        if not USE_BOOTSTRAP_ACE:
            media_obj = super(SmartSnippetPlugin, self).media
        else:
            media_obj = WidgetsMedia(
                js=((
                    static('admin/js/core.js'),
                    static('admin/js/admin/RelatedObjectLookups.js'),
                    static('libs/jquery-2.1.1.min.js'),
                    static('libs/bootstrap/js/bootstrap.min.js'),
                    static('admin/js/custom.js'), )
                ),
                css={
                    'all': (
                        '//fonts.googleapis.com/css?family=Open+Sans:400,300',
                        static('libs/bootstrap/css/bootstrap.css'),
                        static('libs/ace/css/ace.min.css'),
                        static('admin/css/custom.css'), )
                    }
            )

        media_obj.add_js(
            (reverse('admin:jsi18n'),
             static('admin/js/SmartSnippetLib.js'),
             static('admin/js/jquery.init.js'),
             static('admin/js/default.jQuery.init.js')))

        if not USE_BOOTSTRAP_ACE:
            media_obj.add_css({
                'all': (
                    static('admin/css/forms.css'),
                    static('admin/css/base.css'),
                    static('css/tipTip.css'),
                    static('admin/css/snippet_plugin_default.css'), )
            })
            media_obj.add_js((
                static('js/jquery.tipTip.minified.js'),
                static('admin/js/snippet_plugin_default.js'), )
            )
        return media_obj