site icon indicating copy to clipboard operation
site copied to clipboard

Show ellipsis or "Read more" for truncation of tags listing descriptions

Open hedyhli opened this issue 2 years ago • 5 comments

https://www.pythondiscord.com/pages/tags/

IMG_0813

The descriptions are truncated off, possibly from some word or character limit. It would be helpful if we add a ellipsis or "Read more" link at the end.

Since this is such a trivial issue I intended to fix it myself, but after a few minutes of failing to find where the description is truncated, I decided to leave it for others or later instead.

hedyhli avatar Jan 14 '24 10:01 hedyhli

Good idea.

A related improvement would be to do the truncation using css to cap it to a fixed height but avoid stopping in the middle of a line. A bit like this: https://codepen.io/Nuke66/pen/LgzRLW. That may be more complicated though, i'm not sure.

wookie184 avatar Jan 18 '24 00:01 wookie184

The length trimming logic is in listing.js.

https://github.com/python-discord/site/blob/f4f359c1b28163383246c07de0ea0c6742169f2f/pydis_site/static/js/content/listing.js#L4-L39

After spending some time debugging this in the browser, it seems it doesn't work properly in lines 20-23. Is it worth it to modify this script or would it be better to move the truncation to the backend?

lemonyte avatar Jan 18 '24 02:01 lemonyte

A bit like this: https://codepen.io/Nuke66/pen/LgzRLW. That may be more complicated though, i'm not sure.

It looks a bit overkill, but if we're opting for it why not change the read more to an expand instead? The tags are used in the server anyway so they can't be several pages long. Tag content in the listing can then be truncated with a "expand" link/button which could expand to display the entire tag.

After spending some time debugging this in the browser, it seems it doesn't work properly in lines 20-23. Is it worth it to modify this script or would it be better to move the truncation to the backend?

Thanks for finding it! IMO It doesn't seem right to be manipulating non-interactive content with JS. If it's done in the template we can much more easily add the read more link. Although if we're doing my expand idea above then JS could be better.

hedyhli avatar Jan 18 '24 03:01 hedyhli

I think this should be handled in the template as well. The "expand" idea is worth trying, but I also don't want to lose the direct links to tags.

lemonyte avatar Jan 18 '24 05:01 lemonyte

It looks a bit overkill, but if we're opting for it why not change the read more to an expand instead?

Yeah, I think the expand idea could work nicely, while keeping the individual tag pages. As for being overkill, I think it might actually be simpler to be able to replace the current listing.js logic that has to work out where to trim things with just some css to limit the size of the container so it doesn't all display.

wookie184 avatar Jan 19 '24 00:01 wookie184