forked from agusmakmun/django-markdown-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.py
235 lines (218 loc) · 5.77 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
from django.conf import settings
# Choices are: "semantic", "bootstrap"
MARTOR_THEME = getattr(settings, "MARTOR_THEME", "bootstrap")
# Global martor settings
# Input: string boolean, `true/false`
MARTOR_ENABLE_CONFIGS = getattr(
settings,
"MARTOR_ENABLE_CONFIGS",
{
"emoji": "true", # enable/disable emoji icons.
"imgur": "true", # enable/disable imgur/custom uploader.
"mention": "false", # enable/disable mention
"jquery": "true", # include/revoke jquery (require for admin django)
"living": "false", # enable/disable live updates in preview
"spellcheck": "false", # enable/disable spellcheck in form textareas
"hljs": "true", # enable/disable hljs highlighting in preview
},
)
# To show the toolbar buttons
MARTOR_TOOLBAR_BUTTONS = getattr(
settings,
"MARTOR_TOOLBAR_BUTTONS",
[
"bold",
"italic",
"horizontal",
"heading",
"pre-code",
"blockquote",
"unordered-list",
"ordered-list",
"link",
"image-link",
"image-upload",
"emoji",
"direct-mention",
"toggle-maximize",
"help",
],
)
# To setup the martor editor with title label or not (default is False)
MARTOR_ENABLE_LABEL = getattr(settings, "MARTOR_ENABLE_LABEL", False)
# Imgur API Keys
MARTOR_IMGUR_CLIENT_ID = getattr(settings, "MARTOR_IMGUR_CLIENT_ID", "")
MARTOR_IMGUR_API_KEY = getattr(settings, "MARTOR_IMGUR_API_KEY", "")
# Markdownify
MARTOR_MARKDOWNIFY_FUNCTION = getattr(
settings, "MARTOR_MARKDOWNIFY_FUNCTION", "martor.utils.markdownify"
)
MARTOR_MARKDOWNIFY_URL = getattr(
settings, "MARTOR_MARKDOWNIFY_URL", "/martor/markdownify/"
)
# Time to delay the markdownify ajax request, in millisecond.
MARTOR_MARKDOWNIFY_TIMEOUT = getattr(settings, "MARTOR_MARKDOWNIFY_TIMEOUT", 1000)
# Markdown extensions
MARTOR_MARKDOWN_EXTENSIONS = getattr(
settings,
"MARTOR_MARKDOWN_EXTENSIONS",
[
"markdown.extensions.extra",
"markdown.extensions.nl2br",
"markdown.extensions.smarty",
"markdown.extensions.fenced_code",
"markdown.extensions.sane_lists",
# Custom markdown extensions.
"martor.extensions.urlize",
"martor.extensions.del_ins", # ~~strikethrough~~ and ++underscores++
"martor.extensions.mention", # to parse markdown mention
"martor.extensions.emoji", # to parse markdown emoji
"martor.extensions.mdx_video", # to parse embed/iframe video
"martor.extensions.escape_html", # to handle the XSS vulnerabilities
"martor.extensions.mdx_add_id", # to parse id like {#this_is_id}
],
)
# Markdown Extensions Configs
MARTOR_MARKDOWN_EXTENSION_CONFIGS = getattr(
settings, "MARTOR_MARKDOWN_EXTENSION_CONFIGS", {}
)
# Markdown urls
MARTOR_UPLOAD_URL = (
# Allows to disable this endpoint
settings.MARTOR_UPLOAD_URL
if hasattr(settings, "MARTOR_UPLOAD_URL")
else "/martor/uploader/"
)
MARTOR_SEARCH_USERS_URL = (
# Allows to disable this endpoint
settings.MARTOR_SEARCH_USERS_URL
if hasattr(settings, "MARTOR_SEARCH_USERS_URL")
else "/martor/search-user/"
)
# Markdown Extensions
MARTOR_MARKDOWN_BASE_EMOJI_URL = (
# Allows to disable this endpoint
settings.MARTOR_MARKDOWN_BASE_EMOJI_URL
if hasattr(settings, "MARTOR_MARKDOWN_BASE_EMOJI_URL")
else "https://github.githubassets.com/images/icons/emoji/"
)
MARTOR_MARKDOWN_BASE_MENTION_URL = getattr(
settings,
"MARTOR_MARKDOWN_BASE_MENTION_URL",
"",
)
# If you need to use your own themed "bootstrap" or "semantic ui" dependency
# replace the values with the file in your static files dir
MARTOR_ALTERNATIVE_JS_FILE_THEME = getattr(
settings, "MARTOR_ALTERNATIVE_JS_FILE_THEME", None
)
MARTOR_ALTERNATIVE_CSS_FILE_THEME = getattr(
settings, "MARTOR_ALTERNATIVE_CSS_FILE_THEME", None
)
MARTOR_ALTERNATIVE_JQUERY_JS_FILE = getattr(
settings, "MARTOR_ALTERNATIVE_JQUERY_JS_FILE", None
)
# URL schemes that are allowed within links
ALLOWED_URL_SCHEMES = getattr(
settings,
"ALLOWED_URL_SCHEMES",
[
"file",
"ftp",
"ftps",
"http",
"https",
"irc",
"mailto",
"sftp",
"ssh",
"tel",
"telnet",
"tftp",
"vnc",
"xmpp",
],
)
# https://gist.github.com/mrmrs/7650266
ALLOWED_HTML_TAGS = getattr(
settings,
"ALLOWED_HTML_TAGS",
[
"a",
"abbr",
"b",
"blockquote",
"br",
"cite",
"code",
"command",
"dd",
"del",
"dl",
"dt",
"em",
"fieldset",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"hr",
"i",
"iframe",
"img",
"input",
"ins",
"kbd",
"label",
"legend",
"li",
"ol",
"optgroup",
"option",
"p",
"pre",
"small",
"span",
"strong",
"sub",
"sup",
"table",
"tbody",
"td",
"tfoot",
"th",
"thead",
"tr",
"u",
"ul",
],
)
# https://github.com/decal/werdlists/blob/master/html-words/html-attributes-list.txt
ALLOWED_HTML_ATTRIBUTES = getattr(
settings,
"ALLOWED_HTML_ATTRIBUTES",
[
"alt",
"class",
"color",
"colspan",
# "data",
"datetime",
"height",
"href",
"id",
"name",
"reversed",
"rowspan",
"scope",
"src",
"style",
"title",
"type",
"width",
],
)
# Disable admin style when using custom admin interface e.g django-grappelli
MARTOR_ENABLE_ADMIN_CSS = getattr(settings, "MARTOR_ENABLE_ADMIN_CSS", True)