gramps-web
gramps-web copied to clipboard
Automatically detect URLs and make them clickable in source publication field
This is an extension of this feature request to other Gramps reports: https://gramps-project.org/bugs/view.php?id=13337
It would be very nice if reports that show the citations/sources/attributes would detect URLs in the most common places to have them, and made them clickable.
This could potentially be done with detecting if there is a http:// or https:// or something like that and wrap it in a link tag. Unless that causes issues I cant think of.
I think some of the most common locations you may put URLs are: Citation Volume/Page field. Source Publication field. Attributes, both on citation and sources
Good idea. We already do this in notes:
https://github.com/gramps-project/gramps-web/blob/main/src/components/GrampsjsNoteContent.js#L4-L12
So, should be straightforward to generalize.
Good idea. We already do this in notes:
https://github.com/gramps-project/gramps-web/blob/main/src/components/GrampsjsNoteContent.js#L4-L12
So, should be straightforward to generalize.
I did notice its already done in Notes.
If you end up doing it for Gramps Web, is it easy to include in for example Narrative Web and Dynamic Web report too? Like could it maybe just be copy pasted in to those too? I ask mostly because I am curious.
I realized this is a bit trickier than anticipated.
For notes, we're injecting the anchor tags into the note HTML after rendering it. But this is only safe because note content is sanitized by the backend.
For the other elements, they may contain unsafe HTML code in principle - this is not an issue because Lit will not render it as HTML. But if would use the same approach as in notes, we would have to render the raw (unsanitized) string which could contain malitious code.
So this needs a bit more thought to implement in a safe way; either by sanitizing those elements in the backend or finding a way to use lit-html to replace the URLs.
Nevermind, found a way :wink:
Note complete - citation page & attribute values done, source publication missing.