sissbruecker / linkding

Self-hosted bookmark manager that is designed be to be minimal, fast, and easy to set up using Docker.
MIT License
5.33k stars 261 forks source link

description field to support basic text formatting #709

Open soph-sol opened 2 months ago

soph-sol commented 2 months ago

I recently got a linkding instance set up for myself and an issue I've run into is that the description field formats all text as a single unbroken paragraph. I imported a large number of bookmarks where having hard returns in my descriptions is important in being able to easily read the information I put there. Having this field in the bookmarks list respect the returns that are in the input form would be very helpful.

ab623 commented 2 months ago

Can you post a screenshot of exactly where you are seeing the issue. As the description shows up in a few places.

soph-sol commented 2 months ago

sure thing, here you go: description screenshot 1 description screenshot 2

ab623 commented 2 months ago

Is this what you are looking for?

image

image

soph-sol commented 2 months ago

yes exactly!

ab623 commented 2 months ago

Its a simple fix. I'll push a PR for it shortly.

soph-sol commented 2 months ago

wonderful, thanks so much!

sissbruecker commented 2 months ago

The meta description scraped from websites may contain arbitrary line breaks, which are usually ignored when displaying the text. Here's an example: https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/insertRule. Since most people probably just use the automatically generated description, changing the default is a no go. Maybe this could be an option, but I'd wait with adding something until there is a decent amount of interest in this.

At the moment, the notes field would be more appropriate for your use-case, as it is intended to support formatting. Since you imported your bookmarks that's not going to be a huge help. You'd need some automatism that would move your description into the notes field. It should be possible to write a script that does this with the REST API I think.

soph-sol commented 2 months ago

Thanks for the response, I do get it about the default way people use it. Unfortunately, moving my comments into the notes section won't help with my use case because it's important to me for my comments on my shared bookmarks to be visible, as this is a major way I make recommendations to people within my online community. Would you have another suggestion on how I could achieve what I'm looking for (publicly visible comments on bookmarks that can contain line breaks) without interfering with the defaults that other users prefer?

sissbruecker commented 2 months ago

Making the description respect line breaks can be done by adding custom CSS via the settings:

ul.bookmark-list li .description.separate {
  white-space: pre;
}

However that doesn't work properly at the moment due to how the HTML template is formatted - it adds leading and trailing whitespace. That would be an easy fix that could be done in the next patch release.

If you are comfortable with tinkering with files in the Docker container, you could fix it manually by making the following change to /etc/linkding/bookmarks/templates/bookmarks/bookmark_list.html:

-            <div class="description separate">
-              {{ bookmark_item.description }}
-            </div>
+            <div class="description separate">{{ bookmark_item.description }}</div>
sissbruecker commented 2 months ago

But wait, if you want this to work on the shared bookmarks page for anonymous users then this doesn't help either. Those settings are stored in your user's profile, whereas anonymous users use a default profile. The default profile doesn't use a separate description, nor does it show the description over multiple lines. You can test this by logging out and then check the shared bookmarks page - it will look different from what you see when you are logged in.

I think what you want is being able to configure the default profile used for anon users. This is somewhat related: https://github.com/sissbruecker/linkding/issues/533

soph-sol commented 2 months ago

ahhh yes, configuring the default for anon users is definitely what I want, on top of changing my personal view! I'll add that custom css for myself, thanks for that. Should I open a new issue thread for the question of configuring the default profile?

sissbruecker commented 2 months ago

Sure