diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..7ddc3b4 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,6 @@ +[report] +include = + src/collective.volto/* +omit = + */test* + */upgrades/* diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..a83363b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +[*] +indent_style = space +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +charset = utf-8 + +[{*.py,*.cfg}] +indent_size = 4 + +[{*.html,*.dtml,*.pt,*.zpt,*.xml,*.zcml,*.js}] +indent_size = 2 + +[Makefile] +indent_style = tab diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..af46901 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +CHANGES.rst merge=union \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..ead541e --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,16 @@ +* collective.volto.sitesettings version: +* Plone Version: +* Python version: +* Operating System: Linux + +### Description + +Describe what you were trying to get done. +Tell us what happened, what went wrong, and what you expected to happen. + +### What I Did + +``` +Paste the command(s) you ran and the output. +If there was a crash, please include the traceback here. +``` diff --git a/.github/workflows/plone-package.yml b/.github/workflows/plone-package.yml new file mode 100644 index 0000000..9cc2434 --- /dev/null +++ b/.github/workflows/plone-package.yml @@ -0,0 +1,65 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Plone package + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + plone-version: + - 'Plone52' + - 'Plone60' + python-version: [3.7, 3.8, 3.9] + + steps: + - uses: actions/setup-python@v4 + with: + python-version: '3.9' + - uses: actions/checkout@v3 + - uses: actions/cache@v3 + with: + path: | + ~/.cache/pip + ~/buildout-cache + ~/extends + key: ${{ runner.os }}-tox-${{ matrix.python-version }}-${{ matrix.plone-version }}-${{ hashFiles('**/setup.py') }}-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/*.cfg') }}-${{ hashFiles('**/constraints.txt') }}-${{ hashFiles('**/tox.ini') }} + #restore-keys: | + # ${{ runner.os }}-tox- + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: setup buildout cache + run: | + mkdir -p ~/buildout-cache/{eggs,downloads} + mkdir ~/.buildout + echo "[buildout]" > $HOME/.buildout/default.cfg + echo "download-cache = $HOME/buildout-cache/downloads" >> $HOME/.buildout/default.cfg + echo "eggs-directory = $HOME/buildout-cache/eggs" >> $HOME/.buildout/default.cfg + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox tox-gh-actions + - name: Black-Check + run: | + tox -r -e black-check + - name: Test with tox + run: | + tox -r + env: + PLONE-VERSION: ${{ matrix.plone-version }} + PYTHON-VERSION: ${{ matrix.python-version }} + - name: "Upload coverage to Codecov" + uses: "codecov/codecov-action@v3" + with: + fail_ci_if_error: true + if: matrix.python-version == '3.7' diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3988bfb --- /dev/null +++ b/.gitignore @@ -0,0 +1,39 @@ +.coverage +.coverage.* +*.egg-info +*.log +*.mo +*.py? +*.swp +.*project +# dirs +/.settings/ +bin/ +buildout-cache/ +develop-eggs/ +eggs/ +htmlcov/ +include/ +lib/ +local/ +node_modules/ +parts/ +dist/* +test.plone_addon/ +var/ +# files +.installed.cfg +.mr.developer.cfg +coverage.xml +lib64 +local.cfg +log.html +output.xml +pip-selfcheck.json +pyvenv.cfg +report.html +.vscode/ +.tox/ +reports/ +venv/ +# excludes diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..2254cef --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,71 @@ +# This file is a template, and might need editing before it works on your project. +# Official language image. Look for the different tagged releases at: +# https://hub.docker.com/r/library/plone/tags/ +image: python:3.7-buster + +# Change pip's cache directory to be inside the project directory since we can +# only cache local items. +variables: + PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" + +# Pip's cache doesn't store the python packages +# https://pip.pypa.io/en/stable/reference/pip_install/#caching +# +# If you want to also cache the installed packages, you have to install +# them in a virtualenv and cache it as well. +cache: + paths: + - .cache/pip + - venv/ + - downloads/ + - eggs/ + +# Set execution order: first run jobs on 'test' stage on parallel +# then run jobs on 'report' stage +stages: + - test + - report + +before_script: + - echo "deb http://ftp.de.debian.org/debian/ stretch main contrib non-free" >> /etc/apt/sources.list + - apt-get update + - apt-get install -y firefoxdriver + - apt-get install -y xvfb + - python -V # Print out python version for debugging + - pip install virtualenv + - export LC_CTYPE=en_US.UTF-8 + - export LC_ALL=en_US.UTF-8 + - export LANG=en_US.UTF-8 + - python3 -m venv venv + - source venv/bin/activate + - pip install -r requirements.txt + - buildout bootstrap + - bin/buildout -n -c buildout.cfg + +code-analysis: + stage: test + # still not available, see: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5004 + # success_with_warnings: True + script: + - tox -e black-check + - tox -e py37-lint + +test: + stage: test + script: + - export DISPLAY=:99.0 + # - sh -e /etc/init.d/xvfb start + - tox -r + +coverage: + stage: report + script: + - bin/createcoverage + - bin/coverage html + - bin/coverage report + when: on_success + + coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+\%)/' + artifacts: + paths: + - htmlcov diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..0bb2ac1 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,61 @@ +dist: bionic +language: python +cache: + pip: true + directories: + - eggs + - $HOME/buildout-cache + - $HOME/.buildout +python: + - "2.7" +matrix: + include: + - python: "2.7" + env: PLONE_VERSION=43 + - python: "2.7" + env: PLONE_VERSION=51 + - python: "2.7" + env: PLONE_VERSION=52 + - python: "3.7" + env: PLONE_VERSION=52 + fast_finish: true + +before_install: + - mkdir -p $HOME/buildout-cache/{downloads,eggs,extends} + - mkdir -p $HOME/.buildout + - echo "[buildout]" > $HOME/.buildout/default.cfg + - echo "download-cache = $HOME/buildout-cache/downloads" >> $HOME/.buildout/default.cfg + - echo "eggs-directory = $HOME/buildout-cache/eggs" >> $HOME/.buildout/default.cfg + - echo "extends-cache = $HOME/buildout-cache/extends" >> $HOME/.buildout/default.cfg + - echo "abi-tag-eggs = true" >> $HOME/.buildout/default.cfg + - git config --global user.email "travis@travis-ci.org" + - git config --global user.name "Travis CI" + - sudo apt-get install -y firefox-geckodriver + - virtualenv -p `which python` . + - bin/pip install -r requirements.txt -c constraints_plone$PLONE_VERSION.txt + - cp test_plone$PLONE_VERSION.cfg buildout.cfg + +install: + - travis_retry pip install -U tox coveralls coverage -c constraints.txt + +before_script: + - 'export DISPLAY=:99.0' + - export VERBOSE=true + - Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & + - sleep 3 + +script: + - PYTEST_ADDOPTS="-s -vv" tox + +after_success: + - python -m coverage.pickle2json + - coverage combine + - coveralls + +notifications: + email: + recipients: +# - travis-reports@plone.com + - {author} + on_success: change + on_failure: change diff --git a/CHANGES.rst b/CHANGES.rst new file mode 100644 index 0000000..bbc5957 --- /dev/null +++ b/CHANGES.rst @@ -0,0 +1,9 @@ +Changelog +========= + + +1.0a1 (unreleased) +------------------ + +- Initial release. + [cekk] diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst new file mode 100644 index 0000000..83798a9 --- /dev/null +++ b/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +Contributors +============ + +- RedTurtle Technology, sviluppo@redturtle.it diff --git a/DEVELOP.rst b/DEVELOP.rst new file mode 100644 index 0000000..9c4dbc1 --- /dev/null +++ b/DEVELOP.rst @@ -0,0 +1,76 @@ +Using the development buildout +============================== + +plonecli +-------- + +The convenient way, use plonecli build ;):: + + $ plonecli build + +or with --clear if you want to clean your existing venv:: + + $ plonecli build --clear + +Start your instance:: + + $ plonecli serve + + +Without plonecli +---------------- + +Create a virtualenv in the package:: + + $ python3 -m venv venv + +or with --clear if you want to clean your existing venv:: + + $ python3 -m venv venv --clear + +Install requirements with pip:: + + $ ./venv/bin/pip install -r requirements.txt + +bootstrap your buildout:: + + $ ./bin/buildout bootstrap + +Run buildout:: + + $ ./bin/buildout + +Start Plone in foreground:: + + $ ./bin/instance fg + + +Running tests +------------- + + $ tox + +list all tox environments:: + + $ tox -l + py27-Plone43 + py27-Plone51 + py27-Plone52 + py37-Plone52 + build_instance + code-analysis + lint-py27 + lint-py37 + coverage-report + +run a specific tox env:: + + $ tox -e py37-Plone52 + + +CI Github-Actions / codecov +--------------------------- + +The first time you push the repo to github, you might get an error from codecov. +Either you activate the package here: `https://app.codecov.io/gh/collective/+ `_ +Or you just wait a bit, codecov will activate your package automatically. diff --git a/LICENSE.GPL b/LICENSE.GPL new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/LICENSE.GPL @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/LICENSE.rst b/LICENSE.rst new file mode 100644 index 0000000..25e3cb5 --- /dev/null +++ b/LICENSE.rst @@ -0,0 +1,15 @@ +collective.volto.sitesettings Copyright 2024, RedTurtle Technology + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, +MA 02111-1307 USA. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..6dc9750 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,7 @@ +graft src/collective.volto +graft docs +include *.rst +exclude tox.ini +exclude *.txt +exclude .gitlab-ci.yml +global-exclude *.pyc diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..a015697 --- /dev/null +++ b/README.rst @@ -0,0 +1,111 @@ +.. This README is meant for consumption by humans and PyPI. PyPI can render rst files so please do not use Sphinx features. + If you want to learn more about writing documentation, please check out: http://docs.plone.org/about/documentation_styleguide.html + This text does not appear on PyPI or github. It is a comment. + +.. image:: https://github.com/collective/collective.volto.sitesettings/actions/workflows/plone-package.yml/badge.svg + :target: https://github.com/collective/collective.volto.sitesettings/actions/workflows/plone-package.yml + +.. image:: https://coveralls.io/repos/github/collective/collective.volto.sitesettings/badge.svg?branch=main + :target: https://coveralls.io/github/collective/collective.volto.sitesettings?branch=main + :alt: Coveralls + +.. image:: https://codecov.io/gh/collective/collective.volto.sitesettings/branch/master/graph/badge.svg + :target: https://codecov.io/gh/collective/collective.volto.sitesettings + +.. image:: https://img.shields.io/pypi/v/collective.volto.sitesettings.svg + :target: https://pypi.python.org/pypi/collective.volto.sitesettings/ + :alt: Latest Version + +.. image:: https://img.shields.io/pypi/status/collective.volto.sitesettings.svg + :target: https://pypi.python.org/pypi/collective.volto.sitesettings + :alt: Egg Status + +.. image:: https://img.shields.io/pypi/pyversions/collective.volto.sitesettings.svg?style=plastic :alt: Supported - Python Versions + +.. image:: https://img.shields.io/pypi/l/collective.volto.sitesettings.svg + :target: https://pypi.python.org/pypi/collective.volto.sitesettings/ + :alt: License + + +============================= +collective.volto.sitesettings +============================= + +Plone addon to allow to extend @site controlpanel + +Features +-------- + +- Can be bullet points + + +Examples +-------- + +This add-on can be seen in action at the following sites: +- Is there a page on the internet where everybody can see the features? + + +Documentation +------------- + +Full documentation for end users can be found in the "docs" folder, and is also available online at http://docs.plone.org/foo/bar + + +Translations +------------ + +This product has been translated into + +- Klingon (thanks, K'Plai) + + +Installation +------------ + +Install collective.volto.sitesettings by adding it to your buildout:: + + [buildout] + + ... + + eggs = + collective.volto.sitesettings + + +and then running ``bin/buildout`` + + +Authors +------- + +Provided by awesome people ;) + + +Contributors +------------ + +Put your name here, you deserve it! + +- ? + + +Contribute +---------- + +- Issue Tracker: https://github.com/collective/collective.volto.sitesettings/issues +- Source Code: https://github.com/collective/collective.volto.sitesettings +- Documentation: https://docs.plone.org/foo/bar + + +Support +------- + +If you are having issues, please let us know. +We have a mailing list located at: project@example.com + + +License +------- + +The project is licensed under the GPLv2. diff --git a/base.cfg b/base.cfg new file mode 100644 index 0000000..b037dac --- /dev/null +++ b/base.cfg @@ -0,0 +1,111 @@ +[buildout] +show-picked-versions = true +extensions = + mr.developer + +parts = + instance + test +# we use tox for testing and linting, by default +# code-analysis + coverage + test-coverage + createcoverage + releaser + i18ndude + omelette + robot + plone-helper-scripts + vscode + +develop = . + + +[instance] +recipe = plone.recipe.zope2instance +user = admin:admin +http-address = 8080 +environment-vars = + zope_i18n_compile_mo_files true +eggs = + Plone + Pillow + collective.volto.sitesettings [test] + +[vscode] +recipe = collective.recipe.vscode +eggs = ${instance:eggs} +autocomplete-use-omelette = True + +# [code-analysis] +# recipe = plone.recipe.codeanalysis +# directory = ${buildout:directory}/src/collective.volto +# return-status-codes = False + + +[omelette] +recipe = collective.recipe.omelette +eggs = ${instance:eggs} + + +[test] +recipe = zc.recipe.testrunner +eggs = ${instance:eggs} +initialization = + os.environ['TZ'] = 'UTC' +defaults = ['-s', 'collective.volto.sitesettings', '--auto-color', '--auto-progress'] + + +[coverage] +recipe = zc.recipe.egg +eggs = coverage + + +[test-coverage] +recipe = collective.recipe.template +input = inline: + #!/bin/bash + export TZ=UTC + ${buildout:directory}/bin/coverage run bin/test $* + ${buildout:directory}/bin/coverage html + ${buildout:directory}/bin/coverage report -m --fail-under=90 + # Fail (exit status 1) if coverage returns exit status 2 (this happens + # when test coverage is below 100%. +output = ${buildout:directory}/bin/test-coverage +mode = 755 + + +[createcoverage] +recipe = zc.recipe.egg +eggs = createcoverage + + +[robot] +recipe = zc.recipe.egg +eggs = + ${test:eggs} + plone.app.robotframework[debug,reload] + + +[releaser] +recipe = zc.recipe.egg +eggs = zest.releaser + + +[i18ndude] +recipe = zc.recipe.egg +eggs = i18ndude + +[plone-helper-scripts] +recipe = zc.recipe.egg +eggs = + plone.staticresources + ${instance:eggs} +interpreter = zopepy +scripts = + zopepy + plone-compile-resources + +[versions] +# Don't use a released version of collective.volto.sitesettings +collective.volto.sitesettings = diff --git a/bobtemplate.cfg b/bobtemplate.cfg new file mode 100644 index 0000000..d60aea8 --- /dev/null +++ b/bobtemplate.cfg @@ -0,0 +1,5 @@ +[main] +version = 6.0.0 +template = plone_addon +git_init = True +python = python3 diff --git a/buildout.cfg b/buildout.cfg new file mode 100644 index 0000000..74ed0c6 --- /dev/null +++ b/buildout.cfg @@ -0,0 +1,10 @@ +[buildout] + +# use this extend one of the buildout configuration: +extends = +# -*- mrbob: extra extends -*- +# test_plone43.cfg +# test_plone50.cfg +# test_plone51.cfg +# test_plone52.cfg + test_plone60.cfg diff --git a/constraints.txt b/constraints.txt new file mode 100644 index 0000000..c1fb3a1 --- /dev/null +++ b/constraints.txt @@ -0,0 +1 @@ +-c constraints_plone60.txt diff --git a/constraints_plone52.txt b/constraints_plone52.txt new file mode 100644 index 0000000..0408f82 --- /dev/null +++ b/constraints_plone52.txt @@ -0,0 +1,9 @@ +-c https://dist.plone.org/release/5.2-latest/requirements.txt + +# setuptools==40.2.0 +# zc.buildout==2.13.2 + +isort>=5 +black==22.8.0 +tox==4.3.5 +flake8==5.0.4 diff --git a/constraints_plone60.txt b/constraints_plone60.txt new file mode 100644 index 0000000..4dff360 --- /dev/null +++ b/constraints_plone60.txt @@ -0,0 +1,16 @@ +-c https://dist.plone.org/release/6.0-latest/constraints.txt + +#setuptools==54.0.0 +#zc.buildout==3.0.0b2 +#pip==21.0.1 +# +## Windows specific down here (has to be installed here, fails in buildout) +## Dependency of zope.sendmail: +#pywin32 ; platform_system == 'Windows' +# +## SSL Certs on windows, because Python is missing them otherwise: +#certifi ; platform_system == 'Windows' +tox==4.3.5 +isort>=5 +black==22.8.0 +flake8==5.0.4 diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..e2f4f8d --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,239 @@ +# -*- coding: utf-8 -*- +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'collective.volto.sitesettings' +copyright = u'RedTurtle Technology (cekk)' +author = u'RedTurtle Technology (cekk)' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = u'3.0' +# The full version, including alpha/beta/rc tags. +release = u'3.0' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This patterns also effect to html_static_path and html_extra_path +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +#keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = False + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'alabaster' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. +# " v documentation" by default. +#html_title = u'bobtemplates.plone v3.0' + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (relative to this directory) to use as a favicon of +# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +#html_extra_path = [] + +# If not None, a 'Last updated on:' timestamp is inserted at every page +# bottom, using the given strftime format. +# The empty string is equivalent to '%b %d, %Y'. +#html_last_updated_fmt = None + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh' +#html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# 'ja' uses this config value. +# 'zh' user can custom change `jieba` dictionary path. +#html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +#html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'collective.volto.sitesettingsdoc' + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', + +# Latex figure (float) alignment +#'figure_align': 'htbp', +} + + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..be9041f --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,5 @@ +============================= +collective.volto.sitesettings +============================= + +User documentation diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..0ba7f38 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +-r requirements_plone60.txt diff --git a/requirements_plone52.txt b/requirements_plone52.txt new file mode 100644 index 0000000..fa2f614 --- /dev/null +++ b/requirements_plone52.txt @@ -0,0 +1,3 @@ +-c constraints_plone52.txt +setuptools +zc.buildout diff --git a/requirements_plone60.txt b/requirements_plone60.txt new file mode 100644 index 0000000..cab798d --- /dev/null +++ b/requirements_plone60.txt @@ -0,0 +1,3 @@ +-c constraints_plone60.txt +setuptools +zc.buildout diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..7f3f5c2 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,27 @@ +[check-manifest] +ignore = + *.cfg + .coveragerc + .editorconfig + .gitattributes + +[isort] +# black compatible isort rules: +profile = plone + +[flake8] +# black compatible flake8 rules: +ignore = + W503, + C812, + E501 + T001 + C813 + C101 +# E203, E266 +exclude = bootstrap.py,docs,*.egg.,omelette +max-line-length = 88 +max-complexity = 18 +select = B,C,E,F,W,T4,B9 + +builtins = unicode,basestring diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..06a0e45 --- /dev/null +++ b/setup.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- +"""Installer for the collective.volto.sitesettings package.""" + +from setuptools import find_packages +from setuptools import setup + + +long_description = "\n\n".join( + [ + open("README.rst").read(), + open("CONTRIBUTORS.rst").read(), + open("CHANGES.rst").read(), + ] +) + + +setup( + name="collective.volto.sitesettings", + version="1.0a1", + description="Plone addon to allow to extend @site controlpanel", + long_description=long_description, + # Get more from https://pypi.org/classifiers/ + classifiers=[ + "Environment :: Web Environment", + "Framework :: Plone", + "Framework :: Plone :: Addon", + "Framework :: Plone :: 5.2", + "Framework :: Plone :: 6.0", + "Programming Language :: Python", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Operating System :: OS Independent", + "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", + ], + keywords="Python Plone CMS", + author="RedTurtle Technology", + author_email="sviluppo@redturtle.it", + url="https://github.com/collective/collective.volto.sitesettings", + project_urls={ + "PyPI": "https://pypi.org/project/collective.volto.sitesettings/", + "Source": "https://github.com/collective/collective.volto.sitesettings", + "Tracker": "https://github.com/collective/collective.volto.sitesettings/issues", + # 'Documentation': 'https://collective.volto.sitesettings.readthedocs.io/en/latest/', + }, + license="GPL version 2", + packages=find_packages("src", exclude=["ez_setup"]), + namespace_packages=["collective", "collective.volto"], + package_dir={"": "src"}, + include_package_data=True, + zip_safe=False, + python_requires=">=3.7", + install_requires=[ + "setuptools", + # -*- Extra requirements: -*- + "z3c.jbot", + "plone.api>=1.8.4", + "plone.app.dexterity", + ], + extras_require={ + "test": [ + "plone.app.testing", + # Plone KGS does not use this version, because it would break + # Remove if your package shall be part of coredev. + # plone_coredev tests as of 2016-04-01. + "plone.testing>=5.0.0", + "plone.app.contenttypes", + "plone.app.robotframework[debug]", + ], + }, + entry_points=""" + [z3c.autoinclude.plugin] + target = plone + [console_scripts] + update_locale = collective.volto.sitesettings.locales.update:update_locale + """, +) diff --git a/src/collective/__init__.py b/src/collective/__init__.py new file mode 100644 index 0000000..03d08ff --- /dev/null +++ b/src/collective/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +__import__("pkg_resources").declare_namespace(__name__) diff --git a/src/collective/volto/__init__.py b/src/collective/volto/__init__.py new file mode 100644 index 0000000..03d08ff --- /dev/null +++ b/src/collective/volto/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +__import__("pkg_resources").declare_namespace(__name__) diff --git a/src/collective/volto/sitesettings/__init__.py b/src/collective/volto/sitesettings/__init__.py new file mode 100644 index 0000000..879136c --- /dev/null +++ b/src/collective/volto/sitesettings/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +"""Init and utils.""" +from zope.i18nmessageid import MessageFactory + + +_ = MessageFactory("collective.volto.sitesettings") diff --git a/src/collective/volto/sitesettings/browser/__init__.py b/src/collective/volto/sitesettings/browser/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/collective/volto/sitesettings/browser/configure.zcml b/src/collective/volto/sitesettings/browser/configure.zcml new file mode 100644 index 0000000..0883bcb --- /dev/null +++ b/src/collective/volto/sitesettings/browser/configure.zcml @@ -0,0 +1,21 @@ + + + + + + + + + + diff --git a/src/collective/volto/sitesettings/browser/overrides/.gitkeep b/src/collective/volto/sitesettings/browser/overrides/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/collective/volto/sitesettings/browser/static/.gitkeep b/src/collective/volto/sitesettings/browser/static/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/collective/volto/sitesettings/configure.zcml b/src/collective/volto/sitesettings/configure.zcml new file mode 100644 index 0000000..ee2f3ab --- /dev/null +++ b/src/collective/volto/sitesettings/configure.zcml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/collective/volto/sitesettings/interfaces.py b/src/collective/volto/sitesettings/interfaces.py new file mode 100644 index 0000000..c502a42 --- /dev/null +++ b/src/collective/volto/sitesettings/interfaces.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- +"""Module where all interfaces, events and exceptions live.""" + +from zope.publisher.interfaces.browser import IDefaultBrowserLayer + + +class ICollectiveVoltoSitesettingsLayer(IDefaultBrowserLayer): + """Marker interface that defines a browser layer.""" diff --git a/src/collective/volto/sitesettings/locales/README.rst b/src/collective/volto/sitesettings/locales/README.rst new file mode 100644 index 0000000..c0b3cdf --- /dev/null +++ b/src/collective/volto/sitesettings/locales/README.rst @@ -0,0 +1,37 @@ +Adding and updating locales +--------------------------- + +For every language you want to translate into you need a +locales/[language]/LC_MESSAGES/collective.task.po +(e.g. locales/de/LC_MESSAGES/collective.task.po) + +For German + +.. code-block:: console + + $ mkdir de + +For updating locales + +.. code-block:: console + + $ ./bin/update_locale + +Note +---- + +The script uses gettext package for internationalization. + +Install it before running the script. + +On macOS +-------- + +.. code-block:: console + + $ brew install gettext + +On Windows +---------- + +see https://mlocati.github.io/articles/gettext-iconv-windows.html diff --git a/src/collective/volto/sitesettings/locales/__init__.py b/src/collective/volto/sitesettings/locales/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/collective/volto/sitesettings/locales/collective.volto.sitesettings.pot b/src/collective/volto/sitesettings/locales/collective.volto.sitesettings.pot new file mode 100644 index 0000000..e69de29 diff --git a/src/collective/volto/sitesettings/locales/en/LC_MESSAGES/collective.volto.sitesettings.po b/src/collective/volto/sitesettings/locales/en/LC_MESSAGES/collective.volto.sitesettings.po new file mode 100644 index 0000000..e69de29 diff --git a/src/collective/volto/sitesettings/locales/update.py b/src/collective/volto/sitesettings/locales/update.py new file mode 100644 index 0000000..212743c --- /dev/null +++ b/src/collective/volto/sitesettings/locales/update.py @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- + +import os +import pkg_resources +import subprocess + + +domain = "collective.volto.sitesettings" +os.chdir(pkg_resources.resource_filename(domain, "")) +os.chdir("../../../") +target_path = "src/collective.volto/sitesettings/" +locale_path = target_path + "locales/" +i18ndude = "./bin/i18ndude" + +# ignore node_modules files resulting in errors +excludes = '"*.html *json-schema*.xml"' + + +def locale_folder_setup(): + os.chdir(locale_path) + languages = [d for d in os.listdir(".") if os.path.isdir(d)] + for lang in languages: + folder = os.listdir(lang) + if "LC_MESSAGES" in folder: + continue + else: + lc_messages_path = lang + "/LC_MESSAGES/" + os.mkdir(lc_messages_path) + cmd = "msginit --locale={0} --input={1}.pot --output={2}/LC_MESSAGES/{3}.po".format( # NOQA: E501 + lang, + domain, + lang, + domain, + ) + subprocess.call( + cmd, + shell=True, + ) + + os.chdir("../../../../") + + +def _rebuild(): + cmd = "{i18ndude} rebuild-pot --pot {locale_path}/{domain}.pot --exclude {excludes} --create {domain} {target_path}".format( # NOQA: E501 + i18ndude=i18ndude, + locale_path=locale_path, + domain=domain, + target_path=target_path, + excludes=excludes, + ) + subprocess.call( + cmd, + shell=True, + ) + + +def _sync(): + cmd = "{0} sync --pot {1}/{2}.pot {3}*/LC_MESSAGES/{4}.po".format( + i18ndude, + locale_path, + domain, + locale_path, + domain, + ) + subprocess.call( + cmd, + shell=True, + ) + + +def update_locale(): + locale_folder_setup() + _sync() + _rebuild() diff --git a/src/collective/volto/sitesettings/locales/update.sh b/src/collective/volto/sitesettings/locales/update.sh new file mode 100755 index 0000000..b6917bc --- /dev/null +++ b/src/collective/volto/sitesettings/locales/update.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# i18ndude should be available in current $PATH (eg by running +# ``export PATH=$PATH:$BUILDOUT_DIR/bin`` when i18ndude is located in your buildout's bin directory) +# +# For every language you want to translate into you need a +# locales/[language]/LC_MESSAGES/collective.volto.sitesettings.po +# (e.g. locales/de/LC_MESSAGES/collective.volto.sitesettings.po) + +domain=collective.volto.sitesettings + +i18ndude rebuild-pot --pot $domain.pot --create $domain ../ +i18ndude sync --pot $domain.pot */LC_MESSAGES/$domain.po diff --git a/src/collective/volto/sitesettings/permissions.zcml b/src/collective/volto/sitesettings/permissions.zcml new file mode 100644 index 0000000..1f79c8a --- /dev/null +++ b/src/collective/volto/sitesettings/permissions.zcml @@ -0,0 +1,12 @@ + + + + + + + + + diff --git a/src/collective/volto/sitesettings/profiles/default/browserlayer.xml b/src/collective/volto/sitesettings/profiles/default/browserlayer.xml new file mode 100644 index 0000000..08f7095 --- /dev/null +++ b/src/collective/volto/sitesettings/profiles/default/browserlayer.xml @@ -0,0 +1,7 @@ + + + + diff --git a/src/collective/volto/sitesettings/profiles/default/catalog.xml b/src/collective/volto/sitesettings/profiles/default/catalog.xml new file mode 100644 index 0000000..0685c9d --- /dev/null +++ b/src/collective/volto/sitesettings/profiles/default/catalog.xml @@ -0,0 +1,4 @@ + + + + diff --git a/src/collective/volto/sitesettings/profiles/default/metadata.xml b/src/collective/volto/sitesettings/profiles/default/metadata.xml new file mode 100644 index 0000000..3fcf1da --- /dev/null +++ b/src/collective/volto/sitesettings/profiles/default/metadata.xml @@ -0,0 +1,7 @@ + + + 1000 + + + + diff --git a/src/collective/volto/sitesettings/profiles/default/registry/main.xml b/src/collective/volto/sitesettings/profiles/default/registry/main.xml new file mode 100644 index 0000000..eb561f4 --- /dev/null +++ b/src/collective/volto/sitesettings/profiles/default/registry/main.xml @@ -0,0 +1,8 @@ + + + + + + diff --git a/src/collective/volto/sitesettings/profiles/default/rolemap.xml b/src/collective/volto/sitesettings/profiles/default/rolemap.xml new file mode 100644 index 0000000..0a24e7e --- /dev/null +++ b/src/collective/volto/sitesettings/profiles/default/rolemap.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/collective/volto/sitesettings/profiles/uninstall/browserlayer.xml b/src/collective/volto/sitesettings/profiles/uninstall/browserlayer.xml new file mode 100644 index 0000000..bfe230a --- /dev/null +++ b/src/collective/volto/sitesettings/profiles/uninstall/browserlayer.xml @@ -0,0 +1,7 @@ + + + + diff --git a/src/collective/volto/sitesettings/setuphandlers.py b/src/collective/volto/sitesettings/setuphandlers.py new file mode 100644 index 0000000..26f37aa --- /dev/null +++ b/src/collective/volto/sitesettings/setuphandlers.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +from Products.CMFPlone.interfaces import INonInstallable +from zope.interface import implementer + + +@implementer(INonInstallable) +class HiddenProfiles(object): + def getNonInstallableProfiles(self): + """Hide uninstall profile from site-creation and quickinstaller.""" + return [ + "collective.volto.sitesettings:uninstall", + ] + + def getNonInstallableProducts(self): + """Hide the upgrades package from site-creation and quickinstaller.""" + return ["collective.volto.sitesettings.upgrades"] + + +def post_install(context): + """Post install script""" + # Do something at the end of the installation of this package. + + +def uninstall(context): + """Uninstall script""" + # Do something at the end of the uninstallation of this package. diff --git a/src/collective/volto/sitesettings/testing.py b/src/collective/volto/sitesettings/testing.py new file mode 100644 index 0000000..ba8c05c --- /dev/null +++ b/src/collective/volto/sitesettings/testing.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +from plone.app.robotframework.testing import REMOTE_LIBRARY_BUNDLE_FIXTURE +from plone.app.testing import applyProfile +from plone.app.testing import FunctionalTesting +from plone.app.testing import IntegrationTesting +from plone.app.testing import PLONE_FIXTURE +from plone.app.testing import PloneSandboxLayer +from plone.testing import z2 + +import collective.volto.sitesettings + + +class CollectiveVoltoSitesettingsLayer(PloneSandboxLayer): + + defaultBases = (PLONE_FIXTURE,) + + def setUpZope(self, app, configurationContext): + # Load any other ZCML that is required for your tests. + # The z3c.autoinclude feature is disabled in the Plone fixture base + # layer. + import plone.app.dexterity + + self.loadZCML(package=plone.app.dexterity) + import plone.restapi + + self.loadZCML(package=plone.restapi) + self.loadZCML(package=collective.volto.sitesettings) + + def setUpPloneSite(self, portal): + applyProfile(portal, "collective.volto.sitesettings:default") + + +COLLECTIVE_VOLTO_SITESETTINGS_FIXTURE = CollectiveVoltoSitesettingsLayer() + + +COLLECTIVE_VOLTO_SITESETTINGS_INTEGRATION_TESTING = IntegrationTesting( + bases=(COLLECTIVE_VOLTO_SITESETTINGS_FIXTURE,), + name="CollectiveVoltoSitesettingsLayer:IntegrationTesting", +) + + +COLLECTIVE_VOLTO_SITESETTINGS_FUNCTIONAL_TESTING = FunctionalTesting( + bases=(COLLECTIVE_VOLTO_SITESETTINGS_FIXTURE,), + name="CollectiveVoltoSitesettingsLayer:FunctionalTesting", +) + + +COLLECTIVE_VOLTO_SITESETTINGS_ACCEPTANCE_TESTING = FunctionalTesting( + bases=( + COLLECTIVE_VOLTO_SITESETTINGS_FIXTURE, + REMOTE_LIBRARY_BUNDLE_FIXTURE, + z2.ZSERVER_FIXTURE, + ), + name="CollectiveVoltoSitesettingsLayer:AcceptanceTesting", +) diff --git a/src/collective/volto/sitesettings/tests/__init__.py b/src/collective/volto/sitesettings/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/collective/volto/sitesettings/tests/robot/test_example.robot b/src/collective/volto/sitesettings/tests/robot/test_example.robot new file mode 100644 index 0000000..4a3f376 --- /dev/null +++ b/src/collective/volto/sitesettings/tests/robot/test_example.robot @@ -0,0 +1,66 @@ +# ============================================================================ +# EXAMPLE ROBOT TESTS +# ============================================================================ +# +# Run this robot test stand-alone: +# +# $ bin/test -s collective.volto.sitesettings -t test_example.robot --all +# +# Run this robot test with robot server (which is faster): +# +# 1) Start robot server: +# +# $ bin/robot-server --reload-path src collective.volto.sitesettings.testing.COLLECTIVE_VOLTO_SITESETTINGS_ACCEPTANCE_TESTING +# +# 2) Run robot tests: +# +# $ bin/robot src/collective/volto/sitesettings/tests/robot/test_example.robot +# +# See the http://docs.plone.org for further details (search for robot +# framework). +# +# ============================================================================ + +*** Settings ***************************************************************** + +Resource plone/app/robotframework/selenium.robot +Resource plone/app/robotframework/keywords.robot + +Library Remote ${PLONE_URL}/RobotRemote + +Test Setup Open test browser +Test Teardown Close all browsers + + +*** Test Cases *************************************************************** + +Scenario: As a member I want to be able to log into the website + [Documentation] Example of a BDD-style (Behavior-driven development) test. + Given a login form + When I enter valid credentials + Then I am logged in + + +*** Keywords ***************************************************************** + +# --- Given ------------------------------------------------------------------ + +a login form + Go To ${PLONE_URL}/login_form + Wait until page contains Login Name + Wait until page contains Password + + +# --- WHEN ------------------------------------------------------------------- + +I enter valid credentials + Input Text __ac_name admin + Input Text __ac_password secret + Click Button Log in + + +# --- THEN ------------------------------------------------------------------- + +I am logged in + Wait until page contains You are now logged in + Page should contain You are now logged in diff --git a/src/collective/volto/sitesettings/tests/test_robot.py b/src/collective/volto/sitesettings/tests/test_robot.py new file mode 100644 index 0000000..1a990f6 --- /dev/null +++ b/src/collective/volto/sitesettings/tests/test_robot.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +from collective.volto.sitesettings.testing import ( # noqa: E501 + COLLECTIVE_VOLTO_SITESETTINGS_ACCEPTANCE_TESTING, +) +from plone.app.testing import ROBOT_TEST_LEVEL +from plone.testing import layered + +import os +import robotsuite +import unittest + + +def test_suite(): + suite = unittest.TestSuite() + current_dir = os.path.abspath(os.path.dirname(__file__)) + robot_dir = os.path.join(current_dir, "robot") + robot_tests = [ + os.path.join("robot", doc) + for doc in os.listdir(robot_dir) + if doc.endswith(".robot") and doc.startswith("test_") + ] + for robot_test in robot_tests: + robottestsuite = robotsuite.RobotTestSuite(robot_test) + robottestsuite.level = ROBOT_TEST_LEVEL + suite.addTests( + [ + layered( + robottestsuite, + layer=COLLECTIVE_VOLTO_SITESETTINGS_ACCEPTANCE_TESTING, + ), + ] + ) + return suite diff --git a/src/collective/volto/sitesettings/tests/test_setup.py b/src/collective/volto/sitesettings/tests/test_setup.py new file mode 100644 index 0000000..71d2f65 --- /dev/null +++ b/src/collective/volto/sitesettings/tests/test_setup.py @@ -0,0 +1,76 @@ +# -*- coding: utf-8 -*- +"""Setup tests for this package.""" +from collective.volto.sitesettings.testing import ( # noqa: E501 + COLLECTIVE_VOLTO_SITESETTINGS_INTEGRATION_TESTING, +) +from plone import api +from plone.app.testing import setRoles +from plone.app.testing import TEST_USER_ID + +import unittest + + +try: + from Products.CMFPlone.utils import get_installer +except ImportError: + get_installer = None + + +class TestSetup(unittest.TestCase): + """Test that collective.volto.sitesettings is properly installed.""" + + layer = COLLECTIVE_VOLTO_SITESETTINGS_INTEGRATION_TESTING + + def setUp(self): + """Custom shared utility setup for tests.""" + self.portal = self.layer["portal"] + if get_installer: + self.installer = get_installer(self.portal, self.layer["request"]) + else: + self.installer = api.portal.get_tool("portal_quickinstaller") + + def test_product_installed(self): + """Test if collective.volto.sitesettings is installed.""" + self.assertTrue( + self.installer.is_product_installed("collective.volto.sitesettings") + ) + + def test_browserlayer(self): + """Test that ICollectiveVoltoSitesettingsLayer is registered.""" + from collective.volto.sitesettings.interfaces import ( + ICollectiveVoltoSitesettingsLayer, + ) + from plone.browserlayer import utils + + self.assertIn(ICollectiveVoltoSitesettingsLayer, utils.registered_layers()) + + +class TestUninstall(unittest.TestCase): + + layer = COLLECTIVE_VOLTO_SITESETTINGS_INTEGRATION_TESTING + + def setUp(self): + self.portal = self.layer["portal"] + if get_installer: + self.installer = get_installer(self.portal, self.layer["request"]) + else: + self.installer = api.portal.get_tool("portal_quickinstaller") + roles_before = api.user.get_roles(TEST_USER_ID) + setRoles(self.portal, TEST_USER_ID, ["Manager"]) + self.installer.uninstall_product("collective.volto.sitesettings") + setRoles(self.portal, TEST_USER_ID, roles_before) + + def test_product_uninstalled(self): + """Test if collective.volto.sitesettings is cleanly uninstalled.""" + self.assertFalse( + self.installer.is_product_installed("collective.volto.sitesettings") + ) + + def test_browserlayer_removed(self): + """Test that ICollectiveVoltoSitesettingsLayer is removed.""" + from collective.volto.sitesettings.interfaces import ( + ICollectiveVoltoSitesettingsLayer, + ) + from plone.browserlayer import utils + + self.assertNotIn(ICollectiveVoltoSitesettingsLayer, utils.registered_layers()) diff --git a/test_plone52.cfg b/test_plone52.cfg new file mode 100644 index 0000000..ed1d481 --- /dev/null +++ b/test_plone52.cfg @@ -0,0 +1,13 @@ +[buildout] + +extends = + https://raw.githubusercontent.com/collective/buildout.plonetest/master/test-5.2.x.cfg + https://raw.githubusercontent.com/collective/buildout.plonetest/master/qa.cfg + base.cfg + +update-versions-file = test_plone52.cfg + +[versions] +plone.testing = 7.0.1 +collective.recipe.vscode = >=0.1.6 +importlib-metadata = 1.1.3 diff --git a/test_plone60.cfg b/test_plone60.cfg new file mode 100644 index 0000000..d56cb6d --- /dev/null +++ b/test_plone60.cfg @@ -0,0 +1,12 @@ +[buildout] + +extends = + https://raw.githubusercontent.com/collective/buildout.plonetest/master/test-6.0.x.cfg + https://raw.githubusercontent.com/collective/buildout.plonetest/master/qa.cfg + base.cfg + +update-versions-file = test_plone60.cfg + +[versions] +createcoverage = 1.5 +watchdog = 2.1.6 diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..6a7e0ec --- /dev/null +++ b/tox.ini @@ -0,0 +1,186 @@ +[tox] +envlist = + py37-lint, + py38-lint, + py39-lint, + py310-lint, + black-check, + py{38,37}-Plone{52}, + py{39,310}-Plone{60}, +# docs, +# coverage-report, + +skip_missing_interpreters = True + + +[gh-actions] +python = + 3.6: py36 + 3.7: py37 + 3.8: py38 + 3.9: py39 + 3.10: py310 + + +[gh-actions:env] +PLONE-VERSION = + Plone52: Plone52 + Plone60: Plone60 + + +[testenv] +skip_install = true + +extras = + develop + test + +commands = + {envbindir}/buildout -q -c {toxinidir}/{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} bootstrap +# {envbindir}/buildout -c {toxinidir}/{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} annotate + {envbindir}/buildout -n -qq -c {toxinidir}/{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} install test robot + coverage run {envbindir}/test -v1 --auto-color {posargs} + # coverage run {envbindir}/test -v --all -t robot {posargs} + +setenv = + COVERAGE_FILE=.coverage.{envname} + # version_file=test_plone60.cfg + Plone52: version_file=test_plone52.cfg + Plone60: version_file=test_plone60.cfg + +deps = + Plone52: -rrequirements_plone52.txt +# Plone52: -cconstraints_plone52.txt + Plone60: -rrequirements_plone60.txt +# Plone60: -cconstraints_plone60.txt + coverage + + +[testenv:coverage-report] +skip_install = true +usedevelop = True +basepython = python3.9 + +deps = + coverage + -cconstraints_plone60.txt + +setenv = + COVERAGE_FILE=.coverage + +commands = + coverage erase + coverage combine + coverage html + coverage xml + coverage report + + +[lint] +skip_install = true + +deps = + -cconstraints.txt + isort + flake8 + # helper to generate HTML reports: + # flake8-html>=0.4.3 + # Useful flake8 plugins that are Python and Plone specific: + ; flake8-coding + flake8-debugger + flake8-deprecated + flake8-print + #flake8-pytest + flake8-todo + mccabe + # Potential flake8 plugins that should be used: # TBD + #flake8-blind-except + #flake8-commas + #flake8-docstrings + #flake8-mypy + #flake8-pep3101 + #flake8-plone-hasattr + #flake8-string-format + #flake8_strict + #flake8-quotes + #flake8-polyfill + +commands = + mkdir -p {toxinidir}/reports/flake8 + flake8 --doctests {toxinidir}/src {toxinidir}/setup.py + isort --check-only {toxinidir}/src {toxinidir}/setup.py + # black --check --diff -v {toxinidir}/src {toxinidir}/setup.py + +allowlist_externals = + mkdir + + +[testenv:isort-apply] +skip_install = true + +deps = + -cconstraints.txt + isort + +commands = + isort {toxinidir}/src {toxinidir}/setup.py + + +[testenv:black-check] +basepython = python3.9 +skip_install = True +deps = + -cconstraints.txt + black + +commands = + black --check --diff -v src setup.py + + +[testenv:black-enforce] +basepython = python3.9 +skip_install = True +deps = + -cconstraints.txt + black + +commands = + black -v src setup.py + + +[testenv:py37-lint] +basepython = python3.7 +skip_install = true +deps = {[lint]deps} +commands = {[lint]commands} +allowlist_externals = {[lint]allowlist_externals} + +[testenv:py38-lint] +basepython = python3.8 +skip_install = true +deps = {[lint]deps} +commands = {[lint]commands} +allowlist_externals = {[lint]allowlist_externals} + +[testenv:py39-lint] +basepython = python3.9 +skip_install = true +deps = {[lint]deps} +commands = {[lint]commands} +allowlist_externals = {[lint]allowlist_externals} + +[testenv:py310-lint] +basepython = python3.10 +skip_install = true +deps = {[lint]deps} +commands = {[lint]commands} +allowlist_externals = {[lint]allowlist_externals} + +[testenv:docs] +skip_install = true + +deps = + Sphinx + +commands = + sphinx-build -b html -d _build/docs/doctrees docs _build/docs/html