Skip to main content

sanic-quill

Sanic-quill is a port of Flask-quill (https://github.com/drewdru/flask-quill/) to Sanic ecosystem. (wtforms widget for quill.js editor (https://github.com/quilljs/quill))

Quill.js is a modern WYSIWYG editor built for compatibility and extensibility.

To add routes with edit form:

from sanic_quill import add_editor

editor will be able on the route /edit

How to use

Check sample in ‘examples’.

To add WYSIWYG editor to edit any data/fields you need to define 2 methods:

  • get_data (used by editor to get information for model to edit in form)

  • save_data (used by editor to save changes from the form)

Editor expect 3 fields in data:

  • ‘title’,

  • ‘body’,

  • ‘preview’

from sanic_quill import add_editor

...

# your Sanic app code
# with defining app = Sanic()

...

def get_data(_id):
    """ this method defines logic to send to 'edit' form data of the object """
    for post in posts:
        if post['id'] == _id:
            post['title'] = post['title']
            post['content'] = post['text']
            post['preview'] = post['preview']
            return post


def save_data(_id, data):
    """
        this method defines logic to save data from 'edit' form

        data comes like a dict with: content, content_preview and title fields,
        you need map it to your structure
    """
    for num, post in enumerate(posts):
        if post['id'] == _id:
            print('Update post')
            post['title'] = data['title']
            post['text'] = data['content']
            post['description'] = data['preview']
            break

add_editor(app, get_data, save_data)

After that you will have routes ‘/edit?’id=$id_of_your_data_item_to_edit

Also you can define a path where to save an images and route that will be used to serve uploaded images by default it is ‘/img’:

add_editor(app, get_data, save_data, img_folder="/path/for/images", route_for_img='/custom_route')

Metadata

Release files for sanic-quill 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sanic-quill 0.0.2
File Size Uploaded Provenance
sanic-quill-0.0.2.tar.gz 13.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sanic-quill 0.0.2
File Interpreter ABI Platform
sanic_quill-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 28.8 kB

Release files / sanic-quill-0.0.2.tar.gz

Download URL sanic-quill-0.0.2.tar.gz
Size 13.1 kB
Tags Source
SHA-256 checksum
How to use checksums
35552e2e814dec236ff4cc1893b39401c2266c046576c3a7dffc12996ec5f112
BLAKE2b-256 checksum
How to use checksums
4515eb5684f5939ace982b21fdf5f30846b08b2ad79ce5a50f6153609cd0993f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.5 CPython/3.7.4 Darwin/18.7.0

Release files / sanic_quill-0.0.2-py3-none-any.whl

Download URL sanic_quill-0.0.2-py3-none-any.whl
Size 15.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
74ac8644a70365d70310eed9d0a630578fcba250a73eba0e895cf39190a31321
BLAKE2b-256 checksum
How to use checksums
ac564df73864f33ee6f1b377555f6deebfeb1da1772dcbb2b6c6b18977a66ff4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.5 CPython/3.7.4 Darwin/18.7.0

Security for sanic-quill 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page