diff options
author | CoprDistGit <infra@openeuler.org> | 2023-06-20 05:30:06 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-06-20 05:30:06 +0000 |
commit | 0c4a127544d53fab03f5984f22e3a5a81b7ac756 (patch) | |
tree | f6ec3482aebf9ec5dcbe5f61a6a5090c057cbf0b /python-django-jsonsuit.spec | |
parent | ac63dcd2ca55be991bc24ae53df3014bd32adc36 (diff) |
automatic import of python-django-jsonsuitopeneuler20.03
Diffstat (limited to 'python-django-jsonsuit.spec')
-rw-r--r-- | python-django-jsonsuit.spec | 777 |
1 files changed, 777 insertions, 0 deletions
diff --git a/python-django-jsonsuit.spec b/python-django-jsonsuit.spec new file mode 100644 index 0000000..fe21105 --- /dev/null +++ b/python-django-jsonsuit.spec @@ -0,0 +1,777 @@ +%global _empty_manifest_terminate_build 0 +Name: python-django-jsonsuit +Version: 0.5.0 +Release: 1 +Summary: Django goodies to dress JSON data in a suit +License: MIT +URL: https://pypi.org/project/django-jsonsuit/ +Source0: https://mirrors.aliyun.com/pypi/web/packages/6a/a5/a5636d8d70821d7951e027516ad6eb91674dec6ca3d078cb7bbf0fd13ec2/django-jsonsuit-0.5.0.tar.gz +BuildArch: noarch + + +%description +# django-jsonsuit + +![image][1] ![image][2] ![image][3] + +Django goodies to dress JSON data in a suit. + +## Documentation + +The full documentation is at <https://tooreht.github.io/django-jsonsuit>. +An example project can be found at <https://github.com/tooreht/django-jsonsuit-example>. + +## Features + +- Editable and readonly widget +- Change JSON syntax highlighter themes +- Set custom widget media (JS & CSS) files +- Use custom HTML templates + +## Quickstart + +Install django-jsonsuit: + + pip install django-jsonsuit + +Add it to your `INSTALLED_APPS`: + +``` sourceCode +INSTALLED_APPS = ( + ... + 'jsonsuit.apps.JSONSuitConfig', + ... +) +``` + +## Usage + +### Widgets + +django-jsonsuit currently provides two widgets to dress your JSON data: + +1. `JSONSuit`: Widget that displays JSON data with indentation and syntax highlighting as default, but allows to toggle between the standard django `Textarea` for editing. +2. `ReadonlyJSONSuit`: Widget that simply displays JSON data with indentation and syntax highlighting. It is useful for JSON fields that contain readonly data. + +**Note**: Because a widget in django is only responsible for displaying fields, it has no direct access to its field properties. Thus there is no easy way to check if the field is readonly. The readonly behaviour is even handled differently among django forms, model forms and admin. This is why the `ReadonlyJSONSuit` was introduced. + +**Note**: When using multiple form instances or multiple forms with equal field names on the same page use [Formsets](https://docs.djangoproject.com/en/dev/topics/forms/formsets/) or [prefixes](https://docs.djangoproject.com/en/dev/ref/forms/api/#prefixes-for-forms) to avoid HTML element id clashes. + +#### JSONSuit + +In a form or model admin, enable a JSON suit for a particular field: + +```python +from jsonsuit.widgets import JSONSuit + +class JSONForm(forms.ModelForm): + class Meta: + model = Test + fields = '__all__' + widgets = { + 'myjsonfield': JSONSuit(), + } + +class JSONAdmin(admin.ModelAdmin): + form = JSONForm +``` + +Enable JSON suit for every JSONField of a model: + +```python +from django.db import models + +class JSONAdmin(admin.ModelAdmin): + formfield_overrides = { + models.JSONField: {'widget': JSONSuit } + } +``` + +#### ReadonlyJSONSuit + +In a form or model admin, enable a readonly JSON suit for a particular field: + +```python +from jsonsuit.widgets import ReadonlyJSONSuit + +class ReadonlyJSONForm(forms.ModelForm): + class Meta: + model = Test + fields = '__all__' + widgets = { + 'myjsonfield': ReadonlyJSONSuit(), + } + +class ReadonlyJSONAdmin(admin.ModelAdmin): + form = ReadonlyJSONForm +``` + +Enable readonly JSON suit for every JSONField of a model: + +```python +from django.db import models + +class ReadonlyJSONAdmin(admin.ModelAdmin): + formfield_overrides = { + models.JSONField: {'widget': ReadonlyJSONSuit } + } +``` + +### Template Tags + +Use the jsonsuit template tag to display serializable objects in templates. Note that in order to use the `jsonsuit`, `jsonsuit_css` and `jsonsuit_js` tags, they must be loaded using `{% load jsonsuit %}`. + +```html +{% extends "ui/base.html" %} +{% load jsonsuit %} + +{% block title %}{% trans "JSONSuit Template Tag" %}{% endblock %} + +{% block styles %} + {{ block.super }} + {% jsonsuit_css %} <!-- include jsonsuit CSS files --> +{% endblock %} + +{% block content %} +<div class="row"> + <div class="col-md-4"> + <h2>Unnamed Suit</h2> + {% jsonsuit data %} <!-- with no parameter supplied, + a uuid is generated as + HTML attribute value to + identify each individual suit: + data-jsonsuit="<uuid>" --> + </div> + <div class="col-md-8"> + <h2>Named Suit</h2> + {% jsonsuit data 'suit_name' %} <!-- for each suit, + an optional string + can be supplied, which + serves as HTML attribute + value: data-jsonsuit="<suit_name>" --> + </div> +</div> +{% endblock %} + +{% block scripts %} + {{ block.super }} + {% jsonsuit_js %} <!-- include jsonsuit JS files --> +{% endblock %} +``` + +### Theme + +Set JSON syntax highlighter theme in settings: + +```python +JSONSUIT_WIDGET_THEME = 'twilight' +``` + +Available themes: `coy`, `dark`, `default`, `funky`, `okaidia`, `solarizedlight`, `twilight`, `tomorrow`. Defaults to the `default` theme. + +### Custom Widget Media + +Set custom widget media (JS & CSS) files: + +```python +JSONSUIT_WIDGET_MEDIA_JS = ( + 'jsonsuit/js/mysyntaxhighlighter.js', 'jsonsuit/js/myscripts.js' +) + +JSONSUIT_WIDGET_MEDIA_CSS = { + 'all': ('jsonsuit/css/mytheme.css', 'jsonsuit/css/mystyles.css') +} + +JSONSUIT_READONLY_WIDGET_MEDIA_JS = ( + 'jsonsuit/js/mysyntaxhighlighter.js', 'jsonsuit/js/myreadonlyscripts.js' +) + +JSONSUIT_READONLY_WIDGET_MEDIA_CSS = { + 'all': ('jsonsuit/css/mytheme.css', 'jsonsuit/css/myreadonlystyles.css') +} +``` + +To only replace the syntax highlighter assets for all widgets, simply change: + +```python +JSONSUIT_SYNTAX_HIGHLIGHTER_JS = ('jsonsuit/js/mysyntaxhighlighter.js',) +JSONSUIT_SYNTAX_HIGHLIGHTER_CSS = ('jsonsuit/css/mytheme.css',) +``` + +### Custom HTML template + +Override `jsonsuit/widget.html` or `jsonsuit/readonly_widget.html` template: + +```bash +jsonsuit/templates +└── jsonsuit + └── widget.html + └── readonly_widget.html +``` + +## Running Tests + +Does the code actually work? + + source <YOURVIRTUALENV>/bin/activate + (myenv) $ pip install tox + (myenv) $ tox + +## Development commands + + pip install -r requirements_dev.txt + invoke -l + +## Credits + +Project dependencies: + +- [prism](http://prismjs.com/) +- [vanilla-js](http://vanilla-js.com/) + +Project documentation: + +- [MkDocs](http://www.mkdocs.org/) + +Tools used in rendering this package: + +- [Cookiecutter] +- [cookiecutter-djangopackage] +- [Zest.releaser] + + [1]: https://badge.fury.io/py/django-jsonsuit.svg + [2]: https://github.com/tooreht/django-jsonsuit/actions/workflows/check.yml/badge.svg?branch=master + [3]: https://codecov.io/gh/tooreht/django-jsonsuit/branch/master/graph/badge.svg + [Cookiecutter]: https://github.com/audreyr/cookiecutter + [cookiecutter-djangopackage]: https://github.com/pydanny/cookiecutter-djangopackage + [Zest.releaser]: https://zestreleaser.readthedocs.io + + +%package -n python3-django-jsonsuit +Summary: Django goodies to dress JSON data in a suit +Provides: python-django-jsonsuit +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-django-jsonsuit +# django-jsonsuit + +![image][1] ![image][2] ![image][3] + +Django goodies to dress JSON data in a suit. + +## Documentation + +The full documentation is at <https://tooreht.github.io/django-jsonsuit>. +An example project can be found at <https://github.com/tooreht/django-jsonsuit-example>. + +## Features + +- Editable and readonly widget +- Change JSON syntax highlighter themes +- Set custom widget media (JS & CSS) files +- Use custom HTML templates + +## Quickstart + +Install django-jsonsuit: + + pip install django-jsonsuit + +Add it to your `INSTALLED_APPS`: + +``` sourceCode +INSTALLED_APPS = ( + ... + 'jsonsuit.apps.JSONSuitConfig', + ... +) +``` + +## Usage + +### Widgets + +django-jsonsuit currently provides two widgets to dress your JSON data: + +1. `JSONSuit`: Widget that displays JSON data with indentation and syntax highlighting as default, but allows to toggle between the standard django `Textarea` for editing. +2. `ReadonlyJSONSuit`: Widget that simply displays JSON data with indentation and syntax highlighting. It is useful for JSON fields that contain readonly data. + +**Note**: Because a widget in django is only responsible for displaying fields, it has no direct access to its field properties. Thus there is no easy way to check if the field is readonly. The readonly behaviour is even handled differently among django forms, model forms and admin. This is why the `ReadonlyJSONSuit` was introduced. + +**Note**: When using multiple form instances or multiple forms with equal field names on the same page use [Formsets](https://docs.djangoproject.com/en/dev/topics/forms/formsets/) or [prefixes](https://docs.djangoproject.com/en/dev/ref/forms/api/#prefixes-for-forms) to avoid HTML element id clashes. + +#### JSONSuit + +In a form or model admin, enable a JSON suit for a particular field: + +```python +from jsonsuit.widgets import JSONSuit + +class JSONForm(forms.ModelForm): + class Meta: + model = Test + fields = '__all__' + widgets = { + 'myjsonfield': JSONSuit(), + } + +class JSONAdmin(admin.ModelAdmin): + form = JSONForm +``` + +Enable JSON suit for every JSONField of a model: + +```python +from django.db import models + +class JSONAdmin(admin.ModelAdmin): + formfield_overrides = { + models.JSONField: {'widget': JSONSuit } + } +``` + +#### ReadonlyJSONSuit + +In a form or model admin, enable a readonly JSON suit for a particular field: + +```python +from jsonsuit.widgets import ReadonlyJSONSuit + +class ReadonlyJSONForm(forms.ModelForm): + class Meta: + model = Test + fields = '__all__' + widgets = { + 'myjsonfield': ReadonlyJSONSuit(), + } + +class ReadonlyJSONAdmin(admin.ModelAdmin): + form = ReadonlyJSONForm +``` + +Enable readonly JSON suit for every JSONField of a model: + +```python +from django.db import models + +class ReadonlyJSONAdmin(admin.ModelAdmin): + formfield_overrides = { + models.JSONField: {'widget': ReadonlyJSONSuit } + } +``` + +### Template Tags + +Use the jsonsuit template tag to display serializable objects in templates. Note that in order to use the `jsonsuit`, `jsonsuit_css` and `jsonsuit_js` tags, they must be loaded using `{% load jsonsuit %}`. + +```html +{% extends "ui/base.html" %} +{% load jsonsuit %} + +{% block title %}{% trans "JSONSuit Template Tag" %}{% endblock %} + +{% block styles %} + {{ block.super }} + {% jsonsuit_css %} <!-- include jsonsuit CSS files --> +{% endblock %} + +{% block content %} +<div class="row"> + <div class="col-md-4"> + <h2>Unnamed Suit</h2> + {% jsonsuit data %} <!-- with no parameter supplied, + a uuid is generated as + HTML attribute value to + identify each individual suit: + data-jsonsuit="<uuid>" --> + </div> + <div class="col-md-8"> + <h2>Named Suit</h2> + {% jsonsuit data 'suit_name' %} <!-- for each suit, + an optional string + can be supplied, which + serves as HTML attribute + value: data-jsonsuit="<suit_name>" --> + </div> +</div> +{% endblock %} + +{% block scripts %} + {{ block.super }} + {% jsonsuit_js %} <!-- include jsonsuit JS files --> +{% endblock %} +``` + +### Theme + +Set JSON syntax highlighter theme in settings: + +```python +JSONSUIT_WIDGET_THEME = 'twilight' +``` + +Available themes: `coy`, `dark`, `default`, `funky`, `okaidia`, `solarizedlight`, `twilight`, `tomorrow`. Defaults to the `default` theme. + +### Custom Widget Media + +Set custom widget media (JS & CSS) files: + +```python +JSONSUIT_WIDGET_MEDIA_JS = ( + 'jsonsuit/js/mysyntaxhighlighter.js', 'jsonsuit/js/myscripts.js' +) + +JSONSUIT_WIDGET_MEDIA_CSS = { + 'all': ('jsonsuit/css/mytheme.css', 'jsonsuit/css/mystyles.css') +} + +JSONSUIT_READONLY_WIDGET_MEDIA_JS = ( + 'jsonsuit/js/mysyntaxhighlighter.js', 'jsonsuit/js/myreadonlyscripts.js' +) + +JSONSUIT_READONLY_WIDGET_MEDIA_CSS = { + 'all': ('jsonsuit/css/mytheme.css', 'jsonsuit/css/myreadonlystyles.css') +} +``` + +To only replace the syntax highlighter assets for all widgets, simply change: + +```python +JSONSUIT_SYNTAX_HIGHLIGHTER_JS = ('jsonsuit/js/mysyntaxhighlighter.js',) +JSONSUIT_SYNTAX_HIGHLIGHTER_CSS = ('jsonsuit/css/mytheme.css',) +``` + +### Custom HTML template + +Override `jsonsuit/widget.html` or `jsonsuit/readonly_widget.html` template: + +```bash +jsonsuit/templates +└── jsonsuit + └── widget.html + └── readonly_widget.html +``` + +## Running Tests + +Does the code actually work? + + source <YOURVIRTUALENV>/bin/activate + (myenv) $ pip install tox + (myenv) $ tox + +## Development commands + + pip install -r requirements_dev.txt + invoke -l + +## Credits + +Project dependencies: + +- [prism](http://prismjs.com/) +- [vanilla-js](http://vanilla-js.com/) + +Project documentation: + +- [MkDocs](http://www.mkdocs.org/) + +Tools used in rendering this package: + +- [Cookiecutter] +- [cookiecutter-djangopackage] +- [Zest.releaser] + + [1]: https://badge.fury.io/py/django-jsonsuit.svg + [2]: https://github.com/tooreht/django-jsonsuit/actions/workflows/check.yml/badge.svg?branch=master + [3]: https://codecov.io/gh/tooreht/django-jsonsuit/branch/master/graph/badge.svg + [Cookiecutter]: https://github.com/audreyr/cookiecutter + [cookiecutter-djangopackage]: https://github.com/pydanny/cookiecutter-djangopackage + [Zest.releaser]: https://zestreleaser.readthedocs.io + + +%package help +Summary: Development documents and examples for django-jsonsuit +Provides: python3-django-jsonsuit-doc +%description help +# django-jsonsuit + +![image][1] ![image][2] ![image][3] + +Django goodies to dress JSON data in a suit. + +## Documentation + +The full documentation is at <https://tooreht.github.io/django-jsonsuit>. +An example project can be found at <https://github.com/tooreht/django-jsonsuit-example>. + +## Features + +- Editable and readonly widget +- Change JSON syntax highlighter themes +- Set custom widget media (JS & CSS) files +- Use custom HTML templates + +## Quickstart + +Install django-jsonsuit: + + pip install django-jsonsuit + +Add it to your `INSTALLED_APPS`: + +``` sourceCode +INSTALLED_APPS = ( + ... + 'jsonsuit.apps.JSONSuitConfig', + ... +) +``` + +## Usage + +### Widgets + +django-jsonsuit currently provides two widgets to dress your JSON data: + +1. `JSONSuit`: Widget that displays JSON data with indentation and syntax highlighting as default, but allows to toggle between the standard django `Textarea` for editing. +2. `ReadonlyJSONSuit`: Widget that simply displays JSON data with indentation and syntax highlighting. It is useful for JSON fields that contain readonly data. + +**Note**: Because a widget in django is only responsible for displaying fields, it has no direct access to its field properties. Thus there is no easy way to check if the field is readonly. The readonly behaviour is even handled differently among django forms, model forms and admin. This is why the `ReadonlyJSONSuit` was introduced. + +**Note**: When using multiple form instances or multiple forms with equal field names on the same page use [Formsets](https://docs.djangoproject.com/en/dev/topics/forms/formsets/) or [prefixes](https://docs.djangoproject.com/en/dev/ref/forms/api/#prefixes-for-forms) to avoid HTML element id clashes. + +#### JSONSuit + +In a form or model admin, enable a JSON suit for a particular field: + +```python +from jsonsuit.widgets import JSONSuit + +class JSONForm(forms.ModelForm): + class Meta: + model = Test + fields = '__all__' + widgets = { + 'myjsonfield': JSONSuit(), + } + +class JSONAdmin(admin.ModelAdmin): + form = JSONForm +``` + +Enable JSON suit for every JSONField of a model: + +```python +from django.db import models + +class JSONAdmin(admin.ModelAdmin): + formfield_overrides = { + models.JSONField: {'widget': JSONSuit } + } +``` + +#### ReadonlyJSONSuit + +In a form or model admin, enable a readonly JSON suit for a particular field: + +```python +from jsonsuit.widgets import ReadonlyJSONSuit + +class ReadonlyJSONForm(forms.ModelForm): + class Meta: + model = Test + fields = '__all__' + widgets = { + 'myjsonfield': ReadonlyJSONSuit(), + } + +class ReadonlyJSONAdmin(admin.ModelAdmin): + form = ReadonlyJSONForm +``` + +Enable readonly JSON suit for every JSONField of a model: + +```python +from django.db import models + +class ReadonlyJSONAdmin(admin.ModelAdmin): + formfield_overrides = { + models.JSONField: {'widget': ReadonlyJSONSuit } + } +``` + +### Template Tags + +Use the jsonsuit template tag to display serializable objects in templates. Note that in order to use the `jsonsuit`, `jsonsuit_css` and `jsonsuit_js` tags, they must be loaded using `{% load jsonsuit %}`. + +```html +{% extends "ui/base.html" %} +{% load jsonsuit %} + +{% block title %}{% trans "JSONSuit Template Tag" %}{% endblock %} + +{% block styles %} + {{ block.super }} + {% jsonsuit_css %} <!-- include jsonsuit CSS files --> +{% endblock %} + +{% block content %} +<div class="row"> + <div class="col-md-4"> + <h2>Unnamed Suit</h2> + {% jsonsuit data %} <!-- with no parameter supplied, + a uuid is generated as + HTML attribute value to + identify each individual suit: + data-jsonsuit="<uuid>" --> + </div> + <div class="col-md-8"> + <h2>Named Suit</h2> + {% jsonsuit data 'suit_name' %} <!-- for each suit, + an optional string + can be supplied, which + serves as HTML attribute + value: data-jsonsuit="<suit_name>" --> + </div> +</div> +{% endblock %} + +{% block scripts %} + {{ block.super }} + {% jsonsuit_js %} <!-- include jsonsuit JS files --> +{% endblock %} +``` + +### Theme + +Set JSON syntax highlighter theme in settings: + +```python +JSONSUIT_WIDGET_THEME = 'twilight' +``` + +Available themes: `coy`, `dark`, `default`, `funky`, `okaidia`, `solarizedlight`, `twilight`, `tomorrow`. Defaults to the `default` theme. + +### Custom Widget Media + +Set custom widget media (JS & CSS) files: + +```python +JSONSUIT_WIDGET_MEDIA_JS = ( + 'jsonsuit/js/mysyntaxhighlighter.js', 'jsonsuit/js/myscripts.js' +) + +JSONSUIT_WIDGET_MEDIA_CSS = { + 'all': ('jsonsuit/css/mytheme.css', 'jsonsuit/css/mystyles.css') +} + +JSONSUIT_READONLY_WIDGET_MEDIA_JS = ( + 'jsonsuit/js/mysyntaxhighlighter.js', 'jsonsuit/js/myreadonlyscripts.js' +) + +JSONSUIT_READONLY_WIDGET_MEDIA_CSS = { + 'all': ('jsonsuit/css/mytheme.css', 'jsonsuit/css/myreadonlystyles.css') +} +``` + +To only replace the syntax highlighter assets for all widgets, simply change: + +```python +JSONSUIT_SYNTAX_HIGHLIGHTER_JS = ('jsonsuit/js/mysyntaxhighlighter.js',) +JSONSUIT_SYNTAX_HIGHLIGHTER_CSS = ('jsonsuit/css/mytheme.css',) +``` + +### Custom HTML template + +Override `jsonsuit/widget.html` or `jsonsuit/readonly_widget.html` template: + +```bash +jsonsuit/templates +└── jsonsuit + └── widget.html + └── readonly_widget.html +``` + +## Running Tests + +Does the code actually work? + + source <YOURVIRTUALENV>/bin/activate + (myenv) $ pip install tox + (myenv) $ tox + +## Development commands + + pip install -r requirements_dev.txt + invoke -l + +## Credits + +Project dependencies: + +- [prism](http://prismjs.com/) +- [vanilla-js](http://vanilla-js.com/) + +Project documentation: + +- [MkDocs](http://www.mkdocs.org/) + +Tools used in rendering this package: + +- [Cookiecutter] +- [cookiecutter-djangopackage] +- [Zest.releaser] + + [1]: https://badge.fury.io/py/django-jsonsuit.svg + [2]: https://github.com/tooreht/django-jsonsuit/actions/workflows/check.yml/badge.svg?branch=master + [3]: https://codecov.io/gh/tooreht/django-jsonsuit/branch/master/graph/badge.svg + [Cookiecutter]: https://github.com/audreyr/cookiecutter + [cookiecutter-djangopackage]: https://github.com/pydanny/cookiecutter-djangopackage + [Zest.releaser]: https://zestreleaser.readthedocs.io + + +%prep +%autosetup -n django-jsonsuit-0.5.0 + +%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-jsonsuit -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Tue Jun 20 2023 Python_Bot <Python_Bot@openeuler.org> - 0.5.0-1 +- Package Spec generated |