diff --git a/.github/workflows/plone-package.yml b/.github/workflows/plone-package.yml index 7577f41..04f8e44 100644 --- a/.github/workflows/plone-package.yml +++ b/.github/workflows/plone-package.yml @@ -16,24 +16,8 @@ jobs: fail-fast: false matrix: plone-version: - - "Plone60" - - "Plone61" - "Plone62" - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] - - exclude: - - plone-version: "Plone60" - python-version: "3.12" - - plone-version: "Plone60" - python-version: "3.13" - - plone-version: "Plone60" - python-version: "3.14" - - plone-version: "Plone61" - python-version: "3.9" - - plone-version: "Plone61" - python-version: "3.14" - - plone-version: "Plone62" - python-version: "3.9" + python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] steps: - uses: actions/setup-python@v4 diff --git a/.long-description.html b/.long-description.html new file mode 100644 index 0000000..f728e9b --- /dev/null +++ b/.long-description.html @@ -0,0 +1,537 @@ + + + + + +<string> + + + +
+ + + + +https://github.com/codesyntax/cs.srcset/actions/workflows/plone-package.yml/badge.svg + + +Latest Version + + +Egg Status + +https://img.shields.io/pypi/pyversions/cs.srcset.svg?style=plastic:alt:Supported-PythonVersions + +License + +
+

cs.srcset

+

Backport of the srcset method added to the @@images view in plone.namedfile 7.1.0 to be able to use it in older Plone versions. +It also includes an optimized @@image_helper view for Plone 6+ that uses catalog metadata to avoid N+1 performance issues in listings.

+
+

Features

+
    +
  • Adds a view called @@images-srcset for older Plone versions (backport).
  • +
  • Adds a view called @@image_helper optimized for Plone 6+ catalog metadata.
  • +
+

Read more about responsive images and its use in the MDN documentation

+
+
+

Documentation

+

@@images-srcset

+

You should use this view like this

+
+<img tal:define="images context/@@images-srcset;"
+ tal:replace="structure python:images.srcset(
+                             fieldname='image',
+                             scale_in_src='huge',
+                             sizes='(min-width: 570px) 550px,90vw',
+                             css_class='mini w-100 h-100 responsive-3-2',
+                             alt=context.Title(),
+                             title=context.Title(),
+                             loading='lazy')"
+/>
+
+

The meaning of each parameter is the following:

+
    +
  • fieldname: name of the field where the image is stored
  • +
  • scale_in_src: name of the scale that will be used to render the src attribute
  • +
  • sizes: the value of the sizes attribute in the output tag
  • +
  • css_class: CSS classes added to the img tag
  • +
  • additional attributes: any aditional attribute that will be rendered in the img tag, useful to add the title, alt, loading, fetchpriority, id, and other attributes.
  • +
+

@@image_helper

+

This view is designed for high-performance listings in Plone 6. +It attempts to generate the <img> tag using only catalog metadata (image_scales attribute in brains), avoiding expensive getObject() calls. +If metadata is missing, it gracefully falls back to the standard @@images view logic.

+

You should use this view like this

+
+<tal:block tal:define="helper context/@@image_helper">
+    <div tal:replace="structure python:helper.srcset(item, fieldname='image', sizes='25vw', css_class='my-img')" />
+</tal:block>
+
+

Available methods:

+
    +
  • srcset(item, fieldname='image', **kwargs): Returns a responsive <img> tag with the srcset attribute.
  • +
  • tag(item, fieldname='image', scale=None, **kwargs): Returns a fixed <img> tag (optionally for a specific scale).
  • +
+

Parameters:

+
    +
  • item: Either a catalog brain (recommended for performance) or a Plone object.
  • +
  • fieldname: The name of the image field (default: image).
  • +
  • scale_in_src: (Only for the srcset method) The name of the scale to use for the src attribute (default: huge).
  • +
  • scale: (Only for the tag method) The name of the scale to use for the src.
  • +
  • **kwargs: Any other HTML attributes (alt, title, loading, css_class, etc.).
  • +
+

Note: Unlike standard Plone views, this helper does not provide default values for alt or loading attributes. +Developers must provide them explicitly in the template if needed. +However, it does automatically provide width and height based on the rendered scale to prevent layout shifts.

+
+
+

Installation

+

Install cs.srcset by adding it to your buildout:

+
+[buildout]
+
+...
+
+eggs =
+    cs.srcset
+
+

and then running bin/buildout

+

NOTE: You do not need to install the product in the Plone add-ons controlpanel, there is nothing to be installed.

+
+ +
+

Support

+

If you are having issues, please let us know.

+
+
+

License

+

The project is licensed under the GPLv2.

+
+

Contributors

+ +
+
+

Changelog

+
+
+
+

2.0 (unreleased)

+

Breaking changes

+ +

New features

+ +
+
+

1.2 (unreleased)

+
    +
  • Nothing changed yet.
  • +
+
+
+

1.1 (2025-10-14)

+
    +
  • Add default width and heigth attributes if none provided when using the srcset method +[erral]
  • +
+
+
+

1.0 (2025-09-24)

+
    +
  • Initial release. +[codesyntax]
  • +
+
+
+
+ + diff --git a/CHANGES.rst b/CHANGES.rst index 87a7d3c..ae6fa7f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,21 +1,28 @@ -2.0 (unreleased) +2.0.1 (2026-07-28) +------------------ +Internal: -Breaking changes + +- Format changelog @erral + + +Changelog +========= + +2.0 (unreleased) ---------------- +Breaking changes + - Remove Plone 5.2 and Python 3.7/3.8 as unsupported. @erral ([#2](https://github.com/codesyntax/cs.srcset/pull/2)) New features ------------- - Add a @@image-helper view to create image URLs from catalog metadata @erral ([#2](https://github.com/codesyntax/cs.srcset/pull/2)) -Changelog -========= - 1.2 (unreleased) ---------------- diff --git a/README.rst b/README.rst index a1c54e7..d8f20e0 100644 --- a/README.rst +++ b/README.rst @@ -40,7 +40,6 @@ Documentation ------------- @@images-srcset -~~~~~~~~~~~~~~~ You should use this view like this :: @@ -65,7 +64,6 @@ The meaning of each parameter is the following: @@image_helper -~~~~~~~~~~~~~~ This view is designed for high-performance listings in Plone 6. It attempts to generate the ```` tag using only catalog metadata (``image_scales`` attribute in brains), avoiding expensive ``getObject()`` calls. diff --git a/constraints_plone60.txt b/constraints_plone60.txt deleted file mode 100644 index 54e0ec1..0000000 --- a/constraints_plone60.txt +++ /dev/null @@ -1,16 +0,0 @@ --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.11.3 -isort>=5.12.0 -black>=24.4.2 -flake8>=7.0.0 diff --git a/constraints_plone61.txt b/constraints_plone61.txt deleted file mode 100644 index 61920c5..0000000 --- a/constraints_plone61.txt +++ /dev/null @@ -1,16 +0,0 @@ --c https://dist.plone.org/release/6.1-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.11.3 -isort>=5.12.0 -black>=24.4.2 -flake8>=7.0.0 diff --git a/news/.changelog_template.jinja b/news/.changelog_template.jinja new file mode 100644 index 0000000..f9042ca --- /dev/null +++ b/news/.changelog_template.jinja @@ -0,0 +1,15 @@ +{% if sections[""] %} +{% for category, val in definitions.items() if category in sections[""] %} + +{{ definitions[category]['name'] }} + +{% for text, values in sections[""][category].items() %} +- {{ text }} {{ values|join(', ') }} +{% endfor %} + +{% endfor %} +{% else %} +No significant changes. + + +{% endif %} diff --git a/news/.gitkeep b/news/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/news/3.breaking b/news/3.breaking new file mode 100644 index 0000000..ef1e014 --- /dev/null +++ b/news/3.breaking @@ -0,0 +1 @@ +Support Plone 6.2 only @erral diff --git a/pyproject.toml b/pyproject.toml index a8a4f06..75c72fe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,11 +5,35 @@ build-backend = "setuptools.build_meta" [tool.towncrier] directory = "news/" filename = "CHANGES.rst" -title_format = "{version} (unreleased)" -underlines = ["", "-"] -issue_format = "[#{issue}](https://github.com/codesyntax/cs.srcset/pull/{issue})" -type = [ - { directory = "breaking", name = "Breaking changes", showcontent = true }, - { directory = "feature", name = "New features", showcontent = true }, - { directory = "bugfix", name = "Bug fixes", showcontent = true }, -] +title_format = "{version} ({project_date})" +underlines = ["-", ""] + +[[tool.towncrier.type]] +directory = "breaking" +name = "Breaking changes:" +showcontent = true + +[[tool.towncrier.type]] +directory = "feature" +name = "New features:" +showcontent = true + +[[tool.towncrier.type]] +directory = "bugfix" +name = "Bug fixes:" +showcontent = true + +[[tool.towncrier.type]] +directory = "internal" +name = "Internal:" +showcontent = true + +[[tool.towncrier.type]] +directory = "documentation" +name = "Documentation:" +showcontent = true + +[[tool.towncrier.type]] +directory = "tests" +name = "Tests:" +showcontent = true diff --git a/requirements_plone60.txt b/requirements_plone60.txt deleted file mode 100644 index cab798d..0000000 --- a/requirements_plone60.txt +++ /dev/null @@ -1,3 +0,0 @@ --c constraints_plone60.txt -setuptools -zc.buildout diff --git a/requirements_plone61.txt b/requirements_plone61.txt deleted file mode 100644 index 8e34f42..0000000 --- a/requirements_plone61.txt +++ /dev/null @@ -1,3 +0,0 @@ --c constraints_plone61.txt -setuptools -zc.buildout diff --git a/setup.py b/setup.py index f0dcc74..4e198e2 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ setup( name="cs.srcset", - version="2.1.dev0", + version="2.0.2.dev0", description="An add-on for Plone", long_description=long_description, # Get more from https://pypi.org/classifiers/ @@ -23,11 +23,8 @@ "Environment :: Web Environment", "Framework :: Plone", "Framework :: Plone :: Addon", - "Framework :: Plone :: 6.0", - "Framework :: Plone :: 6.1", "Framework :: Plone :: 6.2", "Programming Language :: Python", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", @@ -47,12 +44,9 @@ # 'Documentation': 'https://cs.srcset.readthedocs.io/en/latest/', }, license="GPL version 2", - packages=find_packages("src", exclude=["ez_setup"]), - namespace_packages=["cs"], - package_dir={"": "src"}, include_package_data=True, zip_safe=False, - python_requires=">=3.9", + python_requires=">=3.10", install_requires=[ "setuptools", # -*- Extra requirements: -*- diff --git a/src/cs/__init__.py b/src/cs/__init__.py deleted file mode 100644 index 03d08ff..0000000 --- a/src/cs/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# -*- coding: utf-8 -*- -__import__("pkg_resources").declare_namespace(__name__) diff --git a/test_plone60.cfg b/test_plone60.cfg deleted file mode 100644 index d56cb6d..0000000 --- a/test_plone60.cfg +++ /dev/null @@ -1,12 +0,0 @@ -[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/test_plone61.cfg b/test_plone61.cfg deleted file mode 100644 index 2e28ca3..0000000 --- a/test_plone61.cfg +++ /dev/null @@ -1,12 +0,0 @@ -[buildout] - -extends = - https://raw.githubusercontent.com/collective/buildout.plonetest/master/test-6.1.x.cfg - https://raw.githubusercontent.com/collective/buildout.plonetest/master/qa.cfg - base.cfg - -update-versions-file = test_plone61.cfg - -[versions] -createcoverage = 1.5 -watchdog = 2.1.6