diff options
| author | CoprDistGit <infra@openeuler.org> | 2023-05-05 13:44:53 +0000 |
|---|---|---|
| committer | CoprDistGit <infra@openeuler.org> | 2023-05-05 13:44:53 +0000 |
| commit | f80ab392679991c8af527ede23a207ba2c07421a (patch) | |
| tree | 4cf6e420c11be07f910b27855c8e030ddfb820ca | |
| parent | fc64db1ca18c91dda37be12af8a6f428a1d1ef03 (diff) | |
automatic import of python-django-mdeditoropeneuler20.03
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | python-django-mdeditor.spec | 750 | ||||
| -rw-r--r-- | sources | 1 |
3 files changed, 752 insertions, 0 deletions
@@ -0,0 +1 @@ +/django-mdeditor-0.1.20.tar.gz diff --git a/python-django-mdeditor.spec b/python-django-mdeditor.spec new file mode 100644 index 0000000..749c9f1 --- /dev/null +++ b/python-django-mdeditor.spec @@ -0,0 +1,750 @@ +%global _empty_manifest_terminate_build 0 +Name: python-django-mdeditor +Version: 0.1.20 +Release: 1 +Summary: A simple Django app to edit markdown text. +License: GPL-3.0 License +URL: https://github.com/pylixm/django-mdeditor +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/6b/57/407196a6f3bfe2c07bc710afb312bc47395823de55393068b5acf113ee2b/django-mdeditor-0.1.20.tar.gz +BuildArch: noarch + + +%description +# django-mdeditor + + +[](https://github.com/pylixm/django-mdeditor) +[](./README_CN.md) +[](https://gitter.im/django-mdeditor/Lobby) +[](https://github.com/pylixm/django-mdeditor) +[](https://github.com/pylixm/django-mdeditor) +[](https://github.com/pylixm/django-mdeditor/master/LICENSE.txt) + + + +**Django-mdeditor** is Markdown Editor plugin application for [django](djangoproject.com) base on [Editor.md](https://github.com/pandao/editor.md). + +**Django-mdeditor** was inspired by great [django-ckeditor](https://github.com/django-ckeditor/django-ckeditor). + +**Note:** + +- For Markdown page rendering issues, backend rendering is recommended. Because `Editor.md` has not been updated for a long time, some bugs and compatibility issues need to be debugged. Of course, front-end students can choose. +- Regarding the `Jquery` conflict, it cannot be deleted because it is required by the admin backend. It is recommended to separate the editing page on a single page or a full screen directly, using its own static file to distinguish it from other pages. + +## Features + +- Almost Editor.md features + - Support Standard Markdown / CommonMark and GFM (GitHub Flavored Markdown); + - Full-featured: Real-time Preview, Image (cross-domain) upload, Preformatted text/Code blocks/Tables insert, Search replace, Themes, Multi-languages; + - Markdown Extras : Support ToC (Table of Contents), Emoji; + - Support TeX (LaTeX expressions, Based on KaTeX), Flowchart and Sequence Diagram of Markdown extended syntax; +- Can constom Editor.md toolbar +- The MDTextField field is provided for the model and can be displayed directly in the django admin. +- The MDTextFormField is provided for the Form and ModelForm. +- The MDEditorWidget is provided for the Admin custom widget. + + +## Quick start + +- Installation. +```bash + pipenv install django-mdeditor + # or + pip install django-mdeditor +``` + +- Add `mdeditor` to your INSTALLED_APPS setting like this: +```python + INSTALLED_APPS = [ + ... + 'mdeditor', + ] +``` + +- add frame settings for django3.0+ like this: + +```python +X_FRAME_OPTIONS = 'SAMEORIGIN' +``` + +- Add 'media' url to your settings like this: +```python +MEDIA_ROOT = os.path.join(BASE_DIR, 'uploads') +MEDIA_URL = '/media/' + +``` +Make folder `uploads/editor` in you project for media files. + +- Add url to your urls like this: +```python +from django.conf.urls import url, include +from django.conf.urls.static import static +from django.conf import settings +... + +urlpatterns = [ + ... + url(r'mdeditor/', include('mdeditor.urls')) +] + +if settings.DEBUG: + # static files (images, css, javascript, etc.) + urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + +``` + +- Write your models like this: +```python +from django.db import models +from mdeditor.fields import MDTextField + +class ExampleModel(models.Model): + name = models.CharField(max_length=10) + content = MDTextField() +``` + +- Register your model in `admin.py` + +- Run `python manage.py makemigrations` and `python manage.py migrate` to create your models. + +- Login Admin ,you can see a markdown editor text field like this: + + + + +## Usage + +### Edit fields in the model using Markdown + +Using Markdown to edit the fields in the model, we simply replace the `TextField` of the model with` MDTextField`. + +```python +from django.db import models +from mdeditor.fields import MDTextField + +class ExampleModel (models.Model): + name = models.CharField (max_length = 10) + content = MDTextField () +``` + +Admin in the background, will automatically display markdown edit rich text. + +Used in front-end template, you can use like this: +```python +{% load staticfiles %} +<! DOCTYPE html> +<html lang = "en"> + <head> + <meta http-equiv = "Content-Type" content = "text / html; charset = utf-8" /> + + </ head> + <body> + <form method = "post" action = "./"> + {% csrf_token %} + {{ form.media }} + {{ form.as_p }} + <p> <input type = "submit" value = "post"> </ p> + </ form> + </ body> +</ html> + +``` + +### Edit fields in the Form using markdown + +Use markdown to edit fields in the Form, use `MDTextFormField` instead of` forms.CharField`, as follows: +```python +from mdeditor.fields import MDTextFormField + +class MDEditorForm (forms.Form): + name = forms.CharField () + content = MDTextFormField () +``` + +`ModelForm` can automatically convert the corresponding model field to the form field, which can be used normally: +```python +class MDEditorModleForm (forms.ModelForm): + + class Meta: + model = ExampleModel + fields = '__all__' +``` + +### Use the markdown widget in admin + +Use the markdown widget in admin like as : +```python +from django.contrib import admin +from django.db import models + +# Register your models here. +from. import models as demo_models +from mdeditor.widgets import MDEditorWidget + + +class ExampleModelAdmin (admin.ModelAdmin): + formfield_overrides = { + models.TextField: {'widget': MDEditorWidget} + } + + +admin.site.register (demo_models.ExampleModel, ExampleModelAdmin) +``` +### Customize the toolbar + +Add the following configuration to `settings`: +```python +MDEDITOR_CONFIGS = { + 'default':{ + 'width': '90% ', # Custom edit box width + 'height': 500, # Custom edit box height + 'toolbar': ["undo", "redo", "|", + "bold", "del", "italic", "quote", "ucwords", "uppercase", "lowercase", "|", + "h1", "h2", "h3", "h5", "h6", "|", + "list-ul", "list-ol", "hr", "|", + "link", "reference-link", "image", "code", "preformatted-text", "code-block", "table", "datetime", + "emoji", "html-entities", "pagebreak", "goto-line", "|", + "help", "info", + "||", "preview", "watch", "fullscreen"], # custom edit box toolbar + 'upload_image_formats': ["jpg", "jpeg", "gif", "png", "bmp", "webp"], # image upload format type + 'image_folder': 'editor', # image save the folder name + 'theme': 'default', # edit box theme, dark / default + 'preview_theme': 'default', # Preview area theme, dark / default + 'editor_theme': 'default', # edit area theme, pastel-on-dark / default + 'toolbar_autofixed': True, # Whether the toolbar capitals + 'search_replace': True, # Whether to open the search for replacement + 'emoji': True, # whether to open the expression function + 'tex': True, # whether to open the tex chart function + 'flow_chart': True, # whether to open the flow chart function + 'sequence': True, # Whether to open the sequence diagram function + 'watch': True, # Live preview + 'lineWrapping': False, # lineWrapping + 'lineNumbers': False, # lineNumbers + 'language': 'zh' # zh / en / es + } + +} +``` + +## Feedback + +Welcome to use and feedback! + +You can create a [issue](https://github.com/pylixm/django-mdeditor/issues) or join in QQ Group. + + + +## Reference + +- [django-ckeditor](https://github.com/django-ckeditor/django-ckeditor) + +%package -n python3-django-mdeditor +Summary: A simple Django app to edit markdown text. +Provides: python-django-mdeditor +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-django-mdeditor +# django-mdeditor + + +[](https://github.com/pylixm/django-mdeditor) +[](./README_CN.md) +[](https://gitter.im/django-mdeditor/Lobby) +[](https://github.com/pylixm/django-mdeditor) +[](https://github.com/pylixm/django-mdeditor) +[](https://github.com/pylixm/django-mdeditor/master/LICENSE.txt) + + + +**Django-mdeditor** is Markdown Editor plugin application for [django](djangoproject.com) base on [Editor.md](https://github.com/pandao/editor.md). + +**Django-mdeditor** was inspired by great [django-ckeditor](https://github.com/django-ckeditor/django-ckeditor). + +**Note:** + +- For Markdown page rendering issues, backend rendering is recommended. Because `Editor.md` has not been updated for a long time, some bugs and compatibility issues need to be debugged. Of course, front-end students can choose. +- Regarding the `Jquery` conflict, it cannot be deleted because it is required by the admin backend. It is recommended to separate the editing page on a single page or a full screen directly, using its own static file to distinguish it from other pages. + +## Features + +- Almost Editor.md features + - Support Standard Markdown / CommonMark and GFM (GitHub Flavored Markdown); + - Full-featured: Real-time Preview, Image (cross-domain) upload, Preformatted text/Code blocks/Tables insert, Search replace, Themes, Multi-languages; + - Markdown Extras : Support ToC (Table of Contents), Emoji; + - Support TeX (LaTeX expressions, Based on KaTeX), Flowchart and Sequence Diagram of Markdown extended syntax; +- Can constom Editor.md toolbar +- The MDTextField field is provided for the model and can be displayed directly in the django admin. +- The MDTextFormField is provided for the Form and ModelForm. +- The MDEditorWidget is provided for the Admin custom widget. + + +## Quick start + +- Installation. +```bash + pipenv install django-mdeditor + # or + pip install django-mdeditor +``` + +- Add `mdeditor` to your INSTALLED_APPS setting like this: +```python + INSTALLED_APPS = [ + ... + 'mdeditor', + ] +``` + +- add frame settings for django3.0+ like this: + +```python +X_FRAME_OPTIONS = 'SAMEORIGIN' +``` + +- Add 'media' url to your settings like this: +```python +MEDIA_ROOT = os.path.join(BASE_DIR, 'uploads') +MEDIA_URL = '/media/' + +``` +Make folder `uploads/editor` in you project for media files. + +- Add url to your urls like this: +```python +from django.conf.urls import url, include +from django.conf.urls.static import static +from django.conf import settings +... + +urlpatterns = [ + ... + url(r'mdeditor/', include('mdeditor.urls')) +] + +if settings.DEBUG: + # static files (images, css, javascript, etc.) + urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + +``` + +- Write your models like this: +```python +from django.db import models +from mdeditor.fields import MDTextField + +class ExampleModel(models.Model): + name = models.CharField(max_length=10) + content = MDTextField() +``` + +- Register your model in `admin.py` + +- Run `python manage.py makemigrations` and `python manage.py migrate` to create your models. + +- Login Admin ,you can see a markdown editor text field like this: + + + + +## Usage + +### Edit fields in the model using Markdown + +Using Markdown to edit the fields in the model, we simply replace the `TextField` of the model with` MDTextField`. + +```python +from django.db import models +from mdeditor.fields import MDTextField + +class ExampleModel (models.Model): + name = models.CharField (max_length = 10) + content = MDTextField () +``` + +Admin in the background, will automatically display markdown edit rich text. + +Used in front-end template, you can use like this: +```python +{% load staticfiles %} +<! DOCTYPE html> +<html lang = "en"> + <head> + <meta http-equiv = "Content-Type" content = "text / html; charset = utf-8" /> + + </ head> + <body> + <form method = "post" action = "./"> + {% csrf_token %} + {{ form.media }} + {{ form.as_p }} + <p> <input type = "submit" value = "post"> </ p> + </ form> + </ body> +</ html> + +``` + +### Edit fields in the Form using markdown + +Use markdown to edit fields in the Form, use `MDTextFormField` instead of` forms.CharField`, as follows: +```python +from mdeditor.fields import MDTextFormField + +class MDEditorForm (forms.Form): + name = forms.CharField () + content = MDTextFormField () +``` + +`ModelForm` can automatically convert the corresponding model field to the form field, which can be used normally: +```python +class MDEditorModleForm (forms.ModelForm): + + class Meta: + model = ExampleModel + fields = '__all__' +``` + +### Use the markdown widget in admin + +Use the markdown widget in admin like as : +```python +from django.contrib import admin +from django.db import models + +# Register your models here. +from. import models as demo_models +from mdeditor.widgets import MDEditorWidget + + +class ExampleModelAdmin (admin.ModelAdmin): + formfield_overrides = { + models.TextField: {'widget': MDEditorWidget} + } + + +admin.site.register (demo_models.ExampleModel, ExampleModelAdmin) +``` +### Customize the toolbar + +Add the following configuration to `settings`: +```python +MDEDITOR_CONFIGS = { + 'default':{ + 'width': '90% ', # Custom edit box width + 'height': 500, # Custom edit box height + 'toolbar': ["undo", "redo", "|", + "bold", "del", "italic", "quote", "ucwords", "uppercase", "lowercase", "|", + "h1", "h2", "h3", "h5", "h6", "|", + "list-ul", "list-ol", "hr", "|", + "link", "reference-link", "image", "code", "preformatted-text", "code-block", "table", "datetime", + "emoji", "html-entities", "pagebreak", "goto-line", "|", + "help", "info", + "||", "preview", "watch", "fullscreen"], # custom edit box toolbar + 'upload_image_formats': ["jpg", "jpeg", "gif", "png", "bmp", "webp"], # image upload format type + 'image_folder': 'editor', # image save the folder name + 'theme': 'default', # edit box theme, dark / default + 'preview_theme': 'default', # Preview area theme, dark / default + 'editor_theme': 'default', # edit area theme, pastel-on-dark / default + 'toolbar_autofixed': True, # Whether the toolbar capitals + 'search_replace': True, # Whether to open the search for replacement + 'emoji': True, # whether to open the expression function + 'tex': True, # whether to open the tex chart function + 'flow_chart': True, # whether to open the flow chart function + 'sequence': True, # Whether to open the sequence diagram function + 'watch': True, # Live preview + 'lineWrapping': False, # lineWrapping + 'lineNumbers': False, # lineNumbers + 'language': 'zh' # zh / en / es + } + +} +``` + +## Feedback + +Welcome to use and feedback! + +You can create a [issue](https://github.com/pylixm/django-mdeditor/issues) or join in QQ Group. + + + +## Reference + +- [django-ckeditor](https://github.com/django-ckeditor/django-ckeditor) + +%package help +Summary: Development documents and examples for django-mdeditor +Provides: python3-django-mdeditor-doc +%description help +# django-mdeditor + + +[](https://github.com/pylixm/django-mdeditor) +[](./README_CN.md) +[](https://gitter.im/django-mdeditor/Lobby) +[](https://github.com/pylixm/django-mdeditor) +[](https://github.com/pylixm/django-mdeditor) +[](https://github.com/pylixm/django-mdeditor/master/LICENSE.txt) + + + +**Django-mdeditor** is Markdown Editor plugin application for [django](djangoproject.com) base on [Editor.md](https://github.com/pandao/editor.md). + +**Django-mdeditor** was inspired by great [django-ckeditor](https://github.com/django-ckeditor/django-ckeditor). + +**Note:** + +- For Markdown page rendering issues, backend rendering is recommended. Because `Editor.md` has not been updated for a long time, some bugs and compatibility issues need to be debugged. Of course, front-end students can choose. +- Regarding the `Jquery` conflict, it cannot be deleted because it is required by the admin backend. It is recommended to separate the editing page on a single page or a full screen directly, using its own static file to distinguish it from other pages. + +## Features + +- Almost Editor.md features + - Support Standard Markdown / CommonMark and GFM (GitHub Flavored Markdown); + - Full-featured: Real-time Preview, Image (cross-domain) upload, Preformatted text/Code blocks/Tables insert, Search replace, Themes, Multi-languages; + - Markdown Extras : Support ToC (Table of Contents), Emoji; + - Support TeX (LaTeX expressions, Based on KaTeX), Flowchart and Sequence Diagram of Markdown extended syntax; +- Can constom Editor.md toolbar +- The MDTextField field is provided for the model and can be displayed directly in the django admin. +- The MDTextFormField is provided for the Form and ModelForm. +- The MDEditorWidget is provided for the Admin custom widget. + + +## Quick start + +- Installation. +```bash + pipenv install django-mdeditor + # or + pip install django-mdeditor +``` + +- Add `mdeditor` to your INSTALLED_APPS setting like this: +```python + INSTALLED_APPS = [ + ... + 'mdeditor', + ] +``` + +- add frame settings for django3.0+ like this: + +```python +X_FRAME_OPTIONS = 'SAMEORIGIN' +``` + +- Add 'media' url to your settings like this: +```python +MEDIA_ROOT = os.path.join(BASE_DIR, 'uploads') +MEDIA_URL = '/media/' + +``` +Make folder `uploads/editor` in you project for media files. + +- Add url to your urls like this: +```python +from django.conf.urls import url, include +from django.conf.urls.static import static +from django.conf import settings +... + +urlpatterns = [ + ... + url(r'mdeditor/', include('mdeditor.urls')) +] + +if settings.DEBUG: + # static files (images, css, javascript, etc.) + urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + +``` + +- Write your models like this: +```python +from django.db import models +from mdeditor.fields import MDTextField + +class ExampleModel(models.Model): + name = models.CharField(max_length=10) + content = MDTextField() +``` + +- Register your model in `admin.py` + +- Run `python manage.py makemigrations` and `python manage.py migrate` to create your models. + +- Login Admin ,you can see a markdown editor text field like this: + + + + +## Usage + +### Edit fields in the model using Markdown + +Using Markdown to edit the fields in the model, we simply replace the `TextField` of the model with` MDTextField`. + +```python +from django.db import models +from mdeditor.fields import MDTextField + +class ExampleModel (models.Model): + name = models.CharField (max_length = 10) + content = MDTextField () +``` + +Admin in the background, will automatically display markdown edit rich text. + +Used in front-end template, you can use like this: +```python +{% load staticfiles %} +<! DOCTYPE html> +<html lang = "en"> + <head> + <meta http-equiv = "Content-Type" content = "text / html; charset = utf-8" /> + + </ head> + <body> + <form method = "post" action = "./"> + {% csrf_token %} + {{ form.media }} + {{ form.as_p }} + <p> <input type = "submit" value = "post"> </ p> + </ form> + </ body> +</ html> + +``` + +### Edit fields in the Form using markdown + +Use markdown to edit fields in the Form, use `MDTextFormField` instead of` forms.CharField`, as follows: +```python +from mdeditor.fields import MDTextFormField + +class MDEditorForm (forms.Form): + name = forms.CharField () + content = MDTextFormField () +``` + +`ModelForm` can automatically convert the corresponding model field to the form field, which can be used normally: +```python +class MDEditorModleForm (forms.ModelForm): + + class Meta: + model = ExampleModel + fields = '__all__' +``` + +### Use the markdown widget in admin + +Use the markdown widget in admin like as : +```python +from django.contrib import admin +from django.db import models + +# Register your models here. +from. import models as demo_models +from mdeditor.widgets import MDEditorWidget + + +class ExampleModelAdmin (admin.ModelAdmin): + formfield_overrides = { + models.TextField: {'widget': MDEditorWidget} + } + + +admin.site.register (demo_models.ExampleModel, ExampleModelAdmin) +``` +### Customize the toolbar + +Add the following configuration to `settings`: +```python +MDEDITOR_CONFIGS = { + 'default':{ + 'width': '90% ', # Custom edit box width + 'height': 500, # Custom edit box height + 'toolbar': ["undo", "redo", "|", + "bold", "del", "italic", "quote", "ucwords", "uppercase", "lowercase", "|", + "h1", "h2", "h3", "h5", "h6", "|", + "list-ul", "list-ol", "hr", "|", + "link", "reference-link", "image", "code", "preformatted-text", "code-block", "table", "datetime", + "emoji", "html-entities", "pagebreak", "goto-line", "|", + "help", "info", + "||", "preview", "watch", "fullscreen"], # custom edit box toolbar + 'upload_image_formats': ["jpg", "jpeg", "gif", "png", "bmp", "webp"], # image upload format type + 'image_folder': 'editor', # image save the folder name + 'theme': 'default', # edit box theme, dark / default + 'preview_theme': 'default', # Preview area theme, dark / default + 'editor_theme': 'default', # edit area theme, pastel-on-dark / default + 'toolbar_autofixed': True, # Whether the toolbar capitals + 'search_replace': True, # Whether to open the search for replacement + 'emoji': True, # whether to open the expression function + 'tex': True, # whether to open the tex chart function + 'flow_chart': True, # whether to open the flow chart function + 'sequence': True, # Whether to open the sequence diagram function + 'watch': True, # Live preview + 'lineWrapping': False, # lineWrapping + 'lineNumbers': False, # lineNumbers + 'language': 'zh' # zh / en / es + } + +} +``` + +## Feedback + +Welcome to use and feedback! + +You can create a [issue](https://github.com/pylixm/django-mdeditor/issues) or join in QQ Group. + + + +## Reference + +- [django-ckeditor](https://github.com/django-ckeditor/django-ckeditor) + +%prep +%autosetup -n django-mdeditor-0.1.20 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-django-mdeditor -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 0.1.20-1 +- Package Spec generated @@ -0,0 +1 @@ +e9fda0c2cf524036e64ed53db2d89bc1 django-mdeditor-0.1.20.tar.gz |
