-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve social media preview #3163
base: develop
Are you sure you want to change the base?
Conversation
35489de
to
83348ce
Compare
strip_tags(content.replace("\n", " ").replace("\r", "").replace("<br>", " ")) | ||
) | ||
if len(stripped_content) <= 100: | ||
return stripped_content.strip().replace(" ", " ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this line? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example
Hallo<br>
Welt
will evaluate to Hallo Welt
as we replaced newlines and br tags with empty spaces in line 51.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't re.sub(r"\s+", " ", stripped_content.strip())
work better in this case? Who says we only have two spaces?
Just yesterday I came across a post about implementing preview cards for forgejo. Maybe it helps to cross-compare this: https://codeberg.org/forgejo/forgejo/pulls/6053/files#diff-f9ae2dae24595a0ce188650ca882e187de8cc998 Edit: No, doesn't look like they implement anything but the |
) | ||
if len(stripped_content) <= 100: | ||
return stripped_content.strip().replace(" ", " ") | ||
return stripped_content[:100].strip().rsplit(' ', 1)[0]+" ..." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return stripped_content[:100].strip().rsplit(' ', 1)[0]+" ..." | |
return stripped_content[:100].strip().rsplit(' ', 1)[0]+" …" |
Looking at https://ogp.me/, we might benefit from adding/improving
|
Short description
Improve the social media previews.
More info: https://chat.tuerantuer.org/digitalfabrik/pl/rnoez75xxjyhugxo97mbjuqmte & https://tasks.tuerantuer.org/projects/infra/work_packages/3734/activity?query_id=59
Previews on Signal and WhatsApp are not yet working.
Proposed changes
Side effects
Pull Request Review Guidelines