Giter VIP home page Giter VIP logo

flask-ckeditor's Introduction

Flask-CKEditor

a flask module for CKEditor integration

Flask-CKEditor Demo


### Install
$ pip install flaskckeditor

Situation 1: Basic Usage

Step1: Clone the CKEditor I Have Configured and Put it Under Static Folder

Step2: Writing Forms(In Flask-WTF Case)

from flask_wtf import Form
from wtforms import TextAreaField, SubmitField, StringField

class CKEditorForm(Form):
    title =  StringField()
    ckdemo = TextAreaField()
    submit = SubmitField('submit')

Step3: Replace the Form to CKEditor

<script src="/static/ckeditor/ckeditor.js" type="text/javascript"></script>

<form method="POST">
    {{ form.hidden_tag() }}
    {{ form.title }}
    {{ form.ckdemo(class='ckeditor') }}
    {{ form.submit }}
</form>

Situation 2: Open (file/img)Upload Interface

Step1: Upload Class Inheritance

from flask_wtf import Form
from wtforms import TextAreaField, SubmitField, StringField
from flaskckeditor import CKEditor

class CKEditorForm(Form, CKEditor):
    title =  StringField()
    ckdemo = TextAreaField()
    submit = SubmitField('submit')

Step2: Write Upload View Function

from "forms_module" import CKEditorForm

@app.route("/ckupload/")
def ckupload():
    form = CKEditorForm()
    res = form.upload(endpoint=app)
    return res

Situation 3: Use Blueprint

You need to pay attention to the following points:
1.Blueprint static_folder property should be the absolute path leading to the static folder

blue = Blueprint(
    'blue',
    __name__,
    static_folder = '/abspath/to/static/'
)

2.Endpoint parameter of upload function should be the blueprint name

from "forms_module" import CKEditorForm

@blue.route("/ckupload/")
def ckupload():
    form = CKEditorForm()
    res = form.upload(endpoint=blue)
    return res

API

:class: CKEditor
_:function: gen_rnd_filename()
_ generate random filename
_:function: upload(endpoint=)
_ for upload

LICENSE

MIT: check LICENSE for more detail

flask-ckeditor's People

Contributors

misakar avatar

Watchers

James Cloos avatar tkizm1 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.