-
-
Notifications
You must be signed in to change notification settings - Fork 92
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
feat: new plugin hatsu
#631
base: main
Are you sure you want to change the base?
Conversation
Please, give me some time to review this PR (and the middleware too). I didn't know the hatsu library and want to understand what this plugin does and what's the problem to solve. 🙏 Thanks! |
The Hatsu plugin gets ActivityPub integration from Hatsu by setting up a static .well-known file and setting an activity+json alternate for matching urls. https://hatsu.cli.rs/users/redirecting-with-static-files-and-markup.html On top of this, Hatsu middleware goes a step further and redirects for .well-known and matched activity+json requests to be compatible with more Fediverse software. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have been testing the plugin and left a couple of comments.
I don't have a hatsu server, so I've tested it with https://fed.brid.gy/web/lume.land and the build generates the following files:
Sorry for my ignorance, I don't have enough knowledge about the fediverse and indie web. What these files can do?
For example, Lume has a mastodon account https://fosstodon.org/@lume.
What benefits provides the hatsu plugin?
I'm using a web component to show the replies of a mastodon post as comments of posts (see the comments of this post as an example). Does this plugin make this process easier?
url: "/.well-known/webfinger", | ||
content: await read( | ||
new URL( | ||
`/.well-known/webfinger?resource=acct:${site.options.location.host}@${options.instance.host}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work on local because the url host is always localhost
.
Maybe the plugin should have a username
, handler
or something like this to configure this value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work on local because the url host is always
localhost
. Maybe the plugin should have ausername
,handler
or something like this to configure this value?
Maybe provide options.location
option and fallback to site.options.location
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup!
|
||
return (site: Site) => { | ||
if (options.matches) { | ||
site.process([".html"], (pages) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using regexp for urls, I think it's better to use a Search query. For example: publish=true
to select all pages with the variable publish
set to true
.
You can get all pages with:
const pages = site.search.pages("publish=true")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using regexp for urls, I think it's better to use a Search query. For example:
publish=true
to select all pages with the variablepublish
set totrue
.
Indeed. is there a way to use a similar approach for middleware?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. Do you need it for the middleware?
I'm thinking of a solution similar to redirect plugin: it generates a _redirects.json file with all urls that you can import in the redirect middleware.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need it for the middleware?
Some software only supports redirects instead of HTML link alternates, and middleware redirects requests from them while leaving normal user requests intact.
When a user searches for host-meta is related to webfinger and may be requested by some implementations. Here it is set to the webfinger URL of the Hatsu instance.
The Hatsu plugin only considers integration with Hatsu instances, so there is no benefit. As for why this isn't a generic Fediverse plugin, it's because Hatsu has a unique inferable AS2 URL feature. When the pathname matches, the post will set the <!-- generated alternate for https://example.com/foo/bar -->
<link rel="alternate" type="application/activity+json" href="https://hatsu.local/posts/https://example.com/foo/bar" /> When a Fediverse user searches for
Yes, I have an example in the Hatsu documentation, but this plugin currently doesn't implement that part (since it's available only for theme-simple-blog). https://hatsu.cli.rs/users/backfeed-based-on-mastodon-comments.html#lume |
Thanks for the detailed explanation! If I understand correctly, this plugins does two things:
What do you thing about split this plugin in two? For example, a site.use(webfinger({
data: {}, // Data passed directly
remote: // Url with a remote bridge, like https://hatsu.local
}); Does it make sense to you? And |
yes.
right, I think this is the main feature of this plugin, to provide search discovery on Fediverse for website URLs.
The implementation is simple, though it will make configuration more cumbersome.
I feel necessary to think about the configuration format to try to avoid getting more complicated. |
Description
This is an updated version of the same plugin in Aoba.
Check List
CODE OF CONDUCT
CONTRIBUTING
send multiple pull request.
fmt
to fix the code format before commit.CHANGELOG.md
.