Skip to content

Commit 5400fad

Browse files
committed
fixed issue #14 - setup the editor with label or nope
1 parent be3fa2e commit 5400fad

File tree

7 files changed

+36
-21
lines changed

7 files changed

+36
-21
lines changed

README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ to get ``IMGUR_CLIENT_ID`` and ``IMGUR_API_KEY``.
107107
'jquery': 'true', # to include/revoke jquery (require for admin default django)
108108
}
109109

110+
# To setup the martor edito with label or not (default is False)
111+
MARTOR_ENABLE_LABEL = False
112+
110113
# Imgur API Keys
111114
MARTOR_IMGUR_CLIENT_ID = 'your-client-id'
112115
MARTOR_IMGUR_API_KEY = 'your-api-key'

martor/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
22

3-
__VERSION__ = '1.2.4'
3+
__VERSION__ = '1.2.5'
44
__AUTHOR__ = 'Agus Makmun (Summon Agus)'
55
__AUTHOR_EMAIL__ = '[email protected]'

martor/extensions/mention.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
>>> import markdown
1010
>>> md = markdown.Markdown(extensions=['martor.utils.extensions.mention'])
1111
>>> md.convert('@[summonagus]')
12-
'<p><a href="https://webname.com/profile/summonagus/">summonagus</a></p>'
12+
'<p><a class="direct-mention-link" href="https://webname.com/profile/summonagus/">summonagus</a></p>'
1313
>>>
14-
>>> md.convert('hellp @[summonagus], i mentioned you!')
15-
'<p>hellp <a href="https://webname.com/profile/summonagus/">summonagus</a>, i mentioned you!</p>'
14+
>>> md.convert('hello @[summonagus], i mentioned you!')
15+
'<p>hello <a class="direct-mention-link" href="https://webname.com/profile/summonagus/">summonagus</a>, i mentioned you!</p>'
1616
>>>
1717
"""
1818

@@ -24,9 +24,9 @@ class MentionPattern(markdown.inlinepatterns.Pattern):
2424
def handleMatch(self, m):
2525
username = self.unescape(m.group(2))
2626

27-
"""Makesure `username` is registered."""
27+
"""Makesure `username` is registered and actived."""
2828
if MARTOR_ENABLE_CONFIGS['mention'] == 'true':
29-
if username in [u.username for u in User.objects.all() if u.is_active]:
29+
if username in [u.username for u in User.objects.exclude(is_active=False)]:
3030
url = '{0}{1}/'.format(MARTOR_MARKDOWN_BASE_MENTION_URL, username)
3131
el = markdown.util.etree.Element('a')
3232
el.set('href', url)

martor/fields.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
from django import forms
22

3-
from .widgets import (
4-
MartorWidget,
5-
AdminMartorWidget,
6-
)
3+
from .settings import MARTOR_ENABLE_LABEL
4+
from .widgets import (MartorWidget, AdminMartorWidget)
75

86

97
class MartorFormField(forms.CharField):
108

119
def __init__(self, *args, **kwargs):
12-
kwargs['label'] = '' # To set without label.
10+
11+
# to setup the editor without label
12+
if not MARTOR_ENABLE_LABEL:
13+
kwargs['label'] = ''
14+
1315
super(MartorFormField, self).__init__(*args, **kwargs)
1416

1517
if not issubclass(self.widget.__class__, MartorWidget):

martor/settings.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
}
1111
)
1212

13+
# To setup the martor edito with label or not (default is False)
14+
MARTOR_ENABLE_LABEL = getattr(
15+
settings, 'MARTOR_ENABLE_LABEL', False
16+
)
17+
1318
# Imgur API Keys
1419
MARTOR_IMGUR_CLIENT_ID = getattr(
1520
settings, 'MARTOR_IMGUR_CLIENT_ID', ''

martor/static/martor/js/martor.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* Name : Martor v1.2.4
2+
* Name : Martor v1.2.5
33
* Created by : Agus Makmun (Summon Agus)
4-
* Release date : 18-Sep-2017
4+
* Release date : 02-Dec-2017
55
* License : GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
66
* Repository : https://github.com/agusmakmun/django-markdown-editor
77
**/
@@ -117,7 +117,7 @@
117117
// set css `display:none` fot this textarea.
118118
textareaId.attr({'style': 'display:none'});
119119

120-
// assign all button single toolbar
120+
// assign all `field_name`, uses for a per-single editor.
121121
$(obj).find('.martor-toolbar').find('.markdown-selector').attr({'data-field-name': field_name});
122122
$(obj).find('.upload-progress').attr({'data-field-name': field_name});
123123
$(obj).find('.modal-help-guide').attr({'data-field-name': field_name});
@@ -131,7 +131,7 @@
131131

132132
// resize the editor using `resizable.min.js`
133133
$('#'+editorId).resizable({
134-
direction: 'bottom',
134+
direction: 'bottom',
135135
stop: function() {
136136
editor.resize();
137137
}
@@ -491,7 +491,12 @@
491491
editor=editor,
492492
imageData={name: response.name, link: response.link}
493493
);
494-
}else {console.log(response)}
494+
}else if (response.status == 403) {
495+
alert(response.data.error); // invalid client id
496+
}
497+
else {
498+
console.log(response)
499+
}
495500
},
496501
error: function(response) {
497502
console.log("error", response);
@@ -794,6 +799,6 @@ $(function() {
794799

795800
$( document ).ready(function(){
796801
// Semantic UI
797-
$('.ui.dropdown').dropdown();
802+
$('.ui.martor-toolbar .ui.dropdown').dropdown();
798803
$('.ui.tab-martor-menu .item').tab();
799804
});

martor/static/martor/js/martor.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)