Skip to content

Commit 79ffeff

Browse files
author
Agus Makmun
committed
fix: implement black code style
1 parent 4cc887a commit 79ffeff

23 files changed

+1044
-498
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## martor [![pypi version][1]][2] [![paypal donation][3]][4]
22

3-
[![license][5]][6] [![python version][7]][8] [![django version][9]][10] [![build][11]][12]
3+
[![license][5]][6] [![python version][7]][8] [![django version][9]][10] [![build][11]][12] [![black][18]][19]
44

55
**Martor** is a Markdown Editor plugin for Django, supported for _Bootstrap_ & _Semantic-UI_.
66

@@ -156,6 +156,12 @@ MARTOR_MARKDOWN_BASE_MENTION_URL = 'https://python.web.id/author/'
156156
MARTOR_ALTERNATIVE_JS_FILE_THEME = "semantic-themed/semantic.min.js" # default None
157157
MARTOR_ALTERNATIVE_CSS_FILE_THEME = "semantic-themed/semantic.min.css" # default None
158158
MARTOR_ALTERNATIVE_JQUERY_JS_FILE = "jquery/dist/jquery.min.js" # default None
159+
160+
# URL schemes that are allowed within links
161+
ALLOWED_URL_SCHEMES = [
162+
"file", "ftp", "ftps", "http", "https", "irc", "mailto",
163+
"sftp", "ssh", "tel", "telnet", "tftp", "vnc", "xmpp",
164+
]
159165
```
160166

161167
Check this setting is not set else csrf will not be sent over ajax calls:
@@ -345,7 +351,7 @@ Checkout at http://127.0.0.1:8000/simple-form/ on your browser.
345351
[7]: https://img.shields.io/pypi/pyversions/martor.svg
346352
[8]: https://pypi.python.org/pypi/martor
347353

348-
[9]: https://img.shields.io/badge/Django-1.8%20%3E=%203.2-green.svg
354+
[9]: https://img.shields.io/badge/Django-1.8%20%3E=%204.0-green.svg
349355
[10]: https://www.djangoproject.com
350356

351357
[11]: https://travis-ci.org/agusmakmun/django-markdown-editor.svg?branch=master
@@ -356,3 +362,6 @@ Checkout at http://127.0.0.1:8000/simple-form/ on your browser.
356362
[15]: https://github.com/adi-/django-markdownx
357363
[16]: https://github.com/waylan/Python-Markdown
358364
[17]: http://rst.ninjs.org
365+
366+
[18]: https://img.shields.io/badge/code%20style-black-000000.svg
367+
[19]: https://github.com/ambv/black

martor/__init__.py

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

3-
__VERSION__ = '1.6.8'
4-
__AUTHOR__ = 'Agus Makmun (Summon Agus)'
5-
__AUTHOR_EMAIL__ = '[email protected]'
3+
__VERSION__ = "1.6.8"
4+
__AUTHOR__ = "Agus Makmun (Summon Agus)"
5+
__AUTHOR_EMAIL__ = "[email protected]"

martor/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
class MartorModelAdmin(admin.ModelAdmin):
1111

1212
formfield_overrides = {
13-
MartorField: {'widget': AdminMartorWidget}
13+
MartorField: {"widget": AdminMartorWidget},
1414
}

martor/api.py

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import json
55
import base64
66
import requests
7-
from .settings import (MARTOR_IMGUR_CLIENT_ID, MARTOR_IMGUR_API_KEY)
7+
from .settings import MARTOR_IMGUR_CLIENT_ID, MARTOR_IMGUR_API_KEY
88

99
requests.packages.urllib3.disable_warnings()
1010

@@ -15,35 +15,41 @@ def imgur_uploader(image):
1515
:param `image` is from `request.FILES['markdown-image-upload']`
1616
:return json response
1717
"""
18-
api_url = 'https://api.imgur.com/3/upload.json'
19-
headers = {'Authorization': 'Client-ID ' + MARTOR_IMGUR_CLIENT_ID}
18+
api_url = "https://api.imgur.com/3/upload.json"
19+
headers = {"Authorization": "Client-ID " + MARTOR_IMGUR_CLIENT_ID}
2020
response = requests.post(
2121
api_url,
2222
headers=headers,
2323
data={
24-
'key': MARTOR_IMGUR_API_KEY,
25-
'image': base64.b64encode(image.read()),
26-
'type': 'base64',
27-
'name': image.name
28-
}
24+
"key": MARTOR_IMGUR_API_KEY,
25+
"image": base64.b64encode(image.read()),
26+
"type": "base64",
27+
"name": image.name,
28+
},
2929
)
3030

3131
if response.status_code == 200:
32-
response_data = json.loads(response.content.decode('utf-8'))
33-
return json.dumps({
34-
'status': response_data['status'],
35-
'link': response_data['data']['link'],
36-
'name': response_data['data']['name']
37-
})
32+
response_data = json.loads(response.content.decode("utf-8"))
33+
return json.dumps(
34+
{
35+
"status": response_data["status"],
36+
"link": response_data["data"]["link"],
37+
"name": response_data["data"]["name"],
38+
}
39+
)
3840

3941
elif response.status_code == 415:
4042
# Unsupport File type
41-
return json.dumps({
42-
'status': response.status_code,
43-
'error': response.reason
44-
})
43+
return json.dumps(
44+
{
45+
"status": response.status_code,
46+
"error": response.reason,
47+
}
48+
)
4549

46-
return json.dumps({
47-
'status': response.status_code,
48-
'error': response.content.decode('utf-8')
49-
})
50+
return json.dumps(
51+
{
52+
"status": response.status_code,
53+
"error": response.content.decode("utf-8"),
54+
}
55+
)

martor/extensions/del_ins.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ class DelInsExtension(markdown.extensions.Extension):
3939
"""Adds del_ins extension to Markdown class."""
4040

4141
def extendMarkdown(self, md, md_globals):
42-
del_tag = SimpleTagPattern(DEL_RE, 'del')
43-
ins_tag = SimpleTagPattern(INS_RE, 'ins')
44-
md.inlinePatterns.add('del', del_tag, '<not_strong')
45-
md.inlinePatterns.add('ins', ins_tag, '<not_strong')
42+
del_tag = SimpleTagPattern(DEL_RE, "del")
43+
ins_tag = SimpleTagPattern(INS_RE, "ins")
44+
md.inlinePatterns.add("del", del_tag, "<not_strong")
45+
md.inlinePatterns.add("ins", ins_tag, "<not_strong")
4646

4747

4848
def makeExtension(*args, **kwargs):
@@ -51,4 +51,5 @@ def makeExtension(*args, **kwargs):
5151

5252
if __name__ == "__main__":
5353
import doctest
54+
5455
doctest.testmod()

0 commit comments

Comments
 (0)