Skip to content

Commit

Permalink
Merge pull request #65 from helloflask/release-2.0
Browse files Browse the repository at this point in the history
Remove deprecated code and release 2.0.0 version
  • Loading branch information
greyli authored Feb 18, 2024
2 parents eeded3b + 029a6ec commit 2443ca8
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 234 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ on:
push:
branches:
- main
- master
paths-ignore:
- 'docs/**'
- '*.md'
- '*.rst'
pull_request:
branches:
- main
- master
jobs:
tests:
name: ${{ matrix.name }}
Expand All @@ -18,10 +20,13 @@ jobs:
fail-fast: false
matrix:
include:
- {name: '3.10', python: '3.10', tox: 'py310,py-babelex,py-no-babel'}
- {name: '3.12', python: '3.12', tox: 'py312'}
- {name: '3.11', python: '3.11', tox: 'py311'}
- {name: '3.10', python: '3.10', tox: 'py310'}
- {name: '3.9', python: '3.9', tox: py39}
- {name: '3.8', python: '3.8', tox: py38}
- {name: '3.7', python: '3.7', tox: py37}
- {name: 'Lint', python: '3.12', tox: lint}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
Expand Down
9 changes: 5 additions & 4 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ released date: --

WARNING: **New major upstream release (backwards incompatible!).**

* Remove ``dropzone.load()`` method.
* Remove the deprecated ``dropzone.load()`` method.
* Added more options to customize messages.
* Drop Python 2 support.
* Add an ``id`` parameter for ``dropzone.style()`` to support
customize unique styles for multiple dropzones in one page (`#53 <https://github.com/greyli/flask-dropzone/pull/53>`_).
customize unique styles for multiple dropzones in one page (`#53 <https://github.com/helloflask/flask-dropzone/pull/53>`_).
* Upgrade Dropzone.js to 5.9.3 version.

1.6.0
-----
Expand All @@ -24,7 +25,7 @@ released date: 2021/5/1
-----
released date: 2019/8/4

* Fix CSRF protect bug when in form (`#29 <https://github.com/greyli/flask-dropzone/issues/29>`_).
* Fix CSRF protect bug when in form (`#29 <https://github.com/helloflask/flask-dropzone/issues/29>`_).

1.5.3
-----
Expand Down Expand Up @@ -81,7 +82,7 @@ released date: 2018/5/28
released date: 2018/3/23

* Add support to use custom resources with ``js_url`` and ``css_url`` param in ``load()``.
* Fix built-in static bug (`#11 <https://github.com/greyli/flask-dropzone/issues/11>`_).
* Fix built-in static bug (`#11 <https://github.com/helloflask/flask-dropzone/issues/11>`_).
* Use package instead of module.

1.4.2
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Flask-Dropzone

[![GitHub Actions Build Status](https://github.com/helloflask/flask-dropzone/actions/workflows/tests.yaml/badge.svg)](https://github.com/helloflask/flask-dropzone/actions)
[![PyPI](https://img.shields.io/pypi/v/Flask-Dropzone)](https://pypi.org/project/Flask-Dropzone/)

Upload files in Flask application with [Dropzone.js](http://www.dropzonejs.com/).

NOTICE: This extension is built for simple usage, if you need more flexibility, please use Dropzone.js directly.
Expand All @@ -7,7 +11,7 @@ NOTICE: This extension is built for simple usage, if you need more flexibility,

* [Documentation](https://flask-dropzone.readthedocs.io/en/latest/)
* [PyPI](https://pypi.org/project/Flask-Dropzone/)
* [Examples](https://github.com/greyli/flask-dropzone/tree/master/examples)
* [Examples](https://github.com/helloflask/flask-dropzone/tree/master/examples)

## License

Expand Down
4 changes: 2 additions & 2 deletions docs/_templates/sidebarintro.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h3>Useful Links</h3>
<ul>
<li><a href="http://flask.pocoo.org/">Flask</a></li>
<li><a href="http://pypi.org/project/Flask-dropzone">Flask-Dropzone @ PyPI</a></li>
<li><a href="http://github.com/greyli/flask-dropzone">Flask-Dropzone @ GitHub</a></li>
<li><a href="http://github.com/greyli/flask-dropzone/issues">Issue Tracker</a></li>
<li><a href="http://github.com/helloflask/flask-dropzone">Flask-Dropzone @ GitHub</a></li>
<li><a href="http://github.com/helloflask/flask-dropzone/issues">Issue Tracker</a></li>
<li><a href="http://greyli.com/flask-dropzone/">中文介绍</a></li>
</ul>
6 changes: 0 additions & 6 deletions docs/basic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@ In addition to manage and load resources by yourself
{{ dropzone.load_js() }}
</body>
.. tip::
There is a ``dropzone.load()`` method that was a combination of
``dropzone.load_css()`` and ``dropzone.load_js()``, but we recommend not
to use this method for page load performance consideration. Also,
``dropzone.load()`` will be removed in the near future.

You can assign the version of Dropzone.js through ``version`` argument,
the default value is ``5.2.0``. And, you can pass ``css_url`` and
``js_url`` separately to customize resources URL.
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
html_theme_options = {
# 'github_user': 'greyli',
'index_logo': 'flask-dropzone.png',
# 'github_fork': 'greyli/flask-ckeditor',
# 'github_fork': 'helloflask/flask-ckeditor',
# 'description': 'Create social share component in Jinja2 template based on share.js.',
}

Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Maintainers:
- `yuxiaoy <https://github.com/Yuxiaoy1>`_

See also the list of
`contributors <https://github.com/greyli/flask-dropzone/contributors>`_ on GitHub.
`contributors <https://github.com/helloflask/flask-dropzone/contributors>`_ on GitHub.

License
-------
Expand Down
2 changes: 1 addition & 1 deletion examples/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Try Examples

Open a terminal, type the commands below one by one::

$ git clone https://github.com/greyli/flask-dropzone
$ git clone https://github.com/helloflask/flask-dropzone
$ cd flask-dropzone/examples
$ pip install -r requirements.txt
$ python basic/app.py
Expand Down
154 changes: 4 additions & 150 deletions flask_dropzone/__init__.py
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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion flask_dropzone/static/dropzone.min.js

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions flask_dropzone/utils.py
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

Expand Down
19 changes: 2 additions & 17 deletions setup.py
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

Expand All @@ -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]',
Expand All @@ -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'
]
Expand Down
Loading

0 comments on commit 2443ca8

Please sign in to comment.