Skip to content

Commit baa4c93

Browse files
authored
Merge pull request #136 from agusmakmun/theming
support bootstrap theme
2 parents 54aed6d + 29ac090 commit baa4c93

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2312
-287
lines changed
15 KB
Loading
35.3 KB
Loading
184 KB
Loading

README.rst

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ martor |pypi version|
1111
.. image:: https://img.shields.io/pypi/pyversions/martor.svg
1212
:target: https://pypi.python.org/pypi/martor
1313

14-
.. image:: https://img.shields.io/badge/Django-1.8%20%3E=%203.0-green.svg
14+
.. image:: https://img.shields.io/badge/Django-1.8%20%3E=%203.1-green.svg
1515
:target: https://www.djangoproject.com
1616

1717
.. image:: https://travis-ci.org/agusmakmun/django-markdown-editor.svg?branch=master
@@ -25,8 +25,8 @@ Features
2525

2626
* Live Preview
2727
* Integrated with `Ace Editor`_
28-
* Integrated with `Semantic-UI`_
29-
* Supports Multiple Fields (`fixed this issue`_)
28+
* Supported with `Bootstrap`_ and `Semantic-UI`_
29+
* Supported Multiple Fields (`fixed this issue`_)
3030
* Upload Images to imgur.com `(via API)` and `custom uploader`_.
3131
* Direct Mention users ``@[username]`` - `(requires user to logged in)`
3232
* Supports embed/iframe video from (Youtube, Vimeo, Dailymotion, Yahoo, Veoh, & Metacafe)
@@ -41,9 +41,9 @@ Features
4141
Preview
4242
------------------------------
4343

44-
.. image:: https://raw.githubusercontent.com/agusmakmun/django-markdown-editor/master/.etc/images/martor-preview-editor.png
44+
.. image:: https://raw.githubusercontent.com/agusmakmun/django-markdown-editor/master/.etc/images/bootstrap/martor-editor.png
4545

46-
.. image:: https://raw.githubusercontent.com/agusmakmun/django-markdown-editor/master/.etc/images/martor-preview-result.png
46+
.. image:: https://raw.githubusercontent.com/agusmakmun/django-markdown-editor/master/.etc/images/bootstrap/martor-preview.png
4747

4848

4949
Requirements
@@ -110,6 +110,9 @@ to get ``IMGUR_CLIENT_ID`` and ``IMGUR_API_KEY``.
110110

111111
::
112112

113+
# Choices are: "semantic-ui", "bootstrap"
114+
MARTOR_THEME = 'bootstrap'
115+
113116
# Global martor settings
114117
# Input: string boolean, `true/false`
115118
MARTOR_ENABLE_CONFIGS = {
@@ -171,9 +174,9 @@ to get ``IMGUR_CLIENT_ID`` and ``IMGUR_API_KEY``.
171174

172175
# If you need to use your own themed semantic ui dependency
173176
# 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+
MARTOR_ALTERNATIVE_JS_FILE_THEME = "semantic-themed/semantic.min.js" # default None
178+
MARTOR_ALTERNATIVE_CSS_FILE_THEME = "semantic-themed/semantic.min.css" # default None
179+
MARTOR_ALTERNATIVE_JQUERY_JS_FILE = "jquery/dist/jquery.js" # default None
177180

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

@@ -265,7 +268,7 @@ Checkout at http://127.0.0.1:8000/simple-form/ on your browser.
265268
Martor Commands Reference
266269
--------------------------------
267270

268-
.. image:: https://raw.githubusercontent.com/agusmakmun/django-markdown-editor/master/.etc/images/martor-guide.png
271+
.. image:: https://raw.githubusercontent.com/agusmakmun/django-markdown-editor/master/.etc/images/bootstrap/martor-guide.png
269272

270273

271274
Notes
@@ -275,7 +278,8 @@ Notes
275278

276279

277280
.. _Ace Editor: https://ace.c9.io
278-
.. _Semantic-UI: http://semantic-ui.com
281+
.. _Bootstrap: https://getbootstrap.com
282+
.. _Semantic-UI: https://semantic-ui.com
279283
.. _PyPI: https://pypi.python.org/pypi/martor
280284
.. _django-markdownx: https://github.com/adi-/django-markdownx
281285
.. _Python Markdown: https://github.com/waylan/Python-Markdown

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.5.1'
3+
__VERSION__ = '1.5.2'
44
__AUTHOR__ = 'Agus Makmun (Summon Agus)'
55
__AUTHOR_EMAIL__ = '[email protected]'

martor/admin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
14
from django.contrib import admin
25
from django.db import models
36

martor/api.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
14
import json
25
import base64
36
import requests
@@ -10,15 +13,12 @@ def imgur_uploader(image):
1013
"""
1114
Basic imgur uploader return as json data.
1215
:param `image` is from `request.FILES['markdown-image-upload']`
13-
14-
Return:
15-
success: {'status': 200, 'link': <link_image>, 'name': <image_name>}
16-
error : {'status': <error_code>, 'erorr': <erorr_message>}
16+
:return json response
1717
"""
18-
url_api = 'https://api.imgur.com/3/upload.json'
18+
api_url = 'https://api.imgur.com/3/upload.json'
1919
headers = {'Authorization': 'Client-ID ' + MARTOR_IMGUR_CLIENT_ID}
2020
response = requests.post(
21-
url_api,
21+
api_url,
2222
headers=headers,
2323
data={
2424
'key': MARTOR_IMGUR_API_KEY,
@@ -28,26 +28,21 @@ def imgur_uploader(image):
2828
}
2929
)
3030

31-
"""
32-
Some function we got from `response`:
33-
34-
['connection', 'content', 'cookies', 'elapsed', 'encoding', 'headers','history',
35-
'is_permanent_redirect', 'is_redirect', 'iter_content', 'iter_lines', 'json',
36-
'links', 'ok', 'raise_for_status', 'raw', 'reason', 'request', 'status_code', 'text', 'url']
37-
"""
3831
if response.status_code == 200:
39-
respdata = json.loads(response.content.decode('utf-8'))
32+
response_data = json.loads(response.content.decode('utf-8'))
4033
return json.dumps({
41-
'status': respdata['status'],
42-
'link': respdata['data']['link'],
43-
'name': respdata['data']['name']
34+
'status': response_data['status'],
35+
'link': response_data['data']['link'],
36+
'name': response_data['data']['name']
4437
})
38+
4539
elif response.status_code == 415:
4640
# Unsupport File type
4741
return json.dumps({
4842
'status': response.status_code,
4943
'error': response.reason
5044
})
45+
5146
return json.dumps({
5247
'status': response.status_code,
5348
'error': response.content.decode('utf-8')

0 commit comments

Comments
 (0)