Compare commits
No commits in common. "c1bd6d770f060842a5bd0969eb0281ae4c413f86" and "dd885487a09b4c8e581f47fdb7239c033496138e" have entirely different histories.
c1bd6d770f
...
dd885487a0
|
|
@ -30,7 +30,7 @@ export class MiVoiceBridge {
|
|||
|
||||
constructor(opts: MiVoiceBridgeOptions = {}) {
|
||||
this.#bridgeUrl = opts.bridgeUrl ?? DEFAULT_BRIDGE;
|
||||
this.#voice = opts.voice ?? "en-US-EmmaMultilingualNeural";
|
||||
this.#voice = opts.voice ?? "en-US-AndrewMultilingualNeural";
|
||||
this.#onStateChange = opts.onStateChange ?? null;
|
||||
}
|
||||
|
||||
|
|
@ -191,7 +191,7 @@ export class MiVoiceBridge {
|
|||
const res = await fetch(`${this.#bridgeUrl}${TTS_PATH}`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ text, voice: this.#voice, volume: 0.25, rate: "-8%", pitch: "+0Hz" }),
|
||||
body: JSON.stringify({ text, voice: this.#voice, volume: 0.3, rate: "-10%", pitch: "-6Hz" }),
|
||||
});
|
||||
if (!res.ok) {
|
||||
ws.removeEventListener("message", handler);
|
||||
|
|
@ -224,8 +224,8 @@ export class MiVoiceBridge {
|
|||
this.#speakResolve = resolve;
|
||||
const utterance = new SpeechSynthesisUtterance(text);
|
||||
utterance.rate = 0.95;
|
||||
utterance.pitch = 1.0;
|
||||
utterance.volume = 0.25;
|
||||
utterance.pitch = 0.85;
|
||||
utterance.volume = 0.3;
|
||||
utterance.onend = () => {
|
||||
this.#speakResolve = null;
|
||||
resolve();
|
||||
|
|
|
|||
|
|
@ -200,10 +200,7 @@ function formatBytes(n: number): string {
|
|||
|
||||
function renderReaderPage(opts: { record: import("./publications-store").PublicationRecord; spaceSlug: string }): string {
|
||||
const { record, spaceSlug } = opts;
|
||||
// Always emit canonical subdomain absolute URLs so links are correct
|
||||
// regardless of whether the user arrived via {space}.rspace.online/...
|
||||
// or rspace.online/{space}/... (internal path-scope rewriting form).
|
||||
const base = `https://${encodeURIComponent(record.space)}.rspace.online/rpubs/publications/${encodeURIComponent(record.slug)}`;
|
||||
const base = `/${escapeAttr(spaceSlug)}/rpubs/publications/${escapeAttr(record.slug)}`;
|
||||
const pdfUrl = `${base}/pdf`;
|
||||
const epubUrl = `${base}/epub`;
|
||||
const epubFixedUrl = record.fixedEpubBytes ? `${base}/epub-fixed` : null;
|
||||
|
|
@ -553,18 +550,23 @@ routes.post("/api/publish", async (c) => {
|
|||
fixedEpub,
|
||||
});
|
||||
|
||||
// Canonical subdomain form: {space}.rspace.online/rpubs/publications/{slug}.
|
||||
// The server rewrites subdomain → path-scope internally, so this URL works
|
||||
// even though Hono routes are mounted at `/:space/rpubs/...`.
|
||||
const hostedUrl = `https://${record.space}.rspace.online/rpubs/publications/${record.slug}`;
|
||||
const proto = c.req.header("x-forwarded-proto") || "https";
|
||||
const host = c.req.header("host") || "rspace.online";
|
||||
const baseUrl = `${proto}://${host}`;
|
||||
// The reader lives under the module mount (`/:space/rpubs/publications/:slug`)
|
||||
// or, on the standalone rpubs.online domain, at `/publications/:slug`.
|
||||
const isStandalone = host.includes("rpubs.online");
|
||||
const hostedPath = isStandalone
|
||||
? `/publications/${record.slug}`
|
||||
: `/${record.space}/rpubs/publications/${record.slug}`;
|
||||
|
||||
return c.json({
|
||||
...record,
|
||||
hosted_url: hostedUrl,
|
||||
hosted_path: `/rpubs/publications/${record.slug}`,
|
||||
pdf_url: `${hostedUrl}/pdf`,
|
||||
epub_url: `${hostedUrl}/epub`,
|
||||
epub_fixed_url: fixedEpub ? `${hostedUrl}/epub-fixed` : null,
|
||||
hosted_url: `${baseUrl}${hostedPath}`,
|
||||
hosted_path: hostedPath,
|
||||
pdf_url: `${baseUrl}${hostedPath}/pdf`,
|
||||
epub_url: `${baseUrl}${hostedPath}/epub`,
|
||||
epub_fixed_url: fixedEpub ? `${baseUrl}${hostedPath}/epub-fixed` : null,
|
||||
}, 201);
|
||||
} catch (error) {
|
||||
console.error("[Pubs] Publish error:", error);
|
||||
|
|
@ -596,7 +598,7 @@ routes.get("/publications/:slug", async (c) => {
|
|||
|
||||
const record = await getPublication(dataSpace, slug);
|
||||
if (!record) {
|
||||
return c.html(`<!doctype html><meta charset="utf-8"><title>Not found</title><body style="font:14px system-ui;padding:40px;color:#ddd;background:#111"><h1>Publication not found</h1><p>No publication exists at this URL.</p><p><a style="color:#14b8a6" href="https://${encodeURIComponent(spaceSlug)}.rspace.online/rpubs">Back to rPubs</a></p></body>`, 404);
|
||||
return c.html(`<!doctype html><meta charset="utf-8"><title>Not found</title><body style="font:14px system-ui;padding:40px;color:#ddd;background:#111"><h1>Publication not found</h1><p>No publication exists at this URL.</p><p><a style="color:#14b8a6" href="/${escapeAttr(spaceSlug)}/rpubs">Back to rPubs</a></p></body>`, 404);
|
||||
}
|
||||
|
||||
return c.html(renderShell({
|
||||
|
|
|
|||
Loading…
Reference in New Issue