Source code for browser_markdown_editor.main.forms

# -*- coding: utf-8 -*-
"""This module contains all forms for the main blueprint.

.. module:: forms
    :platform: Unix
    :synopsis: Forms for the main blueprint.

.. moduleauthor:: Simon Larsén <slarse@kth.se>
"""
from flask_wtf import FlaskForm
from flask_wtf.file import FileAllowed, FileRequired, FileField
from flask_pagedown.fields import PageDownField
from wtforms import SubmitField
from wtforms.validators import Required

ALLOWED_FILETYPES = set(['md'])

[docs]class PageDownForm(FlaskForm): """A Markdown form.""" pagedown_field = PageDownField("<h2>Enter markdown here!</h2>" "<h3>(Click and drag bottom right corner to resize window)</h3>") download = SubmitField("Download", validators=[Required()])
[docs]class FileUploadForm(FlaskForm): """A form for uploading a single .md file.""" upload = FileField(label="Upload a .md file", validators=[ FileAllowed(ALLOWED_FILETYPES), FileRequired("No file uploaded!")]) submit = SubmitField("Upload", validators=[Required()])