jekyll-webmention_io
jekyll-webmention_io copied to clipboard
How can you get the text version of a received webmention?
Until now, I didn't get in touch with ruby at all. So after browsing the code for like an hour and not finding out anything useful:
To be honest, I do not want to trust strangers to put arbitrary html- and potentially javascript-code to my website. So I need to adapt which part of the json object is used as the content that will be build into the webpage.
Where is the json object of the received mention parsed and the content of the webmention handled? Or is there even a simpler method of converting the html to raw text?
Thanks and have a good new year :smile:
I kept having Ruby/Jekyll issues when upgrading my Mac, so I have moved off of Jekyll and will not be working on this project anymore, going forward. I am going to flag this as won’t fix, but leave it open in case someone else wants to pick up the project from here.
So there's two areas you'll want to be looking. First, there's lib/jekyll/webmention_io/webmention_item.rb
, and two specific methods, #determine_content
and #markdownify
(the former of which calls the latter).
That code is what takes the original webmention and renders the markdown which is ultimately cached in webmention_io_received.yml
.
Additionally, the lib/jekyll/templates/
contains the templates that the result is rendered into. For example, the webmentions
template (which you can override in your layout) embeds the cached HTML that is a result of #determine_content
that was previously called.
Now, all that said, I have similar concerns and want to explore how to properly present/render webmention text. Passing it through a markdown parser doesn't seem quite right to me, but I need to learn more.
So following up (over a year later) on my previous comment, webmention.io sends over sanitized HTML in the webmention content which is processed through XRay:
https://github.com/aaronpk/XRay/issues/2
As a result, there should be little risk in rendering the content as-is within the browser.
That said, we do receive stripped text as well, and I could explore ways to make that text available, either through a different tag or config.
BTW, one last remark before I close this issue.
Getting back to the original question: the content is rendered in the webmentions.html template, which can be replaced by the user.
If you check the docs for the configuration you can find the incantations to specify your own templates that are used to render the webmentions on your site.
If you want to see the defaults, you can find them in the tree here.
If you check the default webmentions.html template, you can see how it accesses the 'content' element of the webmention hash to render the text. So if you want to strip or sanitize that text beyond what webmention.io does, you'd want to modify that template accordingly.