-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from helloflask/release-2.0
Remove deprecated code and release 2.0.0 version
- Loading branch information
Showing
15 changed files
with
36 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
flask_dropzone | ||
~~~~~~~~~~~~~~ | ||
:author: Grey Li <[email protected]> | ||
:copyright: (c) 2017 by Grey Li. | ||
:license: MIT, see LICENSE for more details. | ||
""" | ||
import warnings | ||
|
||
from flask import Blueprint, current_app, render_template_string, url_for | ||
|
@@ -26,147 +17,9 @@ | |
|
||
|
||
class _Dropzone(object): | ||
@staticmethod | ||
def load(js_url="", css_url="", version="5.2.0"): | ||
"""Load Dropzone resources with given version and init dropzone configuration. | ||
.. versionchanged:: 1.4.3 | ||
Added ``js_url`` and ``css_url`` parameters to pass custom resource URL. | ||
.. versionchanged:: 1.4.4 | ||
This method was deprecated due to inflexible. Now it's divided into three methods: | ||
1. Use ``load_css()`` to load css resources. | ||
2. Use ``load_js()`` to load js resources. | ||
3. Use ``config()`` to configure Dropzone. | ||
:param js_url: The JavaScript url for Dropzone.js. | ||
:param css_url: The CSS url for Dropzone.js. | ||
:param version: The version of Dropzone.js. | ||
""" | ||
warnings.warn("The method will be removed in 2.0, see docs for more details.") | ||
js_filename = "dropzone.min.js" | ||
css_filename = "dropzone.min.css" | ||
|
||
upload_multiple = current_app.config["DROPZONE_UPLOAD_MULTIPLE"] | ||
parallel_uploads = current_app.config["DROPZONE_PARALLEL_UPLOADS"] | ||
|
||
if upload_multiple in [True, "true", "True", 1]: | ||
upload_multiple = "true" | ||
else: | ||
upload_multiple = "false" | ||
|
||
serve_local = current_app.config["DROPZONE_SERVE_LOCAL"] | ||
size = current_app.config["DROPZONE_MAX_FILE_SIZE"] | ||
param = current_app.config["DROPZONE_INPUT_NAME"] | ||
redirect_view = current_app.config["DROPZONE_REDIRECT_VIEW"] | ||
|
||
if redirect_view is not None: | ||
redirect_js = """ | ||
this.on("queuecomplete", function(file) { | ||
// Called when all files in the queue finish uploading. | ||
window.location = "%s"; | ||
});""" % url_for(redirect_view) | ||
else: | ||
redirect_js = "" | ||
|
||
if not current_app.config["DROPZONE_ALLOWED_FILE_CUSTOM"]: | ||
allowed_type = allowed_file_extensions[ | ||
current_app.config["DROPZONE_ALLOWED_FILE_TYPE"] | ||
] | ||
else: | ||
allowed_type = current_app.config["DROPZONE_ALLOWED_FILE_TYPE"] | ||
|
||
max_files = current_app.config["DROPZONE_MAX_FILES"] | ||
default_message = current_app.config["DROPZONE_DEFAULT_MESSAGE"] | ||
invalid_file_type = current_app.config["DROPZONE_INVALID_FILE_TYPE"] | ||
file_too_big = current_app.config["DROPZONE_FILE_TOO_BIG"] | ||
server_error = current_app.config["DROPZONE_SERVER_ERROR"] | ||
browser_unsupported = current_app.config["DROPZONE_BROWSER_UNSUPPORTED"] | ||
max_files_exceeded = current_app.config["DROPZONE_MAX_FILE_EXCEED"] | ||
cancelUpload = current_app.config["DROPZONE_CANCEL_UPLOAD"] | ||
removeFile = current_app.config["DROPZONE_REMOVE_FILE"] | ||
cancelConfirmation = current_app.config["DROPZONE_CANCEL_CONFIRMATION"] | ||
uploadCanceled = current_app.config["DROPZONE_UPLOAD_CANCELED"] | ||
|
||
timeout = current_app.config["DROPZONE_TIMEOUT"] | ||
if timeout: | ||
timeout_js = "timeout: %d," % timeout | ||
else: | ||
timeout_js = "" | ||
|
||
if serve_local: | ||
js = '<script src="%s"></script>\n' % url_for( | ||
"dropzone.static", filename=js_filename | ||
) | ||
css = '<link rel="stylesheet" href="%s" type="text/css">\n' % url_for( | ||
"dropzone.static", filename=css_filename | ||
) | ||
else: | ||
js = ( | ||
'<script src="https://cdn.jsdelivr.net/npm/dropzone@%s/dist/%s"></script>\n' | ||
% (version, js_filename) | ||
) | ||
css = ( | ||
'<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dropzone@%s/dist/min/%s"' | ||
' type="text/css">\n' % (version, css_filename) | ||
) | ||
|
||
if js_url: | ||
js = '<script src="%s"></script>\n' % js_url | ||
if css_url: | ||
css = '<link rel="stylesheet" href="%s" type="text/css">\n' % css_url | ||
|
||
return Markup( | ||
""" | ||
%s%s<script> | ||
Dropzone.options.myDropzone = { | ||
init: function() {%s}, | ||
uploadMultiple: %s, | ||
parallelUploads: %d, | ||
paramName: "%s", // The name that will be used to transfer the file | ||
maxFilesize: %d, // MB | ||
acceptedFiles: "%s", | ||
maxFiles: %s, | ||
dictDefaultMessage: "%s", // message display on drop area | ||
dictFallbackMessage: "%s", | ||
dictInvalidFileType: "%s", | ||
dictFileTooBig: "%s", | ||
dictResponseError: "%s", | ||
dictMaxFilesExceeded: "%s", | ||
dictCancelUpload: "%s", | ||
dictRemoveFile: "%s", | ||
dictCancelUploadConfirmation: "%s", | ||
dictUploadCanceled: "%s", | ||
%s // timeout | ||
}; | ||
</script> | ||
""" | ||
% ( | ||
css, | ||
js, | ||
redirect_js, | ||
upload_multiple, | ||
parallel_uploads, | ||
param, | ||
size, | ||
allowed_type, | ||
max_files, | ||
default_message, | ||
browser_unsupported, | ||
invalid_file_type, | ||
file_too_big, | ||
server_error, | ||
max_files_exceeded, | ||
cancelUpload, | ||
removeFile, | ||
cancelConfirmation, | ||
uploadCanceled, | ||
timeout_js, | ||
) | ||
) | ||
|
||
@staticmethod | ||
def load_css(css_url=None, version="5.9.2"): | ||
def load_css(css_url=None, version="5.9.3"): | ||
"""Load Dropzone's css resources with given version. | ||
.. versionadded:: 1.4.4 | ||
|
@@ -192,7 +45,7 @@ def load_css(css_url=None, version="5.9.2"): | |
return Markup(css) | ||
|
||
@staticmethod | ||
def load_js(js_url=None, version="5.9.2"): | ||
def load_js(js_url=None, version="5.9.3"): | ||
"""Load Dropzone's js resources with given version. | ||
.. versionadded:: 1.4.4 | ||
|
@@ -236,7 +89,8 @@ def config( | |
:param redirect_url: The URL to redirect when upload complete. | ||
:param custom_init: Custom javascript code in ``init: function() {}``. | ||
:param custom_options: Custom javascript code in ``Dropzone.options.myDropzone = {}``. | ||
:param nonce: Pass a nonce value that is newhen embedding the JavaScript code into a Content Security Policy protected web page. | ||
:param nonce: Pass a nonce value that is newhen embedding the JavaScript code into | ||
a Content Security Policy protected web page. | ||
:param id: The id of the dropzone element, it must matches the ``id`` argument passed to | ||
``dropzone.create()`` if provided. | ||
:param **kwargs: Mirror configuration variable, lowercase and without prefix. | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,3 @@ | ||
""" | ||
flask_dropzone.utils | ||
~~~~~~~~~~~~~~~~~~~~~ | ||
:author: Grey Li <[email protected]> | ||
:copyright: (c) 2017 by Grey Li. | ||
:license: MIT, see LICENSE for more details. | ||
""" | ||
import os | ||
import uuid | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Flask-Dropzone | ||
~~~~~~~~~~~~~~~ | ||
Upload file in Flask with Dropzone.js. | ||
:author: Grey Li <[email protected]> | ||
:copyright: (c) 2017 by Grey Li. | ||
:license: MIT, see LICENSE for more details. | ||
""" | ||
import io | ||
from setuptools import setup | ||
|
||
|
@@ -17,8 +7,8 @@ | |
|
||
setup( | ||
name='Flask-Dropzone', | ||
version='1.6.0', | ||
url='https://github.com/greyli/flask-dropzone', | ||
version='2.0.0', | ||
url='https://github.com/helloflask/flask-dropzone', | ||
license='MIT', | ||
author='Grey Li', | ||
author_email='[email protected]', | ||
|
@@ -38,12 +28,7 @@ | |
'Intended Audience :: Developers', | ||
'License :: OSI Approved :: MIT License', | ||
'Programming Language :: Python', | ||
'Programming Language :: Python :: 2', | ||
'Programming Language :: Python :: 2.7', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: Python :: 3.4', | ||
'Programming Language :: Python :: 3.5', | ||
'Programming Language :: Python :: 3.6', | ||
'Topic :: Internet :: WWW/HTTP :: Dynamic Content', | ||
'Topic :: Software Development :: Libraries :: Python Modules' | ||
] | ||
|
Oops, something went wrong.