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

Automatically detect URLs and make them clickable in source publication field #457

Open
TheMihle opened this issue Jun 28, 2024 · 5 comments · Fixed by #464
Open

Automatically detect URLs and make them clickable in source publication field #457

TheMihle opened this issue Jun 28, 2024 · 5 comments · Fixed by #464

Comments

@TheMihle
Copy link

TheMihle commented Jun 28, 2024

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

@DavidMStraub
Copy link
Member

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.

@DavidMStraub DavidMStraub added the enhancement New feature or request label Jun 29, 2024
@TheMihle
Copy link
Author

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.

@DavidMStraub
Copy link
Member

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.

@DavidMStraub
Copy link
Member

Nevermind, found a way 😉

@DavidMStraub
Copy link
Member

Note complete - citation page & attribute values done, source publication missing.

@DavidMStraub DavidMStraub changed the title Automatically detect URLs and make them clickable in Citation, source, attributes. Automatically detect URLs and make them clickable in source publication field Aug 9, 2024
@DavidMStraub DavidMStraub removed their assignment Aug 9, 2024
@DavidMStraub DavidMStraub removed the enhancement New feature or request label Nov 26, 2024
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 a pull request may close this issue.

2 participants