Unverified Commit 2073b445 authored by Hong Minhee's avatar Hong Minhee
Browse files

Adjust design of `fedify inbox` web interface

parent b25a1e09
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -20,6 +20,12 @@ To be released.
    the web interface when the `fedify` command was installed using
    `deno install` command from JSR.

 -  The web interface of the `fedify inbox` command was slightly redesigned:

     -  The Fedify logo with the cute dinosaur is now displayed at the top of
        the page.
     -  You can easily copy the fediverse handle of the ephemeral actor.

[#209]: https://github.com/fedify-dev/fedify/issues/209


+23 −3
Original line number Diff line number Diff line
@@ -24,7 +24,8 @@ import {
} from "@fedify/fedify";
import { getLogger } from "@logtape/logtape";
import { parse } from "@std/semver";
import { Hono } from "hono";
import { type Context as HonoContext, Hono } from "hono";
import type { BlankEnv, BlankInput } from "hono/types";
import ora from "ora";
import metadata from "./deno.json" with { type: "json" };
import { getDocumentLoader } from "./docloader.ts";
@@ -370,11 +371,23 @@ function printActivityEntry(idx: number, entry: ActivityEntry): void {
    .render();
}

function getHandle<T extends string>(
  c: HonoContext<BlankEnv, T, BlankInput>,
): string {
  return `@i@${c.req.url}`;
}

const app = new Hono();

app.get("/", (c) => c.redirect("/r"));

app.get("/r", (c) => c.html(<ActivityListPage entries={activities} />));
app.get(
  "/r",
  (c) =>
    c.html(
      <ActivityListPage handle={getHandle(c)} entries={activities} />,
    ),
);

app.get("/r/:idx{[0-9]+}", (c) => {
  const idx = parseInt(c.req.param("idx"));
@@ -387,7 +400,14 @@ app.get("/r/:idx{[0-9]+}", (c) => {
  ) {
    return c.notFound();
  }
  return c.html(<ActivityEntryPage idx={idx} entry={activity} tabPage={tab} />);
  return c.html(
    <ActivityEntryPage
      handle={getHandle(c)}
      idx={idx}
      entry={activity}
      tabPage={tab}
    />,
  );
});

async function fetch(request: Request): Promise<Response> {
+6 −1
Original line number Diff line number Diff line
@@ -8,6 +8,8 @@ import { Hono } from "hono";
import type { ActivityEntry } from "./entry.ts";
import { ActivityEntryPage, ActivityListPage } from "./view.tsx";

const DUMB_HANDLE = "@test@localhost";

const app = new Hono();

app.get("/r/0", async (c) => {
@@ -81,6 +83,7 @@ app.get("/r/0", async (c) => {
  };
  return c.html(
    <ActivityEntryPage
      handle={DUMB_HANDLE}
      idx={idx}
      entry={entry}
      // @ts-ignore:
@@ -99,6 +102,7 @@ app.get("/r/1", (c) => {
  };
  return c.html(
    <ActivityEntryPage
      handle={DUMB_HANDLE}
      idx={idx}
      entry={entry}
      // @ts-ignore:
@@ -116,6 +120,7 @@ app.get("/r/2", (c) => {
  };
  return c.html(
    <ActivityEntryPage
      handle={DUMB_HANDLE}
      idx={idx}
      entry={entry}
      // @ts-ignore:
@@ -166,7 +171,7 @@ app.get("/r", (c) => {
    },
  ];
  return c.html(
    <ActivityListPage entries={entries} />,
    <ActivityListPage handle={DUMB_HANDLE} entries={entries} />,
  );
});

+222 −12

File changed.

Preview size limit exceeded, changes collapsed.

+330 B (256 KiB)

File changed.

No diff preview for this file type.

Loading