Have wagtaildocs, wagtailembeds, wagtailimages and wagtailsnippets register their page editor JS components through the insert_editor_js hook, rather than hard-coding them into _editor_js.html

pull/242/merge
Matt Westcott 2014-05-10 19:35:51 +01:00
rodzic 27debc3289
commit fd737f0ab0
6 zmienionych plików z 44 dodań i 18 usunięć

Wyświetl plik

@ -4,11 +4,6 @@
CSS declarations to be included on the 'create page' and 'edit page' views
{% endcomment %}
{% comment %}
TODO: have a mechanism for sub-apps to specify their own declarations -
ideally wagtailadmin shouldn't have to know anything at all about wagtailimages and friends
{% endcomment %}
{% compress css %}
<link rel="stylesheet" href="{{ STATIC_URL }}wagtailadmin/scss/layouts/page-editor.scss" type="text/x-scss" />
<link rel="stylesheet" href="{{ STATIC_URL }}wagtailadmin/scss/panels/rich-text.scss" type="text/x-scss" />

Wyświetl plik

@ -14,21 +14,9 @@
<script src="{{ STATIC_URL }}wagtailadmin/js/hallo-plugins/hallo-wagtail-toolbar.js"></script>
<script src="{{ STATIC_URL }}wagtailadmin/js/hallo-plugins/hallo-wagtaillink.js"></script>
<script src="{{ STATIC_URL }}wagtailadmin/js/hallo-plugins/hallo-hr.js"></script>
<script src="{{ STATIC_URL }}wagtailimages/js/hallo-plugins/hallo-wagtailimage.js"></script>
<script src="{{ STATIC_URL }}wagtailembeds/js/hallo-plugins/hallo-wagtailembeds.js"></script>
<script src="{{ STATIC_URL }}wagtaildocs/js/hallo-plugins/hallo-wagtaildoclink.js"></script>
<script src="{{ STATIC_URL }}wagtailadmin/js/page-editor.js"></script>
<script src="{{ STATIC_URL }}wagtailadmin/js/page-chooser.js"></script>
{% comment %}
TODO: use the insert_editor_js hook to inject things like image-chooser.js and hallo-wagtailimage.js
from their respective apps such as wagtailimages -
ideally wagtailadmin shouldn't have to know anything at all about wagtailimages.
TODO: a method of injecting these sorts of things on demand when the modal is spawned.
{% endcomment %}
<script src="{{ STATIC_URL }}wagtailimages/js/image-chooser.js"></script>
<script src="{{ STATIC_URL }}wagtaildocs/js/document-chooser.js"></script>
<script src="{{ STATIC_URL }}wagtailsnippets/js/snippet-chooser.js"></script>
<script src="{{ STATIC_URL }}admin/js/urlify.js"></script>
{% hook_output 'insert_editor_js' %}
@ -41,7 +29,6 @@
{% comment %}
Additional js from widgets media. Allows for custom widgets in admin panel.
Can be used for TODO above (including image-choser.js at wagtailimages)
{% endcomment %}
{{ edit_handler.form.media.js }}

Wyświetl plik

@ -1,5 +1,7 @@
from django.conf import settings
from django.conf.urls import include, url
from django.core import urlresolvers
from django.utils.html import format_html_join
from django.utils.translation import ugettext_lazy as _
from wagtail.wagtailadmin import hooks
@ -21,3 +23,14 @@ def construct_main_menu(request, menu_items):
MenuItem(_('Documents'), urlresolvers.reverse('wagtaildocs_index'), classnames='icon icon-doc-full-inverse', order=400)
)
hooks.register('construct_main_menu', construct_main_menu)
def editor_js():
js_files = [
'wagtaildocs/js/hallo-plugins/hallo-wagtaildoclink.js',
'wagtaildocs/js/document-chooser.js',
]
return format_html_join('\n', '<script src="{0}{1}"></script>',
((settings.STATIC_URL, filename) for filename in js_files)
)
hooks.register('insert_editor_js', editor_js)

Wyświetl plik

@ -1,4 +1,6 @@
from django.conf import settings
from django.conf.urls import include, url
from django.utils.html import format_html
from wagtail.wagtailadmin import hooks
from wagtail.wagtailembeds import urls
@ -9,3 +11,10 @@ def register_admin_urls():
url(r'^embeds/', include(urls)),
]
hooks.register('register_admin_urls', register_admin_urls)
def editor_js():
return format_html('<script src="{0}{1}"></script>',
settings.STATIC_URL, 'wagtailembeds/js/hallo-plugins/hallo-wagtailembeds.js'
)
hooks.register('insert_editor_js', editor_js)

Wyświetl plik

@ -1,5 +1,7 @@
from django.conf import settings
from django.conf.urls import include, url
from django.core import urlresolvers
from django.utils.html import format_html_join
from django.utils.translation import ugettext_lazy as _
from wagtail.wagtailadmin import hooks
@ -21,3 +23,14 @@ def construct_main_menu(request, menu_items):
MenuItem(_('Images'), urlresolvers.reverse('wagtailimages_index'), classnames='icon icon-image', order=300)
)
hooks.register('construct_main_menu', construct_main_menu)
def editor_js():
js_files = [
'wagtailimages/js/hallo-plugins/hallo-wagtailimage.js',
'wagtailimages/js/image-chooser.js',
]
return format_html_join('\n', '<script src="{0}{1}"></script>',
((settings.STATIC_URL, filename) for filename in js_files)
)
hooks.register('insert_editor_js', editor_js)

Wyświetl plik

@ -1,5 +1,7 @@
from django.conf import settings
from django.conf.urls import include, url
from django.core import urlresolvers
from django.utils.html import format_html
from django.utils.translation import ugettext_lazy as _
from wagtail.wagtailadmin import hooks
@ -22,3 +24,10 @@ def construct_main_menu(request, menu_items):
MenuItem(_('Snippets'), urlresolvers.reverse('wagtailsnippets_index'), classnames='icon icon-snippet', order=500)
)
hooks.register('construct_main_menu', construct_main_menu)
def editor_js():
return format_html('<script src="{0}{1}"></script>',
settings.STATIC_URL, 'wagtailsnippets/js/snippet-chooser.js'
)
hooks.register('insert_editor_js', editor_js)