-
Notifications
You must be signed in to change notification settings - Fork 5
Add actor detail pages #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
base: main
Are you sure you want to change the base?
Changes from all commits
7e9be09
5042f78
15d9b58
51a3e24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| // DrFed: A web-based platform for developing and debugging ActivityPub apps | ||
| // Copyright (C) 2026 DrFed team | ||
| // | ||
| // 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/>. | ||
|
|
||
| import { A } from "@solidjs/router"; | ||
| import { graphql } from "relay-runtime"; | ||
| import { Show } from "solid-js"; | ||
| import { createFragment } from "solid-relay"; | ||
|
|
||
| import type { ActorCard_actor$key } from "./__generated__/ActorCard_actor.graphql.ts"; | ||
|
|
||
| import styles from "~/styles/instance.module.css"; | ||
|
|
||
| export const ActorCard = (props: { $actor: ActorCard_actor$key }) => { | ||
| const actorData = createFragment( | ||
| graphql` | ||
| fragment ActorCard_actor on Actor { | ||
| handle | ||
| id | ||
| } | ||
| `, | ||
| () => props.$actor, | ||
| ); | ||
|
|
||
| return ( | ||
| <Show when={actorData()}> | ||
| {(actor) => ( | ||
| <article class={styles.actorCard}> | ||
| <span class={styles.actorMarker} aria-hidden="true" /> | ||
| <A href={`/actor/${encodeURIComponent(actor().id)}`}> | ||
| {actor().handle} | ||
| </A> | ||
| </article> | ||
| )} | ||
| </Show> | ||
| ); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| // DrFed: A web-based platform for developing and debugging ActivityPub apps | ||
| // Copyright (C) 2026 DrFed team | ||
| // | ||
| // 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/>. | ||
|
|
||
| import { createSignal } from "solid-js"; | ||
|
|
||
| import styles from "~/styles/buttons.module.css"; | ||
|
|
||
| /** | ||
| * Copy a value to the clipboard and announce the result. | ||
| * @returns A copy button with accessible feedback. | ||
| */ | ||
| export function CopyButton(props: { value: string; label: string }) { | ||
| const [message, setMessage] = createSignal(""); | ||
| async function copy() { | ||
| try { | ||
| await navigator.clipboard.writeText(props.value); | ||
| setMessage("Copied."); | ||
| } catch { | ||
| setMessage("Could not copy. Select and copy the text manually."); | ||
| } | ||
| } | ||
| return ( | ||
| <span class={styles.copyControl}> | ||
| <button | ||
| type="button" | ||
| onClick={() => { | ||
| void copy(); | ||
| }} | ||
| aria-label={`Copy ${props.label}`} | ||
| > | ||
| Copy | ||
| </button> | ||
| <output>{message()}</output> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the “Copied” message should appear briefly after copying, then disappear. How about refer Mastodon's copy button? 2026-09-24.12.40.15.mov
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i also thought about just symbol, no texts. so state change would be copy symbol to check symbol or something similar. |
||
| </span> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| // DrFed: A web-based platform for developing and debugging ActivityPub apps | ||
| // Copyright (C) 2026 DrFed team | ||
| // | ||
| // 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/>. | ||
|
|
||
| import { Title } from "@solidjs/meta"; | ||
| import { | ||
| A, | ||
| type RouteDefinition, | ||
| type RouteSectionProps, | ||
| query, | ||
| } from "@solidjs/router"; | ||
| import { graphql } from "relay-runtime"; | ||
| import { ErrorBoundary, Show, Suspense } from "solid-js"; | ||
| import { | ||
| createPreloadedQuery, | ||
| loadQuery, | ||
| useRelayEnvironment, | ||
| } from "solid-relay"; | ||
|
|
||
| import { ActorDetail } from "~/components/ActorDetail.tsx"; | ||
|
|
||
| import type { ActorDetailQuery } from "./__generated__/ActorDetailQuery.graphql.ts"; | ||
|
|
||
| import styles from "~/styles/actor.module.css"; | ||
|
|
||
| const actorDetailQuery = graphql` | ||
| query ActorDetailQuery($id: ID!) @throwOnFieldError { | ||
| node(id: $id) { | ||
| ... on Actor @alias(as: "actor") { | ||
| ...ActorDetail_actor | ||
| } | ||
| } | ||
| } | ||
| `; | ||
|
|
||
| const loadActorDetailQuery = query( | ||
| (id: string) => | ||
| loadQuery<ActorDetailQuery>(useRelayEnvironment()(), actorDetailQuery, { | ||
| id, | ||
| }), | ||
| "ActorDetailQuery", | ||
| ); | ||
|
|
||
| export const route = { | ||
| preload({ params }) { | ||
| if (params.id === undefined) { | ||
| throw new Error("Missing actor ID route parameter."); | ||
| } | ||
| return loadActorDetailQuery(params.id); | ||
| }, | ||
| } satisfies RouteDefinition; | ||
|
|
||
| type RouteData = ReturnType<typeof loadActorDetailQuery>; | ||
|
|
||
| export default function ActorDetailPage(props: RouteSectionProps<RouteData>) { | ||
| return ( | ||
| <main class={styles.page}> | ||
| <Title>Actor — DrFed</Title> | ||
| <A class={styles.backLink} href="/workspace"> | ||
| ← All instances | ||
| </A> | ||
| <ErrorBoundary | ||
| fallback={ | ||
| <p role="alert"> | ||
| Unable to load this actor. Please reload the page to try again. | ||
| </p> | ||
| } | ||
| > | ||
| <Suspense fallback={<output>Loading actor…</output>}> | ||
| <ActorDetailContent data={props.data} /> | ||
| </Suspense> | ||
| </ErrorBoundary> | ||
| </main> | ||
| ); | ||
| } | ||
|
|
||
| function ActorDetailContent(props: { data: RouteData }) { | ||
| const data = createPreloadedQuery<ActorDetailQuery>( | ||
| actorDetailQuery, | ||
| () => props.data, | ||
| ); | ||
| const actor = () => { | ||
| const node = data()?.node; | ||
| return node?.actor; | ||
| }; | ||
| return ( | ||
| <Show when={data()}> | ||
| <Show when={actor()} fallback={<p>Actor not found.</p>}> | ||
| {(value) => <ActorDetail $actor={value()} />} | ||
| </Show> | ||
| </Show> | ||
| ); | ||
| } |
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 don't think this should be an anchor. For example, ActivityPub instances usually don't accept GET requests to the inbox/outbox endpoint. How about refer Hackers'Pub Actor page? In Hackers'Pub Actor page, if you click handle, then the content of the span element is selected and you can copy it immediately.
2026-09-24.12.44.26.mov
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.
or we can combine both of them #92 (comment) if you click those URLs then copied already.