Skip to content

Commit

Permalink
0.2.6 Release
Browse files Browse the repository at this point in the history
SimpleMDE is now loaded from settings.
DAJE_SIMPLE_MDE_CSS and DAJE_SIMPLE_MDE_JS are arrays of files that should be loaded.
We default to the original simple MDE.
In the example project, we override those with the custom Designlab SimpleMDE files and the DesignLab Showdown Extensions
  • Loading branch information
cjdreiss committed Mar 29, 2018
1 parent 800fccb commit 4eac6ad
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 6 deletions.
2 changes: 1 addition & 1 deletion django_admin_json_editor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .admin import JSONEditorWidget # noqa

__version__ = '0.2.5'
__version__ = '0.2.6'
9 changes: 7 additions & 2 deletions django_admin_json_editor/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import collections
from django import forms
from .conf import conf
from django.utils.safestring import mark_safe
from django.template.loader import render_to_string

Expand Down Expand Up @@ -62,19 +63,19 @@ def render(self, name, value, attrs=None, renderer=None):

@property
def media(self):


css = {
'all': [
'django_admin_json_editor/bootstrap/css/bootstrap.min.css',
'django_admin_json_editor/fontawesome/css/font-awesome.min.css',
'django_admin_json_editor/style.css',
'django_admin_json_editor/simplemde/simplemde.min.css'
]
}
js = [
'django_admin_json_editor/jquery/jquery.min.js',
'django_admin_json_editor/bootstrap/js/bootstrap.min.js',
'django_admin_json_editor/jsoneditor/jsoneditor.min.js',
'django_admin_json_editor/simplemde/simplemde.min.js'
]
if self._sceditor:
css['all'].append('django_admin_json_editor/sceditor/themes/default.min.css')
Expand All @@ -83,4 +84,8 @@ def media(self):
if self._default_options.get('template') == 'handlebars':
js.append('django_admin_json_editor/handlebars/handlebars-v4.0.11.js')

# Load our default Simple MDE files, but these can be overridden in django settings.
css['all'] += conf.DAJE_SIMPLE_MDE_CSS
js += conf.DAJE_SIMPLE_MDE_JS

return forms.Media(css=css, js=js)
18 changes: 18 additions & 0 deletions django_admin_json_editor/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from django.conf import settings


class Settings(object):
"""
Shadow Django's settings with a little logic
"""

@property
def DAJE_SIMPLE_MDE_CSS(self):
return getattr(settings, 'DAJE_SIMPLE_MDE_CSS', ['django_admin_json_editor/simplemde/simplemde.min.css'])

@property
def DAJE_SIMPLE_MDE_JS(self):
return getattr(settings, 'DAJE_SIMPLE_MDE_JS', ['django_admin_json_editor/simplemde/simplemde.min.js'])


conf = Settings()

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions example/app/static/app/designlab-showdown-extensions.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4eac6ad

Please sign in to comment.