From e5004cf57a184e802367f8f5e60b863e7722216f Mon Sep 17 00:00:00 2001 From: jackahl Date: Wed, 25 Sep 2024 19:02:22 +0200 Subject: [PATCH 01/16] Add alt_text field to image content type --- news/700.feature | 2 + .../contenttypes/browser/templates/image.pt | 3 +- plone/app/contenttypes/schema/image.xml | 14 +++++++ plone/app/contenttypes/tests/test_image.py | 41 +++++++++++++++++++ 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 news/700.feature diff --git a/news/700.feature b/news/700.feature new file mode 100644 index 00000000..b73a4c8e --- /dev/null +++ b/news/700.feature @@ -0,0 +1,2 @@ +Add alt_text field to image content type. This allows users to manually set the value of alt tag, for usage in automated listings. +[@cekk, @jackahl] diff --git a/plone/app/contenttypes/browser/templates/image.pt b/plone/app/contenttypes/browser/templates/image.pt index cb77820f..2f75f1f3 100644 --- a/plone/app/contenttypes/browser/templates/image.pt +++ b/plone/app/contenttypes/browser/templates/image.pt @@ -27,7 +27,8 @@
Description + + + Briefly describe the meaning of the image for people using assistive technology like screen readers. + This will be used when the image is viewed by itself or in automated contexts like listings. + Do not duplicate the Title or Description fields, since those might also be read by screen readers. + Alt text should describe what a sighted user sees when looking at the image. + This might include text the image contains, or even a description of an abstract pattern. + In case your description already sufficiently describes your image leave this field blank. + + False + Alt Text + + diff --git a/plone/app/contenttypes/tests/test_image.py b/plone/app/contenttypes/tests/test_image.py index b31a514a..e187bc94 100644 --- a/plone/app/contenttypes/tests/test_image.py +++ b/plone/app/contenttypes/tests/test_image.py @@ -72,7 +72,16 @@ def setUp(self): image.title = "My Image" image.description = "This is my image." image.image = dummy_image() + + self.portal.invokeFactory('Image', 'image-with-alt') + image_alt = self.portal['image-with-alt'] + image_alt.title = 'My Image 2' + image_alt.description = 'This is my second image.' + image_alt.alt_text = 'An alt text' + image.image = dummy_image() + self.image = image + self.image_alt = image_alt self.request.set("URL", image.absolute_url()) self.request.set("ACTUAL_URL", image.absolute_url()) alsoProvides(self.request, IPloneFormLayer) @@ -85,6 +94,30 @@ def test_image_view(self): self.assertTrue("My Image" in view()) self.assertTrue("This is my image." in view()) + def test_image_view_alt(self): + view = self.image_alt.restrictedTraverse('@@view') + + self.assertTrue(view()) + self.assertEqual(view.request.response.status, 200) + self.assertTrue('My Image 2' in view()) + self.assertTrue('This is my second image.' in view()) + self.assertTrue('An alt text' in view()) + + def test_image_alt_in_listing_view(self): + self.image_alt.image = dummy_image(u'image.svg') + view = self.portal.restrictedTraverse('@@listing_view') + self.assertTrue('An alt text' in view()) + + def test_image_alt_in_summary_view(self): + self.image_alt.image = dummy_image(u'image.svg') + view = self.portal.restrictedTraverse('@@summary_view') + self.assertTrue('An alt text' in view()) + + def test_image_alt_in_album_view(self): + self.image_alt.image = dummy_image(u'image.svg') + view = self.portal.restrictedTraverse('@@album_view') + self.assertTrue('An alt text' in view()) + # XXX: Not working. See ImageFunctionalTest test_image_view_fullscreen # Problem seems to be that the image is not properly uploaded. # def test_image_view_fullscreen(self): @@ -105,6 +138,14 @@ def test_svg_image(self): r'My Image', # noqa: E501 ) + def test_svg_image_alt(self): + self.image_alt.image = dummy_image(u'image.svg') + scale = self.image_alt.restrictedTraverse('@@images') + self.assertRegex( + scale.scale('image', scale='large').tag(), + r'An alt text' # noqa: E501 + ) + class ImageFunctionalTest(unittest.TestCase): layer = PLONE_APP_CONTENTTYPES_FUNCTIONAL_TESTING From c98e5768793d06c594b0e225069226029d6103a2 Mon Sep 17 00:00:00 2001 From: jackahl <44289551+jackahl@users.noreply.github.com> Date: Thu, 26 Sep 2024 09:57:50 +0200 Subject: [PATCH 02/16] Fix typo in image type alt field description Co-authored-by: David Glick --- plone/app/contenttypes/schema/image.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plone/app/contenttypes/schema/image.xml b/plone/app/contenttypes/schema/image.xml index 2719b8e4..c77cfe4e 100644 --- a/plone/app/contenttypes/schema/image.xml +++ b/plone/app/contenttypes/schema/image.xml @@ -27,7 +27,7 @@ Do not duplicate the Title or Description fields, since those might also be read by screen readers. Alt text should describe what a sighted user sees when looking at the image. This might include text the image contains, or even a description of an abstract pattern. - In case your description already sufficiently describes your image leave this field blank. + In case your description already sufficiently describes your image, leave this field blank. False Alt Text From 8a14bd3fbfae543f684d97a678ed3f2a003f794c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Andrei?= Date: Thu, 26 Sep 2024 10:44:35 +0200 Subject: [PATCH 03/16] Setup local installation --- .gitignore | 2 + .meta.toml | 6 +++ Makefile | 123 +++++++++++++++++++++++++++++++++++++++++++ constraints.txt | 1 + instance.yaml | 7 +++ mx.ini | 9 ++++ news/+setup.internal | 2 + requirements.txt | 1 + 8 files changed, 151 insertions(+) create mode 100644 Makefile create mode 100644 constraints.txt create mode 100644 instance.yaml create mode 100644 mx.ini create mode 100644 news/+setup.internal create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index 486392f6..8d63c885 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,8 @@ local.cfg /venv/ .installed.txt +/test_* +robot_* ## # Add extra configuration options in .meta.toml: diff --git a/.meta.toml b/.meta.toml index 3bf9f054..74ca55db 100644 --- a/.meta.toml +++ b/.meta.toml @@ -11,3 +11,9 @@ dependencies_ignores = "['ZServer', 'plone.app.event', 'Products.CMFPlone',]" [tox] constraints_file = "https://dist.plone.org/release/6.1-dev/constraints.txt" + +[gitignore] +extra_lines = """ +/test_* +robot_* +""" diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..cf20422b --- /dev/null +++ b/Makefile @@ -0,0 +1,123 @@ +### Defensive settings for make: +# https://tech.davis-hansson.com/p/make/ +SHELL:=bash +.ONESHELL: +.SHELLFLAGS:=-xeu -o pipefail -O inherit_errexit -c +.SILENT: +.DELETE_ON_ERROR: +MAKEFLAGS+=--warn-undefined-variables +MAKEFLAGS+=--no-builtin-rules + +# We like colors +# From: https://coderwall.com/p/izxssa/colored-makefile-for-golang-projects +RED=`tput setaf 1` +GREEN=`tput setaf 2` +RESET=`tput sgr0` +YELLOW=`tput setaf 3` + +BACKEND_FOLDER=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) +DOCS_DIR=${BACKEND_FOLDER}/docs + +# Python checks +PYTHON?=python3 + +# installed? +ifeq (, $(shell which $(PYTHON) )) + $(error "PYTHON=$(PYTHON) not found in $(PATH)") +endif + +# version ok? +PYTHON_VERSION_MIN=3.8 +PYTHON_VERSION_OK=$(shell $(PYTHON) -c "import sys; print((int(sys.version_info[0]), int(sys.version_info[1])) >= tuple(map(int, '$(PYTHON_VERSION_MIN)'.split('.'))))") +ifeq ($(PYTHON_VERSION_OK),0) + $(error "Need python $(PYTHON_VERSION) >= $(PYTHON_VERSION_MIN)") +endif + +all: build + +# Add the following 'help' target to your Makefile +# And add help text after each target name starting with '\#\#' +.PHONY: help +help: ## This help message + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +.PHONY: clean +clean: clean-build clean-pyc clean-test clean-venv clean-instance ## remove all build, test, coverage and Python artifacts + +.PHONY: clean-instance +clean-instance: ## remove existing instance + rm -fr instance etc inituser var + +.PHONY: clean-venv +clean-venv: ## remove virtual environment + rm -fr bin include lib lib64 env pyvenv.cfg .tox .pytest_cache constraints-mxdev.txt requirements-mxdev.txt sources/ + +.PHONY: clean-build +clean-build: ## remove build artifacts + rm -fr build/ + rm -fr dist/ + rm -fr .eggs/ + rm -fr parts/ + rm -fr coverage.xml + find . -name '*.egg-info' -exec rm -fr {} + + find . -name '*.egg' -exec rm -rf {} + + +.PHONY: clean-pyc +clean-pyc: ## remove Python file artifacts + find . -name '*.pyc' -exec rm -f {} + + find . -name '*.pyo' -exec rm -f {} + + find . -name '*~' -exec rm -f {} + + find . -name '__pycache__' -exec rm -fr {} + + +.PHONY: clean-test +clean-test: ## remove test and coverage artifacts + rm -f .coverage + rm -fr htmlcov/ + rm -fr test_* + rm -fr robot_* + +bin/pip bin/tox bin/mxdev: + @echo "$(GREEN)==> Setup Virtual Env$(RESET)" + $(PYTHON) -m venv . + bin/pip install -U "pip" "wheel" "cookiecutter" "mxdev" "tox" "pre-commit" + bin/pre-commit install + +.PHONY: config +config: bin/pip ## Create instance configuration + @echo "$(GREEN)==> Create instance configuration$(RESET)" + bin/cookiecutter -f --no-input --config-file instance.yaml gh:plone/cookiecutter-zope-instance + +.PHONY: install-plone-6.0 +install-plone-6.0: config ## pip install Plone packages + @echo "$(GREEN)==> Setup Build$(RESET)" + bin/mxdev -c mx.ini + bin/pip install -r requirements-mxdev.txt + +.PHONY: install +install: install-plone-6.0 ## Install Plone 6.0 + +.PHONY: start +start: ## Start a Plone instance on localhost:8080 + PYTHONWARNINGS=ignore ./bin/runwsgi instance/etc/zope.ini + +.PHONY: console +console: ## Start a console on a Plone instance + PYTHONWARNINGS=ignore ./bin/zconsole debug instance/etc/zope.conf + +.PHONY: format +format: bin/tox ## Format the codebase according to our standards + @echo "$(GREEN)==> Format codebase$(RESET)" + bin/tox -e format + +.PHONY: lint +lint: ## check code style + bin/tox -e lint + +# Tests +.PHONY: test +test: bin/tox ## run tests + bin/tox -e test + +.PHONY: test-coverage +test-coverage: bin/tox ## run tests with coverage + bin/tox -e coverage diff --git a/constraints.txt b/constraints.txt new file mode 100644 index 00000000..3bb2e326 --- /dev/null +++ b/constraints.txt @@ -0,0 +1 @@ +-c https://dist.plone.org/release/6.0.13/constraints.txt diff --git a/instance.yaml b/instance.yaml new file mode 100644 index 00000000..fe9d3149 --- /dev/null +++ b/instance.yaml @@ -0,0 +1,7 @@ +default_context: + initial_user_name: 'admin' + initial_user_password: 'admin' + + zcml_package_includes: ['plone.app.contenttypes'] + + db_storage: direct diff --git a/mx.ini b/mx.ini new file mode 100644 index 00000000..db2906f9 --- /dev/null +++ b/mx.ini @@ -0,0 +1,9 @@ +; This is a mxdev configuration file +; it can be used to override versions of packages already defined in the +; constraints files and to add new packages from VCS like git. +; to learn more about mxdev visit https://pypi.org/project/mxdev/ + +[settings] +main-package = -e .[test] +version-overrides = + plone.app.contenttypes >= 4.0.1.dev0 diff --git a/news/+setup.internal b/news/+setup.internal new file mode 100644 index 00000000..3ca94f9d --- /dev/null +++ b/news/+setup.internal @@ -0,0 +1,2 @@ +Setup local installation +[@ericof] diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..da443200 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +-c constraints.txt From f5409885bb6bfdc3abd3f825770bf4749485805f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Andrei?= Date: Thu, 26 Sep 2024 11:20:07 +0200 Subject: [PATCH 04/16] Fix MANIFEST.in --- MANIFEST.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MANIFEST.in b/MANIFEST.in index 74225c91..5993732e 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -8,3 +8,9 @@ global-exclude *.pyc recursive-exclude news * exclude news + +include requirements.txt +include constraints.txt +include *.yaml +include Makefile +exclude *-mxdev.txt From f70879b7eae560cc9235d029baa33152298f7e27 Mon Sep 17 00:00:00 2001 From: jackahl Date: Thu, 26 Sep 2024 13:11:45 +0200 Subject: [PATCH 05/16] set install as default command in makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index cf20422b..053d9d8b 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ ifeq ($(PYTHON_VERSION_OK),0) $(error "Need python $(PYTHON_VERSION) >= $(PYTHON_VERSION_MIN)") endif -all: build +all: install # Add the following 'help' target to your Makefile # And add help text after each target name starting with '\#\#' From c95678e5eaf57ff5f02c07eed0400647acc4ee93 Mon Sep 17 00:00:00 2001 From: jackahl Date: Fri, 27 Sep 2024 13:35:28 +0200 Subject: [PATCH 06/16] formatting --- .../contenttypes/browser/templates/image.pt | 4 +- plone/app/contenttypes/schema/image.xml | 4 +- plone/app/contenttypes/tests/test_image.py | 47 +++++++++---------- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/plone/app/contenttypes/browser/templates/image.pt b/plone/app/contenttypes/browser/templates/image.pt index 2f75f1f3..5c0592ff 100644 --- a/plone/app/contenttypes/browser/templates/image.pt +++ b/plone/app/contenttypes/browser/templates/image.pt @@ -86,7 +86,9 @@ >Download View full-size image + > + View full-size image + diff --git a/plone/app/contenttypes/schema/image.xml b/plone/app/contenttypes/schema/image.xml index 2719b8e4..3fa3eea8 100644 --- a/plone/app/contenttypes/schema/image.xml +++ b/plone/app/contenttypes/schema/image.xml @@ -20,7 +20,8 @@ Description + type="zope.schema.TextLine" + > Briefly describe the meaning of the image for people using assistive technology like screen readers. This will be used when the image is viewed by itself or in automated contexts like listings. @@ -41,4 +42,3 @@ - diff --git a/plone/app/contenttypes/tests/test_image.py b/plone/app/contenttypes/tests/test_image.py index e187bc94..bd3aadba 100644 --- a/plone/app/contenttypes/tests/test_image.py +++ b/plone/app/contenttypes/tests/test_image.py @@ -73,12 +73,12 @@ def setUp(self): image.description = "This is my image." image.image = dummy_image() - self.portal.invokeFactory('Image', 'image-with-alt') - image_alt = self.portal['image-with-alt'] - image_alt.title = 'My Image 2' - image_alt.description = 'This is my second image.' - image_alt.alt_text = 'An alt text' - image.image = dummy_image() + self.portal.invokeFactory("Image", "image-with-alt") + image_alt = self.portal["image-with-alt"] + image_alt.title = "My Image 2" + image_alt.description = "This is my second image." + image_alt.alt_text = "An alt text" + image_alt.image = dummy_image() self.image = image self.image_alt = image_alt @@ -95,28 +95,27 @@ def test_image_view(self): self.assertTrue("This is my image." in view()) def test_image_view_alt(self): - view = self.image_alt.restrictedTraverse('@@view') - + view = self.image_alt.restrictedTraverse("@@view") self.assertTrue(view()) self.assertEqual(view.request.response.status, 200) - self.assertTrue('My Image 2' in view()) - self.assertTrue('This is my second image.' in view()) - self.assertTrue('An alt text' in view()) + self.assertTrue("My Image 2" in view()) + self.assertTrue("This is my second image." in view()) + self.assertTrue("An alt text" in view()) def test_image_alt_in_listing_view(self): - self.image_alt.image = dummy_image(u'image.svg') - view = self.portal.restrictedTraverse('@@listing_view') - self.assertTrue('An alt text' in view()) + self.image_alt.image = dummy_image("image.svg") + view = self.portal.restrictedTraverse("@@listing_view") + self.assertTrue("An alt text" in view()) def test_image_alt_in_summary_view(self): - self.image_alt.image = dummy_image(u'image.svg') - view = self.portal.restrictedTraverse('@@summary_view') - self.assertTrue('An alt text' in view()) + self.image_alt.image = dummy_image("image.svg") + view = self.portal.restrictedTraverse("@@summary_view") + self.assertTrue("An alt text" in view()) def test_image_alt_in_album_view(self): - self.image_alt.image = dummy_image(u'image.svg') - view = self.portal.restrictedTraverse('@@album_view') - self.assertTrue('An alt text' in view()) + self.image_alt.image = dummy_image("image.svg") + view = self.portal.restrictedTraverse("@@album_view") + self.assertTrue("An alt text" in view()) # XXX: Not working. See ImageFunctionalTest test_image_view_fullscreen # Problem seems to be that the image is not properly uploaded. @@ -139,11 +138,11 @@ def test_svg_image(self): ) def test_svg_image_alt(self): - self.image_alt.image = dummy_image(u'image.svg') - scale = self.image_alt.restrictedTraverse('@@images') + self.image_alt.image = dummy_image("image.svg") + scale = self.image_alt.restrictedTraverse("@@images") self.assertRegex( - scale.scale('image', scale='large').tag(), - r'An alt text' # noqa: E501 + scale.scale("image", scale="large").tag(), + r'An alt text', # noqa: E501 ) From 6ffeaff3602e9e022c365df910e155849e514578 Mon Sep 17 00:00:00 2001 From: jackahl Date: Fri, 27 Sep 2024 16:43:45 +0200 Subject: [PATCH 07/16] fix test for alt text in image templates --- plone/app/contenttypes/tests/test_image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plone/app/contenttypes/tests/test_image.py b/plone/app/contenttypes/tests/test_image.py index bd3aadba..cd6cd905 100644 --- a/plone/app/contenttypes/tests/test_image.py +++ b/plone/app/contenttypes/tests/test_image.py @@ -95,7 +95,7 @@ def test_image_view(self): self.assertTrue("This is my image." in view()) def test_image_view_alt(self): - view = self.image_alt.restrictedTraverse("@@view") + view = self.image_alt.restrictedTraverse("@@image_view") self.assertTrue(view()) self.assertEqual(view.request.response.status, 200) self.assertTrue("My Image 2" in view()) From 0a3fb93e414e0bfb754e0bf03c64c9e979d64ace Mon Sep 17 00:00:00 2001 From: jackahl Date: Tue, 1 Oct 2024 12:54:18 +0200 Subject: [PATCH 08/16] include alt_tag in listing templates as well --- plone/app/contenttypes/browser/templates/listing.pt | 3 ++- plone/app/contenttypes/browser/templates/listing_album.pt | 4 ++-- plone/app/contenttypes/browser/templates/listing_summary.pt | 2 +- plone/app/contenttypes/browser/templates/listing_tabular.pt | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/plone/app/contenttypes/browser/templates/listing.pt b/plone/app/contenttypes/browser/templates/listing.pt index 9ad3df22..276a7db2 100644 --- a/plone/app/contenttypes/browser/templates/listing.pt +++ b/plone/app/contenttypes/browser/templates/listing.pt @@ -66,6 +66,7 @@ item_link python:item_type in view.use_view_action and item_url+'/view' or item_url; item_is_event python:view.is_event(obj); item_has_image python:item.getIcon; + item_alt_text python:item.alt_text; item_type_class python:('contenttype-' + view.normalizeString(item_type)) if showicons else ''; "> @@ -161,7 +162,7 @@ - + diff --git a/plone/app/contenttypes/browser/templates/listing_album.pt b/plone/app/contenttypes/browser/templates/listing_album.pt index 70561c0e..3c21532b 100644 --- a/plone/app/contenttypes/browser/templates/listing_album.pt +++ b/plone/app/contenttypes/browser/templates/listing_album.pt @@ -48,7 +48,7 @@
@@ -79,7 +79,7 @@
diff --git a/plone/app/contenttypes/browser/templates/listing_summary.pt b/plone/app/contenttypes/browser/templates/listing_summary.pt index fec35e61..58ade3ba 100644 --- a/plone/app/contenttypes/browser/templates/listing_summary.pt +++ b/plone/app/contenttypes/browser/templates/listing_summary.pt @@ -72,7 +72,7 @@ - +
diff --git a/plone/app/contenttypes/browser/templates/listing_tabular.pt b/plone/app/contenttypes/browser/templates/listing_tabular.pt index 29b8cdc3..feb34be1 100644 --- a/plone/app/contenttypes/browser/templates/listing_tabular.pt +++ b/plone/app/contenttypes/browser/templates/listing_tabular.pt @@ -138,7 +138,7 @@ - Date: Tue, 1 Oct 2024 12:55:32 +0200 Subject: [PATCH 09/16] remove test for svg image alt --- plone/app/contenttypes/tests/test_image.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/plone/app/contenttypes/tests/test_image.py b/plone/app/contenttypes/tests/test_image.py index cd6cd905..27f6d786 100644 --- a/plone/app/contenttypes/tests/test_image.py +++ b/plone/app/contenttypes/tests/test_image.py @@ -137,14 +137,6 @@ def test_svg_image(self): r'My Image', # noqa: E501 ) - def test_svg_image_alt(self): - self.image_alt.image = dummy_image("image.svg") - scale = self.image_alt.restrictedTraverse("@@images") - self.assertRegex( - scale.scale("image", scale="large").tag(), - r'An alt text', # noqa: E501 - ) - class ImageFunctionalTest(unittest.TestCase): layer = PLONE_APP_CONTENTTYPES_FUNCTIONAL_TESTING From 9a8e282db915e5a5b15530f4c8abc8b4b83c8ee5 Mon Sep 17 00:00:00 2001 From: jackahl Date: Tue, 1 Oct 2024 16:41:03 +0200 Subject: [PATCH 10/16] add alt_text indexer --- plone/app/contenttypes/indexers.py | 5 +++++ plone/app/contenttypes/indexers.zcml | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/plone/app/contenttypes/indexers.py b/plone/app/contenttypes/indexers.py index 973dfe83..2517b616 100644 --- a/plone/app/contenttypes/indexers.py +++ b/plone/app/contenttypes/indexers.py @@ -190,3 +190,8 @@ def getIcon(obj): if obj.aq_base.image: return True return False + + +@indexer(IDexterityContent) +def getAltTag(obj): + return obj.alt_text diff --git a/plone/app/contenttypes/indexers.zcml b/plone/app/contenttypes/indexers.zcml index 52b15f0c..6c79c341 100644 --- a/plone/app/contenttypes/indexers.zcml +++ b/plone/app/contenttypes/indexers.zcml @@ -50,5 +50,9 @@ factory=".indexers.mime_type" name="mime_type" /> + From f0b02e2a21ec2c2921c353309f4b372bed74cc29 Mon Sep 17 00:00:00 2001 From: jackahl Date: Tue, 1 Oct 2024 17:25:41 +0200 Subject: [PATCH 11/16] add upgrade_step for alt_field --- plone/app/contenttypes/profiles/default/metadata.xml | 2 +- plone/app/contenttypes/profiles/default/types.xml | 1 - plone/app/contenttypes/upgrades.zcml | 8 ++++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/plone/app/contenttypes/profiles/default/metadata.xml b/plone/app/contenttypes/profiles/default/metadata.xml index b3d89363..680e2b76 100644 --- a/plone/app/contenttypes/profiles/default/metadata.xml +++ b/plone/app/contenttypes/profiles/default/metadata.xml @@ -1,6 +1,6 @@ - 3000 + 3001 profile-plone.app.dexterity:default profile-plone.app.querystring:default diff --git a/plone/app/contenttypes/profiles/default/types.xml b/plone/app/contenttypes/profiles/default/types.xml index 5499ce02..6cd90d8e 100644 --- a/plone/app/contenttypes/profiles/default/types.xml +++ b/plone/app/contenttypes/profiles/default/types.xml @@ -67,5 +67,4 @@ - diff --git a/plone/app/contenttypes/upgrades.zcml b/plone/app/contenttypes/upgrades.zcml index 9ecfe4be..919e8b09 100644 --- a/plone/app/contenttypes/upgrades.zcml +++ b/plone/app/contenttypes/upgrades.zcml @@ -12,4 +12,12 @@ handler=".upgrades.update_type_icons" /> + + From 3ae8f7462cb775b85d4c8605cb95bd1b2eb6e25a Mon Sep 17 00:00:00 2001 From: jackahl Date: Wed, 2 Oct 2024 11:09:58 +0200 Subject: [PATCH 12/16] Revert "add upgrade_step for alt_field" This reverts commit f0b02e2a21ec2c2921c353309f4b372bed74cc29. --- plone/app/contenttypes/profiles/default/metadata.xml | 2 +- plone/app/contenttypes/profiles/default/types.xml | 1 + plone/app/contenttypes/upgrades.zcml | 8 -------- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/plone/app/contenttypes/profiles/default/metadata.xml b/plone/app/contenttypes/profiles/default/metadata.xml index 680e2b76..b3d89363 100644 --- a/plone/app/contenttypes/profiles/default/metadata.xml +++ b/plone/app/contenttypes/profiles/default/metadata.xml @@ -1,6 +1,6 @@ - 3001 + 3000 profile-plone.app.dexterity:default profile-plone.app.querystring:default diff --git a/plone/app/contenttypes/profiles/default/types.xml b/plone/app/contenttypes/profiles/default/types.xml index 6cd90d8e..5499ce02 100644 --- a/plone/app/contenttypes/profiles/default/types.xml +++ b/plone/app/contenttypes/profiles/default/types.xml @@ -67,4 +67,5 @@ + diff --git a/plone/app/contenttypes/upgrades.zcml b/plone/app/contenttypes/upgrades.zcml index 919e8b09..9ecfe4be 100644 --- a/plone/app/contenttypes/upgrades.zcml +++ b/plone/app/contenttypes/upgrades.zcml @@ -12,12 +12,4 @@ handler=".upgrades.update_type_icons" /> - - From 55faeecc58b410f2979ecc605be03bed2fa94c60 Mon Sep 17 00:00:00 2001 From: jackahl Date: Wed, 2 Oct 2024 11:41:31 +0200 Subject: [PATCH 13/16] onyl try to retrieve alt_text in listing template if applicable --- plone/app/contenttypes/browser/templates/listing.pt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plone/app/contenttypes/browser/templates/listing.pt b/plone/app/contenttypes/browser/templates/listing.pt index 276a7db2..5be2631e 100644 --- a/plone/app/contenttypes/browser/templates/listing.pt +++ b/plone/app/contenttypes/browser/templates/listing.pt @@ -66,7 +66,7 @@ item_link python:item_type in view.use_view_action and item_url+'/view' or item_url; item_is_event python:view.is_event(obj); item_has_image python:item.getIcon; - item_alt_text python:item.alt_text; + item_alt_text python:getattr(item, 'alt_text', '') if item_has_image else ''; item_type_class python:('contenttype-' + view.normalizeString(item_type)) if showicons else ''; "> From 1fe65fc82a33b6820a46ac82615dc7373c5f74a9 Mon Sep 17 00:00:00 2001 From: jackahl Date: Wed, 2 Oct 2024 15:23:36 +0200 Subject: [PATCH 14/16] fix for crash on album view --- plone/app/contenttypes/browser/templates/listing_album.pt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plone/app/contenttypes/browser/templates/listing_album.pt b/plone/app/contenttypes/browser/templates/listing_album.pt index 3c21532b..d3f5f3b3 100644 --- a/plone/app/contenttypes/browser/templates/listing_album.pt +++ b/plone/app/contenttypes/browser/templates/listing_album.pt @@ -48,7 +48,9 @@
@@ -79,7 +81,9 @@ diff --git a/plone/app/contenttypes/browser/templates/listing_tabular.pt b/plone/app/contenttypes/browser/templates/listing_tabular.pt index feb34be1..56205c2a 100644 --- a/plone/app/contenttypes/browser/templates/listing_tabular.pt +++ b/plone/app/contenttypes/browser/templates/listing_tabular.pt @@ -79,6 +79,7 @@ item_wf_state_class python:'state-' + view.normalizeString(item_wf_state); item_creator python:item.Creator(); item_has_image python:item.getIcon; + item_alt_text python:getattr(item, 'alt_text', '') if item_has_image else ''; item_link python:item_type in view.use_view_action and item_url+'/view' or item_url; item_mime_type python:item.mime_type; item_mime_type_icon python: 'mimetype-' + item_mime_type; @@ -138,7 +139,7 @@ - Date: Mon, 21 Oct 2024 11:58:19 +0200 Subject: [PATCH 16/16] image schema: move new alt_text field after the image field. The git diff shows this as a move of the image field above the alt_text field, which boils down to the same thing. ;-) --- plone/app/contenttypes/schema/image.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plone/app/contenttypes/schema/image.xml b/plone/app/contenttypes/schema/image.xml index 86627cb7..af70b3b4 100644 --- a/plone/app/contenttypes/schema/image.xml +++ b/plone/app/contenttypes/schema/image.xml @@ -19,6 +19,13 @@ False Description + + + Image + @@ -33,12 +40,5 @@ False Alt Text - - - Image -