diff --git a/modules/rsocials/components/folk-campaign-manager.ts b/modules/rsocials/components/folk-campaign-manager.ts index 8b9c0f6..c03a9c6 100644 --- a/modules/rsocials/components/folk-campaign-manager.ts +++ b/modules/rsocials/components/folk-campaign-manager.ts @@ -72,6 +72,14 @@ export class FolkCampaignManager extends HTMLElement { }); } + private get basePath() { + const host = window.location.hostname; + if (host.endsWith('.rspace.online') || host.endsWith('.rsocials.online')) { + return '/rsocials/'; + } + return `/${this._space}/rsocials/`; + } + private esc(s: string): string { return s.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"'); } @@ -131,7 +139,7 @@ export class FolkCampaignManager extends HTMLElement {
- Open Thread Editor + Open Thread Editor
${phaseHTML} diff --git a/modules/rsocials/components/folk-campaign-planner.ts b/modules/rsocials/components/folk-campaign-planner.ts index 34787b9..b610e47 100644 --- a/modules/rsocials/components/folk-campaign-planner.ts +++ b/modules/rsocials/components/folk-campaign-planner.ts @@ -121,6 +121,14 @@ class FolkCampaignPlanner extends HTMLElement { private shadow: ShadowRoot; private space = ''; + private get basePath() { + const host = window.location.hostname; + if (host.endsWith('.rspace.online') || host.endsWith('.rsocials.online')) { + return '/rsocials/'; + } + return `/${this.space}/rsocials/`; + } + // Data private nodes: CampaignPlannerNode[] = []; private edges: CampaignEdge[] = []; @@ -820,7 +828,7 @@ class FolkCampaignPlanner extends HTMLElement { } else if (action === 'open-thread') { const d = node.data as ThreadNodeData; if (d.threadId) { - window.location.href = `/rsocials/thread-editor/${d.threadId}/edit`; + window.location.href = `${this.basePath}thread-editor/${d.threadId}/edit`; } } }); @@ -1457,7 +1465,7 @@ class FolkCampaignPlanner extends HTMLElement { if (node?.type === 'thread') { const d = node.data as ThreadNodeData; if (d.threadId) { - window.location.href = `/rsocials/thread-editor/${d.threadId}/edit`; + window.location.href = `${this.basePath}thread-editor/${d.threadId}/edit`; } } }); diff --git a/modules/rsocials/components/folk-thread-builder.ts b/modules/rsocials/components/folk-thread-builder.ts index 89f1386..37ba06f 100644 --- a/modules/rsocials/components/folk-thread-builder.ts +++ b/modules/rsocials/components/folk-thread-builder.ts @@ -274,7 +274,7 @@ export class FolkThreadBuilder extends HTMLElement {
${tweetCards}
- Edit Thread + Edit Thread
@@ -289,8 +289,8 @@ export class FolkThreadBuilder extends HTMLElement {
- Create Your Own Thread - Browse All Threads + Create Your Own Thread + Browse All Threads
diff --git a/modules/rsocials/components/folk-thread-gallery.ts b/modules/rsocials/components/folk-thread-gallery.ts index ce58a33..78767a3 100644 --- a/modules/rsocials/components/folk-thread-gallery.ts +++ b/modules/rsocials/components/folk-thread-gallery.ts @@ -82,6 +82,14 @@ export class FolkThreadGallery extends HTMLElement { this.render(); } + private get basePath() { + const host = window.location.hostname; + if (host.endsWith('.rspace.online') || host.endsWith('.rsocials.online')) { + return '/rsocials/'; + } + return `/${this._space}/rsocials/`; + } + private esc(s: string): string { return s.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"'); } @@ -94,7 +102,7 @@ export class FolkThreadGallery extends HTMLElement { const cardsHTML = threads.length === 0 ? `

No threads yet. Create your first thread!

- Create Thread + Create Thread
` : `
${threads.map(t => { @@ -105,8 +113,8 @@ export class FolkThreadGallery extends HTMLElement { ? `
` : ''; const href = this._isDemoFallback - ? `/rsocials/thread-editor` - : `/rsocials/thread-editor/${this.esc(t.id)}/edit`; + ? `${this.basePath}thread-editor` + : `${this.basePath}thread-editor/${this.esc(t.id)}/edit`; return ` ${imageTag}

${this.esc(t.title || 'Untitled Thread')}

@@ -165,7 +173,7 @@ export class FolkThreadGallery extends HTMLElement {
diff --git a/modules/rsocials/mod.ts b/modules/rsocials/mod.ts index 80d9c0f..7ea05b6 100644 --- a/modules/rsocials/mod.ts +++ b/modules/rsocials/mod.ts @@ -644,7 +644,9 @@ routes.get("/landing", (c) => { routes.get("/", (c) => { const space = c.req.param("space") || "demo"; - const base = `/${escapeHtml(space)}/rsocials`; + const host = c.req.header("host")?.split(":")[0] || ""; + const isSubdomain = (host.endsWith(".rspace.online") && host !== "rspace.online" && !host.startsWith("www.")) || host.endsWith(".rsocials.online"); + const base = isSubdomain ? "/rsocials" : `/${escapeHtml(space)}/rsocials`; return c.html(renderShell({ title: `rSocials — ${space} | rSpace`, moduleId: "rsocials",