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/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}}" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..d191889 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,42 @@ +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>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/.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)}}' 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..965a7f1 --- /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.6.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.13.2" + hooks: + - id: isort + - repo: https://github.com/psf/black + rev: 24.4.0 + hooks: + - id: black + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: 'v0.3.7' + hooks: + - id: ruff + - repo: https://github.com/asottile/pyupgrade + rev: v3.15.2 + hooks: + - id: pyupgrade + args: + - --py3-plus + - repo: https://github.com/adamchainz/django-upgrade + rev: "1.16.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..e3072c4 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -3,110 +3,6 @@ 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: - -Types of Contributions ----------------------- - -Report Bugs -~~~~~~~~~~~ - -Report bugs at https://github.com/nephila/django-ckeditor-filebrowser-filer/issues. - -If you are reporting a bug, please include: - -* Your operating system name and version. -* Any details about your local setup that might be helpful in troubleshooting. -* Detailed steps to reproduce the bug. - -Fix Bugs -~~~~~~~~ - -Look through the GitHub issues for bugs. Anything tagged with "bug" -is open to whoever wants to implement it. - -Implement Features -~~~~~~~~~~~~~~~~~~ - -Look through the GitHub issues for features. Anything tagged with "feature" -is open to whoever wants to implement it. - -Write Documentation -~~~~~~~~~~~~~~~~~~~ - -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. - -Submit Feedback -~~~~~~~~~~~~~~~ - -The best way to send feedback is to file an issue at https://github.com/nephila/django-ckeditor-filebrowser-filer/issues. - -If you are proposing a feature: - -* Explain in detail how it would work. -* Keep the scope as narrow as possible, to make it easier to implement. -* Remember that this is a volunteer-driven project, and that contributions - are welcome :) - -Get Started! ------------- - -Ready to contribute? Here's how to set up `django-ckeditor-filebrowser-filer` for local development. - -1. Fork the `django-ckeditor-filebrowser-filer` repo on GitHub. -2. Clone your fork locally:: - - $ git clone git@github.com:your_name_here/django-ckeditor-filebrowser-filer.git - -3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:: - - $ mkvirtualenv django-ckeditor-filebrowser-filer - $ cd django-ckeditor-filebrowser-filer/ - $ python setup.py develop - -4. Create a branch for local development:: - - $ git checkout -b name-of-your-bugfix-or-feature - -Now you can make your changes locally. - -5. When you're done making changes, check that your changes pass flake8 and the -tests, including testing other Python versions with tox:: - - $ flake8 ckeditor_filebrowser_filer tests - $ python setup.py test - $ tox - -To get flake8 and tox, just pip install them into your virtualenv. - -6. Commit your changes and push your branch to GitHub:: - - $ git add . - $ git commit -m "Your detailed description of your changes." - $ git push origin name-of-your-bugfix-or-feature - -7. Submit a pull request through the GitHub website. - -Pull Request Guidelines ------------------------ - -Before you submit a pull request, check that it meets these guidelines: - -1. The pull request should include tests. -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 - https://travis-ci.org/nephila/django-ckeditor-filebrowser-filer/pull_requests - and make sure that the tests pass for all supported Python versions. - -Tips ----- - -To run a subset of tests:: - - $ python -m unittest tests.test_ckeditor_filebrowser_filer \ No newline at end of file +Please read the instructions `here `_ to start contributing to `django-ckeditor-filebrowser-filer`. diff --git a/HISTORY.rst b/HISTORY.rst index b66126f..fd235f1 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,55 +1,73 @@ .. :changelog: +------- History ------- +.. towncrier release notes start + +0.5.0 (2023-09-27) +================== + +Bugfixes +-------- + +- Fix filer_version url and migrate to bump-my-version (#59) + + +0.4.0 (2023-08-03) +================== + +- Added compatibility with Django 4.2 +- Drop support for Django<3.2 + 0.3.0 (2019-03-23) -++++++++++++++++++ +================== -* Added compatibility with Django 2.0 +- Added compatibility with Django 2.0 0.2.5 (2018-03-29) -++++++++++++++++++ +================== -* Fixed error when editing an image +- Fixed error when editing an image 0.2.4 (2018-01-09) -++++++++++++++++++ +================== -* Fixed filer version detection -* Added support for Django 1.11 +- Fixed filer version detection +- Added support for Django 1.11 0.2.3 (2017-04-19) -++++++++++++++++++ +================== -* Added russian translations +- Added russian translations 0.2.2 (2017-03-14) -++++++++++++++++++ +================== -* Added french translations +- Added french translations 0.2.1 (2017-01-01) -++++++++++++++++++ +================== -* Added support for Django 1.10 +- Added support for Django 1.10 0.2.0 (2016-10-22) -++++++++++++++++++ +================== -* Added support for canonical urls feature of filer 1.0 -* Added support to django-ckeditor (without django CMS) -* Added support to filer up to 1.2 -* Added support to ThumbnailOption -* Updated to work with djangocms-text-ckeditor 2.7 -* Fixed support for advanced deployment structure +- Added support for canonical urls feature of filer 1.0 +- Added support to django-ckeditor (without django CMS) +- Added support to filer up to 1.2 +- Added support to ThumbnailOption +- Updated to work with djangocms-text-ckeditor 2.7 +- Fixed support for advanced deployment structure 0.1.1 (2014-09-27) -++++++++++++++++++ +================== -* Fix static files position +- Fix static files position 0.1.0 (2014-01-27) -++++++++++++++++++ +================== -* First release on PyPI. +- First release on PyPI. 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/README.rst b/README.rst index 8a0feb9..8a3a92a 100644 --- a/README.rst +++ b/README.rst @@ -9,11 +9,11 @@ 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 +django-filer: 2.0 and above Documentation ------------- diff --git a/ckeditor_filebrowser_filer/__init__.py b/ckeditor_filebrowser_filer/__init__.py index a750fdc..bcaaf3b 100644 --- a/ckeditor_filebrowser_filer/__init__.py +++ b/ckeditor_filebrowser_filer/__init__.py @@ -1,2 +1 @@ -# -*- coding: utf-8 -*- -__version__ = '0.3.0' +__version__ = "0.5.1.dev1" 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 index 3fee423..ed19b3b --- a/ckeditor_filebrowser_filer/static/ckeditor/ckeditor/plugins/filerimage/plugin.js +++ b/ckeditor_filebrowser_filer/static/ckeditor/ckeditor/plugins/filerimage/plugin.js @@ -40,7 +40,7 @@ editor.base_admin = data.replace(/\/$/, ""); }); - jQuery.get('/filebrowser_filer/filer_version/', { }, function(data) { + jQuery.get('/filebrowser_filer/version/', { }, function(data) { editor.filer_version = data; if(data == '1.1' || data == '1.2') { CKEDITOR.scriptLoader.load( that.path + '../../../../filer/js/addons/popup_handling.js' ); 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 index 3fee423..ed19b3b --- 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 @@ -40,7 +40,7 @@ editor.base_admin = data.replace(/\/$/, ""); }); - jQuery.get('/filebrowser_filer/filer_version/', { }, function(data) { + jQuery.get('/filebrowser_filer/version/', { }, function(data) { editor.filer_version = data; if(data == '1.1' || data == '1.2') { CKEDITOR.scriptLoader.load( that.path + '../../../../filer/js/addons/popup_handling.js' ); 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..8d14f0c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,80 @@ +[build-system] +requires = ["setuptools>=40.6.0", "wheel"] +build-backend = "setuptools.build_meta" + +[tool.black] +line-length = 119 +target-version = ["py310"] + +[tool.towncrier] +package = "ckeditor_filebrowser_filer" +directory = "changes" +filename = "HISTORY.rst" +title_format = "{version} ({project_date})" + +[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 + +[tool.bumpversion] +allow_dirty = false +commit = true +message = "Release {new_version}" +commit_args = "--no-verify" +tag = false +current_version = "0.5.1.dev1" +parse = """(?x) + (?P[0-9]+) + \\.(?P[0-9]+) + \\.(?P[0-9]+) + (?: + .(?Pdev) + (?:(?P[0-9]+))? + )? +""" +serialize = [ + "{major}.{minor}.{patch}.{release}{relver}", + "{major}.{minor}.{patch}" +] + +[tool.bumpversion.parts.release] +values = [ + "dev", + "" +] +optional_value = "dev" + +[[tool.bumpversion.files]] +filename = "ckeditor_filebrowser_filer/__init__.py" +search = "{current_version}" 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..2ac7c57 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>=2.0 +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..d987d76 --- /dev/null +++ b/tasks.py @@ -0,0 +1,145 @@ +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"bump-my-version bump {level}{new_version}") + + +@task +def tag_dev(c, level, new_version=""): + """Tag development version.""" + if new_version: + new_version = f" --new-version {new_version}" + elif level == "release": + c.run("bump-my-version bump patch --no-commit") + level = "relver" + c.run(f"bump-my-version bump {level} --message='Bump develop version [ci skip]' {new_version} --allow-dirty") + + +@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