-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,7 @@ | |
"multikey", | ||
"nodeinfo", | ||
"phensley", | ||
"pico", | ||
"Pixelfed", | ||
"Tailscale", | ||
"unfollow", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,10 @@ Deno.test("createBot()", async () => { | |
rel: "self", | ||
type: "application/activity+json", | ||
}, | ||
{ | ||
href: "https://example.com/", | ||
rel: "http://webfinger.net/rel/profile-page", | ||
}, | ||
], | ||
subject: "acct:[email protected]", | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// BotKit by Fedify: A framework for creating ActivityPub bots | ||
// Copyright (C) 2025 Hong Minhee <https://hongminhee.org/> | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as | ||
// published by the Free Software Foundation, either version 3 of the | ||
// License, or (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
/** @jsx react-jsx */ | ||
/** @jsxImportSource @hono/hono/jsx */ | ||
import type { JSX } from "@hono/hono/jsx/jsx-runtime"; | ||
import type { BotImpl } from "../bot-impl.ts"; | ||
|
||
export interface LayoutProps extends JSX.ElementChildrenAttribute { | ||
readonly bot: BotImpl<unknown>; | ||
readonly host: string; | ||
readonly title?: string; | ||
readonly activityLink?: string | URL; | ||
} | ||
|
||
export function Layout( | ||
{ bot, host, title, activityLink, children }: LayoutProps, | ||
) { | ||
const handle = `@${bot.username}@${host}`; | ||
return ( | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title> | ||
{title == null | ||
? bot.name == null ? handle : `${bot.name} (${handle})` | ||
: title} | ||
</title> | ||
{activityLink && | ||
( | ||
<link | ||
rel="alternate" | ||
type="application/activity+json" | ||
href={activityLink.toString()} | ||
/> | ||
)} | ||
<link rel="stylesheet" href={`/css/pico.${bot.pages.color}.min.css`} /> | ||
<style>{bot.pages.css}</style> | ||
</head> | ||
<body> | ||
{children} | ||
</body> | ||
</html> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// BotKit by Fedify: A framework for creating ActivityPub bots | ||
// Copyright (C) 2025 Hong Minhee <https://hongminhee.org/> | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as | ||
// published by the Free Software Foundation, either version 3 of the | ||
// License, or (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
/** @jsx react-jsx */ | ||
/** @jsxImportSource @hono/hono/jsx */ | ||
import type { Context } from "@fedify/fedify/federation"; | ||
import { LanguageString } from "@fedify/fedify/runtime"; | ||
import { getActorHandle, Link } from "@fedify/fedify/vocab"; | ||
import type { MessageClass } from "../message.ts"; | ||
|
||
export interface MessageProps { | ||
readonly message: MessageClass; | ||
readonly context: Context<unknown>; | ||
} | ||
|
||
export async function Message({ context, message }: MessageProps) { | ||
const author = await message.getAttribution({ | ||
documentLoader: context.documentLoader, | ||
contextLoader: context.contextLoader, | ||
suppressError: true, | ||
}); | ||
const authorIcon = await author?.getIcon({ | ||
documentLoader: context.documentLoader, | ||
contextLoader: context.contextLoader, | ||
suppressError: true, | ||
}); | ||
const authorHandle = author == null ? null : await getActorHandle(author); | ||
return ( | ||
<article> | ||
<header> | ||
{author?.id | ||
? ( | ||
<hgroup> | ||
{authorIcon?.url && ( | ||
<img | ||
src={authorIcon.url instanceof Link | ||
? authorIcon.url.href?.href | ||
: authorIcon.url.href} | ||
width={authorIcon.width ?? undefined} | ||
height={authorIcon.height ?? undefined} | ||
alt={authorIcon.name?.toString() ?? undefined} | ||
style="float: left; margin-right: 1em; height: 64px;" | ||
/> | ||
)} | ||
<h3> | ||
<a href={author.url?.href?.toString() ?? author.id.href}> | ||
{author.name} | ||
</a> | ||
</h3>{" "} | ||
<p> | ||
<span style="user-select: all;">{authorHandle}</span> | ||
</p> | ||
</hgroup> | ||
) | ||
: <em>(Deleted account)</em>} | ||
</header> | ||
<div | ||
dangerouslySetInnerHTML={{ __html: `${message.content}` }} | ||
lang={message.content instanceof LanguageString | ||
? message.content.language.compact() | ||
: undefined} | ||
/> | ||
<footer> | ||
{message.published && | ||
( | ||
<a href={message.url?.href?.toString() ?? message.id?.href}> | ||
<small> | ||
<time dateTime={message.published.toString()}> | ||
{message.published.toLocaleString("en", { | ||
dateStyle: "full", | ||
timeStyle: "short", | ||
})} | ||
</time> | ||
</small> | ||
</a> | ||
)} | ||
</footer> | ||
</article> | ||
); | ||
} |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pico.min.css |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.