Skip to content

Commit

Permalink
Merge pull request #73 from timmyomahony/develop
Browse files Browse the repository at this point in the history
Fixes for 2.1 and other small changes
  • Loading branch information
timmyomahony authored Aug 17, 2018
2 parents a97ed5f + 4dd1585 commit 43f50ad
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 20 deletions.
3 changes: 1 addition & 2 deletions pagedown/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@


class PagedownField(forms.CharField):

""" A simple CharField that allows us avoid having to write widget code """

widget = PagedownWidget


class AdminPagedownField(forms.CharField):

""" A simple CharField that allows us avoid having to write widget code """

widget = AdminPagedownWidget


try:
from south.modelsinspector import add_introspection_rules

add_introspection_rules([], ["^pagedown\.forms\.PagedownField"])
add_introspection_rules([], ["^pagedown\.forms\.AdminPagedownField"])
except ImportError:
Expand Down
5 changes: 2 additions & 3 deletions pagedown/settings.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from django.conf import settings


SHOW_PREVIEW = getattr(settings, "PAGEDOWN_SHOW_PREVIEW", True)
WIDGET_TEMPLATE = getattr(
settings, "PAGEDOWN_WIDGET_TEMPLATE", "pagedown/widgets/default.html")
settings, "PAGEDOWN_WIDGET_TEMPLATE", "pagedown/widgets/default.html")
WIDGET_CSS = getattr(
settings, "PAGEDOWN_WIDGET_CSS", ("pagedown/demo/browser/demo.css", ))
settings, "PAGEDOWN_WIDGET_CSS", ("pagedown/demo/browser/demo.css",))
EXTENSIONS = getattr(settings, "PAGEDOWN_EXTENSIONS", [])
10 changes: 5 additions & 5 deletions pagedown/static/admin/css/pagedown.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@
padding: 12px 14px;
margin: 0;
background: #f8f8f8;
border: 1px solid #eee;
border-radius: 4px;
}

.wmd-preview * {
font-family: "Roboto","Lucida Grande","DejaVu Sans","Bitstream Vera Sans",Verdana,Arial,sans-serif !important;
}

.wmd-preview *:last-child {
margin-bottom: 0;
}

.wmd-preview a {
color: #447e9b;
Expand Down Expand Up @@ -95,7 +96,7 @@
.wmd-preview h6 {
margin:0 0 12px 0;
padding: 0;
color: #666;
color: #333;
font-weight: bold;
background: none;
}
Expand Down Expand Up @@ -175,12 +176,11 @@
word-wrap: break-word;
margin: 15px 0;
padding: 10px;
color: #333;

margin: 0 0 15px 0;
padding-left: 1em;
border-left: 0.5em #ddd solid;
background-color: #eee;
border-radius: 0 4px 4px 0;
}
.wmd-preview pre code {
background-color: transparent;
Expand Down
10 changes: 6 additions & 4 deletions pagedown/templates/pagedown/widgets/default.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<div class="wmd-wrapper" id="{{ id }}-wmd-wrapper">
<div class="wmd-panel">
<div id="{{ id|safe }}_wmd_button_bar"></div>
<textarea{{ attrs|safe }}>{{ body }}</textarea>
<textarea {{ attrs|safe }}>{{ body }}</textarea>
</div>
{% if show_preview %}
<p class="wmd-preview-title"><small>HTML Preview:</small></p>
<div id="{{ id|safe }}_wmd_preview" class="wmd-panel wmd-preview"></div>
<p class="wmd-preview-title">
<small>HTML Preview:</small>
</p>
<div id="{{ id|safe }}_wmd_preview" class="wmd-panel wmd-preview"></div>
{% endif %}
</div>
</div>
1 change: 0 additions & 1 deletion pagedown/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


def compatible_staticpath(path):

"""
Try to return a path to static the static files compatible all
the way back to Django 1.2. If anyone has a cleaner or better
Expand Down
21 changes: 16 additions & 5 deletions pagedown/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from pagedown import settings as pagedown_settings
from pagedown.utils import compatible_staticpath


# Python 3 compatibility
# https://docs.djangoproject.com/en/1.5/topics/python3/#string-handling
try:
Expand Down Expand Up @@ -45,19 +44,30 @@ def _media(self):
compatible_staticpath("pagedown-extra/Markdown.Extra.js"),
compatible_staticpath("pagedown_init.js"),
))

media = property(_media)

def render(self, name, value, attrs=None):
def render(self, name, value, attrs=None, renderer=None):
if value is None:
value = ""

extra_attrs = {
'name': name
}

extra_attrs.update(self.attrs)

# Signature for build_attrs changed in 1.11
# https://code.djangoproject.com/ticket/28095
if VERSION < (1, 11):
final_attrs = self.build_attrs(attrs, name=name)
final_attrs = self.build_attrs(attrs, **extra_attrs)
else:
final_attrs = self.build_attrs(attrs, {'name': name})

final_attrs = self.build_attrs(attrs, extra_attrs=extra_attrs)
if "class" not in final_attrs:
final_attrs["class"] = ""
final_attrs["class"] += " wmd-input"

template = loader.get_template(self.template)

# Compatibility fix:
Expand All @@ -81,4 +91,5 @@ def _media(self):
js=(
compatible_staticpath("admin/js/pagedown.js"),
))

media = property(_media)

0 comments on commit 43f50ad

Please sign in to comment.