Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Branch: refs/heads/master Date: 2022-06-27T11:54:53+02:00 Author: Peter Mathis (petschki) <peter.mathis@kombinat.at> Commit: plone/plone.namedfile@f8ff13e Do not use full url in image_scales dictionary Files changed: M plone/namedfile/adapters.py M plone/namedfile/scaling.py Repository: plone.namedfile Branch: refs/heads/master Date: 2022-06-27T11:54:59+02:00 Author: Peter Mathis (petschki) <peter.mathis@kombinat.at> Commit: plone/plone.namedfile@39bbe7d add changenote Files changed: A news/123.bugfix Repository: plone.namedfile Branch: refs/heads/master Date: 2022-06-27T12:03:17+02:00 Author: Peter Mathis (petschki) <peter.mathis@kombinat.at> Commit: plone/plone.namedfile@136fa54 fix tests Files changed: M plone/namedfile/tests/test_adapters.py Repository: plone.namedfile Branch: refs/heads/master Date: 2022-06-27T14:48:19+02:00 Author: Peter Mathis (petschki) <peter.mathis@kombinat.at> Commit: plone/plone.namedfile@59db776 comment why saving scale view only Files changed: M plone/namedfile/adapters.py Repository: plone.namedfile Branch: refs/heads/master Date: 2022-06-27T14:56:29+02:00 Author: Peter Mathis (petschki) <peter.mathis@kombinat.at> Commit: plone/plone.namedfile@11aae67 check if metadata scale url starts with "http" Files changed: M plone/namedfile/scaling.py Repository: plone.namedfile Branch: refs/heads/master Date: 2022-06-27T15:47:14+02:00 Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org> Commit: plone/plone.namedfile@d2bbbce Merge pull request #124 from plone/issue-123 Do not use full url in `image_scales` dictionary Files changed: A news/123.bugfix M plone/namedfile/adapters.py M plone/namedfile/scaling.py M plone/namedfile/tests/test_adapters.py
- Loading branch information
1 parent
d1a654e
commit 8544141
Showing
1 changed file
with
79 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,96 @@ | ||
Repository: plone.app.content | ||
Repository: plone.namedfile | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2022-06-27T09:13:48+02:00 | ||
Author: Mikel Larreategi (erral) <mlarreategi@codesyntax.com> | ||
Commit: https://github.com/plone/plone.app.content/commit/f81cd1376bf42b3c4d246a7f11030f72f03eec97 | ||
Date: 2022-06-27T11:54:53+02:00 | ||
Author: Peter Mathis (petschki) <peter.mathis@kombinat.at> | ||
Commit: https://github.com/plone/plone.namedfile/commit/f8ff13e07c9a7e5c175b73386699c566060ad80c | ||
|
||
change msgids, they mean similar things, but they are different | ||
Do not use full url in image_scales dictionary | ||
|
||
Files changed: | ||
A news/249.bugfix | ||
M plone/app/content/browser/content_status_history.py | ||
M plone/app/content/browser/templates/content_status_history.pt | ||
M plone/namedfile/adapters.py | ||
M plone/namedfile/scaling.py | ||
|
||
b'diff --git a/news/249.bugfix b/news/249.bugfix\nnew file mode 100644\nindex 00000000..b266a47b\n--- /dev/null\n+++ b/news/249.bugfix\n@@ -0,0 +1,2 @@\n+Change some msgids, we have similar ones but are slightly different default values\n+[erral]\ndiff --git a/plone/app/content/browser/content_status_history.py b/plone/app/content/browser/content_status_history.py\nindex a8d49699..b2882b97 100644\n--- a/plone/app/content/browser/content_status_history.py\n+++ b/plone/app/content/browser/content_status_history.py\n@@ -19,7 +19,7 @@ class IContentStatusHistoryDates(Interface):\n effective_date = Datetime(\n title=_("label_effective_date", default="Publishing Date"),\n description=_(\n- "help_effective_date",\n+ "help_effective_date_content_status_history",\n default="The date when the item will be published. If no "\n "date is selected the item will be published immediately.",\n ),\n@@ -29,7 +29,7 @@ class IContentStatusHistoryDates(Interface):\n expiration_date = Datetime(\n title=_("label_expiration_date", default="Expiration Date"),\n description=_(\n- "help_expiration_date",\n+ "help_expiration_date_content_status_history",\n default="The date when the item expires. This will automatically "\n "make the item invisible for others at the given date. "\n "If no date is chosen, it will never expire.",\ndiff --git a/plone/app/content/browser/templates/content_status_history.pt b/plone/app/content/browser/templates/content_status_history.pt\nindex cff394cc..6edd7a9d 100644\n--- a/plone/app/content/browser/templates/content_status_history.pt\n+++ b/plone/app/content/browser/templates/content_status_history.pt\n@@ -227,7 +227,7 @@\n <div class="field" tal:define="error errors/effective_date | nothing;">\n <label i18n:translate="label_effective_date">Publishing Date</label>\n <div class="formHelp"\n- i18n:translate="help_effective_date">\n+ i18n:translate="help_effective_date_content_status_history">\n The date when the item will be published. If no date is selected the\n item will be published immediately.\n </div>\n@@ -251,7 +251,7 @@\n tal:define="error errors/expiration_date | nothing;">\n <label i18n:translate="label_expiration_date">Expiration Date</label>\n <div class="formHelp"\n- i18n:translate="help_expiration_date">\n+ i18n:translate="help_expiration_date_content_status_history">\n The date when the item expires. This will automatically\n make the item invisible for others at the given date.\n If no date is chosen, it will never expire.\n' | ||
b'diff --git a/plone/namedfile/adapters.py b/plone/namedfile/adapters.py\nindex c38bdda..8c147cf 100644\n--- a/plone/namedfile/adapters.py\n+++ b/plone/namedfile/adapters.py\n@@ -69,7 +69,7 @@ def __call__(self):\n "filename": image.filename,\n "content-type": image.contentType,\n "size": image.getSize(),\n- "download": url,\n+ "download": self._scale_view_from_url(url),\n "width": width,\n "height": height,\n "scales": scales,\n@@ -109,7 +109,7 @@ def get_scales(self, field, width, height):\n actual_height = scale.height\n \n scales[name] = {\n- "download": url,\n+ "download": self._scale_view_from_url(url),\n "width": actual_width,\n "height": actual_height,\n }\n@@ -127,3 +127,6 @@ def get_original_image_url(self, fieldname, width, height):\n )\n # Corrupt images may not have a scale.\n return scale.url if scale else None\n+\n+ def _scale_view_from_url(self, url):\n+ return url.replace(self.context.absolute_url(), "").lstrip("/")\ndiff --git a/plone/namedfile/scaling.py b/plone/namedfile/scaling.py\nindex 074662c..2855592 100644\n--- a/plone/namedfile/scaling.py\n+++ b/plone/namedfile/scaling.py\n@@ -752,7 +752,7 @@ def _tag_from_brain_image_scales(\n if alt is _marker:\n alt = title\n values = [\n- ("src", data["download"]),\n+ ("src", f"{brain.getURL()}/{data[\'download\']}"),\n ("alt", alt),\n ("title", title),\n ("height", data["height"]),\n' | ||
|
||
Repository: plone.app.content | ||
Repository: plone.namedfile | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2022-06-27T12:40:03+02:00 | ||
Author: Mikel Larreategi (erral) <mlarreategi@codesyntax.com> | ||
Commit: https://github.com/plone/plone.app.content/commit/2d167741201ca3e4453bb812e0636699847cf6db | ||
Date: 2022-06-27T11:54:59+02:00 | ||
Author: Peter Mathis (petschki) <peter.mathis@kombinat.at> | ||
Commit: https://github.com/plone/plone.namedfile/commit/39bbe7d0173045cb4f16f267da4bcc0e3c94794e | ||
|
||
Merge pull request #249 from plone/erral-i18n-fixes | ||
add changenote | ||
|
||
change msgids, they mean similar things, but they are different | ||
Files changed: | ||
A news/123.bugfix | ||
|
||
b'diff --git a/news/123.bugfix b/news/123.bugfix\nnew file mode 100644\nindex 0000000..6d2933e\n--- /dev/null\n+++ b/news/123.bugfix\n@@ -0,0 +1,2 @@\n+Do not use full url in `image_scales` dictionary.\n+[petschki]\n' | ||
|
||
Repository: plone.namedfile | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2022-06-27T12:03:17+02:00 | ||
Author: Peter Mathis (petschki) <peter.mathis@kombinat.at> | ||
Commit: https://github.com/plone/plone.namedfile/commit/136fa544a426c851ed028f320b27946340225c0d | ||
|
||
fix tests | ||
|
||
Files changed: | ||
M plone/namedfile/tests/test_adapters.py | ||
|
||
b'diff --git a/plone/namedfile/tests/test_adapters.py b/plone/namedfile/tests/test_adapters.py\nindex b144aeb..7a14782 100644\n--- a/plone/namedfile/tests/test_adapters.py\n+++ b/plone/namedfile/tests/test_adapters.py\n@@ -85,8 +85,7 @@ def test_field_adapter_return_scales(self):\n },\n )\n # Note: self.content.absolute_url() is actually empty in this test.\n- images_url = self.content.absolute_url() + "/@@images"\n- self.assertTrue(download.startswith(f"{images_url}/image1-16-"))\n+ self.assertTrue(download.startswith(f"@@images/image1-16-"))\n self.assertTrue(download.endswith(".gif"))\n self.assertIn("listing", scales)\n self.assertEqual(len(scales), 1)\n@@ -95,7 +94,7 @@ def test_field_adapter_return_scales(self):\n self.assertEqual(listing["height"], 16)\n self.assertEqual(listing["width"], 16)\n download = listing["download"]\n- self.assertTrue(download.startswith(f"{images_url}/image1-16-"))\n+ self.assertTrue(download.startswith(f"@@images/image1-16-"))\n self.assertTrue(download.endswith(".gif"))\n \n @unittest.skipIf(IImageScalesFieldAdapter is not None, "Skipping on Plone 6")\n@@ -132,8 +131,7 @@ def test_field_adapter_does_not_return_larger_scales(self):\n },\n )\n # Note: self.content.absolute_url() is actually empty in this test.\n- images_url = self.content.absolute_url() + "/@@images"\n- self.assertTrue(download.startswith(f"{images_url}/image1-900-"))\n+ self.assertTrue(download.startswith(f"@@images/image1-900-"))\n self.assertTrue(download.endswith(".jpeg"))\n # larger and huge should not be in here: these scales would return the same\n # content as the original.\n@@ -144,4 +142,4 @@ def test_field_adapter_does_not_return_larger_scales(self):\n preview = scales["preview"]\n self.assertEqual(preview["width"], 400)\n self.assertEqual(preview["height"], 400)\n- self.assertTrue(preview["download"].startswith(f"{images_url}/image1-400-"))\n+ self.assertTrue(preview["download"].startswith(f"@@images/image1-400-"))\n' | ||
|
||
Repository: plone.namedfile | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2022-06-27T14:48:19+02:00 | ||
Author: Peter Mathis (petschki) <peter.mathis@kombinat.at> | ||
Commit: https://github.com/plone/plone.namedfile/commit/59db77651d813386fa0e8304ae6e23a2b51948af | ||
|
||
comment why saving scale view only | ||
|
||
Files changed: | ||
M plone/namedfile/adapters.py | ||
|
||
b'diff --git a/plone/namedfile/adapters.py b/plone/namedfile/adapters.py\nindex 8c147cf..dc831b2 100644\n--- a/plone/namedfile/adapters.py\n+++ b/plone/namedfile/adapters.py\n@@ -129,4 +129,8 @@ def get_original_image_url(self, fieldname, width, height):\n return scale.url if scale else None\n \n def _scale_view_from_url(self, url):\n+ # The "download" information for scales is the path to\n+ # "@@images/foo-scale" only.\n+ # The full URL to the scale is rendered by the scaling adapter at\n+ # runtime to make sure they are correct in virtual hostings.\n return url.replace(self.context.absolute_url(), "").lstrip("/")\n' | ||
|
||
Repository: plone.namedfile | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2022-06-27T14:56:29+02:00 | ||
Author: Peter Mathis (petschki) <peter.mathis@kombinat.at> | ||
Commit: https://github.com/plone/plone.namedfile/commit/11aae67f25c5b74e9d4f6586c1fbebf933d0123c | ||
|
||
check if metadata scale url starts with "http" | ||
|
||
Files changed: | ||
M plone/namedfile/scaling.py | ||
|
||
b'diff --git a/plone/namedfile/scaling.py b/plone/namedfile/scaling.py\nindex 2855592..1b75a27 100644\n--- a/plone/namedfile/scaling.py\n+++ b/plone/namedfile/scaling.py\n@@ -751,8 +751,17 @@ def _tag_from_brain_image_scales(\n title = title()\n if alt is _marker:\n alt = title\n+\n+ # common case is a local path to "@@images/img-scale"\n+ # but it might be a custom url starting with "http"\n+ src = (\n+ data["download"]\n+ if data["download"].startswith("http")\n+ else f"{brain.getURL()}/{data[\'download\']}"\n+ )\n+\n values = [\n- ("src", f"{brain.getURL()}/{data[\'download\']}"),\n+ ("src", src),\n ("alt", alt),\n ("title", title),\n ("height", data["height"]),\n' | ||
|
||
Repository: plone.namedfile | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2022-06-27T15:47:14+02:00 | ||
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org> | ||
Commit: https://github.com/plone/plone.namedfile/commit/d2bbbce427b55bdb8b77f3e45ef657168d7e2c9d | ||
|
||
Merge pull request #124 from plone/issue-123 | ||
|
||
Do not use full url in `image_scales` dictionary | ||
|
||
Files changed: | ||
A news/249.bugfix | ||
M plone/app/content/browser/content_status_history.py | ||
M plone/app/content/browser/templates/content_status_history.pt | ||
A news/123.bugfix | ||
M plone/namedfile/adapters.py | ||
M plone/namedfile/scaling.py | ||
M plone/namedfile/tests/test_adapters.py | ||
|
||
b'diff --git a/news/249.bugfix b/news/249.bugfix\nnew file mode 100644\nindex 00000000..b266a47b\n--- /dev/null\n+++ b/news/249.bugfix\n@@ -0,0 +1,2 @@\n+Change some msgids, we have similar ones but are slightly different default values\n+[erral]\ndiff --git a/plone/app/content/browser/content_status_history.py b/plone/app/content/browser/content_status_history.py\nindex a8d49699..b2882b97 100644\n--- a/plone/app/content/browser/content_status_history.py\n+++ b/plone/app/content/browser/content_status_history.py\n@@ -19,7 +19,7 @@ class IContentStatusHistoryDates(Interface):\n effective_date = Datetime(\n title=_("label_effective_date", default="Publishing Date"),\n description=_(\n- "help_effective_date",\n+ "help_effective_date_content_status_history",\n default="The date when the item will be published. If no "\n "date is selected the item will be published immediately.",\n ),\n@@ -29,7 +29,7 @@ class IContentStatusHistoryDates(Interface):\n expiration_date = Datetime(\n title=_("label_expiration_date", default="Expiration Date"),\n description=_(\n- "help_expiration_date",\n+ "help_expiration_date_content_status_history",\n default="The date when the item expires. This will automatically "\n "make the item invisible for others at the given date. "\n "If no date is chosen, it will never expire.",\ndiff --git a/plone/app/content/browser/templates/content_status_history.pt b/plone/app/content/browser/templates/content_status_history.pt\nindex cff394cc..6edd7a9d 100644\n--- a/plone/app/content/browser/templates/content_status_history.pt\n+++ b/plone/app/content/browser/templates/content_status_history.pt\n@@ -227,7 +227,7 @@\n <div class="field" tal:define="error errors/effective_date | nothing;">\n <label i18n:translate="label_effective_date">Publishing Date</label>\n <div class="formHelp"\n- i18n:translate="help_effective_date">\n+ i18n:translate="help_effective_date_content_status_history">\n The date when the item will be published. If no date is selected the\n item will be published immediately.\n </div>\n@@ -251,7 +251,7 @@\n tal:define="error errors/expiration_date | nothing;">\n <label i18n:translate="label_expiration_date">Expiration Date</label>\n <div class="formHelp"\n- i18n:translate="help_expiration_date">\n+ i18n:translate="help_expiration_date_content_status_history">\n The date when the item expires. This will automatically\n make the item invisible for others at the given date.\n If no date is chosen, it will never expire.\n' | ||
b'diff --git a/news/123.bugfix b/news/123.bugfix\nnew file mode 100644\nindex 0000000..6d2933e\n--- /dev/null\n+++ b/news/123.bugfix\n@@ -0,0 +1,2 @@\n+Do not use full url in `image_scales` dictionary.\n+[petschki]\ndiff --git a/plone/namedfile/adapters.py b/plone/namedfile/adapters.py\nindex c38bdda..dc831b2 100644\n--- a/plone/namedfile/adapters.py\n+++ b/plone/namedfile/adapters.py\n@@ -69,7 +69,7 @@ def __call__(self):\n "filename": image.filename,\n "content-type": image.contentType,\n "size": image.getSize(),\n- "download": url,\n+ "download": self._scale_view_from_url(url),\n "width": width,\n "height": height,\n "scales": scales,\n@@ -109,7 +109,7 @@ def get_scales(self, field, width, height):\n actual_height = scale.height\n \n scales[name] = {\n- "download": url,\n+ "download": self._scale_view_from_url(url),\n "width": actual_width,\n "height": actual_height,\n }\n@@ -127,3 +127,10 @@ def get_original_image_url(self, fieldname, width, height):\n )\n # Corrupt images may not have a scale.\n return scale.url if scale else None\n+\n+ def _scale_view_from_url(self, url):\n+ # The "download" information for scales is the path to\n+ # "@@images/foo-scale" only.\n+ # The full URL to the scale is rendered by the scaling adapter at\n+ # runtime to make sure they are correct in virtual hostings.\n+ return url.replace(self.context.absolute_url(), "").lstrip("/")\ndiff --git a/plone/namedfile/scaling.py b/plone/namedfile/scaling.py\nindex 074662c..1b75a27 100644\n--- a/plone/namedfile/scaling.py\n+++ b/plone/namedfile/scaling.py\n@@ -751,8 +751,17 @@ def _tag_from_brain_image_scales(\n title = title()\n if alt is _marker:\n alt = title\n+\n+ # common case is a local path to "@@images/img-scale"\n+ # but it might be a custom url starting with "http"\n+ src = (\n+ data["download"]\n+ if data["download"].startswith("http")\n+ else f"{brain.getURL()}/{data[\'download\']}"\n+ )\n+\n values = [\n- ("src", data["download"]),\n+ ("src", src),\n ("alt", alt),\n ("title", title),\n ("height", data["height"]),\ndiff --git a/plone/namedfile/tests/test_adapters.py b/plone/namedfile/tests/test_adapters.py\nindex b144aeb..7a14782 100644\n--- a/plone/namedfile/tests/test_adapters.py\n+++ b/plone/namedfile/tests/test_adapters.py\n@@ -85,8 +85,7 @@ def test_field_adapter_return_scales(self):\n },\n )\n # Note: self.content.absolute_url() is actually empty in this test.\n- images_url = self.content.absolute_url() + "/@@images"\n- self.assertTrue(download.startswith(f"{images_url}/image1-16-"))\n+ self.assertTrue(download.startswith(f"@@images/image1-16-"))\n self.assertTrue(download.endswith(".gif"))\n self.assertIn("listing", scales)\n self.assertEqual(len(scales), 1)\n@@ -95,7 +94,7 @@ def test_field_adapter_return_scales(self):\n self.assertEqual(listing["height"], 16)\n self.assertEqual(listing["width"], 16)\n download = listing["download"]\n- self.assertTrue(download.startswith(f"{images_url}/image1-16-"))\n+ self.assertTrue(download.startswith(f"@@images/image1-16-"))\n self.assertTrue(download.endswith(".gif"))\n \n @unittest.skipIf(IImageScalesFieldAdapter is not None, "Skipping on Plone 6")\n@@ -132,8 +131,7 @@ def test_field_adapter_does_not_return_larger_scales(self):\n },\n )\n # Note: self.content.absolute_url() is actually empty in this test.\n- images_url = self.content.absolute_url() + "/@@images"\n- self.assertTrue(download.startswith(f"{images_url}/image1-900-"))\n+ self.assertTrue(download.startswith(f"@@images/image1-900-"))\n self.assertTrue(download.endswith(".jpeg"))\n # larger and huge should not be in here: these scales would return the same\n # content as the original.\n@@ -144,4 +142,4 @@ def test_field_adapter_does_not_return_larger_scales(self):\n preview = scales["preview"]\n self.assertEqual(preview["width"], 400)\n self.assertEqual(preview["height"], 400)\n- self.assertTrue(preview["download"].startswith(f"{images_url}/image1-400-"))\n+ self.assertTrue(preview["download"].startswith(f"@@images/image1-400-"))\n' | ||
|