File tree Expand file tree Collapse file tree 6 files changed +49
-6
lines changed
djangocms_bootstrap4/contrib/bootstrap4_content
templates/djangocms_bootstrap4/admin Expand file tree Collapse file tree 6 files changed +49
-6
lines changed Original file line number Diff line number Diff line change 22Changelog
33=========
44
5+ unreleased
6+ ==========
7+
8+ * Added support for djangocms-static-ace to serve the ace code editor locally
59
6102.0.0 (2020-09-02)
711==================
Original file line number Diff line number Diff line change @@ -83,6 +83,13 @@ For a manual install:
8383
8484* run ``python manage.py migrate ``
8585
86+ The Code plugin uses the ace code editor which is loaded from a CDN by default.
87+ If you want the ace code editor to be served from static files, please use
88+ ``djangocms-bootstrap4[static-ace] `` instead of ``djangocms-bootstrap4 `` in your
89+ requirements or with pip. Make the static files fore the ace code editor available
90+ to your project by adding ``djangocms_static_ace `` to your project's
91+ ``INSTALLED_APPS ``.
92+
8693
8794Configuration
8895-------------
@@ -110,7 +117,8 @@ It provides the following **standard** Bootstrap 4 components:
110117* `Tabs <https://getbootstrap.com/docs/4.0/components/navs/#tabs >`_
111118* `Utilities (Spacing) <https://getbootstrap.com/docs/4.0/utilities/ >`_
112119
113- django CMS Bootstrap 4 **does not ** add the styles or javascript files to your frontend, these need to be added at your discretion.
120+ django CMS Bootstrap 4 **does not ** add the styles or javascript files to your
121+ frontend, these need to be added at your discretion.
114122
115123
116124Settings
Original file line number Diff line number Diff line change 1+ from django .conf import settings as django_settings
12from django .forms .models import ModelForm
23from django .forms .widgets import Textarea
34
45
56class Bootstrap4CodeForm (ModelForm ):
7+ class Media :
8+ js = (
9+ "admin/vendor/ace/ace.js"
10+ if "djangocms_static_ace" in django_settings .INSTALLED_APPS
11+ else "https://cdnjs.cloudflare.com/ajax/libs/ace/1.9.6/ace.js" ,
12+ )
13+
614 class Meta :
715 # When used inside djangocms-text-ckeditor
816 # this causes the label field to be prefilled with the selected text.
Original file line number Diff line number Diff line change 11{% extends "admin/change_form.html" %}
22
33{% block object-tools %}
4- {{ block.super }}
5-
6- < script src ="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.9/ace.js "> </ script >
7- < script >
4+ {{ block.super }}< script >
85django . jQuery ( function ( ) {
96 // ace editor cannot be attached directly to a textarea
107 var textarea = django . jQuery ( 'textarea' ) . css ( 'display' , 'none' ) ;
1815
1916 // init editor with settings
2017 var editor = ace . edit ( div [ 0 ] ) ;
21- editor . setTheme ( 'ace/theme/github' ) ;
18+ var darkMode ;
19+
20+ if ( window . parent . CMS . API . Helpers . getColorScheme ) {
21+ darkMode = window . parent . CMS . API . Helpers . getColorScheme ( ) === 'dark' ;
22+ } else {
23+ // django CMS pre-3.11.1
24+ darkMode = window . matchMedia && window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches ;
25+ }
26+ if ( darkMode ) {
27+ editor . setTheme ( 'ace/theme/tomorrow_night' ) ;
28+ } else {
29+ editor . setTheme ( 'ace/theme/github' ) ;
30+ }
2231 editor . getSession ( ) . setValue ( textarea . val ( ) ) ;
2332 editor . getSession ( ) . setMode ( 'ace/mode/html' ) ;
2433 editor . setOptions ( {
Original file line number Diff line number Diff line change 1515]
1616
1717
18+ EXTRA_REQUIREMENTS = {
19+ "static-ace" : [
20+ "djangocms-static-ace" ,
21+ ]
22+ }
23+
24+
1825CLASSIFIERS = [
1926 'Development Status :: 5 - Production/Stable' ,
2027 'Environment :: Web Environment' ,
5663 include_package_data = True ,
5764 zip_safe = False ,
5865 install_requires = REQUIREMENTS ,
66+ extras_require = EXTRA_REQUIREMENTS ,
5967 classifiers = CLASSIFIERS ,
6068 test_suite = 'tests.settings.run' ,
6169)
Original file line number Diff line number Diff line change 44
55from django .core .management import call_command
66from django .test import TestCase , override_settings
7+ from cms import __version__
8+ from distutils .version import LooseVersion
79
810
911class MigrationTestCase (TestCase ):
1012
1113 @override_settings (MIGRATION_MODULES = {})
1214 def test_for_missing_migrations (self ):
15+ if LooseVersion ("3.9" ) <= LooseVersion (__version__ ) < LooseVersion ("3.10" ):
16+ # django-cms 3.9 creates migrations to BigAutoField hence skip this test
17+ return
18+
1319 output = StringIO ()
1420 options = {
1521 'interactive' : False ,
You can’t perform that action at this time.
0 commit comments