mirror of
https://github.com/Hopiu/django-markdownx.git
synced 2026-04-28 17:04:43 +00:00
Documentations.
This commit is contained in:
parent
8120d067b2
commit
ea677caafb
26 changed files with 1015 additions and 0 deletions
20
docs/Makefile
Normal file
20
docs/Makefile
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# Minimal makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
SPHINXBUILD = sphinx-build
|
||||
SPHINXPROJ = DjangoMarkdownx
|
||||
SOURCEDIR = src
|
||||
BUILDDIR = build
|
||||
|
||||
# Put it first so that "make" without argument is like "make help".
|
||||
help:
|
||||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
||||
.PHONY: help Makefile
|
||||
|
||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||
%: Makefile
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
14
docs/create_docs.sh
Executable file
14
docs/create_docs.sh
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Compile the docs.
|
||||
make clean
|
||||
make html
|
||||
|
||||
# Open in the browser.
|
||||
URL="build/html/index.html"
|
||||
|
||||
echo "Documentations index file: $URL"
|
||||
|
||||
[[ -x $BROWSER ]] && exec "$BROWSER" "$URL"
|
||||
path=$(which xdg-open || which gnome-open || which open) && exec "$path" "$URL"
|
||||
echo "Couldn't find a browser."
|
||||
44
docs/src/_ext/edit_on_github.py
Normal file
44
docs/src/_ext/edit_on_github.py
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
"""
|
||||
Sphinx extension to add ReadTheDocs-style "Edit on GitHub" links to the
|
||||
sidebar.
|
||||
Loosely based on https://github.com/astropy/astropy/pull/347
|
||||
"""
|
||||
|
||||
import os
|
||||
import warnings
|
||||
|
||||
|
||||
__licence__ = 'BSD (3 clause)'
|
||||
|
||||
|
||||
def get_github_url(app, view, path):
|
||||
return 'https://github.com/{project}/{view}/{branch}/{path}'.format(
|
||||
project=app.config.edit_on_github_project,
|
||||
view=view,
|
||||
branch=app.config.edit_on_github_branch,
|
||||
path=path
|
||||
)
|
||||
|
||||
|
||||
def html_page_context(app, pagename, templatename, context, doctree):
|
||||
if templatename != 'page.html':
|
||||
return None
|
||||
|
||||
if not app.config.edit_on_github_project:
|
||||
warnings.warn("edit_on_github_project not specified")
|
||||
return None
|
||||
|
||||
path = os.path.relpath(doctree.get('source'), app.builder.srcdir)
|
||||
show_url = get_github_url(app, 'blob', path)
|
||||
edit_url = get_github_url(app, 'edit', path)
|
||||
|
||||
context['show_on_github_url'] = show_url
|
||||
context['edit_on_github_url'] = edit_url
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def setup(app):
|
||||
app.add_config_value('edit_on_github_project', '', True)
|
||||
app.add_config_value('edit_on_github_branch', 'master', True)
|
||||
app.connect('html-page-context', html_page_context)
|
||||
BIN
docs/src/_static/osi.png
Normal file
BIN
docs/src/_static/osi.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9 KiB |
17
docs/src/_templates/sourcelink.html
Normal file
17
docs/src/_templates/sourcelink.html
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<!--Created by: Pouria Hadjibagheri-->
|
||||
|
||||
{%- if show_source and has_source and sourcename %}
|
||||
<h3>{{ _('This Page') }}</h3>
|
||||
<ul class="this-page-menu">
|
||||
<li><a href="{{ pathto('_sources/' + sourcename, true)|e }}"
|
||||
rel="nofollow">{{ _('Show Source') }}</a></li>
|
||||
{%- if show_on_github_url %}
|
||||
<li><a href="{{ show_on_github_url }}"
|
||||
rel="nofollow">{{ _('Show on GitHub') }}</a></li>
|
||||
{%- endif %}
|
||||
{%- if edit_on_github_url %}
|
||||
<li><a href="{{ edit_on_github_url }}"
|
||||
rel="nofollow">{{ _('Edit on GitHub') }}</a></li>
|
||||
{%- endif %}
|
||||
</ul>
|
||||
{%- endif %}
|
||||
17
docs/src/_templates/sourcelink.html.py
Normal file
17
docs/src/_templates/sourcelink.html.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
XXXXXXXXXXX XXX XXXXXX XXXXXXXXXXXXXXX
|
||||
|
||||
B BB BBBBBBBBBBB BBB BBBBBBBBBB BBB BBBBBBBBBB
|
||||
XXXX _('This Page') XXXXX
|
||||
XXX XXXXXXXXXXXXXXXXXXXXXXX
|
||||
XXXXXX XXXXXXFX
|
||||
XXXXXXXXXXXXXXX _('Show Source') XXXXXXXXX
|
||||
B BB BBBBBBBBBBBBBBBBBB
|
||||
XXXXXX XXXXXXX
|
||||
XXXXXXXXXXXXXXX _('Show on GitHub') XXXXXXXXX
|
||||
B BBBBB
|
||||
B BB BBBBBBBBBBBBBBBBBB
|
||||
XXXXXX XXXXXXX
|
||||
XXXXXXXXXXXXXXX _('Edit on GitHub') XXXXXXXXX
|
||||
B BBBBB
|
||||
XXXXX
|
||||
B BBBBB
|
||||
1
docs/src/_themes/sphinx_rtd_theme
Submodule
1
docs/src/_themes/sphinx_rtd_theme
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit dcd1ad7dd60e301cf23b0ed006c24613085ad720
|
||||
148
docs/src/conf.py
Normal file
148
docs/src/conf.py
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Django Markdownx documentation build configuration file, created by
|
||||
# sphinx-quickstart on Fri Mar 10 22:41:38 2017.
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its
|
||||
# containing dir.
|
||||
#
|
||||
# Note that not all possible configuration values are present in this
|
||||
# autogenerated file.
|
||||
#
|
||||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
|
||||
from os import path
|
||||
import sys
|
||||
from datetime import datetime
|
||||
from re import compile as re_compile, MULTILINE
|
||||
|
||||
sys.path.insert(0, path.abspath(path.join(path.pardir, path.pardir)))
|
||||
sys.path.insert(0, path.abspath('_ext'))
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
'sphinx.ext.autodoc',
|
||||
'sphinx.ext.coverage',
|
||||
'sphinx.ext.mathjax',
|
||||
'sphinx.ext.viewcode',
|
||||
'sphinx.ext.githubpages',
|
||||
'classycode',
|
||||
'sphinxcontrib.autoanysrc',
|
||||
# 'edit_on_github'
|
||||
]
|
||||
|
||||
templates_path = ['_templates']
|
||||
html_theme_path = ['_themes']
|
||||
html_static_path = ['_static']
|
||||
source_suffix = '.rst'
|
||||
pygments_style = 'sphinx'
|
||||
html_theme = 'sphinx_rtd_theme'
|
||||
language = None
|
||||
exclude_patterns = []
|
||||
todo_include_todos = False
|
||||
html_theme_options = {}
|
||||
htmlhelp_basename = 'DjangoMarkdownxdoc'
|
||||
master_doc = 'index'
|
||||
|
||||
# sphinxcontrib-srclinks extension settings:
|
||||
edit_on_github_project = 'adi-/django-markdownx'
|
||||
edit_on_github_branch = 'master'
|
||||
|
||||
# General information about the project.
|
||||
project = 'Django Markdownx'
|
||||
copyright = '{:%Y} - Adi, Pouria Hadjibagheri'.format(datetime.now())
|
||||
author = 'Adi, Pouria Hadjibagheri'
|
||||
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
(
|
||||
master_doc,
|
||||
'DjangoMarkdownx.tex',
|
||||
'Django Markdownx Documentation',
|
||||
'Adi, Pouria Hadjibagheri',
|
||||
'manual'
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
# -- Options for manual page output ---------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
(
|
||||
master_doc,
|
||||
'djangomarkdownx',
|
||||
'Django Markdownx Documentation',
|
||||
[author],
|
||||
1
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
# -- Options for Texinfo output -------------------------------------------
|
||||
|
||||
# Grouping the document tree into Texinfo files. List of tuples
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(
|
||||
master_doc,
|
||||
'DjangoMarkdownx',
|
||||
'Django Markdownx Documentation',
|
||||
author,
|
||||
'DjangoMarkdownx',
|
||||
'A comprehensive Markdown editor built for Django.',
|
||||
'Miscellaneous'
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
# -- Options for LaTeX output ---------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
'papersize': 'a4paper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
'pointsize': '12pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
# 'preamble': '',
|
||||
|
||||
# Latex figure (float) alignment
|
||||
# 'figure_align': 'htbp',
|
||||
}
|
||||
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
doc_paths = path.split(path.dirname(__file__))[0]
|
||||
init_file = path.join(doc_paths, path.pardir, 'markdownx', '__init__.py')
|
||||
pattern = re_compile(r"^__version__.+[\'\"](?P<version>(.+))[\'\"][.\n]?$", MULTILINE)
|
||||
|
||||
with open(init_file, mode='r') as dt:
|
||||
found = pattern.search(dt.read())
|
||||
if found:
|
||||
_version = found.group('version')
|
||||
|
||||
version = str.join('.', _version.split('.')[:2])
|
||||
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = str.join('.', _version.split('.')[2:])
|
||||
142
docs/src/customization.rst
Normal file
142
docs/src/customization.rst
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
Customization
|
||||
=============
|
||||
|
||||
|
||||
Settings
|
||||
--------
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
INSTALLED_APPS = (
|
||||
# [...]
|
||||
'markdownx',
|
||||
)
|
||||
|
||||
|
||||
You may place and alter any of you the variables as follows in your :guilabel:`settings.py` to override default
|
||||
behaviours.
|
||||
|
||||
----
|
||||
|
||||
Customization
|
||||
-------------
|
||||
|
||||
All customizations concerning the back-end behaviour of **MarkdownX** may be applied from the :guilabel:`settings.py`
|
||||
file.
|
||||
|
||||
Markdownify
|
||||
...........
|
||||
Default function that compiles markdown using defined extensions. Using custom function can allow you to
|
||||
pre-process or post-process markdown text. See below for more info.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
MARKDOWNX_MARKDOWNIFY_FUNCTION = 'markdownx.utils.markdownify'
|
||||
|
||||
Markdown Extensions
|
||||
...................
|
||||
|
||||
List of Markdown extensions that you would like to use. See below for additional information.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
MARKDOWNX_MARKDOWN_EXTENSIONS = []
|
||||
|
||||
|
||||
Configuration object for used markdown extensions.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
MARKDOWNX_MARKDOWN_EXTENSION_CONFIGS = {}
|
||||
|
||||
Markdown URLs
|
||||
.............
|
||||
|
||||
URL that trans-compiles the Markdown text and returns HTML.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
MARKDOWNX_URLS_PATH = '/markdownx/markdownify/'
|
||||
|
||||
URL that accepts file uploads (images) and returns markdown formatted text for the image.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
MARKDOWNX_UPLOAD_URLS_PATH = '/markdownx/upload/'
|
||||
|
||||
Media Path
|
||||
..........
|
||||
|
||||
Path, where images will be stored in :guilabel:`MEDIA_ROOT` folder.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
MARKDOWNX_MEDIA_PATH = 'markdownx/'
|
||||
|
||||
Image
|
||||
.....
|
||||
|
||||
Maximum image size allowed in bytes: Default is 50MB, which is equal to 52,428,800 bytes.
|
||||
|
||||
.. tip::
|
||||
It is considered a good practice to display large numbers in a meaningful way. For instance, 52,438,800 bytes is
|
||||
better displayed in code as ``= 50 * 1024 * 1024 # 50 MB in bytes`` instead.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
MARKDOWNX_UPLOAD_MAX_SIZE = 50 * 1024 * 1024
|
||||
|
||||
Acceptable file content types (image formats):
|
||||
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
MARKDOWNX_UPLOAD_CONTENT_TYPES = ['image/jpeg', 'image/png', 'image/svg+xml']
|
||||
|
||||
Different options describing final image processing; e.g. size and compression.
|
||||
|
||||
.. Note::
|
||||
Quality restrictions do not apply to ``image/svg+xml`` formatted graphics.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
MARKDOWNX_IMAGE_MAX_SIZE = {'size': (500, 500), 'quality': 90,}
|
||||
|
||||
Security
|
||||
........
|
||||
SVG graphics are in essence XML files formatted in a specific way; which means that they can contain JavaScript codes.
|
||||
This introduces a potential front-end security vulnerability for prospective users who will see the SVG image in
|
||||
context; e.g. it may be employed to collect the user's IP address or other personal information.
|
||||
|
||||
.. Note::
|
||||
This type of attack is known as `XSS (Cross-site
|
||||
Scripting) attack <https://www.owasp.org/index.php/Cross-site_Scripting_(XSS)>`_.
|
||||
See `this presentation <https://www.owasp.org/images/0/03/Mario_Heiderich_OWASP_Sweden_The_image_that_called_me.pdf>`_
|
||||
by Mario Heiderich to learn more on SVG XSS attacks. There are a number of ways to deal with this vulnerability.
|
||||
|
||||
Django is great at security, and provides very good protection against XSS attacks (see the
|
||||
`documentations <https://docs.djangoproject.com/en/dev/topics/security/#cross-site-scripting-xss-protection>`_ for
|
||||
additional information) providing the
|
||||
`CSRF protection middleware <https://docs.djangoproject.com/en/dev/ref/middleware/#module-django.middleware.csrf>`_
|
||||
is enabled. When it comes to AJAX requests, however, CSRF protection may sometimes be disabled for various reasons.
|
||||
|
||||
.. Important::
|
||||
MarkdownX does *not* disable CSRF protection by default.
|
||||
|
||||
|
||||
As a last resort, however, we have included an *optional* integrity check against JavaScript tags for SVG
|
||||
formatted files just in case everything else is disabled. This protection is enabled by default, and may be disabled
|
||||
by setting the value to ``False`` if so is desired.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
MARKDOWNX_SVG_JAVASCRIPT_PROTECTION = True
|
||||
|
||||
Editor
|
||||
......
|
||||
|
||||
Change the editor's height to match the height of the inner contents whilst typing:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
MARKDOWNX_EDITOR_RESIZABLE = True
|
||||
91
docs/src/example.rst
Normal file
91
docs/src/example.rst
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
Example
|
||||
=======
|
||||
|
||||
Model
|
||||
-----
|
||||
.. code-block:: python
|
||||
:linenos:
|
||||
|
||||
from markdownx.models import MarkdownxField
|
||||
|
||||
class MyModel(models.Model):
|
||||
myfield = MarkdownxField()
|
||||
|
||||
|
||||
... and then, include a form's required media in the template using ``{{ form.media }}``:
|
||||
|
||||
.. code-block:: html
|
||||
|
||||
<form method="POST" action="">{% csrf_token %}
|
||||
{{ form }}
|
||||
</form>
|
||||
|
||||
{{ form.media }}
|
||||
|
||||
|
||||
Form
|
||||
----
|
||||
.. code-block:: python
|
||||
:linenos:
|
||||
|
||||
from markdownx.fields import MarkdownxFormField
|
||||
|
||||
class MyForm(forms.Form):
|
||||
myfield = MarkdownxFormField()
|
||||
|
||||
|
||||
... and then, include a form's required media in the template using ``{{ form.media }}``:
|
||||
|
||||
.. code-block:: html
|
||||
|
||||
<form method="POST" action="">{% csrf_token %}
|
||||
{{ form }}
|
||||
</form>
|
||||
|
||||
{{ form.media }}
|
||||
|
||||
|
||||
Django Admin
|
||||
------------
|
||||
When using included ``MarkdowxModel`` class in your models, just use ``MarkdownxModelAdmin`` in
|
||||
your :guilabel:`admin.py` as follows:
|
||||
|
||||
.. code-block:: python
|
||||
:linenos:
|
||||
|
||||
from django.contrib import admin
|
||||
from markdownx.admin import MarkdownxModelAdmin
|
||||
from .models import MyModel
|
||||
|
||||
|
||||
admin.site.register(MyModel, MarkdownxModelAdmin)
|
||||
|
||||
|
||||
Field customization
|
||||
...................
|
||||
We have ensured that **MarkdownX** is fully extensible and provides a high degree of flexibility in development.
|
||||
|
||||
There are times that you may wish to Markdownify a different type field, or utilize your own customized model. To
|
||||
accommodate this, we have provided the tools to apply **MarkdownX** infrastructure to other fields through *Widgets*.
|
||||
|
||||
For instance, to apply **MarkdownX** to ``TextField`` instances in your Django Admins, you can override the default
|
||||
widget in the Admins module in :guilabel:`admin.py` of your Django App as follows:
|
||||
|
||||
.. code-block:: python
|
||||
:linenos:
|
||||
|
||||
from django.db import models
|
||||
from django.contrib import admin
|
||||
|
||||
from markdownx.widgets import AdminMarkdownxWidget
|
||||
|
||||
from .models import MyModel
|
||||
|
||||
|
||||
class MyModelAdmin(admin.ModelAdmin):
|
||||
formfield_overrides = {
|
||||
models.TextField: {'widget': AdminMarkdownxWidget},
|
||||
}
|
||||
|
||||
|
||||
admin.site.register(MyModel, MyModelAdmin)
|
||||
38
docs/src/getting_started.rst
Normal file
38
docs/src/getting_started.rst
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
Getting Started
|
||||
===============
|
||||
|
||||
1. Add ``'markdownx'`` to the ``INSTALLED_APPS`` in :guilabel:`settings.py` file:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
INSTALLED_APPS = (
|
||||
# [...]
|
||||
'markdownx',
|
||||
)
|
||||
|
||||
2. Add url pattern to the :guilabel:`urls.py` file:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
urlpatterns = [
|
||||
# [...]
|
||||
url(r'^markdownx/', include('markdownx.urls')),
|
||||
]
|
||||
|
||||
3. Collect included :guilabel:`markdownx.js` and :guilabel:`markdownx.css` (for Django Admin) to
|
||||
your :guilabel:`STATIC_ROOT` folder:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
python3 manage.py collectstatic
|
||||
|
||||
|
||||
.. tip::
|
||||
Don't forget to include jQuery (2.1 or later) in the html template file.
|
||||
|
||||
.. code-block:: html
|
||||
|
||||
<head>
|
||||
<!-- [...] -->
|
||||
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
|
||||
</head>
|
||||
62
docs/src/index.rst
Normal file
62
docs/src/index.rst
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
.. Django Markdownx documentation master file, created by
|
||||
sphinx-quickstart on Fri Mar 10 22:41:38 2017.
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
:github_url: https://github.com/adi-/django-markdownx
|
||||
|
||||
Django MarkdownX
|
||||
================
|
||||
|
||||
|PyPi_Status| |Build_Status| |Format| |Supported_versions_of_Python| |Supported_versions_of_Django| |License|
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<iframe src="https://ghbtns.com/github-btn.html?user=adi-&repo=django-markdownx&type=star&count=true"
|
||||
frameborder="0" scrolling="0" width="120px" height="20px"></iframe>
|
||||
<iframe src="https://ghbtns.com/github-btn.html?user=adi-&repo=django-markdownx&type=watch&count=true&v=2"
|
||||
frameborder="0" scrolling="0" width="120px" height="20px"></iframe>
|
||||
|
||||
.. |PyPi_Status| image:: https://img.shields.io/pypi/status/django-markdownx.svg
|
||||
.. |Build_Status| image:: https://img.shields.io/travis/adi-/django-markdownx.svg
|
||||
.. |Format| image:: https://img.shields.io/pypi/format/django-markdownx.svg
|
||||
.. |Supported_versions_of_Python| image:: https://img.shields.io/pypi/pyversions/django-markdownx.svg
|
||||
.. |Supported_versions_of_Django| image:: https://img.shields.io/badge/Django-1.8,%201.9,%201.10-green.svg
|
||||
.. |License| image:: https://img.shields.io/pypi/l/django-markdownx.svg
|
||||
|
||||
------------
|
||||
|
||||
|
||||
Documentations
|
||||
--------------
|
||||
**Welcome**
|
||||
|
||||
.. automodule:: markdownx
|
||||
|
||||
Contents
|
||||
--------
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:glob:
|
||||
|
||||
installation
|
||||
getting_started
|
||||
example
|
||||
customization
|
||||
translation
|
||||
js/js
|
||||
markdownx/markdownx
|
||||
license
|
||||
|
||||
* :ref:`modindex`
|
||||
* :ref:`genindex`
|
||||
* :ref:`search`
|
||||
|
||||
|
||||
Acknowledgements
|
||||
----------------
|
||||
We acknowledge and appreciate every contribution made towards improving **Django MarkdownX**, a list of which can be
|
||||
found on our `GitHub <https://github.com/adi-/django-markdownx/graphs/contributors>`_.
|
||||
|
||||
**Django MarkdownX** was inspired by the great `Django Images <https://github.com/mirumee/django-images>`_ and
|
||||
`Django Bootstrap Markdown <https://github.com/aj-may/django-bootstrap-markdown>`_ packages.
|
||||
41
docs/src/installation.rst
Normal file
41
docs/src/installation.rst
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
Installation
|
||||
============
|
||||
Using PIP
|
||||
---------
|
||||
Django MarkdownX may be installed directly using Python Package Index (PyPi):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
python3 -m pip install django-markdownx
|
||||
|
||||
|
||||
From the source
|
||||
---------------
|
||||
Should you wish to download and install it using the source code, you can do as follows:
|
||||
|
||||
.. Note::
|
||||
Make sure you have activated your virtual environment if you're using one.
|
||||
|
||||
We start off by downloading the source code from GitHub and navigate to the downloaded directory:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
git clone https://github.com/adi-/django-markdownx.git
|
||||
cd django-markdownx/
|
||||
|
||||
|
||||
Install the package.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
python3 setup.py install
|
||||
|
||||
|
||||
.. Tip::
|
||||
You can replace ``python3`` with ``python`` or any of |Supported_versions_of_Python| if
|
||||
you have multiple versions installed on your machine:
|
||||
|
||||
|
||||
.. |Supported_versions_of_Python| image:: https://img.shields.io/pypi/pyversions/django-markdownx.svg
|
||||
|
||||
.. automodule:: setup
|
||||
114
docs/src/js/docs.rst
Normal file
114
docs/src/js/docs.rst
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
:github_url: https://github.com/adi-/django-markdownx/tree/master/markdownx/static/markdownx/js
|
||||
|
||||
JavaScript Code
|
||||
---------------
|
||||
|
||||
.. js:function:: getCookie(name)
|
||||
|
||||
Looks for a cookie, and if found, returns the values.
|
||||
|
||||
.. Note::
|
||||
|
||||
Only the first item in the array is returned to eliminate the need for array deconstruction
|
||||
in the target.
|
||||
|
||||
.. Attention::
|
||||
|
||||
The function catches the **TypeError** and returns ``null`` if the ``name`` provided for the cookie is not
|
||||
found. A notification is then provided in the console to inform the developer that the requested cookie does
|
||||
not exist.
|
||||
|
||||
:param string name: The name of the cookie.
|
||||
:returns: Value of the cookie with the key ``name`` or ``null``.
|
||||
|
||||
|
||||
.. js:function:: preparePostData(data)
|
||||
|
||||
Creates a new instance of **FormData** to be used in AJAX calls.
|
||||
|
||||
:param Object data: Data to be embedded in the form in **JSON** format, where the *key* is the name/ID of the field
|
||||
whose values are to be altered/created and corresponds to ``dict`` keys in Django
|
||||
``request.POST``.
|
||||
|
||||
:param Boolean csrf: If ``true``, includes the CSRF token (under the name ``csrfmiddlewaretoken``) in the form.
|
||||
Default is ``true``.
|
||||
|
||||
:returns: A new instance **FormData** that incorporated the data embedded in ``data`` and the CSRF token in enabled.
|
||||
:return type: FormData
|
||||
|
||||
|
||||
.. js:class:: MarkdownX(editor, preview)
|
||||
|
||||
:param HTMLTextAreaElement editor: Markdown editor element.
|
||||
:param HTMLElement preview: Markdown preview element.
|
||||
|
||||
.. js:attribute:: editor
|
||||
|
||||
(*HTMLTextAreaElement*) Instance editor.
|
||||
|
||||
.. js:attribute:: preview
|
||||
|
||||
(*HMTLElement*) Instance preview.
|
||||
|
||||
.. js:attribute:: timeout
|
||||
|
||||
(*number* | *null*) Private property; timeout settings.
|
||||
|
||||
.. js:attribute:: _editorIsResizable
|
||||
|
||||
(*Boolean*) Private property; ``true`` if instance editor is resizable, otherwise ``false``.
|
||||
|
||||
.. js:function:: getEditorHeight(editor)
|
||||
|
||||
:param HTMLTextAreaElement editor: Markdown editor element.
|
||||
:returns: The editor's height in pixels; e.g. ``"150px"``.
|
||||
:return type: string
|
||||
|
||||
|
||||
.. js:function:: _markdownify()
|
||||
|
||||
Private settings for ``timeout``.
|
||||
|
||||
.. js:function:: _routineEventResponse()
|
||||
|
||||
Private routine tasks for event handlers (e.g. default preventions).
|
||||
|
||||
.. js:function:: inputChanged()
|
||||
|
||||
Event handlers in response to alterations in the instance editor.
|
||||
|
||||
.. js:function:: onDragEnter()
|
||||
|
||||
Event handler for :guilabel:`dragEnter` events.
|
||||
|
||||
.. js:function:: onDragLeave()
|
||||
|
||||
Event handler for :guilabel:`dragLeave` events.
|
||||
|
||||
.. js:function:: onDrop()
|
||||
|
||||
Event handler for :guilabel:`drop` events (in drag and drops).
|
||||
|
||||
.. js:function:: onKeyDown()
|
||||
|
||||
Event handler for :guilabel:`keyDown` events as registered in the instance editor.
|
||||
|
||||
.. js:function:: sendFile()
|
||||
|
||||
pass
|
||||
|
||||
.. js:function:: getMarkdown()
|
||||
|
||||
pass
|
||||
|
||||
.. js:function:: insertImage()
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
114
docs/src/js/events.rst
Normal file
114
docs/src/js/events.rst
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
Events
|
||||
======
|
||||
|
||||
Each **MarkdownX** jQuery object triggers a number of basic events. To handle events in JavaScript, you may
|
||||
take advantage of events listeners.
|
||||
|
||||
Events Reference
|
||||
----------------
|
||||
|
||||
+---------------------+-----------------------------------------+-------------------------------------------------------+
|
||||
| Event | JavaScript handler | Description |
|
||||
+=====================+=========================================+=======================================================+
|
||||
| Initialization | ``markdownx.init`` | Triggered after jQuery plugin init. |
|
||||
+---------------------+-----------------------------------------+-------------------------------------------------------+
|
||||
| Update | ``markdownx.update`` | Triggered when editor text is markdownified. |
|
||||
| | | |
|
||||
| | | Returns: **response** (*string*) |
|
||||
| | | variable containing markdownified text. |
|
||||
+---------------------+-----------------------------------------+-------------------------------------------------------+
|
||||
| Update error | ``markdownx.updateError`` | Triggered when a problem occurred during markdownify. |
|
||||
+---------------------+-----------------------------------------+-------------------------------------------------------+
|
||||
| Beginning to upload | ``markdownx.markdownx.fileUploadBegin`` | Triggered when the file is posted. |
|
||||
+---------------------+-----------------------------------------+-------------------------------------------------------+
|
||||
| File upload end | ``markdownx.fileUploadEnd`` | Triggered when the file has been uploaded. |
|
||||
+---------------------+-----------------------------------------+-------------------------------------------------------+
|
||||
| File upload error | ``markdownx.fileUploadError`` | Triggered if the upload didn't work. |
|
||||
+---------------------+-----------------------------------------+-------------------------------------------------------+
|
||||
|
||||
|
||||
----
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
.. Note::
|
||||
All examples use JQuery event listeners.
|
||||
|
||||
|
||||
Initialization
|
||||
``markdownx.init``
|
||||
|
||||
.. code-block:: javascript
|
||||
:linenos:
|
||||
|
||||
$('.markdownx').on('markdownx.init', function() {
|
||||
|
||||
console.log("init");
|
||||
|
||||
});
|
||||
|
||||
|
||||
Update
|
||||
``markdownx.update``
|
||||
|
||||
.. code-block:: javascript
|
||||
:linenos:
|
||||
|
||||
$('.markdownx').on('markdownx.update', function(e, response) {
|
||||
|
||||
console.info("Update " + response);
|
||||
|
||||
});
|
||||
|
||||
|
||||
Update error
|
||||
``markdownx.updateError``
|
||||
|
||||
.. code-block:: javascript
|
||||
:linenos:
|
||||
|
||||
$('.markdownx').on('markdownx.updateError', function(e) {
|
||||
|
||||
console.error("Update error.");
|
||||
|
||||
});
|
||||
|
||||
|
||||
Beginning to upload
|
||||
``markdownx.fileUploadBegin``
|
||||
|
||||
.. code-block:: javascript
|
||||
:linenos:
|
||||
|
||||
$('.markdownx').on('markdownx.fileUploadBegin', function(e) {
|
||||
|
||||
console.log("Uploading has started.");
|
||||
|
||||
});
|
||||
|
||||
|
||||
File upload end
|
||||
``markdownx.fileUploadEnd``
|
||||
|
||||
.. code-block:: javascript
|
||||
:linenos:
|
||||
|
||||
$('.markdownx').on('markdownx.fileUploadEnd', function(e) {
|
||||
|
||||
console.log("Uploading has ended.");
|
||||
|
||||
});
|
||||
|
||||
|
||||
File upload error
|
||||
``markdownx.fileUploadError``
|
||||
|
||||
.. code-block:: javascript
|
||||
:linenos:
|
||||
|
||||
$('.markdownx').on('markdownx.fileUploadError', function(e) {
|
||||
|
||||
console.error("Error during file upload.");
|
||||
|
||||
});
|
||||
39
docs/src/js/js.rst
Normal file
39
docs/src/js/js.rst
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
JavaScript
|
||||
==========
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:glob:
|
||||
|
||||
*
|
||||
|
||||
----
|
||||
|
||||
Compatibility
|
||||
-------------
|
||||
|
||||
We rely on JavaScript to handle front-end events (e.g. trans-compilation of Markdown to HTML, uploading image).
|
||||
|
||||
.. Note::
|
||||
**MarkdownX** currently supports browsers compatible with :guilabel:`ECMAScript 5` (approved in 2011), which
|
||||
includes all major browsers (see the details on `browser compatibilities`_).
|
||||
|
||||
|
||||
JQuery
|
||||
------
|
||||
Our JavaScript infrastructure relies heavily on `JQuery`_, and as such, it is essential that :guilabel:`JQuery 2.1` or
|
||||
later is included inside the ``<head>`` element of any pages in which **MarkdownX** fields are used.
|
||||
|
||||
.. Tip::
|
||||
You can include JQuery in your template by copying and pasting one of the links provided by `Google Developers`_
|
||||
content delivery network (CDN) in your template.
|
||||
|
||||
|
||||
.. Note::
|
||||
Django Admin includes JQuery by default. See `Django documentations`_ for additional information.
|
||||
|
||||
|
||||
.. _Django documentations: https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/javascript/#javascript-patches
|
||||
.. _JQuery: https://jquery.com
|
||||
.. _Google Developers: https://developers.google.com/speed/libraries/#jquery
|
||||
.. _browser compatibilities: https://kangax.github.io/compat-table/es5/
|
||||
32
docs/src/license.rst
Normal file
32
docs/src/license.rst
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
License
|
||||
-------
|
||||
|
||||
MarkdownX is licensed under the `2-clause BSD <https://opensource.org/licenses/BSD-2-Clause>`_
|
||||
license, and Open Source Initiative approved license.
|
||||
|
||||
|
||||
.. image:: _static/osi.png
|
||||
:alt: Open Source Initiative (OSI) Logo
|
||||
:align: center
|
||||
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
This software is provided by the copyright holders and contributors "as is" and
|
||||
any express or implied warranties, including, but not limited to, the implied
|
||||
warranties of merchantability and fitness for a particular purpose are
|
||||
disclaimed. in no event shall the copyright owner or contributors be liable for
|
||||
any direct, indirect, incidental, special, exemplary, or consequential damages
|
||||
(including, but not limited to, procurement of substitute goods or services;
|
||||
loss of use, data, or profits; or business interruption) however caused and
|
||||
on any theory of liability, whether in contract, strict liability, or tort
|
||||
(including negligence or otherwise) arising in any way out of the use of this
|
||||
software, even if advised of the possibility of such damage.
|
||||
6
docs/src/markdownx/admins.rst
Normal file
6
docs/src/markdownx/admins.rst
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
:github_url: https://github.com/adi-/django-markdownx/tree/master/markdownx/admin.py
|
||||
|
||||
Admin
|
||||
-----
|
||||
.. automodule:: markdownx.admin
|
||||
:members:
|
||||
7
docs/src/markdownx/exceptions.rst
Normal file
7
docs/src/markdownx/exceptions.rst
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
:github_url: https://github.com/adi-/django-markdownx/tree/master/markdownx/exceptions.py
|
||||
|
||||
|
||||
Exceptions
|
||||
----------
|
||||
.. automodule:: markdownx.exceptions
|
||||
:members:
|
||||
6
docs/src/markdownx/fields.rst
Normal file
6
docs/src/markdownx/fields.rst
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
:github_url: https://github.com/adi-/django-markdownx/tree/master/markdownx/fields.py
|
||||
|
||||
Fields
|
||||
------
|
||||
.. automodule:: markdownx.fields
|
||||
:members:
|
||||
9
docs/src/markdownx/forms.rst
Normal file
9
docs/src/markdownx/forms.rst
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
:github_url: https://github.com/adi-/django-markdownx/tree/master/markdownx/forms.py
|
||||
|
||||
|
||||
Form
|
||||
----
|
||||
|
||||
.. automodule:: markdownx.forms
|
||||
:members:
|
||||
|
||||
7
docs/src/markdownx/markdownx.rst
Normal file
7
docs/src/markdownx/markdownx.rst
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
MarkdownX Modules
|
||||
-----------------
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:glob:
|
||||
|
||||
*
|
||||
6
docs/src/markdownx/models.rst
Normal file
6
docs/src/markdownx/models.rst
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
:github_url: https://github.com/adi-/django-markdownx/tree/master/markdownx/models.py
|
||||
|
||||
Models
|
||||
------
|
||||
.. automodule:: markdownx.models
|
||||
:members:
|
||||
6
docs/src/markdownx/utilities.rst
Normal file
6
docs/src/markdownx/utilities.rst
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
:github_url: https://github.com/adi-/django-markdownx/tree/master/markdownx/utils.py
|
||||
|
||||
Utilities
|
||||
---------
|
||||
.. automodule:: markdownx.utils
|
||||
:members:
|
||||
6
docs/src/markdownx/views.rst
Normal file
6
docs/src/markdownx/views.rst
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
:github_url: https://github.com/adi-/django-markdownx/tree/master/markdownx/views.py
|
||||
|
||||
Views
|
||||
-----
|
||||
.. automodule:: markdownx.views
|
||||
:members:
|
||||
28
docs/src/translation.rst
Normal file
28
docs/src/translation.rst
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
:github_url: https://github.com/adi-/django-markdownx/tree/master/markdownx/locale
|
||||
|
||||
Translation
|
||||
===========
|
||||
|
||||
Django's strength is in its global community. Similarly, **MarkdownX** developers come from across the world too. We are
|
||||
therefore commit to make the plugin as inclusive as possible. To this end, we provide translation of all messages
|
||||
produced by **MarkdownX** to various languages.
|
||||
|
||||
|
||||
**Current languages**:
|
||||
|
||||
- English
|
||||
- Polish (Polski)
|
||||
- German (Deutsch)
|
||||
- French (Français)
|
||||
- Persian (فارسی)
|
||||
- Dutch (Nederlands)
|
||||
|
||||
|
||||
.. help:: Your language is not included?
|
||||
|
||||
Wanna contribute?
|
||||
Why not help us with the translation of messages? It's not really that long.
|
||||
|
||||
|
||||
Even more?
|
||||
Help us translate the documentations.
|
||||
Loading…
Reference in a new issue