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

Ensure tag names do not contain spaces #182

Closed
Fivefold opened this issue Dec 12, 2021 · 3 comments · Fixed by #184
Closed

Ensure tag names do not contain spaces #182

Fivefold opened this issue Dec 12, 2021 · 3 comments · Fixed by #184
Labels
bug Something isn't working

Comments

@Fivefold
Copy link
Contributor

This is an enhancement/feature request

issue

linkding will happily (and correctly) import bookmarks with spaces in tags (e.g. my tag). tags like this can be selected during bookmark creation but will be split into two tags (i.e. my and tag) upon saving because spaces are used as tag separators.

As mentioned in #86 filtering via such tags is not possible since the search term #my tag does not return any results.

workaround

The only current workaround is to create a bookmark and add tags with spaces to it either by using the django administration or otherwise manipulating the sqlite database.

Other alternative is to switch over to -, _ or camelCase as word seperators in tags of course.

solution

The easiest solution I can think of is supporting commas as an optional tag separator and ignoring spaces as separators when a comma is present. Of course this would make it impossible to use commas in tags. I believe it's much more uncommon to use commas in tags compared to spaces however.

Another option would be to have a user setting for preferred tag separator.

In both cases the tag search would need to be worked on though.

alternative solution

If spaces in tags won't be supported it would be good to either automatically convert the spaces to some other separator during import or not accepting such import files (with proper explanation/documentation to the user of course). This would prevent having broken tags with spaces in the database.

@sissbruecker
Copy link
Owner

Thanks for pointing this out, there is indeed an inconsistency here. The intention was definitely for tags to not contain spaces, given how the forms, the search function, and the tag cloud use space as separator. Supporting spaces in tags is an option, but that would require several changes that I'm not sure if they're worth it (fix search queries like #my tag being ambiguous, visual separation of tags in the tag cloud, form changes).

I think I would rather go with declaring this a bug, and that the application should ensure that tag names do not contain spaces. Instead of preventing the import I would suggest to automatically replace spaces with a different character such as _ in the importer, as well as the REST API. Not sure how to deal with databases that already contain tags with spaces. It would be possible to add a migration script for fixing these automatically. Alternatively let users clean those up in the admin themselves.

@Fivefold
Copy link
Contributor Author

That's okay too, it's the quickest way after all and more options also mean more clutter/complexity. I have the impression linkding tries to avoid bloat (which is a good thing).

Fixing existing databases probably is not needed unless there's a lot of demand. I personally don't need it, I changed the separator in the html file before importing.

Feel free to close/rename/declare as bug

@sissbruecker sissbruecker added the bug Something isn't working label Dec 12, 2021
@sissbruecker sissbruecker changed the title Support spaces in tags Ensure tag names do not contain spaces Dec 12, 2021
@sissbruecker
Copy link
Owner

Alright, then let's go with that. Updated the title to reflect the proposed solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants