From f7d62262744aa484c89ee8bd75719b8847658779 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 22 Apr 2023 22:55:00 +0200 Subject: [PATCH 01/12] Upgrade to django 4.2 --- .github/ISSUE_TEMPLATE/---bug-report.md | 48 ++ .github/ISSUE_TEMPLATE/---feature-request.md | 42 ++ .github/pull_request_template.md | 18 + .github/workflows/lint.yml | 41 ++ .github/workflows/publish.yml | 38 ++ .gitignore | 525 +++++++++++++++++- .pre-commit-config.yaml | 42 ++ .pyup.yml | 7 + AUTHORS.rst | 2 +- CONTRIBUTING.rst | 10 +- LICENSE | 2 +- MANIFEST.in | 2 +- Makefile | 46 -- ckeditor_filebrowser_filer/__init__.py | 3 +- ckeditor_filebrowser_filer/models.py | 1 - .../filerimage/dialogs/filerImageDialog.js | 0 .../ckeditor/plugins/filerimage/plugin.js | 0 .../filerimage/dialogs/filerImageDialog.js | 0 .../ckeditor/plugins/filerimage/plugin.js | 0 ckeditor_filebrowser_filer/urls.py | 50 +- ckeditor_filebrowser_filer/views.py | 60 +- pyproject.toml | 42 ++ requirements.txt | 2 +- setup.cfg | 56 +- setup.py | 61 +- tasks.py | 142 +++++ tox.ini | 91 +++ 27 files changed, 1122 insertions(+), 209 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/---bug-report.md create mode 100644 .github/ISSUE_TEMPLATE/---feature-request.md create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/publish.yml create mode 100644 .pre-commit-config.yaml create mode 100644 .pyup.yml delete mode 100644 Makefile mode change 100755 => 100644 ckeditor_filebrowser_filer/static/ckeditor/ckeditor/plugins/filerimage/dialogs/filerImageDialog.js mode change 100755 => 100644 ckeditor_filebrowser_filer/static/ckeditor/ckeditor/plugins/filerimage/plugin.js mode change 100755 => 100644 ckeditor_filebrowser_filer/static/djangocms_text_ckeditor/ckeditor/plugins/filerimage/dialogs/filerImageDialog.js mode change 100755 => 100644 ckeditor_filebrowser_filer/static/djangocms_text_ckeditor/ckeditor/plugins/filerimage/plugin.js create mode 100644 pyproject.toml mode change 100755 => 100644 setup.py create mode 100644 tasks.py create mode 100644 tox.ini diff --git a/.github/ISSUE_TEMPLATE/---bug-report.md b/.github/ISSUE_TEMPLATE/---bug-report.md new file mode 100644 index 0000000..19d08d8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/---bug-report.md @@ -0,0 +1,48 @@ +--- +name: "\U0001F41B Bug report" +about: Create a report to help us improve +title: '' +labels: 'type: bug' +assignees: '' + +--- + + + +## Description + + + +## Steps to reproduce + + + +## Versions + + + +## Expected behaviour + + + +## Actual behaviour + + + +## Additional information + + diff --git a/.github/ISSUE_TEMPLATE/---feature-request.md b/.github/ISSUE_TEMPLATE/---feature-request.md new file mode 100644 index 0000000..5b74e5f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/---feature-request.md @@ -0,0 +1,42 @@ +--- +name: "\U0001F389 Feature request" +about: Share your idea, let's discuss it! +title: '' +labels: 'type: feature' +assignees: '' + +--- + + + +## Description + + + +## Use cases + + + +## Proposed solution + + + +## Alternatives + + + +## Additional information + + diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..bf20706 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,18 @@ +# Description + +Describe: + +* Content of the pull request +* Feature added / Problem fixed + +## References + +Provide any github issue fixed (as in ``Fix #XYZ``) + +# Checklist + +* [ ] I have read the [contribution guide](https://djangocms-blog.readthedocs.io/en/latest/contributing.html) +* [ ] Code lint checked via `inv lint` +* [ ] ``changes`` file included (see [docs](https://djangocms-blog.readthedocs.io/en/latest/contributing.html#pull-request-guidelines)) +* [ ] Usage documentation added in case of new features +* [ ] Tests added diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..465a08f --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,41 @@ +name: Code quality + +on: [push, pull_request] + +jobs: + lint: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[skip ci]')" + strategy: + matrix: + python-version: ["3.11.x"] + toxenv: [ruff, isort, black, pypi-description] + steps: + - uses: actions/checkout@v3 + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.ref }} + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Cache pip + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ matrix.toxenv }} + restore-keys: | + ${{ runner.os }}-pip-${{ matrix.toxenv }} + - name: Cache tox + uses: actions/cache@v3 + with: + path: .tox + key: ${{ runner.os }}-lint-${{ matrix.toxenv }}-${{ hashFiles('setup.cfg') }} + restore-keys: | + ${{ runner.os }}-lint-${{ matrix.toxenv }}- + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools tox>=1.8 + - name: Test with tox + run: | + tox -e${{ matrix.toxenv }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..4084eb7 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,38 @@ +name: Upload Python Package + +on: + release: + types: [published,prereleased] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + - name: Cache pip + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ matrix.toxenv }} + restore-keys: | + ${{ runner.os }}-pip-${{ matrix.toxenv }} + - name: Cache tox + uses: actions/cache@v3 + with: + path: .tox + key: ${{ runner.os }}-tox-release-${{ hashFiles('setup.cfg') }} + restore-keys: | + ${{ runner.os }}-tox-release- + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools tox>=1.8 + - name: Build and publish + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + tox -erelease diff --git a/.gitignore b/.gitignore index 618e1ef..0137a63 100644 --- a/.gitignore +++ b/.gitignore @@ -1,53 +1,524 @@ + +# Created by https://www.gitignore.io/api/vim,node,sass,vuejs,linux,macos,django,python,pycharm,windows,virtualenv,sublimetext,visualstudiocode +# Edit at https://www.gitignore.io/?templates=vim,node,sass,vuejs,linux,macos,django,python,pycharm,windows,virtualenv,sublimetext,visualstudiocode + +### Django ### +*.log +*.pot +*.pyc +__pycache__/ +local_settings.py +db.sqlite3 +db.sqlite3-journal +media + +# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/ +# in your Git repository. Update and uncomment the following line accordingly. +# /staticfiles/ + +### Django.Python Stack ### +# Byte-compiled / optimized / DLL files *.py[cod] +*$py.class # C extensions *.so -# Packages -*.egg -*.egg-info -dist -build -eggs -parts -bin -var -sdist -develop-eggs +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ .installed.cfg -lib -lib64 +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec # Installer logs pip-log.txt +pip-delete-this-directory.txt # Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ .coverage -.tox +.coverage.* +.cache nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ # Translations *.mo +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + # Mr Developer .mr.developer.cfg .project .pydevproject -# Complexity -output/*.html -output/*/index.html +# mkdocs documentation +/site -# Sphinx -docs/_build +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json -# Temporary exclusion -tox.ini -.travis.yml -runtests.py -docs -tests -requirements-test.txt +# Pyre type checker +.pyre/ -# OS +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General .DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Node ### +# Logs +logs +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) + +# next.js build output +.next + +# nuxt.js build output +.nuxt + +# rollup.js default build output + +# Uncomment the public line if your project uses Gatsby +# https://nextjs.org/blog/next-9-1#public-directory-support +# https://create-react-app.dev/docs/using-the-public-folder/#docsNav +# public + +# Storybook build outputs +.out +.storybook-out + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# Temporary folders +tmp/ +temp/ + +### PyCharm ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### PyCharm Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +.idea/**/sonarlint/ + +# SonarQube Plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator/ + +### Python ### +# Byte-compiled / optimized / DLL files + +# C extensions + +# Distribution / packaging + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. + +# Installer logs + +# Unit test / coverage reports + +# Translations + +# Scrapy stuff: + +# Sphinx documentation + +# PyBuilder + +# pyenv + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. + +# celery beat schedule file + +# SageMath parsed files + +# Spyder project settings + +# Rope project settings + +# Mr Developer + +# mkdocs documentation + +# mypy + +# Pyre type checker + +### Sass ### +.sass-cache/ +*.css.map +*.sass.map +*.scss.map + +### SublimeText ### +# Cache files for Sublime Text +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache + +# Workspace files are user-specific +*.sublime-workspace + +# Project files should be checked into the repository, unless a significant +# proportion of contributors will probably not be using Sublime Text +# *.sublime-project + +# SFTP configuration file +sftp-config.json + +# Package control specific files +Package Control.last-run +Package Control.ca-list +Package Control.ca-bundle +Package Control.system-ca-bundle +Package Control.cache/ +Package Control.ca-certs/ +Package Control.merged-ca-bundle +Package Control.user-ca-bundle +oscrypto-ca-bundle.crt +bh_unicode_properties.cache + +# Sublime-github package stores a github token in this file +# https://packagecontrol.io/packages/sublime-github +GitHub.sublime-settings + +### Vim ### +# Swap +[._]*.s[a-v][a-z] +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist + +# Auto-generated tag files +tags + +# Persistent undo +[._]*.un~ + +# Coc configuration directory +.vim + +### VirtualEnv ### +# Virtualenv +# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ +pyvenv.cfg +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ +pip-selfcheck.json + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history + +### Vuejs ### +# Recommended template: Node.gitignore + +npm-debug.log +yarn-error.log + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.gitignore.io/api/vim,node,sass,vuejs,linux,macos,django,python,pycharm,windows,virtualenv,sublimetext,visualstudiocode + + +*.sqlite +data diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..14c41a3 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,42 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +exclude: "(.idea|node_modules|.tox)" +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: trailing-whitespace + exclude: "setup.cfg" + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + - id: check-builtin-literals + - id: check-executables-have-shebangs + - id: check-merge-conflict + - id: check-toml + - id: fix-encoding-pragma + args: + - --remove + - repo: https://github.com/PyCQA/isort + rev: "5.12.0" + hooks: + - id: isort + - repo: https://github.com/psf/black + rev: 23.3.0 + hooks: + - id: black + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: 'v0.0.262' + hooks: + - id: ruff + - repo: https://github.com/asottile/pyupgrade + rev: v3.3.1 + hooks: + - id: pyupgrade + args: + - --py3-plus + - repo: https://github.com/adamchainz/django-upgrade + rev: "1.13.0" + hooks: + - id: django-upgrade + args: [--target-version, "3.2"] diff --git a/.pyup.yml b/.pyup.yml new file mode 100644 index 0000000..2809577 --- /dev/null +++ b/.pyup.yml @@ -0,0 +1,7 @@ +update: all +pin: False +branch: +schedule: "every day" +search: True +branch_prefix: pyup/ +close_prs: True diff --git a/AUTHORS.rst b/AUTHORS.rst index be774ea..b454cc0 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -18,4 +18,4 @@ Fernando Macedo Gasim Gasimzada Mateus Pรกdua Paolo Romolini -Richard Terry \ No newline at end of file +Richard Terry diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 36fd67f..2467b9d 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -3,7 +3,7 @@ Contributing ============ Contributions are welcome, and they are greatly appreciated! Every -little bit helps, and credit will always be given. +little bit helps, and credit will always be given. You can contribute in many ways: @@ -36,7 +36,7 @@ is open to whoever wants to implement it. Write Documentation ~~~~~~~~~~~~~~~~~~~ -django-ckeditor-filebrowser-filer could always use more documentation, whether as part of the +django-ckeditor-filebrowser-filer could always use more documentation, whether as part of the official django-ckeditor-filebrowser-filer docs, in docstrings, or even on the web in blog posts, articles, and such. @@ -81,7 +81,7 @@ tests, including testing other Python versions with tox:: $ python setup.py test $ tox -To get flake8 and tox, just pip install them into your virtualenv. +To get flake8 and tox, just pip install them into your virtualenv. 6. Commit your changes and push your branch to GitHub:: @@ -100,7 +100,7 @@ Before you submit a pull request, check that it meets these guidelines: 2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst. -3. The pull request should work for Python 2.6, 2.7, and 3.3, and for PyPy. Check +3. The pull request should work for Python 2.6, 2.7, and 3.3, and for PyPy. Check https://travis-ci.org/nephila/django-ckeditor-filebrowser-filer/pull_requests and make sure that the tests pass for all supported Python versions. @@ -109,4 +109,4 @@ Tips To run a subset of tests:: - $ python -m unittest tests.test_ckeditor_filebrowser_filer \ No newline at end of file + $ python -m unittest tests.test_ckeditor_filebrowser_filer diff --git a/LICENSE b/LICENSE index a9a249c..f2578ad 100644 --- a/LICENSE +++ b/LICENSE @@ -9,4 +9,4 @@ Redistribution and use in source and binary forms, with or without modification, * Neither the name of django-ckeditor-filebrowser-filer nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/MANIFEST.in b/MANIFEST.in index bb90d32..8690462 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,4 +3,4 @@ include CONTRIBUTING.rst include HISTORY.rst include LICENSE include README.rst -recursive-include ckeditor_filebrowser_filer *.html *.png *.gif *js *.css *jpg *jpeg *svg *py \ No newline at end of file +recursive-include ckeditor_filebrowser_filer *.html *.png *.gif *js *.css *jpg *jpeg *svg *py diff --git a/Makefile b/Makefile deleted file mode 100644 index a60f029..0000000 --- a/Makefile +++ /dev/null @@ -1,46 +0,0 @@ -.PHONY: clean-pyc clean-build docs - -help: - @echo "clean-build - remove build artifacts" - @echo "clean-pyc - remove Python file artifacts" - @echo "lint - check style with flake8" - @echo "test - run tests quickly with the default Python" - @echo "test-all - run tests on every Python version with tox" - @echo "coverage - check code coverage quickly with the default Python" - @echo "release - package and upload a release" - @echo "sdist - package" - -clean: clean-build clean-pyc - -clean-build: - python setup.py clean --all - rm -fr build/ - rm -fr dist/ - rm -fr *.egg-info - -clean-pyc: - find . -name '*.pyc' -exec rm -f {} + - find . -name '*.pyo' -exec rm -f {} + - find . -name '*~' -exec rm -f {} + - -lint: - tox -epep8,isort - -test: - python setup.py test - -test-all: - tox - -coverage: - coverage erase - coverage run setup.py test - coverage report -m - -release: clean - python setup.py clean --all sdist bdist_wheel - twine upload dist/* - -sdist: clean - python setup.py sdist - ls -l dist diff --git a/ckeditor_filebrowser_filer/__init__.py b/ckeditor_filebrowser_filer/__init__.py index 4642865..4b57329 100644 --- a/ckeditor_filebrowser_filer/__init__.py +++ b/ckeditor_filebrowser_filer/__init__.py @@ -1,2 +1 @@ -# -*- coding: utf-8 -*- -__version__ = '0.3.0.post1' +__version__ = "0.3.0.post1" diff --git a/ckeditor_filebrowser_filer/models.py b/ckeditor_filebrowser_filer/models.py index 7c68785..e69de29 100644 --- a/ckeditor_filebrowser_filer/models.py +++ b/ckeditor_filebrowser_filer/models.py @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- \ No newline at end of file diff --git a/ckeditor_filebrowser_filer/static/ckeditor/ckeditor/plugins/filerimage/dialogs/filerImageDialog.js b/ckeditor_filebrowser_filer/static/ckeditor/ckeditor/plugins/filerimage/dialogs/filerImageDialog.js old mode 100755 new mode 100644 diff --git a/ckeditor_filebrowser_filer/static/ckeditor/ckeditor/plugins/filerimage/plugin.js b/ckeditor_filebrowser_filer/static/ckeditor/ckeditor/plugins/filerimage/plugin.js old mode 100755 new mode 100644 diff --git a/ckeditor_filebrowser_filer/static/djangocms_text_ckeditor/ckeditor/plugins/filerimage/dialogs/filerImageDialog.js b/ckeditor_filebrowser_filer/static/djangocms_text_ckeditor/ckeditor/plugins/filerimage/dialogs/filerImageDialog.js old mode 100755 new mode 100644 diff --git a/ckeditor_filebrowser_filer/static/djangocms_text_ckeditor/ckeditor/plugins/filerimage/plugin.js b/ckeditor_filebrowser_filer/static/djangocms_text_ckeditor/ckeditor/plugins/filerimage/plugin.js old mode 100755 new mode 100644 diff --git a/ckeditor_filebrowser_filer/urls.py b/ckeditor_filebrowser_filer/urls.py index 4283d92..fecf2b9 100644 --- a/ckeditor_filebrowser_filer/urls.py +++ b/ckeditor_filebrowser_filer/urls.py @@ -1,22 +1,32 @@ -# -*- coding: utf-8 -*- -from django.conf.urls import url -try: - from django.conf.urls import patterns -except: - def patterns(prefix, *urls): - return urls +from django.urls import path, re_path -from .views import * +from .views import filer_version, get_setting, serve_image, thumbnail_options, url_image, url_reverse -urlpatterns = patterns('', - url(r'version/$', filer_version, name='filer_version'), - url(r'setting/(?P\w+)/$', get_setting, name='get_setting'), - url(r'url_reverse/$', url_reverse, name='js_url_reverse'), - url(r'url_image/(?P\d+)/$', url_image, name='url_image'), - url(r'url_image/(?P\d+)/(?P\d+)/$', url_image, name='url_image'), - url(r'url_image/(?P\d+)/(?P\d+)/(?P\d+)/$', url_image, name='url_image'), - url(r'serve/(?P\d+)/$', serve_image, name='serve_image'), - url(r'serve/(?P\d+)/(?P\d+)/$', serve_image, name='serve_image'), - url(r'serve/(?P\d+)/(?P\d+)/(?P\d+)/$', serve_image, name='serve_image'), - url(r'thumbnail_options/$', thumbnail_options, name='thumbnail_options'), -) +urlpatterns = [ + path("version/", filer_version, name="filer_version"), + re_path(r"setting/(?P\w+)/$", get_setting, name="get_setting"), + path("url_reverse/", url_reverse, name="js_url_reverse"), + path("url_image//", url_image, name="url_image"), + path( + "url_image///", + url_image, + name="url_image", + ), + path( + "url_image////", + url_image, + name="url_image", + ), + path("serve//", serve_image, name="serve_image"), + path( + "serve///", + serve_image, + name="serve_image", + ), + path( + "serve////", + serve_image, + name="serve_image", + ), + path("thumbnail_options/", thumbnail_options, name="thumbnail_options"), +] diff --git a/ckeditor_filebrowser_filer/views.py b/ckeditor_filebrowser_filer/views.py index d3783ee..658158d 100644 --- a/ckeditor_filebrowser_filer/views.py +++ b/ckeditor_filebrowser_filer/views.py @@ -1,37 +1,19 @@ -# -*- coding: utf-8 -*- import json -from distutils.version import LooseVersion -from django import http +from django import http, urls from django.conf import settings -from django import urls from django.http import HttpResponseRedirect - -from filer.models import File +from filer.models import File, ThumbnailOption from filer.server.views import server -try: - from filer.models import ThumbnailOption -except ImportError: - from cmsplugin_filer_image.models import ThumbnailOption - def filer_version(request): - import filer - filer_legacy = LooseVersion(filer.__version__) < LooseVersion('1.1') - filer_11 = not filer_legacy and LooseVersion(filer.__version__) < LooseVersion('1.2') - filer_12 = LooseVersion(filer.__version__) >= LooseVersion('1.2') - if filer_11: - version = '1.1' - elif filer_12: - version = '1.2' - else: - version = '1.0' + version = "1.2" return http.HttpResponse(version) def get_setting(request, setting): - setting = 'CKEDITOR_FILEBROWSER_{}'.format(setting).upper() + setting = "CKEDITOR_FILEBROWSER_{}".format(setting).upper() try: return http.HttpResponse(int(getattr(settings, setting, False))) except ValueError: @@ -45,16 +27,16 @@ def url_reverse(request): :param request: Request object :return: The reversed path """ - if request.method in ('GET', 'POST'): - data = getattr(request, request.method) - url_name = data.get('url_name') - try: - path = urls.reverse(url_name, args=data.getlist('args')) + if request.method in ("GET", "POST"): + data = getattr(request, request.method) + url_name = data.get("url_name") + try: + path = urls.reverse(url_name, args=data.getlist("args")) (view_func, args, kwargs) = urls.resolve(path) - return http.HttpResponse(path, content_type='text/plain') - except urls.NoReverseMatch: - return http.HttpResponse('Error', content_type='text/plain') - return http.HttpResponseNotAllowed(('GET', 'POST')) + return http.HttpResponse(path, content_type="text/plain") + except urls.NoReverseMatch: + return http.HttpResponse("Error", content_type="text/plain") + return http.HttpResponseNotAllowed(("GET", "POST")) def _return_thumbnail(image, thumb_options=None, width=None, height=None): @@ -67,7 +49,7 @@ def _return_thumbnail(image, thumb_options=None, width=None, height=None): height = int(height) size = (width, height) - thumbnail_options.update({'size': size}) + thumbnail_options.update({"size": size}) if thumbnail_options != {}: thumbnailer = image.easy_thumbnails_thumbnailer @@ -88,7 +70,7 @@ def url_image(request, image_id, thumb_options=None, width=None, height=None): :return: JSON serialized URL components ('url', 'width', 'height') """ image = File.objects.get(pk=image_id) - if getattr(image, 'canonical_url', None): + if getattr(image, "canonical_url", None): url = image.canonical_url else: url = image.url @@ -97,11 +79,11 @@ def url_image(request, image_id, thumb_options=None, width=None, height=None): image = thumb url = image.url data = { - 'url': url, - 'width': image.width, - 'height': image.height, + "url": url, + "width": image.width, + "height": image.height, } - return http.HttpResponse(json.dumps(data), content_type='application/json') + return http.HttpResponse(json.dumps(data), content_type="application/json") def thumbnail_options(request): @@ -111,7 +93,7 @@ def thumbnail_options(request): :param request: Request object :return: JSON serialized ThumbnailOption """ - response_data = [{'id': opt.pk, 'name': opt.name} for opt in ThumbnailOption.objects.all()] + response_data = [{"id": opt.pk, "name": opt.name} for opt in ThumbnailOption.objects.all()] return http.HttpResponse(json.dumps(response_data), content_type="application/json") @@ -127,7 +109,7 @@ def serve_image(request, image_id, thumb_options=None, width=None, height=None): :return: JSON serialized URL components ('url', 'width', 'height') """ image = File.objects.get(pk=image_id) - if getattr(image, 'canonical_url', None): + if getattr(image, "canonical_url", None): url = image.canonical_url else: url = image.url diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..d4c9b45 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,42 @@ +[build-system] +requires = ["setuptools>=40.6.0", "wheel"] +build-backend = "setuptools.build_meta" + +[tool.black] +line-length = 119 +target-version = ["py310"] + +[tool.interrogate] +ignore-init-method = true +ignore-init-module = true +ignore-magic = false +ignore-semiprivate = false +ignore-private = false +ignore-module = true +ignore-nested-functions = true +fail-under = 0 +exclude = ["docs", ".tox"] +ignore-regex = ["^get$", "^mock_.*", ".*BaseClass.*"] +verbose = 0 +quiet = false +whitelist-regex = [] +color = true + +[tool.isort] +profile = "black" +combine_as_imports = true +default_section = "THIRDPARTY" +force_grid_wrap = 0 +include_trailing_comma = true +known_first_party = "knocker" +line_length = 119 +multi_line_output = 3 +use_parentheses = true + +[tool.ruff] +ignore = [] +line-length = 119 +target-version = "py310" + +[tool.ruff.mccabe] +max-complexity = 10 diff --git a/requirements.txt b/requirements.txt index d9aa73f..d08662f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -e . -wheel==0.22.0 \ No newline at end of file +wheel diff --git a/setup.cfg b/setup.cfg index 5eeb646..6acaee9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,51 @@ -[wheel] -universal = 1 +[metadata] +name = django-ckeditor-filebrowser-filer +version = attr: ckeditor_filebrowser_filer.__version__ +url = https://github.com/nephila/django-ckeditor-filebrowser-filer +author = Iacopo Spalletti +author_email = i.spalletti@nephila.it +description = A django-filer based CKEditor filebrowser +long_description = file: README.rst, HISTORY.rst +long_description_content_type = text/x-rst +license = BSD +license_file = LICENSE +classifiers = + License :: OSI Approved :: BSD License + Development Status :: 5 - Production/Stable + Framework :: Django + Framework :: Django :: 3.2 + Framework :: Django :: 4.1 + Framework :: Django :: 4.2 + Programming Language :: Python + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 + +[options] +include_package_data = True +install_requires = + django-filer>=1.3 +setup_requires = + setuptools +packages = ckeditor_filebrowser_filer +python_requires = >=3.7 +zip_safe = False +keywords = + django-ckeditor-filebrowser-filer + django + filer + ckeditor + filebrowser + +[options.package_data] +* = *.txt, *.rst +ckeditor_filebrowser_filer = *.html *.png *.gif *js *jpg *jpeg *svg *py *mo *po -[flake8] -max-line-length = 100 -ignore = E501 -exclude = tests/* +[sdist] +formats = zip + +[bdist_wheel] +universal = 1 diff --git a/setup.py b/setup.py old mode 100755 new mode 100644 index 87b73ae..b908cbe --- a/setup.py +++ b/setup.py @@ -1,60 +1,3 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- +import setuptools -import os -import sys - -import ckeditor_filebrowser_filer - -try: - from setuptools import setup -except ImportError: - from distutils.core import setup - -version = ckeditor_filebrowser_filer.__version__ - -if sys.argv[-1] == 'publish': - os.system('python setup.py sdist upload') - print('You probably want to also tag the version now:') - print(' git tag -a %s -m \'version %s\'' % (version, version)) - print(' git push --tags') - sys.exit() - -readme = open('README.rst').read() -history = open('HISTORY.rst').read().replace('.. :changelog:', '') - -setup( - name='django-ckeditor-filebrowser-filer', - version=version, - description='A django-filer based CKEditor filebrowser', - long_description=readme + '\n\n' + history, - author='Iacopo Spalletti', - author_email='i.spalletti@nephila.it', - url='https://github.com/nephila/django-ckeditor-filebrowser-filer', - packages=[ - 'ckeditor_filebrowser_filer', - ], - include_package_data=True, - install_requires=[ - 'django-filer>=1.0', - ], - license='BSD', - zip_safe=False, - keywords='django-ckeditor-filebrowser-filer, django, filer, ckeditor, filebrowser', - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Framework :: Django', - 'Framework :: Django :: 1.11', - 'Framework :: Django :: 2.0', - 'Framework :: Django :: 2.1', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: BSD License', - 'Natural Language :: English', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - ], -) +setuptools.setup() diff --git a/tasks.py b/tasks.py new file mode 100644 index 0000000..b4d9fcd --- /dev/null +++ b/tasks.py @@ -0,0 +1,142 @@ +import io +import os +import re +import sys +from glob import glob + +from invoke import task + +DOCS_PORT = os.environ.get("DOCS_PORT", 8000) +#: branch prefixes for which some checks are skipped +SPECIAL_BRANCHES = ("master", "develop", "release") + + +@task +def clean(c): + """Remove artifacts and binary files.""" + c.run("python setup.py clean --all") + patterns = ["build", "dist"] + patterns.extend(glob("*.egg*")) + patterns.append("docs/_build") + patterns.append("**/*.pyc") + for pattern in patterns: + c.run("rm -rf {}".format(pattern)) + + +@task +def lint(c): + """Run linting tox environments.""" + c.run("tox -eruff,isort,black,pypi-description") + + +@task # NOQA +def format(c): # NOQA + """Run code formatting tasks.""" + c.run("tox -eblacken,isort_format") + + +@task +def towncrier_check(c): # NOQA + """Check towncrier files.""" + output = io.StringIO() + c.run("git branch -a --contains HEAD", out_stream=output) + skipped_branch_prefix = ["pull/", "release/", "develop", "master", "HEAD"] + # cleanup branch names by removing PR-only names in local, remote and disconnected branches to ensure the current + # (i.e. user defined) branch name is used + branches = list( + filter( + lambda x: x and all(not x.startswith(part) for part in skipped_branch_prefix), + ( + branch.replace("origin/", "").replace("remotes/", "").strip("* (") + for branch in output.getvalue().split("\n") + ), + ) + ) + if not branches: + # if no branch name matches, we are in one of the excluded branches above, so we just exit + return + branch = branches[0] + towncrier_file = None + for branch in branches: + if any(branch.startswith(prefix) for prefix in SPECIAL_BRANCHES): + sys.exit(0) + try: + parts = re.search(r"(?P\w+)/\D*(?P\d+)\D*", branch).groups() + towncrier_file = os.path.join("changes", "{1}.{0}".format(*parts)) + if not os.path.exists(towncrier_file) or os.path.getsize(towncrier_file) == 0: + print( + "=========================\n" + "Current tree does not contain the towncrier file {} or file is empty\n" + "please check CONTRIBUTING documentation.\n" + "=========================" + "".format(towncrier_file) + ) + sys.exit(2) + else: + break + except AttributeError: + pass + if not towncrier_file: + print( + "=========================\n" + "Branch {} does not respect the '/(-)-description' format\n" + "=========================\n" + "".format(branch) + ) + sys.exit(1) + + +@task +def test(c): + """Run test in local environment.""" + c.run("python setup.py test") + + +@task +def test_all(c): + """Run all tox environments.""" + c.run("tox") + + +@task +def coverage(c): + """Run test with coverage in local environment.""" + c.run("coverage erase") + c.run("run setup.py test") + c.run("report -m") + + +@task +def tag_release(c, level, new_version=""): + """Tag release version.""" + if new_version: + new_version = f" --new-version {new_version}" + c.run(f"bumpversion --list {level} --no-tag{new_version}") + + +@task +def tag_dev(c, level="patch", new_version=""): + """Tag development version.""" + if new_version: + new_version = f" --new-version {new_version}" + c.run(f"bumpversion --list {level} --message='Bump develop version [ci skip]' --no-tag{new_version}") + + +@task(pre=[clean]) +def docbuild(c): + """Build documentation.""" + os.chdir("docs") + build_dir = os.environ.get("BUILD_DIR", "_build/html") + c.run("python -msphinx -W -b html -d _build/doctrees . %s" % build_dir) + + +@task(docbuild) +def docserve(c): + """Serve docs at http://localhost:$DOCS_PORT/ (default port is 8000).""" + from livereload import Server + + server = Server() + server.watch("docs/conf.py", lambda: docbuild(c)) + server.watch("CONTRIBUTING.rst", lambda: docbuild(c)) + server.watch("docs/*.rst", lambda: docbuild(c)) + server.serve(port=DOCS_PORT, root="_build/html") diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..cfe15ed --- /dev/null +++ b/tox.ini @@ -0,0 +1,91 @@ +[tox] +envlist = + black + blacken + docs + isort + isort_format + ruff + pypi-description + +[testenv] +passenv = + COMMAND + PYTEST_* + +[testenv:ruff] +commands = + {envpython} -m ruff check ckeditor_filebrowser_filer {posargs} + {envpython} -minterrogate -c pyproject.toml ckeditor_filebrowser_filer +deps = + interrogate + ruff +skip_install = true + +[testenv:isort] +commands = + {envpython} -m isort -c --df ckeditor_filebrowser_filer +deps = isort>=5.12.0,<5.13.0 +skip_install = true + +[testenv:isort_format] +commands = + {envpython} -m isort ckeditor_filebrowser_filer +deps = {[testenv:isort]deps} +skip_install = true + +[testenv:black] +commands = + {envpython} -m black --check --diff . +deps = black +skip_install = true + +[testenv:blacken] +commands = + {envpython} -m black . +deps = {[testenv:black]deps} +skip_install = true + +[testenv:pypi-description] +commands = + {envpython} -m invoke clean + {envpython} -m check_manifest + {envpython} -m build . + {envpython} -m twine check dist/* +deps = + invoke + check-manifest + build + twine +skip_install = true + +[testenv:release] +commands = + {envpython} -m invoke clean + {envpython} -m check_manifest + {envpython} -m build . + {envpython} -m twine upload {posargs} dist/* +deps = {[testenv:pypi-description]deps} +passenv = + TWINE_* +skip_install = true + +[check-manifest] +ignore = + .* + *.ini + *.toml + *.json + *.txt + *.yml + *.yaml + .tx/** + changes/** + docs/** + cms_helper.py + aldryn_config.py + tasks.py + tests/** + *.mo +ignore-bad-ideas = + *.mo From bb381daaa0fa315fec45c450d0e39eb2b67499ba Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 25 Apr 2023 03:46:57 +0000 Subject: [PATCH 02/12] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/pyupgrade: v3.3.1 โ†’ v3.3.2](https://github.com/asottile/pyupgrade/compare/v3.3.1...v3.3.2) --- .github/workflows/codeql-analysis.yml | 76 +++++++++++++++++++++++++++ .github/workflows/lint.yml | 3 +- .pre-commit-config.yaml | 2 +- 3 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..0310222 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,76 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ "master" ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "master" ] + schedule: + - cron: '37 3 * * 3' + +jobs: + analyze: + name: Analyze + runs-on: 'ubuntu-latest' + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'python' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Use only 'java' to analyze code written in Java, Kotlin or both + # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # โ„น๏ธ Command-line programs to run using the OS shell. + # ๐Ÿ“š See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 465a08f..d191889 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -35,7 +35,8 @@ jobs: ${{ runner.os }}-lint-${{ matrix.toxenv }}- - name: Install dependencies run: | - python -m pip install --upgrade pip setuptools tox>=1.8 + python -m pip install --upgrade pip setuptools tox>4 - name: Test with tox + if: ${{ matrix.toxenv != 'towncrier' || (!contains(github.event.head_commit.message, '[pre-commit.ci]') && !contains(github.event.pull_request.body, 'pre-commit.ci start')) }} run: | tox -e${{ matrix.toxenv }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 14c41a3..d27d231 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,7 +30,7 @@ repos: hooks: - id: ruff - repo: https://github.com/asottile/pyupgrade - rev: v3.3.1 + rev: v3.3.2 hooks: - id: pyupgrade args: From 9002e2ecb1a37a942bfbfa4993b670027729d525 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Tue, 25 Apr 2023 10:22:19 +0200 Subject: [PATCH 03/12] Create codeql.yml --- .github/workflows/codeql.yml | 76 ++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..02952f5 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,76 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ "develop" ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "develop" ] + schedule: + - cron: '45 4 * * 6' + +jobs: + analyze: + name: Analyze + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'javascript', 'python' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Use only 'java' to analyze code written in Java, Kotlin or both + # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # โ„น๏ธ Command-line programs to run using the OS shell. + # ๐Ÿ“š See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" From 8243ce3b02a50c97cad74f763bc48b89e77fbf1a Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Tue, 25 Apr 2023 10:22:43 +0200 Subject: [PATCH 04/12] Delete codeql-analysis.yml --- .github/workflows/codeql-analysis.yml | 76 --------------------------- 1 file changed, 76 deletions(-) delete mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 0310222..0000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,76 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -on: - push: - branches: [ "master" ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ "master" ] - schedule: - - cron: '37 3 * * 3' - -jobs: - analyze: - name: Analyze - runs-on: 'ubuntu-latest' - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'python' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Use only 'java' to analyze code written in Java, Kotlin or both - # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # โ„น๏ธ Command-line programs to run using the OS shell. - # ๐Ÿ“š See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:${{matrix.language}}" From dcfa908a153e379f6f667e11adeab2a795bc6d33 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Tue, 25 Apr 2023 10:25:51 +0200 Subject: [PATCH 05/12] Add GH actions logger --- .github/workflows/logger.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/workflows/logger.yml diff --git a/.github/workflows/logger.yml b/.github/workflows/logger.yml new file mode 100644 index 0000000..7b47896 --- /dev/null +++ b/.github/workflows/logger.yml @@ -0,0 +1,11 @@ +name: Event Logger +on: push + +jobs: + log-github-event-goodies: + name: "LOG Everything on GitHub Event" + runs-on: ubuntu-latest + steps: + - name: Logging + run: | + echo '${{toJSON(github.event)}}' From 68b187eb5d0866268bfc79501458d0c4ba459361 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 2 May 2023 03:56:46 +0000 Subject: [PATCH 06/12] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/charliermarsh/ruff-pre-commit: v0.0.262 โ†’ v0.0.263](https://github.com/charliermarsh/ruff-pre-commit/compare/v0.0.262...v0.0.263) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d27d231..fc66912 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,7 +26,7 @@ repos: hooks: - id: black - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: 'v0.0.262' + rev: 'v0.0.263' hooks: - id: ruff - repo: https://github.com/asottile/pyupgrade From 1cf07ce954462adb3b996c6799e2fafdedd4e183 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 9 May 2023 04:31:35 +0000 Subject: [PATCH 07/12] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/charliermarsh/ruff-pre-commit: v0.0.263 โ†’ v0.0.265](https://github.com/charliermarsh/ruff-pre-commit/compare/v0.0.263...v0.0.265) - [github.com/asottile/pyupgrade: v3.3.2 โ†’ v3.4.0](https://github.com/asottile/pyupgrade/compare/v3.3.2...v3.4.0) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fc66912..ebb139e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,11 +26,11 @@ repos: hooks: - id: black - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: 'v0.0.263' + rev: 'v0.0.265' hooks: - id: ruff - repo: https://github.com/asottile/pyupgrade - rev: v3.3.2 + rev: v3.4.0 hooks: - id: pyupgrade args: From f63728ff3ed148d232020c739920ff6e59c40afa Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 16 May 2023 03:47:21 +0000 Subject: [PATCH 08/12] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/charliermarsh/ruff-pre-commit: v0.0.265 โ†’ v0.0.267](https://github.com/charliermarsh/ruff-pre-commit/compare/v0.0.265...v0.0.267) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ebb139e..3b6c37d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,7 +26,7 @@ repos: hooks: - id: black - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: 'v0.0.265' + rev: 'v0.0.267' hooks: - id: ruff - repo: https://github.com/asottile/pyupgrade From d216188f2efb7bfd804c3b9dc7429a6eca157476 Mon Sep 17 00:00:00 2001 From: Corentin Bettiol Date: Thu, 6 Jul 2023 10:08:02 +0200 Subject: [PATCH 09/12] MAINT: update contributing commands --- CONTRIBUTING.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 2467b9d..7cbdde2 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -66,7 +66,7 @@ Ready to contribute? Here's how to set up `django-ckeditor-filebrowser-filer` fo $ mkvirtualenv django-ckeditor-filebrowser-filer $ cd django-ckeditor-filebrowser-filer/ - $ python setup.py develop + $ python3 -m pip install -e . 4. Create a branch for local development:: @@ -78,7 +78,7 @@ Now you can make your changes locally. tests, including testing other Python versions with tox:: $ flake8 ckeditor_filebrowser_filer tests - $ python setup.py test + $ python3 setup.py test $ tox To get flake8 and tox, just pip install them into your virtualenv. @@ -109,4 +109,4 @@ Tips To run a subset of tests:: - $ python -m unittest tests.test_ckeditor_filebrowser_filer + $ python3 -m unittest tests.test_ckeditor_filebrowser_filer From 2360bfe81a94faa90a723baae80468aedcf89fc7 Mon Sep 17 00:00:00 2001 From: Corentin Bettiol Date: Thu, 6 Jul 2023 10:09:42 +0200 Subject: [PATCH 10/12] FIX: remove double "search" image in modal Improve display of options (split line) --- .../filerimage/dialogs/filerImageDialog.js | 33 ++++++++++-------- .../filerimage/dialogs/filerImageDialog.js | 34 +++++++++++-------- 2 files changed, 37 insertions(+), 30 deletions(-) diff --git a/ckeditor_filebrowser_filer/static/ckeditor/ckeditor/plugins/filerimage/dialogs/filerImageDialog.js b/ckeditor_filebrowser_filer/static/ckeditor/ckeditor/plugins/filerimage/dialogs/filerImageDialog.js index 0200ff6..454d6bf 100644 --- a/ckeditor_filebrowser_filer/static/ckeditor/ckeditor/plugins/filerimage/dialogs/filerImageDialog.js +++ b/ckeditor_filebrowser_filer/static/ckeditor/ckeditor/plugins/filerimage/dialogs/filerImageDialog.js @@ -40,7 +40,6 @@ ' ' + '' + - '' + lang.browse +'' + '' + '' + lang.clear + '' + '
' + @@ -135,20 +134,8 @@ var extra_items = [ { type: 'hbox', - widths: [ '33%', '33%', '33%' ], + widths: [ '50%', '50%' ], children: [ - { - type: 'checkbox', - id: 'use_original_image', - label: lang.useOriginal, - setup: function (element) { - this.setValue(element.getAttribute('original_image')); - }, - // Called by the main commitContent call on dialog confirmation. - commit: function (element) { - element.setAttribute('original_image', this.getValue()); - } - }, { type: 'text', id: 'width', @@ -158,7 +145,6 @@ var ratio = this.getValue() / imageWidth; // get ratio for scaling image dialog.getContentElement('tab-basic', 'height').setValue(Math.ceil(imageHeight * ratio)); } - //getImageUrl(); }, setup: function (element) { @@ -187,6 +173,23 @@ ] }, { + type: 'hbox', + widths: [ '100%'], + children: [ + { + type: 'checkbox', + id: 'use_original_image', + label: lang.useOriginal, + setup: function (element) { + this.setValue(element.getAttribute('original_image')); + }, + // Called by the main commitContent call on dialog confirmation. + commit: function (element) { + element.setAttribute('original_image', this.getValue()); + } + } + ] + }, { type: 'hbox', widths: [ '33%', '33%', '33%' ], children: [ diff --git a/ckeditor_filebrowser_filer/static/djangocms_text_ckeditor/ckeditor/plugins/filerimage/dialogs/filerImageDialog.js b/ckeditor_filebrowser_filer/static/djangocms_text_ckeditor/ckeditor/plugins/filerimage/dialogs/filerImageDialog.js index 0200ff6..699f2a6 100644 --- a/ckeditor_filebrowser_filer/static/djangocms_text_ckeditor/ckeditor/plugins/filerimage/dialogs/filerImageDialog.js +++ b/ckeditor_filebrowser_filer/static/djangocms_text_ckeditor/ckeditor/plugins/filerimage/dialogs/filerImageDialog.js @@ -40,7 +40,6 @@ ' ' + '' + - '' + lang.browse +'' + '' + '' + lang.clear + '' + '
' + @@ -135,20 +134,8 @@ var extra_items = [ { type: 'hbox', - widths: [ '33%', '33%', '33%' ], + widths: [ '50%', '50%' ], children: [ - { - type: 'checkbox', - id: 'use_original_image', - label: lang.useOriginal, - setup: function (element) { - this.setValue(element.getAttribute('original_image')); - }, - // Called by the main commitContent call on dialog confirmation. - commit: function (element) { - element.setAttribute('original_image', this.getValue()); - } - }, { type: 'text', id: 'width', @@ -158,7 +145,6 @@ var ratio = this.getValue() / imageWidth; // get ratio for scaling image dialog.getContentElement('tab-basic', 'height').setValue(Math.ceil(imageHeight * ratio)); } - //getImageUrl(); }, setup: function (element) { @@ -186,6 +172,24 @@ } ] }, + { + type: 'hbox', + widths: [ '100%'], + children: [ + { + type: 'checkbox', + id: 'use_original_image', + label: lang.useOriginal, + setup: function (element) { + this.setValue(element.getAttribute('original_image')); + }, + // Called by the main commitContent call on dialog confirmation. + commit: function (element) { + element.setAttribute('original_image', this.getValue()); + } + } + ] + }, { type: 'hbox', widths: [ '33%', '33%', '33%' ], From 435abe31d845a27ba4e0c0467f97b8ff53c12b8e Mon Sep 17 00:00:00 2001 From: Corentin Bettiol Date: Thu, 6 Jul 2023 10:12:39 +0200 Subject: [PATCH 11/12] DOCS: update readme --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 8a0feb9..332d916 100644 --- a/README.rst +++ b/README.rst @@ -9,9 +9,9 @@ A django-filer based CKEditor filebrowser Supported versions ================== -Python: 2.7, 3.5, 3.6, 2.7 +Python: 3.7 to 3.11 -Django: 1.11 to 2.1 +Django: 3.2 to 4.2 django-filer: 1.2 and above From f1cae2f7ec7dbd19d5db63504c927ef7d08874c0 Mon Sep 17 00:00:00 2001 From: Corentin Bettiol Date: Thu, 6 Jul 2023 10:13:26 +0200 Subject: [PATCH 12/12] MAINT: add dependency to django-ckeditor<=6.6.1 (contains dark theme-related fixes) --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index 6acaee9..8424400 100644 --- a/setup.cfg +++ b/setup.cfg @@ -28,6 +28,7 @@ classifiers = include_package_data = True install_requires = django-filer>=1.3 + django-ckeditor>=6.6.1 setup_requires = setuptools packages = ckeditor_filebrowser_filer