diff --git a/CHANGELOG b/CHANGELOG index b10f90c..2aa76dc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +2018-09-10 TROUVERIE Joachim + * V 1.1 + * Update Doc 2016-02-28 TROUVERIE Joachim * V 1.0 * Wheel support diff --git a/README.rst b/README.rst index ae41fff..410b527 100644 --- a/README.rst +++ b/README.rst @@ -13,32 +13,32 @@ Example A simple example of how to use this module .. code:: python - - from flask.ext.wtf import Form - from flask.ext.codemirror.fields import CodeMirrorField + + from flask_wtf import FlaskForm + from flask_codemirror.fields import CodeMirrorField from wtforms.fields import SubmitField - - class MyForm(Form): - source_code = CodeMirrorField(language='python', config={'lineNumbers' : 'true'}) + + class MyForm(FlaskForm): + source_code = CodeMirrorField(language='python', config={'lineNumbers': 'true'}) submit = SubmitField('Submit') The `CodeMirrorField` works exactly like a `TextAreaField` .. code:: python - + @app.route('/', methods = ['GET', 'POST']) def index(): form = MyForm() if form.validate_on_submit(): text = form.source_code.data - return render_template('index.html', form = form) + return render_template('index.html', form=form) The module needs to be initialized in the usual way and can be configured using app.config keys .. code:: python - - from flask import Flask - from flask.ext.codemirror import CodeMirror + + from flask import Flask + from flask_codemirror import CodeMirror # mandatory CODEMIRROR_LANGUAGES = ['python', 'html'] WTF_CSRF_ENABLED = True @@ -46,7 +46,7 @@ The module needs to be initialized in the usual way and can be configured using # optional CODEMIRROR_THEME = '3024-day' CODEMIRROR_ADDONS = ( - ('ADDON_DIR','ADDON_NAME'), + ('ADDON_DIR','ADDON_NAME'), ) app = Flask(__name__) app.config.from_object(__name__) @@ -74,4 +74,3 @@ Finally, the template needs the support Javascript code added, by calling `codem The Javascript classes are imported from a CDN, there are no static files that need to be served by the application. - diff --git a/docs/index.rst b/docs/index.rst index f9225ee..735f66f 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,68 +1,68 @@ -Welcome to Flask-CodeMirror's documentation +Welcome to Flask-CodeMirror's documentation =========================================== -Implementation of source code editor for **Flask** and **Flask-WTF** -using **CodeMirror** Javascript library +Implementation of source code editor for **Flask** and **Flask-WTF** +using **CodeMirror** Javascript library -Installation +Installation ------------ .. code-block:: bash - - $ pip install flask-codemirror -Basic Example -------------- + $ pip install flask-codemirror + +Basic Example +------------- A simple example of how to use this module:: - from flask.ext.wtf import Form - from flask.ext.codemirror.fields import CodeMirrorField + from flask_wtf import FlaskForm + from flask_codemirror.fields import CodeMirrorField from wtforms.fields import SubmitField - class MyForm(Form): + class MyForm(FlaskForm): source_code = CodeMirrorField(language='python', config={'lineNumbers' : 'true'}) - submit = SubmitField('Submit') + submit = SubmitField('Submit') The ``CodeMirrorField`` works exactly like a ``TextAreaField``:: - + @app.route('/', methods = ['GET', 'POST']) def index(): form = MyForm() if form.validate_on_submit(): text = form.source_code.data - return render_template('index.html', form=form) + return render_template('index.html', form=form) The module needs to be initialized in the usual way and can be configured using ``app.config`` keys:: - - from flask.ext.codemirror import CodeMirror - + + from flask_codemirror import CodeMirror + SECRET_KEY = 'secret!' # mandatory CODEMIRROR_LANGUAGES = ['python', 'html'] # optional CODEMIRROR_THEME = '3024-day' CODEMIRROR_ADDONS = ( - ('display','placeholder'), + ('display','placeholder'), ) - + app = Flask(__name__) app.config.from_object(__name__) - codemirror = CodeMirror(app) + codemirror = CodeMirror(app) -The config ``CODEMIRROR_LANGUAGES`` needs to be initialized to load JavaScript. It defined all the languages you want to edit with your fields. If the field is not defined a ``CodeMirrorConfigException`` will be raised. +The config ``CODEMIRROR_LANGUAGES`` needs to be initialized to load JavaScript. It defined all the languages you want to edit with your fields. If the field is not defined a ``CodeMirrorConfigException`` will be raised. -The config ``CODEMIRROR_THEME`` is optional and is used to style your TextArea -using css from `CodeMirror website`_. +The config ``CODEMIRROR_THEME`` is optional and is used to style your TextArea +using css from `CodeMirror website`_. -The config ``CODEMIRROR_ADDONS`` is optional and can enable many cool options see `Codemirror Addons`_ for available addons. +The config ``CODEMIRROR_ADDONS`` is optional and can enable many cool options see `Codemirror Addons`_ for available addons. Finally, the template needs the support Javascript code added, by calling ``codemirror.include_codemirror()`` .. code-block:: html - + {{ codemirror.include_codemirror() }} @@ -72,32 +72,32 @@ Finally, the template needs the support Javascript code added, by calling ``code {{ form.source_code }} - + -The Javascript classes are imported from a CDN, there are no static files that need to be served by the application. +The Javascript classes are imported from a CDN, there are no static files that need to be served by the application. -API ---- +API +--- -.. automodule:: flask.ext.codemirror +.. automodule:: flask_codemirror .. autoclass:: CodeMirror - + .. automethod:: init_app - + .. autoclass:: CodeMirrorHeaders - + .. automethod:: include_codemirror - -.. automodule:: flask.ext.codemirror.fields + +.. automodule:: flask_codemirror.fields .. autoclass:: CodeMirrorField - -.. automodule:: flask.ext.codemirror.widgets + +.. automodule:: flask_codemirror.widgets .. autoclass:: CodeMirrorWidget - - .. automethod:: _generate_content + + .. automethod:: _generate_content .. _CodeMirror website: http://codemirror.net/theme/ .. _Codemirror Addons: http://codemirror.net/addon/ diff --git a/setup.py b/setup.py index 9b0a2db..e410ed8 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ """ from setuptools import setup -__version__ = '1.0' +__version__ = '1.1' __author__ = 'TROUVERIE Joachim' __contact__ = 'joachim.trouverie@linoame.fr'