parent
578b504c92
commit
ca3dc82a62
18
core/html.py
18
core/html.py
|
@ -92,9 +92,9 @@ class ContentRenderer:
|
|||
html = self.imageify_emojis(html, identity=post.author)
|
||||
return mark_safe(html)
|
||||
|
||||
def render_identity(self, html: str, identity, strip: bool = False) -> str:
|
||||
def render_identity_summary(self, html: str, identity, strip: bool = False) -> str:
|
||||
"""
|
||||
Given identity field HTML, normalises it and renders it for presentation.
|
||||
Given identity summary HTML, normalises it and renders it for presentation.
|
||||
"""
|
||||
if not html:
|
||||
return ""
|
||||
|
@ -107,6 +107,20 @@ class ContentRenderer:
|
|||
html = self.imageify_emojis(html, identity=identity)
|
||||
return mark_safe(html)
|
||||
|
||||
def render_identity_data(self, html: str, identity, strip: bool = False) -> str:
|
||||
"""
|
||||
Given name/basic value HTML, normalises it and renders it for presentation.
|
||||
"""
|
||||
if not html:
|
||||
return ""
|
||||
if strip:
|
||||
html = strip_html(html)
|
||||
else:
|
||||
html = sanitize_html(html)
|
||||
if self.local:
|
||||
html = self.imageify_emojis(html, identity=identity)
|
||||
return mark_safe(html)
|
||||
|
||||
def linkify_mentions(self, html: str, post) -> str:
|
||||
"""
|
||||
Links mentions _in the context of the post_ - as in, using the mentions
|
||||
|
|
|
@ -283,7 +283,7 @@ class Identity(StatorModel):
|
|||
|
||||
@property
|
||||
def safe_summary(self):
|
||||
return ContentRenderer(local=True).render_identity(self.summary, self)
|
||||
return ContentRenderer(local=True).render_identity_summary(self.summary, self)
|
||||
|
||||
@property
|
||||
def safe_metadata(self):
|
||||
|
@ -293,8 +293,8 @@ class Identity(StatorModel):
|
|||
return []
|
||||
return [
|
||||
{
|
||||
"name": renderer.render_identity(data["name"], self, strip=True),
|
||||
"value": renderer.render_identity(data["value"], self, strip=True),
|
||||
"name": renderer.render_identity_data(data["name"], self, strip=True),
|
||||
"value": renderer.render_identity_data(data["value"], self, strip=True),
|
||||
}
|
||||
for data in self.metadata
|
||||
]
|
||||
|
@ -367,7 +367,7 @@ class Identity(StatorModel):
|
|||
"""
|
||||
Return the name_or_handle with any HTML substitutions made
|
||||
"""
|
||||
return ContentRenderer(local=True).render_identity(
|
||||
return ContentRenderer(local=True).render_identity_data(
|
||||
self.name_or_handle, self, strip=True
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue