Skip to content

Commit c4420eb

Browse files
authored
Merge pull request #131 from KayleeTheMech/master
Alternative Version of Semantic and JQuery
2 parents 4c6143a + 038942d commit c4420eb

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

README.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ to get ``IMGUR_CLIENT_ID`` and ``IMGUR_API_KEY``.
169169
MARTOR_MARKDOWN_BASE_EMOJI_URL = 'https://github.githubassets.com/images/icons/emoji/' # default from github
170170
MARTOR_MARKDOWN_BASE_MENTION_URL = 'https://python.web.id/author/' # please change this to your domain
171171

172+
# If you need to use your own themed semantic ui dependency
173+
# replace the values with the file in your static files dir
174+
MARTOR_ALTERNATIVE_SEMANTIC_JS_FILE = "semantic-themed/semantic.min.js"
175+
MARTOR_ALTERNATIVE_SEMANTIC_CSS_FILE = "semantic-themed/semantic.min.css"
176+
MARTOR_ALTERNATIVE_JQUERY_JS_FILE = "jquery/dist/jquery.js"
177+
172178
Check this setting is not set else csrf will not be sent over ajax calls:
173179

174180
::

martor/settings.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
'living': 'false', # to enable/disable live updates in preview
1212
'spellcheck': 'false', # to enable/disable spellcheck in form textareas
1313
'hljs': 'true', # to enable/disable hljs highlighting in preview
14+
'semantic': 'true', # to enable/disable using packaged semantic version
1415
}
1516
)
1617

@@ -29,6 +30,16 @@
2930
settings, 'MARTOR_ENABLE_LABEL', False
3031
)
3132

33+
MARTOR_ALTERNATIVE_SEMANTIC_JS_FILE = getattr(
34+
settings, 'MARTOR_ALTERNATIVE_SEMANTIC_JS_FILE', None
35+
)
36+
MARTOR_ALTERNATIVE_SEMANTIC_CSS_FILE = getattr(
37+
settings, 'MARTOR_ALTERNATIVE_SEMANTIC_CSS_FILE', None
38+
)
39+
MARTOR_ALTERNATIVE_JQUERY_JS_FILE = getattr(
40+
settings, 'MARTOR_ALTERNATIVE_JQUERY_JS_FILE', None
41+
)
42+
3243
# Imgur API Keys
3344
MARTOR_IMGUR_CLIENT_ID = getattr(
3445
settings, 'MARTOR_IMGUR_CLIENT_ID', ''

martor/widgets.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
MARTOR_MARKDOWNIFY_URL,
99
MARTOR_SEARCH_USERS_URL,
1010
MARTOR_MARKDOWN_BASE_EMOJI_URL,
11-
MARTOR_TOOLBAR_BUTTONS
11+
MARTOR_TOOLBAR_BUTTONS,
12+
MARTOR_ALTERNATIVE_SEMANTIC_JS_FILE,
13+
MARTOR_ALTERNATIVE_SEMANTIC_CSS_FILE,
14+
MARTOR_ALTERNATIVE_JQUERY_JS_FILE
1215
)
1316

1417

@@ -56,15 +59,13 @@ class Media:
5659
css = {
5760
'all': (
5861
'plugins/css/ace.min.css',
59-
'plugins/css/semantic.min.css',
6062
'plugins/css/resizable.min.css',
6163
'martor/css/martor.min.css',
6264
'martor/css/martor-admin.min.css'
6365
)
6466
}
6567
js = (
6668
'plugins/js/ace.js',
67-
'plugins/js/semantic.min.js',
6869
'plugins/js/mode-markdown.js',
6970
'plugins/js/ext-language_tools.js',
7071
'plugins/js/theme-github.js',
@@ -74,12 +75,24 @@ class Media:
7475
'martor/js/martor.min.js',
7576
)
7677

78+
if MARTOR_ALTERNATIVE_SEMANTIC_CSS_FILE is None:
79+
css["all"] = ('plugins/css/semantic.min.css',).__add__(css.get('all'))
80+
else:
81+
css["all"] = (MARTOR_ALTERNATIVE_SEMANTIC_CSS_FILE,).__add__(css.get('all'))
82+
7783
if MARTOR_ENABLE_CONFIGS.get('spellcheck') == 'true':
7884
# Adding the following scripts to the end of the tuple in case it affects behaviour
7985
js = ('plugins/js/typo.js', 'plugins/js/spellcheck.js').__add__(js)
8086

87+
if MARTOR_ALTERNATIVE_SEMANTIC_JS_FILE is None:
88+
js = ('plugins/js/semantic.min.js',).__add__(js)
89+
else:
90+
js = (MARTOR_ALTERNATIVE_SEMANTIC_JS_FILE,).__add__(js)
91+
8192
if MARTOR_ENABLE_CONFIGS.get('jquery') == 'true':
8293
js = ('plugins/js/jquery.min.js',).__add__(js)
94+
elif MARTOR_ALTERNATIVE_JQUERY_JS_FILE:
95+
js = (MARTOR_ALTERNATIVE_JQUERY_JS_FILE,).__add__(js)
8396

8497

8598
class AdminMartorWidget(MartorWidget, widgets.AdminTextareaWidget):

0 commit comments

Comments
 (0)