Fixed #31080 -- Removed redundant type="text/javascript" attribute from <script> tags.

This commit is contained in:
Jon Dufresne 2019-12-11 00:49:54 -08:00 committed by Carlton Gibson
parent d8e2333528
commit e703b93a65
24 changed files with 137 additions and 141 deletions

View File

@ -3,7 +3,7 @@
{% load admin_urls %} {% load admin_urls %}
{% block extrahead %}{{ block.super }} {% block extrahead %}{{ block.super }}
<script type="text/javascript" src="{% url 'admin:jsi18n' %}"></script> <script src="{% url 'admin:jsi18n' %}"></script>
{% endblock %} {% endblock %}
{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}">{% endblock %} {% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}">{% endblock %}
{% block bodyclass %}{{ block.super }} {{ opts.app_label }}-{{ opts.model_name }} change-form{% endblock %} {% block bodyclass %}{{ block.super }} {{ opts.app_label }}-{{ opts.model_name }} change-form{% endblock %}

View File

@ -2,7 +2,7 @@
{% load i18n admin_urls static admin_modify %} {% load i18n admin_urls static admin_modify %}
{% block extrahead %}{{ block.super }} {% block extrahead %}{{ block.super }}
<script type="text/javascript" src="{% url 'admin:jsi18n' %}"></script> <script src="{% url 'admin:jsi18n' %}"></script>
{{ media }} {{ media }}
{% endblock %} {% endblock %}
@ -64,8 +64,7 @@
{% block submit_buttons_bottom %}{% submit_row %}{% endblock %} {% block submit_buttons_bottom %}{% submit_row %}{% endblock %}
{% block admin_change_form_document_ready %} {% block admin_change_form_document_ready %}
<script type="text/javascript" <script id="django-admin-form-add-constants"
id="django-admin-form-add-constants"
src="{% static 'admin/js/change_form.js' %}" src="{% static 'admin/js/change_form.js' %}"
{% if adminform and add %} {% if adminform and add %}
data-model-name="{{ opts.model_name }}" data-model-name="{{ opts.model_name }}"

View File

@ -8,7 +8,7 @@
<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}"> <link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}">
{% endif %} {% endif %}
{% if cl.formset or action_form %} {% if cl.formset or action_form %}
<script type="text/javascript" src="{% url 'admin:jsi18n' %}"></script> <script src="{% url 'admin:jsi18n' %}"></script>
{% endif %} {% endif %}
{{ media.css }} {{ media.css }}
{% if not actions_on_top and not actions_on_bottom %} {% if not actions_on_top and not actions_on_bottom %}

View File

@ -4,7 +4,7 @@
{% block extrahead %} {% block extrahead %}
{{ block.super }} {{ block.super }}
{{ media }} {{ media }}
<script type="text/javascript" src="{% static 'admin/js/cancel.js' %}"></script> <script src="{% static 'admin/js/cancel.js' %}"></script>
{% endblock %} {% endblock %}
{% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} delete-confirmation{% endblock %} {% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} delete-confirmation{% endblock %}

View File

@ -4,7 +4,7 @@
{% block extrahead %} {% block extrahead %}
{{ block.super }} {{ block.super }}
{{ media }} {{ media }}
<script type="text/javascript" src="{% static 'admin/js/cancel.js' %}"></script> <script src="{% static 'admin/js/cancel.js' %}"></script>
{% endblock %} {% endblock %}
{% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} delete-confirmation delete-selected-confirmation{% endblock %} {% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} delete-confirmation delete-selected-confirmation{% endblock %}

View File

@ -2,8 +2,7 @@
<html> <html>
<head><title>{% trans 'Popup closing…' %}</title></head> <head><title>{% trans 'Popup closing…' %}</title></head>
<body> <body>
<script type="text/javascript" <script id="django-admin-popup-response-constants"
id="django-admin-popup-response-constants"
src="{% static "admin/js/popup_response.js" %}" src="{% static "admin/js/popup_response.js" %}"
data-popup-response="{{ popup_response_data }}"> data-popup-response="{{ popup_response_data }}">
</script> </script>

View File

@ -1,6 +1,5 @@
{% load l10n static %} {% load l10n static %}
<script type="text/javascript" <script id="django-admin-prepopulated-fields-constants"
id="django-admin-prepopulated-fields-constants"
src="{% static "admin/js/prepopulate_init.js" %}" src="{% static "admin/js/prepopulate_init.js" %}"
data-prepopulated-fields="{{ prepopulated_fields_json }}"> data-prepopulated-fields="{{ prepopulated_fields_json }}">
</script> </script>

View File

@ -25,7 +25,7 @@
<![endif]--> <![endif]-->
{% endblock %} {% endblock %}
<span id="{{ id }}_admin_map"> <span id="{{ id }}_admin_map">
<script type="text/javascript"> <script>
//<![CDATA[ //<![CDATA[
{% block openlayers %}{% include "gis/admin/openlayers.js" %}{% endblock %} {% block openlayers %}{% include "gis/admin/openlayers.js" %}{% endblock %}
//]]> //]]>
@ -36,5 +36,5 @@
{% endif %} {% endif %}
{% if display_wkt %}<p>{% trans "WKT debugging window:" %} </p>{% endif %} {% if display_wkt %}<p>{% trans "WKT debugging window:" %} </p>{% endif %}
<textarea id="{{ id }}" class="vWKTField required" cols="150" rows="10" name="{{ name }}">{{ wkt }}</textarea> <textarea id="{{ id }}" class="vWKTField required" cols="150" rows="10" name="{{ name }}">{{ wkt }}</textarea>
<script type="text/javascript">{% block init_function %}{{ module }}.init();{% endblock %}</script> <script>{% block init_function %}{{ module }}.init();{% endblock %}</script>
</span> </span>

View File

@ -12,7 +12,7 @@
{% if not disabled %}<span class="clear_features"><a href="javascript:{{ module }}.clearFeatures()">{% trans "Delete all Features" %}</a></span>{% endif %} {% if not disabled %}<span class="clear_features"><a href="javascript:{{ module }}.clearFeatures()">{% trans "Delete all Features" %}</a></span>{% endif %}
{% if display_raw %}<p>{% trans "Debugging window (serialized value)" %}</p>{% endif %} {% if display_raw %}<p>{% trans "Debugging window (serialized value)" %}</p>{% endif %}
<textarea id="{{ id }}" class="vSerializedField required" cols="150" rows="10" name="{{ name }}">{{ serialized }}</textarea> <textarea id="{{ id }}" class="vSerializedField required" cols="150" rows="10" name="{{ name }}">{{ serialized }}</textarea>
<script type="text/javascript"> <script>
{% block map_options %}var map_options = {};{% endblock %} {% block map_options %}var map_options = {};{% endblock %}
{% block base_layer %} {% block base_layer %}
var base_layer = new ol.layer.Tile({ var base_layer = new ol.layer.Tile({

View File

@ -80,7 +80,7 @@ class Media:
def render_js(self): def render_js(self):
return [ return [
format_html( format_html(
'<script type="text/javascript" src="{}"></script>', '<script src="{}"></script>',
self.absolute_path(path) self.absolute_path(path)
) for path in self._js ) for path in self._js
] ]

View File

@ -63,7 +63,7 @@
.append-bottom { margin-bottom: 10px; } .append-bottom { margin-bottom: 10px; }
</style> </style>
{% if not is_email %} {% if not is_email %}
<script type="text/javascript"> <script>
function hideAll(elems) { function hideAll(elems) {
for (var e = 0; e < elems.length; e++) { for (var e = 0; e < elems.length; e++) {
elems[e].style.display = 'none'; elems[e].style.display = 'none';

View File

@ -21,8 +21,8 @@
{# as it causes problems in compiled CHM files. #} {# as it causes problems in compiled CHM files. #}
{% if builder != "htmlhelp" %} {% if builder != "htmlhelp" %}
{{ super() }} {{ super() }}
<script type="text/javascript" src="{{ pathto('templatebuiltins.js', 1) }}"></script> <script src="{{ pathto('templatebuiltins.js', 1) }}"></script>
<script type="text/javascript"> <script>
(function($) { (function($) {
if (!django_template_builtins) { if (!django_template_builtins) {
// templatebuiltins.js missing, do nothing. // templatebuiltins.js missing, do nothing.

View File

@ -28,7 +28,7 @@ In your custom ``change_form.html`` template, extend the
{% block admin_change_form_document_ready %} {% block admin_change_form_document_ready %}
{{ block.super }} {{ block.super }}
<script type="text/javascript" src="{% static 'app/formset_handlers.js' %}"></script> <script src="{% static 'app/formset_handlers.js' %}"></script>
{% endblock %} {% endblock %}
.. code-block:: javascript .. code-block:: javascript
@ -66,7 +66,7 @@ listen to the event triggered from there. For example:
{% block admin_change_form_document_ready %} {% block admin_change_form_document_ready %}
{{ block.super }} {{ block.super }}
<script type="text/javascript" src="{% static 'app/unregistered_handlers.js' %}"></script> <script src="{% static 'app/unregistered_handlers.js' %}"></script>
{% endblock %} {% endblock %}
.. code-block:: javascript .. code-block:: javascript

View File

@ -136,7 +136,7 @@ and read the token from the DOM with JavaScript:
.. code-block:: html+django .. code-block:: html+django
{% csrf_token %} {% csrf_token %}
<script type="text/javascript"> <script>
// using jQuery // using jQuery
var csrftoken = jQuery("[name=csrfmiddlewaretoken]").val(); var csrftoken = jQuery("[name=csrfmiddlewaretoken]").val();
</script> </script>

View File

@ -72,8 +72,8 @@ can be retrieved through this property::
>>> w = CalendarWidget() >>> w = CalendarWidget()
>>> print(w.media) >>> print(w.media)
<link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet"> <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="http://static.example.com/animations.js"></script> <script src="http://static.example.com/animations.js"></script>
<script type="text/javascript" src="http://static.example.com/actions.js"></script> <script src="http://static.example.com/actions.js"></script>
Here's a list of all possible ``Media`` options. There are no required options. Here's a list of all possible ``Media`` options. There are no required options.
@ -147,9 +147,9 @@ example above::
>>> print(w.media) >>> print(w.media)
<link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet"> <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet">
<link href="http://static.example.com/fancy.css" type="text/css" media="all" rel="stylesheet"> <link href="http://static.example.com/fancy.css" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="http://static.example.com/animations.js"></script> <script src="http://static.example.com/animations.js"></script>
<script type="text/javascript" src="http://static.example.com/actions.js"></script> <script src="http://static.example.com/actions.js"></script>
<script type="text/javascript" src="http://static.example.com/whizbang.js"></script> <script src="http://static.example.com/whizbang.js"></script>
The FancyCalendar widget inherits all the assets from its parent The FancyCalendar widget inherits all the assets from its parent
widget. If you don't want ``Media`` to be inherited in this way, add widget. If you don't want ``Media`` to be inherited in this way, add
@ -166,7 +166,7 @@ an ``extend=False`` declaration to the ``Media`` declaration::
>>> w = FancyCalendarWidget() >>> w = FancyCalendarWidget()
>>> print(w.media) >>> print(w.media)
<link href="http://static.example.com/fancy.css" type="text/css" media="all" rel="stylesheet"> <link href="http://static.example.com/fancy.css" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="http://static.example.com/whizbang.js"></script> <script src="http://static.example.com/whizbang.js"></script>
If you require even more control over inheritance, define your assets using a If you require even more control over inheritance, define your assets using a
:ref:`dynamic property <dynamic-property>`. Dynamic properties give you :ref:`dynamic property <dynamic-property>`. Dynamic properties give you
@ -229,16 +229,16 @@ was ``None``::
>>> w = CalendarWidget() >>> w = CalendarWidget()
>>> print(w.media) >>> print(w.media)
<link href="/css/pretty.css" type="text/css" media="all" rel="stylesheet"> <link href="/css/pretty.css" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="http://uploads.example.com/animations.js"></script> <script src="http://uploads.example.com/animations.js"></script>
<script type="text/javascript" src="http://othersite.com/actions.js"></script> <script src="http://othersite.com/actions.js"></script>
But if :setting:`STATIC_URL` is ``'http://static.example.com/'``:: But if :setting:`STATIC_URL` is ``'http://static.example.com/'``::
>>> w = CalendarWidget() >>> w = CalendarWidget()
>>> print(w.media) >>> print(w.media)
<link href="/css/pretty.css" type="text/css" media="all" rel="stylesheet"> <link href="/css/pretty.css" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="http://static.example.com/animations.js"></script> <script src="http://static.example.com/animations.js"></script>
<script type="text/javascript" src="http://othersite.com/actions.js"></script> <script src="http://othersite.com/actions.js"></script>
Or if :mod:`~django.contrib.staticfiles` is configured using the Or if :mod:`~django.contrib.staticfiles` is configured using the
:class:`~django.contrib.staticfiles.storage.ManifestStaticFilesStorage`:: :class:`~django.contrib.staticfiles.storage.ManifestStaticFilesStorage`::
@ -246,8 +246,8 @@ Or if :mod:`~django.contrib.staticfiles` is configured using the
>>> w = CalendarWidget() >>> w = CalendarWidget()
>>> print(w.media) >>> print(w.media)
<link href="/css/pretty.css" type="text/css" media="all" rel="stylesheet"> <link href="/css/pretty.css" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="https://static.example.com/animations.27e20196a850.js"></script> <script src="https://static.example.com/animations.27e20196a850.js"></script>
<script type="text/javascript" src="http://othersite.com/actions.js"></script> <script src="http://othersite.com/actions.js"></script>
``Media`` objects ``Media`` objects
================= =================
@ -269,8 +269,8 @@ operator to filter out a medium of interest. For example::
>>> w = CalendarWidget() >>> w = CalendarWidget()
>>> print(w.media) >>> print(w.media)
<link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet"> <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="http://static.example.com/animations.js"></script> <script src="http://static.example.com/animations.js"></script>
<script type="text/javascript" src="http://static.example.com/actions.js"></script> <script src="http://static.example.com/actions.js"></script>
>>> print(w.media['css']) >>> print(w.media['css'])
<link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet"> <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet">
@ -301,9 +301,9 @@ specified by both::
>>> w2 = OtherWidget() >>> w2 = OtherWidget()
>>> print(w1.media + w2.media) >>> print(w1.media + w2.media)
<link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet"> <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="http://static.example.com/animations.js"></script> <script src="http://static.example.com/animations.js"></script>
<script type="text/javascript" src="http://static.example.com/actions.js"></script> <script src="http://static.example.com/actions.js"></script>
<script type="text/javascript" src="http://static.example.com/whizbang.js"></script> <script src="http://static.example.com/whizbang.js"></script>
.. _form-media-asset-order: .. _form-media-asset-order:
@ -327,10 +327,10 @@ For example::
>>> w1 = CalendarWidget() >>> w1 = CalendarWidget()
>>> w2 = TimeWidget() >>> w2 = TimeWidget()
>>> print(w1.media + w2.media) >>> print(w1.media + w2.media)
<script type="text/javascript" src="http://static.example.com/jQuery.js"></script> <script src="http://static.example.com/jQuery.js"></script>
<script type="text/javascript" src="http://static.example.com/calendar.js"></script> <script src="http://static.example.com/calendar.js"></script>
<script type="text/javascript" src="http://static.example.com/time.js"></script> <script src="http://static.example.com/time.js"></script>
<script type="text/javascript" src="http://static.example.com/noConflict.js"></script> <script src="http://static.example.com/noConflict.js"></script>
Combining ``Media`` objects with assets in a conflicting order results in a Combining ``Media`` objects with assets in a conflicting order results in a
``MediaOrderConflictWarning``. ``MediaOrderConflictWarning``.
@ -357,9 +357,9 @@ are part of the form::
>>> f = ContactForm() >>> f = ContactForm()
>>> f.media >>> f.media
<link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet"> <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="http://static.example.com/animations.js"></script> <script src="http://static.example.com/animations.js"></script>
<script type="text/javascript" src="http://static.example.com/actions.js"></script> <script src="http://static.example.com/actions.js"></script>
<script type="text/javascript" src="http://static.example.com/whizbang.js"></script> <script src="http://static.example.com/whizbang.js"></script>
If you want to associate additional assets with a form -- for example, If you want to associate additional assets with a form -- for example,
CSS for form layout -- add a ``Media`` declaration to the form:: CSS for form layout -- add a ``Media`` declaration to the form::
@ -377,6 +377,6 @@ CSS for form layout -- add a ``Media`` declaration to the form::
>>> f.media >>> f.media
<link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet"> <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet">
<link href="http://static.example.com/layout.css" type="text/css" media="all" rel="stylesheet"> <link href="http://static.example.com/layout.css" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="http://static.example.com/animations.js"></script> <script src="http://static.example.com/animations.js"></script>
<script type="text/javascript" src="http://static.example.com/actions.js"></script> <script src="http://static.example.com/actions.js"></script>
<script type="text/javascript" src="http://static.example.com/whizbang.js"></script> <script src="http://static.example.com/whizbang.js"></script>

View File

@ -1052,7 +1052,7 @@ To use the catalog, pull in the dynamically generated script like this:
.. code-block:: html+django .. code-block:: html+django
<script type="text/javascript" src="{% url 'javascript-catalog' %}"></script> <script src="{% url 'javascript-catalog' %}"></script>
This uses reverse URL lookup to find the URL of the JavaScript catalog view. This uses reverse URL lookup to find the URL of the JavaScript catalog view.
When the catalog is loaded, your JavaScript code can use the following methods: When the catalog is loaded, your JavaScript code can use the following methods:

View File

@ -1,6 +1,5 @@
{% load l10n static %} {% load l10n static %}
<script type="text/javascript" <script id="django-admin-prepopulated-fields-constants"
id="django-admin-prepopulated-fields-constants"
class="override-prepopulated_fields_js" class="override-prepopulated_fields_js"
src="{% static "admin/js/prepopulate_init.js" %}" src="{% static "admin/js/prepopulate_init.js" %}"
data-prepopulated-fields="{{ prepopulated_fields_json }}"> data-prepopulated-fields="{{ prepopulated_fields_json }}">

View File

@ -19,9 +19,9 @@ class FormsMediaTestCase(SimpleTestCase):
str(m), str(m),
"""<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet"> """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet"> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="/path/to/js1"></script> <script src="/path/to/js1"></script>
<script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script src="http://media.other.com/path/to/js2"></script>
<script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""" <script src="https://secure.other.com/path/to/js3"></script>"""
) )
self.assertEqual( self.assertEqual(
repr(m), repr(m),
@ -40,9 +40,9 @@ class FormsMediaTestCase(SimpleTestCase):
str(m3), str(m3),
"""<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet"> """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet"> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="/path/to/js1"></script> <script src="/path/to/js1"></script>
<script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script src="http://media.other.com/path/to/js2"></script>
<script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""" <script src="https://secure.other.com/path/to/js3"></script>"""
) )
# A widget can exist without a media definition # A widget can exist without a media definition
@ -72,9 +72,9 @@ class FormsMediaTestCase(SimpleTestCase):
str(w1.media), str(w1.media),
"""<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet"> """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet"> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="/path/to/js1"></script> <script src="/path/to/js1"></script>
<script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script src="http://media.other.com/path/to/js2"></script>
<script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""" <script src="https://secure.other.com/path/to/js3"></script>"""
) )
# Media objects can be interrogated by media type # Media objects can be interrogated by media type
@ -86,9 +86,9 @@ class FormsMediaTestCase(SimpleTestCase):
self.assertEqual( self.assertEqual(
str(w1.media['js']), str(w1.media['js']),
"""<script type="text/javascript" src="/path/to/js1"></script> """<script src="/path/to/js1"></script>
<script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script src="http://media.other.com/path/to/js2"></script>
<script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""" <script src="https://secure.other.com/path/to/js3"></script>"""
) )
def test_combine_media(self): def test_combine_media(self):
@ -123,10 +123,10 @@ class FormsMediaTestCase(SimpleTestCase):
"""<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet"> """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet"> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet"> <link href="/path/to/css3" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="/path/to/js1"></script> <script src="/path/to/js1"></script>
<script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script src="http://media.other.com/path/to/js2"></script>
<script type="text/javascript" src="/path/to/js4"></script> <script src="/path/to/js4"></script>
<script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""" <script src="https://secure.other.com/path/to/js3"></script>"""
) )
# media addition hasn't affected the original objects # media addition hasn't affected the original objects
@ -134,9 +134,9 @@ class FormsMediaTestCase(SimpleTestCase):
str(w1.media), str(w1.media),
"""<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet"> """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet"> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="/path/to/js1"></script> <script src="/path/to/js1"></script>
<script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script src="http://media.other.com/path/to/js2"></script>
<script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""" <script src="https://secure.other.com/path/to/js3"></script>"""
) )
# Regression check for #12879: specifying the same CSS or JS file # Regression check for #12879: specifying the same CSS or JS file
@ -149,7 +149,7 @@ class FormsMediaTestCase(SimpleTestCase):
w4 = MyWidget4() w4 = MyWidget4()
self.assertEqual(str(w4.media), """<link href="/path/to/css1" type="text/css" media="all" rel="stylesheet"> self.assertEqual(str(w4.media), """<link href="/path/to/css1" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="/path/to/js1"></script>""") <script src="/path/to/js1"></script>""")
def test_media_deduplication(self): def test_media_deduplication(self):
# A deduplication test applied directly to a Media object, to confirm # A deduplication test applied directly to a Media object, to confirm
@ -160,7 +160,7 @@ class FormsMediaTestCase(SimpleTestCase):
js=('/path/to/js1', '/path/to/js1'), js=('/path/to/js1', '/path/to/js1'),
) )
self.assertEqual(str(media), """<link href="/path/to/css1" type="text/css" media="all" rel="stylesheet"> self.assertEqual(str(media), """<link href="/path/to/css1" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="/path/to/js1"></script>""") <script src="/path/to/js1"></script>""")
def test_media_property(self): def test_media_property(self):
############################################################### ###############################################################
@ -175,7 +175,7 @@ class FormsMediaTestCase(SimpleTestCase):
w4 = MyWidget4() w4 = MyWidget4()
self.assertEqual(str(w4.media), """<link href="/some/path" type="text/css" media="all" rel="stylesheet"> self.assertEqual(str(w4.media), """<link href="/some/path" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="/some/js"></script>""") <script src="/some/js"></script>""")
# Media properties can reference the media of their parents # Media properties can reference the media of their parents
class MyWidget5(MyWidget4): class MyWidget5(MyWidget4):
@ -186,8 +186,8 @@ class FormsMediaTestCase(SimpleTestCase):
w5 = MyWidget5() w5 = MyWidget5()
self.assertEqual(str(w5.media), """<link href="/some/path" type="text/css" media="all" rel="stylesheet"> self.assertEqual(str(w5.media), """<link href="/some/path" type="text/css" media="all" rel="stylesheet">
<link href="/other/path" type="text/css" media="all" rel="stylesheet"> <link href="/other/path" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="/some/js"></script> <script src="/some/js"></script>
<script type="text/javascript" src="/other/js"></script>""") <script src="/other/js"></script>""")
def test_media_property_parent_references(self): def test_media_property_parent_references(self):
# Media properties can reference the media of their parents, # Media properties can reference the media of their parents,
@ -210,10 +210,10 @@ class FormsMediaTestCase(SimpleTestCase):
"""<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet"> """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
<link href="/other/path" type="text/css" media="all" rel="stylesheet"> <link href="/other/path" type="text/css" media="all" rel="stylesheet">
<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet"> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="/path/to/js1"></script> <script src="/path/to/js1"></script>
<script type="text/javascript" src="/other/js"></script> <script src="/other/js"></script>
<script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script src="http://media.other.com/path/to/js2"></script>
<script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""" <script src="https://secure.other.com/path/to/js3"></script>"""
) )
def test_media_inheritance(self): def test_media_inheritance(self):
@ -237,9 +237,9 @@ class FormsMediaTestCase(SimpleTestCase):
str(w7.media), str(w7.media),
"""<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet"> """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet"> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="/path/to/js1"></script> <script src="/path/to/js1"></script>
<script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script src="http://media.other.com/path/to/js2"></script>
<script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""" <script src="https://secure.other.com/path/to/js3"></script>"""
) )
# If a widget extends another but defines media, it extends the parent widget's media by default # If a widget extends another but defines media, it extends the parent widget's media by default
@ -256,10 +256,10 @@ class FormsMediaTestCase(SimpleTestCase):
"""<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet"> """<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet">
<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet"> <link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet"> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="/path/to/js1"></script> <script src="/path/to/js1"></script>
<script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script src="http://media.other.com/path/to/js2"></script>
<script type="text/javascript" src="/path/to/js4"></script> <script src="/path/to/js4"></script>
<script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""" <script src="https://secure.other.com/path/to/js3"></script>"""
) )
def test_media_inheritance_from_property(self): def test_media_inheritance_from_property(self):
@ -289,8 +289,8 @@ class FormsMediaTestCase(SimpleTestCase):
str(w9.media), str(w9.media),
"""<link href="/some/path" type="text/css" media="all" rel="stylesheet"> """<link href="/some/path" type="text/css" media="all" rel="stylesheet">
<link href="/other/path" type="text/css" media="all" rel="stylesheet"> <link href="/other/path" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="/some/js"></script> <script src="/some/js"></script>
<script type="text/javascript" src="/other/js"></script>""" <script src="/other/js"></script>"""
) )
# A widget can disable media inheritance by specifying 'extend=False' # A widget can disable media inheritance by specifying 'extend=False'
@ -305,8 +305,8 @@ class FormsMediaTestCase(SimpleTestCase):
w10 = MyWidget10() w10 = MyWidget10()
self.assertEqual(str(w10.media), """<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet"> self.assertEqual(str(w10.media), """<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet">
<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet"> <link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="/path/to/js1"></script> <script src="/path/to/js1"></script>
<script type="text/javascript" src="/path/to/js4"></script>""") <script src="/path/to/js4"></script>""")
def test_media_inheritance_extends(self): def test_media_inheritance_extends(self):
# A widget can explicitly enable full media inheritance by specifying 'extend=True' # A widget can explicitly enable full media inheritance by specifying 'extend=True'
@ -331,10 +331,10 @@ class FormsMediaTestCase(SimpleTestCase):
"""<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet"> """<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet">
<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet"> <link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet"> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="/path/to/js1"></script> <script src="/path/to/js1"></script>
<script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script src="http://media.other.com/path/to/js2"></script>
<script type="text/javascript" src="/path/to/js4"></script> <script src="/path/to/js4"></script>
<script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""" <script src="https://secure.other.com/path/to/js3"></script>"""
) )
def test_media_inheritance_single_type(self): def test_media_inheritance_single_type(self):
@ -360,8 +360,8 @@ class FormsMediaTestCase(SimpleTestCase):
"""<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet"> """<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet">
<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet"> <link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet"> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="/path/to/js1"></script> <script src="/path/to/js1"></script>
<script type="text/javascript" src="/path/to/js4"></script>""" <script src="/path/to/js4"></script>"""
) )
def test_multi_media(self): def test_multi_media(self):
@ -386,8 +386,8 @@ class FormsMediaTestCase(SimpleTestCase):
<link href="/file3" type="text/css" media="screen" rel="stylesheet"> <link href="/file3" type="text/css" media="screen" rel="stylesheet">
<link href="/file1" type="text/css" media="screen, print" rel="stylesheet"> <link href="/file1" type="text/css" media="screen, print" rel="stylesheet">
<link href="/file2" type="text/css" media="screen, print" rel="stylesheet"> <link href="/file2" type="text/css" media="screen, print" rel="stylesheet">
<script type="text/javascript" src="/path/to/js1"></script> <script src="/path/to/js1"></script>
<script type="text/javascript" src="/path/to/js4"></script>""" <script src="/path/to/js4"></script>"""
) )
def test_multi_widget(self): def test_multi_widget(self):
@ -429,10 +429,10 @@ class FormsMediaTestCase(SimpleTestCase):
"""<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet"> """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet"> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet"> <link href="/path/to/css3" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="/path/to/js1"></script> <script src="/path/to/js1"></script>
<script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script src="http://media.other.com/path/to/js2"></script>
<script type="text/javascript" src="/path/to/js4"></script> <script src="/path/to/js4"></script>
<script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""" <script src="https://secure.other.com/path/to/js3"></script>"""
) )
def test_form_media(self): def test_form_media(self):
@ -471,10 +471,10 @@ class FormsMediaTestCase(SimpleTestCase):
"""<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet"> """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet"> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet"> <link href="/path/to/css3" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="/path/to/js1"></script> <script src="/path/to/js1"></script>
<script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script src="http://media.other.com/path/to/js2"></script>
<script type="text/javascript" src="/path/to/js4"></script> <script src="/path/to/js4"></script>
<script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""" <script src="https://secure.other.com/path/to/js3"></script>"""
) )
# Form media can be combined to produce a single media definition. # Form media can be combined to produce a single media definition.
@ -486,10 +486,10 @@ class FormsMediaTestCase(SimpleTestCase):
"""<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet"> """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet"> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet"> <link href="/path/to/css3" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="/path/to/js1"></script> <script src="/path/to/js1"></script>
<script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script src="http://media.other.com/path/to/js2"></script>
<script type="text/javascript" src="/path/to/js4"></script> <script src="/path/to/js4"></script>
<script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""" <script src="https://secure.other.com/path/to/js3"></script>"""
) )
# Forms can also define media, following the same rules as widgets. # Forms can also define media, following the same rules as widgets.
@ -509,21 +509,21 @@ class FormsMediaTestCase(SimpleTestCase):
<link href="/some/form/css" type="text/css" media="all" rel="stylesheet"> <link href="/some/form/css" type="text/css" media="all" rel="stylesheet">
<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet"> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet"> <link href="/path/to/css3" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="/path/to/js1"></script> <script src="/path/to/js1"></script>
<script type="text/javascript" src="/some/form/javascript"></script> <script src="/some/form/javascript"></script>
<script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script src="http://media.other.com/path/to/js2"></script>
<script type="text/javascript" src="/path/to/js4"></script> <script src="/path/to/js4"></script>
<script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""" <script src="https://secure.other.com/path/to/js3"></script>"""
) )
# Media works in templates # Media works in templates
self.assertEqual( self.assertEqual(
Template("{{ form.media.js }}{{ form.media.css }}").render(Context({'form': f3})), Template("{{ form.media.js }}{{ form.media.css }}").render(Context({'form': f3})),
"""<script type="text/javascript" src="/path/to/js1"></script> """<script src="/path/to/js1"></script>
<script type="text/javascript" src="/some/form/javascript"></script> <script src="/some/form/javascript"></script>
<script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script src="http://media.other.com/path/to/js2"></script>
<script type="text/javascript" src="/path/to/js4"></script> <script src="/path/to/js4"></script>
<script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""" <script src="https://secure.other.com/path/to/js3"></script>"""
"""<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet"> """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet">
<link href="/some/form/css" type="text/css" media="all" rel="stylesheet"> <link href="/some/form/css" type="text/css" media="all" rel="stylesheet">
<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet"> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">

View File

@ -2386,7 +2386,7 @@ class OtherModelFormTests(TestCase):
self.assertHTMLEqual( self.assertHTMLEqual(
str(f.media), str(f.media),
'''<link href="/some/form/css" type="text/css" media="all" rel="stylesheet"> '''<link href="/some/form/css" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="/some/form/javascript"></script>''' <script src="/some/form/javascript"></script>'''
) )
def test_choices_type(self): def test_choices_type(self):

View File

@ -31,8 +31,8 @@ class StaticFilesFormsMediaTestCase(SimpleTestCase):
str(m), str(m),
"""<link href="https://example.com/assets/path/to/css1" type="text/css" media="all" rel="stylesheet"> """<link href="https://example.com/assets/path/to/css1" type="text/css" media="all" rel="stylesheet">
<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet"> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="/path/to/js1"></script> <script src="/path/to/js1"></script>
<script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script src="http://media.other.com/path/to/js2"></script>
<script type="text/javascript" src="https://secure.other.com/path/to/js3"></script> <script src="https://secure.other.com/path/to/js3"></script>
<script type="text/javascript" src="https://example.com/assets/relative/path/to/js4"></script>""" <script src="https://example.com/assets/relative/path/to/js4"></script>"""
) )

View File

@ -1,7 +1,7 @@
{% extends "admin/change_list.html" %} {% extends "admin/change_list.html" %}
{% block extrahead %} {% block extrahead %}
<script type="text/javascript"> <script>
var hello = '{{ extra_var }}'; var hello = '{{ extra_var }}';
</script> </script>
{% endblock %} {% endblock %}

View File

@ -24,8 +24,8 @@
<script src="https://a248.e.akamai.net/assets.github.com/assets/frameworks-d76b58e749b52bc47a4c46620bf2c320fabe5248.js" type="text/javascript"></script> <script src="https://a248.e.akamai.net/assets.github.com/assets/frameworks-d76b58e749b52bc47a4c46620bf2c320fabe5248.js"></script>
<script src="https://a248.e.akamai.net/assets.github.com/assets/github-67b55380cff8d6766b298e6935a3c1db7d5c6d5d.js" type="text/javascript"></script> <script src="https://a248.e.akamai.net/assets.github.com/assets/github-67b55380cff8d6766b298e6935a3c1db7d5c6d5d.js"></script>
<meta http-equiv="x-pjax-version" content="1212ad79754350a805cefbcd08a3dadf"> <meta http-equiv="x-pjax-version" content="1212ad79754350a805cefbcd08a3dadf">

View File

@ -1,15 +1,15 @@
<html> <html>
<head> <head>
<script type="text/javascript" src="/jsi18n/app1/"></script> <script src="/jsi18n/app1/"></script>
<script type="text/javascript" src="/jsi18n/app2/"></script> <script src="/jsi18n/app2/"></script>
<body> <body>
<p id="app1string"> <p id="app1string">
<script type="text/javascript"> <script>
document.write(gettext('this app1 string is to be translated')) document.write(gettext('this app1 string is to be translated'))
</script> </script>
</p> </p>
<p id="app2string"> <p id="app2string">
<script type="text/javascript"> <script>
document.write(gettext('this app2 string is to be translated')) document.write(gettext('this app2 string is to be translated'))
</script> </script>
</p> </p>

View File

@ -1,11 +1,11 @@
<html> <html>
<head> <head>
<script type="text/javascript" src="/jsi18n_admin/"></script> <script src="/jsi18n_admin/"></script>
</head> </head>
<body> <body>
<p id="formats"> <p id="formats">
<script type="text/javascript"> <script>
document.write("DATE_INPUT_FORMATS is an " + typeof get_format("DATE_INPUT_FORMATS") + "; "); document.write("DATE_INPUT_FORMATS is an " + typeof get_format("DATE_INPUT_FORMATS") + "; ");
document.write("DECIMAL_SEPARATOR is a " + typeof get_format("DECIMAL_SEPARATOR") + "; "); document.write("DECIMAL_SEPARATOR is a " + typeof get_format("DECIMAL_SEPARATOR") + "; ");
document.write("FIRST_DAY_OF_WEEK is a " + typeof get_format("FIRST_DAY_OF_WEEK") + ";"); document.write("FIRST_DAY_OF_WEEK is a " + typeof get_format("FIRST_DAY_OF_WEEK") + ";");
@ -13,44 +13,44 @@
</p> </p>
<p id="gettext"> <p id="gettext">
<script type="text/javascript"> <script>
document.write(gettext("Remove")); document.write(gettext("Remove"));
</script> </script>
</p> </p>
<p id="ngettext_sing"> <p id="ngettext_sing">
<script type="text/javascript"> <script>
document.write(interpolate(ngettext("%s item", "%s items", 1), [1])); document.write(interpolate(ngettext("%s item", "%s items", 1), [1]));
</script> </script>
</p> </p>
<p id="ngettext_plur"> <p id="ngettext_plur">
<script type="text/javascript"> <script>
document.write(interpolate(ngettext("%s item", "%s items", 455), [455])); document.write(interpolate(ngettext("%s item", "%s items", 455), [455]));
</script> </script>
</p> </p>
<p id="ngettext_onnonplural"> <p id="ngettext_onnonplural">
<!-- The po file only contains the non plural "Image" string. --> <!-- The po file only contains the non plural "Image" string. -->
<script type="text/javascript"> <script>
document.write(interpolate(ngettext("Image", "Images", 5), [1])); document.write(interpolate(ngettext("Image", "Images", 5), [1]));
</script> </script>
</p> </p>
<p id="pgettext"> <p id="pgettext">
<script type="text/javascript"> <script>
document.write(pgettext("verb", "May")); document.write(pgettext("verb", "May"));
</script> </script>
</p> </p>
<p id="npgettext_sing"> <p id="npgettext_sing">
<script type="text/javascript"> <script>
document.write(interpolate(npgettext("search", "%s result", "%s results", 1), [1])); document.write(interpolate(npgettext("search", "%s result", "%s results", 1), [1]));
</script> </script>
</p> </p>
<p id="npgettext_plur"> <p id="npgettext_plur">
<script type="text/javascript"> <script>
document.write(interpolate(npgettext("search", "%s result", "%s results", 455), [455])); document.write(interpolate(npgettext("search", "%s result", "%s results", 455), [455]));
</script> </script>
</p> </p>