Skip to content
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

Truncate titles and descriptions when they exceed limits #559

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

KyleMaas
Copy link
Contributor

Description

Users on an instance I'm running like to use really long titles and descriptions. Per:

https://www.w3.org/Provider/Style/TITLE.html#:~:text=The%20title%20should%20ideally%20be,there%20is%20only%20limited%20room.

...titles should only be 64 characters long, and meta descriptions should usually be limited to 160 characters. This change truncates both if they exceed limits to keep things in compliance.

Steps

Pre-deploy

Post-deploy

@@ -1,13 +1,13 @@
{% extends "base.html" %}
{% load static %}

{% block headtitle %}{{media_object.title}} - {{PORTAL_NAME}}{% endblock headtitle %}
{% block headtitle %}{{media_object.title|add:" - "|add:PORTAL_NAME|truncatechars:64}}{% endblock headtitle %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think
{{media_object.title|truncatechars:5}} - {{PORTAL_NAME}} is what you want here, if you want to truncate the title and keep the portal name at the end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, I figured it was more important to have the media title in there than to always have the portal name in there, which is why I truncated the concatenation instead.

@mgogoulos
Copy link
Contributor

This is unrelated with the scope of this PR, however if you have the capacity to add it it would be great to wrap the description below the media (with a show more option) - since now it will display the whole description

@KyleMaas
Copy link
Contributor Author

Fair enough. I'll see what I can do.

@KyleMaas
Copy link
Contributor Author

This is unrelated with the scope of this PR, however if you have the capacity to add it it would be great to wrap the description below the media (with a show more option) - since now it will display the whole description

I split this off into its own issue (#660) so I can remember to work on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants