Skip to content

Commit

Permalink
Use staticfiles_storage to generate static files urls for widgets.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Gaberel committed Oct 18, 2015
1 parent 0c8081b commit b8b745d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ Contributors:
* Tom O'onnor' (https://github.com/tomoconnor)
* Wellington Cordeiro (https://github.com/wldcordeiro)
* dfeinzeig (https://github.com/dfeinzeig)
* Nathan Gaberel (https://github.com/n6g7)
5 changes: 5 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
2015-10-04 Nathan Gaberel

* Use staticfiles_storage to generate static files urls for widgets.

2014-12-08 wldcordeiro

* Fixing the static loading issue properly.
* version 0.8.2

Expand Down
1 change: 0 additions & 1 deletion django_markdown/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
""" Supports preview. """
from django.core.files.storage import default_storage
from django.shortcuts import render

from . import settings
Expand Down
13 changes: 6 additions & 7 deletions django_markdown/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from django import forms
from django.contrib.admin.widgets import AdminTextareaWidget
from django.core.files.storage import default_storage
from django.contrib.staticfiles.storage import staticfiles_storage
from django.utils.safestring import mark_safe

from . import settings
Expand Down Expand Up @@ -41,18 +41,17 @@ def render(self, name, value, attrs=None):
class Media:
css = {
'screen': (
os.path.join('django_markdown', 'skins', settings.MARKDOWN_EDITOR_SKIN, 'style.css'),
os.path.join(settings.MARKDOWN_SET_PATH, settings.MARKDOWN_SET_NAME, 'style.css')
staticfiles_storage.url(os.path.join('django_markdown', 'skins', settings.MARKDOWN_EDITOR_SKIN, 'style.css')),
staticfiles_storage.url(os.path.join(settings.MARKDOWN_SET_PATH, settings.MARKDOWN_SET_NAME, 'style.css'))
)
}

js = (
os.path.join('django_markdown', 'jquery.init.js'),
os.path.join('django_markdown', 'jquery.markitup.js'),
os.path.join(settings.MARKDOWN_SET_PATH, settings.MARKDOWN_SET_NAME, 'set.js')
staticfiles_storage.url(os.path.join('django_markdown', 'jquery.init.js')),
staticfiles_storage.url(os.path.join('django_markdown', 'jquery.markitup.js')),
staticfiles_storage.url(os.path.join(settings.MARKDOWN_SET_PATH, settings.MARKDOWN_SET_NAME, 'set.js'))
)


class AdminMarkdownWidget(MarkdownWidget, AdminTextareaWidget):

""" Support markdown widget in Django Admin. """
Expand Down

0 comments on commit b8b745d

Please sign in to comment.