Skip to content

Commit

Permalink
Merge pull request #53 from eea/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
avoinea authored Feb 4, 2025
2 parents 9305c50 + c2478e5 commit 27f4fea
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
11 changes: 9 additions & 2 deletions docs/HISTORY.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

6.3 - (2025-02-03)
---------------------------
* Fix: Context Navigation root_path extract from root_node
[avoinea - refs #283961]
* Change: Fix Serializer HTML
[dobri1408 - refs #282435]

6.2 - (2025-01-08)
---------------------------
* Fix: Add serializer for slate and html blocks refs
Expand Down Expand Up @@ -30,7 +37,7 @@ Changelog
---------------------------
* Feature: added getObjSize info for File portal_type used to get file size information
[ichim-david - refs #280463]
* Bug fix: fixed title of the initial navigation item when `side_title_nav` isn't set
* Bug fix: fixed title of the initial navigation item when `side_title_nav` isn't set
[ichim-david - refs #280463]

5.7 - (2024-11-24)
Expand All @@ -54,7 +61,7 @@ Changelog

5.4 - (2024-10-09)
---------------------------
* Fix: Create a content upgrade script to fix SVGs display
* Fix: Create a content upgrade script to fix SVGs display
[@dobri1408 - refs #276995]

5.3 - (2024-08-23)
Expand Down
24 changes: 11 additions & 13 deletions eea/volto/policy/restapi/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,21 @@ class HTMLBlockDeserializerBase:
"""
HTML block Deserializer for the hrefs and src
"""
order = 100
order = 9999
block_type = "html"

def __init__(self, context, request):
self.context = context
self.request = request

def _clean_download_image(self, url: str) -> str:
"""
Remove /@@download/image
"""
return url.replace("/@@download/image", "")

def __call__(self, block):
raw_html = block.get("html", "")

if not raw_html:
return block

Expand All @@ -61,24 +66,18 @@ def __call__(self, block):
# Resolve all <a> and <img> tags to UIDs
for tag in soup.find_all(["a", "img"]):
if tag.name == "a" and tag.has_attr("href"):
tag["href"] = self._clean_download_image(tag["href"])

tag["href"] = path2uid(context=self.context, link=tag["href"])

elif tag.name == "img" and tag.has_attr("src"):
tag["src"] = self._clean_download_image(tag["src"])
tag["src"] = path2uid(context=self.context, link=tag["src"])

# Serialize the modified HTML back into the block
block["html"] = str(soup)
return block

def _convert_to_uid(self, url, is_image=False):
"""
Convert relative or absolute URLs into resolve UID links.
"""
uid = path2uid(self.context, url)
if uid:
return f"/resolveuid/{uid}"
return url
return block


class HTMLBlockSerializerBase:
Expand All @@ -101,7 +100,6 @@ def __call__(self, block):

# Parse the HTML using BeautifulSoup
soup = BeautifulSoup(raw_html, "html.parser")

# Resolve all <a> and <img> tags
for tag in soup.find_all(["a", "img"]):
if tag.name == "a" and tag.has_attr("href"):
Expand Down Expand Up @@ -185,7 +183,7 @@ def __call__(self, value):
):
root_nav_item = value["root_node"][0]
url = urlparse(root_nav_item.get("@id", ""))
value["root_path"] = url.path if url.scheme else ""
value["root_path"] = url.path

data = eea_extract_data(IEEANavigationPortlet, value, prefix=None)

Expand Down
2 changes: 1 addition & 1 deletion eea/volto/policy/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.2
6.3

0 comments on commit 27f4fea

Please sign in to comment.