Skip to content

Commit

Permalink
Possibility to use your own semantic version
Browse files Browse the repository at this point in the history
  • Loading branch information
KayleeTheMech committed Jul 30, 2020
1 parent acbfb58 commit ae74b93
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
5 changes: 4 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ to get ``IMGUR_CLIENT_ID`` and ``IMGUR_API_KEY``.
'living': 'false', # to enable/disable live updates in preview
'spellcheck': 'false', # to enable/disable spellcheck in form textareas
'hljs': 'true', # to enable/disable hljs highlighting in preview
'semantic': 'true', # to enable/disable the packaged semantic ui version
}

# To show the toolbar buttons
Expand Down Expand Up @@ -172,6 +171,10 @@ to get ``IMGUR_CLIENT_ID`` and ``IMGUR_API_KEY``.
MARTOR_MARKDOWN_BASE_EMOJI_URL = 'https://github.githubassets.com/images/icons/emoji/' # default from github
MARTOR_MARKDOWN_BASE_MENTION_URL = 'https://python.web.id/author/' # please change this to your domain

# If you need to use your own themed semantic ui dependency
MARTOR_ALTERNATIVE_SEMANTIC_JS_FILE = "semantic-themed/semantic.min.js"
MARTOR_ALTERNATIVE_SEMANTIC_CSS_FILE = "semantic-themed/semantic.min.css"

Check this setting is not set else csrf will not be sent over ajax calls:

::
Expand Down
7 changes: 7 additions & 0 deletions martor/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
settings, 'MARTOR_ENABLE_LABEL', False
)

MARTOR_ALTERNATIVE_SEMANTIC_JS_FILE = getattr(
settings, 'MARTOR_ALTERNATIVE_SEMANTIC_JS_FILE', None
)
MARTOR_ALTERNATIVE_SEMANTIC_CSS_FILE = getattr(
settings, 'MARTOR_ALTERNATIVE_SEMANTIC_CSS_FILE', None
)

# Imgur API Keys
MARTOR_IMGUR_CLIENT_ID = getattr(
settings, 'MARTOR_IMGUR_CLIENT_ID', ''
Expand Down
15 changes: 11 additions & 4 deletions martor/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
MARTOR_MARKDOWNIFY_URL,
MARTOR_SEARCH_USERS_URL,
MARTOR_MARKDOWN_BASE_EMOJI_URL,
MARTOR_TOOLBAR_BUTTONS
MARTOR_TOOLBAR_BUTTONS,
MARTOR_ALTERNATIVE_SEMANTIC_JS_FILE,
MARTOR_ALTERNATIVE_SEMANTIC_CSS_FILE
)


Expand Down Expand Up @@ -72,10 +74,15 @@ class Media:
'martor/js/martor.min.js',
)

if MARTOR_ENABLE_CONFIGS.get('semantic') == 'true':
# Allows to disable the included semantic version if a custom themed semantic version shouldn't be overriden
css["all"] = ('plugins/css/semantic.min.css',).__add__(css.get('all'))
if MARTOR_ALTERNATIVE_SEMANTIC_JS_FILE is None:
js = ('plugins/js/semantic.min.js',).__add__(js)
else:
js = (MARTOR_ALTERNATIVE_SEMANTIC_JS_FILE,).__add__(js)

if MARTOR_ALTERNATIVE_SEMANTIC_CSS_FILE is None:
css["all"] = ('plugins/css/semantic.min.css',).__add__(css.get('all'))
else:
css["all"] = (MARTOR_ALTERNATIVE_SEMANTIC_CSS_FILE,).__add__(css.get('all'))

if MARTOR_ENABLE_CONFIGS.get('spellcheck') == 'true':
# Adding the following scripts to the end of the tuple in case it affects behaviour
Expand Down

0 comments on commit ae74b93

Please sign in to comment.