Separate landing page from space creation

Move the create-space form out of the landing page into its own
route at /create-space. Landing page now shows CTA buttons for
"Create a Space" and "Try the Demo". /new redirects to /create-space.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jeff Emmett 2026-02-21 23:55:25 +00:00
parent c99c25f174
commit f3314477d8
4 changed files with 352 additions and 170 deletions

View File

@ -319,14 +319,17 @@ app.get("/", async (c) => {
}); });
// Create new space page // Create new space page
app.get("/new", async (c) => { app.get("/create-space", async (c) => {
const file = Bun.file(resolve(DIST_DIR, "index.html")); const file = Bun.file(resolve(DIST_DIR, "create-space.html"));
if (await file.exists()) { if (await file.exists()) {
return new Response(file, { headers: { "Content-Type": "text/html" } }); return new Response(file, { headers: { "Content-Type": "text/html" } });
} }
return c.text("Create space", 200); return c.text("Create space", 200);
}); });
// Legacy redirect
app.get("/new", (c) => c.redirect("/create-space", 301));
// Space root: /:space → redirect to /:space/canvas // Space root: /:space → redirect to /:space/canvas
app.get("/:space", (c) => { app.get("/:space", (c) => {
const space = c.req.param("space"); const space = c.req.param("space");

View File

@ -704,6 +704,7 @@ export default defineConfig({
input: { input: {
index: resolve(__dirname, "./website/index.html"), index: resolve(__dirname, "./website/index.html"),
canvas: resolve(__dirname, "./website/canvas.html"), canvas: resolve(__dirname, "./website/canvas.html"),
"create-space": resolve(__dirname, "./website/create-space.html"),
}, },
}, },
modulePreload: { modulePreload: {

317
website/create-space.html Normal file
View File

@ -0,0 +1,317 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🌌</text></svg>">
<title>Create a Space — rSpace</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
color: white;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
padding-top: 56px;
}
.hero {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: calc(100vh - 56px);
width: 100%;
}
.container {
text-align: center;
max-width: 520px;
padding: 40px 20px;
width: 100%;
}
h1 {
font-size: 2.5rem;
margin-bottom: 0.75rem;
background: linear-gradient(135deg, #14b8a6, #22d3ee);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.tagline {
font-size: 1.1rem;
color: #94a3b8;
margin-bottom: 2.5rem;
}
.create-form {
display: flex;
flex-direction: column;
gap: 1.25rem;
background: rgba(255, 255, 255, 0.05);
padding: 2rem;
border-radius: 16px;
border: 1px solid rgba(255, 255, 255, 0.1);
}
.form-group {
display: flex;
flex-direction: column;
gap: 0.5rem;
text-align: left;
}
label {
font-size: 0.875rem;
color: #94a3b8;
}
input, select {
padding: 12px 16px;
border-radius: 8px;
border: 1px solid rgba(255, 255, 255, 0.2);
background: rgba(255, 255, 255, 0.05);
color: white;
font-size: 1rem;
}
select option {
background: #1e293b;
color: white;
}
input:focus, select:focus {
outline: none;
border-color: #14b8a6;
}
input::placeholder {
color: #64748b;
}
.slug-preview {
font-size: 0.875rem;
color: #64748b;
margin-top: 0.25rem;
}
.slug-preview span {
color: #14b8a6;
}
button {
padding: 14px 28px;
border-radius: 8px;
border: none;
background: linear-gradient(135deg, #14b8a6, #0d9488);
color: white;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
transition: transform 0.2s, box-shadow 0.2s;
}
button:hover {
transform: translateY(-2px);
box-shadow: 0 8px 20px rgba(20, 184, 166, 0.3);
}
button:active {
transform: translateY(0);
}
button:disabled {
opacity: 0.6;
cursor: not-allowed;
transform: none;
box-shadow: none;
}
.error {
color: #ef4444;
font-size: 0.875rem;
margin-top: 0.5rem;
}
.help-text {
font-size: 0.8rem;
color: #64748b;
margin-top: 0.25rem;
}
.back-link {
display: inline-block;
margin-top: 1.5rem;
color: #64748b;
text-decoration: none;
font-size: 0.9rem;
transition: color 0.2s;
}
.back-link:hover {
color: #94a3b8;
}
</style>
<link rel="stylesheet" href="/shell.css">
<script defer src="https://rdata.online/collect.js" data-website-id="6ee7917b-0ed7-44cb-a4c8-91037638526b"></script>
</head>
<body data-theme="dark">
<header class="rstack-header" data-theme="dark">
<div class="rstack-header__left">
<rstack-app-switcher current=""></rstack-app-switcher>
<rstack-space-switcher current="" name="Spaces"></rstack-space-switcher>
</div>
<div class="rstack-header__right">
<rstack-identity></rstack-identity>
</div>
</header>
<div class="hero">
<div class="container">
<h1>Create a Space</h1>
<p class="tagline">Start a collaborative community space with all the r* tools built in.</p>
<form class="create-form" id="create-form">
<div class="form-group">
<label for="community-name">Space Name</label>
<input
type="text"
id="community-name"
placeholder="e.g. MycoFi Commons"
required
/>
</div>
<div class="form-group">
<label for="community-slug">URL Slug</label>
<input
type="text"
id="community-slug"
placeholder="e.g. mycofi"
pattern="[a-z0-9-]+"
required
/>
<p class="slug-preview">Your space will be at: <span id="slug-preview">___.rspace.online</span></p>
</div>
<div class="form-group">
<label for="visibility">Visibility</label>
<select id="visibility">
<option value="public">Public — anyone can read and write</option>
<option value="public_read" selected>Public Read — anyone can view, sign in to edit</option>
<option value="authenticated">Authenticated — sign in to view and edit</option>
<option value="members_only">Members Only — invite-only access</option>
</select>
<p class="help-text">You can change this later in space settings.</p>
</div>
<button type="submit">Create Space</button>
<p class="error" id="error-message" style="display: none;"></p>
</form>
<a href="/" class="back-link">&larr; Back to rSpace</a>
</div>
</div>
<script type="module">
import { RStackIdentity } from "@shared/components/rstack-identity";
import { RStackAppSwitcher } from "@shared/components/rstack-app-switcher";
import { RStackSpaceSwitcher } from "@shared/components/rstack-space-switcher";
import { requireAuth, isAuthenticated, getAccessToken } from "@shared/components/rstack-identity";
RStackIdentity.define();
RStackAppSwitcher.define();
RStackSpaceSwitcher.define();
fetch("/api/modules").then(r => r.json()).then(data => {
document.querySelector("rstack-app-switcher")?.setModules(data.modules || []);
}).catch(() => {});
const nameInput = document.getElementById("community-name");
const slugInput = document.getElementById("community-slug");
const slugPreview = document.getElementById("slug-preview");
const form = document.getElementById("create-form");
const errorMessage = document.getElementById("error-message");
const visibility = document.getElementById("visibility");
nameInput.addEventListener("input", () => {
const slug = nameInput.value
.toLowerCase()
.replace(/[^a-z0-9]+/g, "-")
.replace(/^-|-$/g, "");
slugInput.value = slug;
slugPreview.textContent = slug ? `${slug}.rspace.online` : "___.rspace.online";
});
slugInput.addEventListener("input", () => {
const slug = slugInput.value.toLowerCase().replace(/[^a-z0-9-]/g, "");
slugInput.value = slug;
slugPreview.textContent = slug ? `${slug}.rspace.online` : "___.rspace.online";
});
async function submitCreateCommunity() {
errorMessage.style.display = "none";
const name = nameInput.value.trim();
const slug = slugInput.value.trim();
if (!name || !slug) {
errorMessage.textContent = "Please fill in all fields";
errorMessage.style.display = "block";
return;
}
const token = getAccessToken();
if (!token) {
errorMessage.textContent = "Authentication token missing. Please sign in again.";
errorMessage.style.display = "block";
return;
}
const submitBtn = form.querySelector("button");
submitBtn.disabled = true;
submitBtn.textContent = "Creating...";
try {
const response = await fetch("/api/communities", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`,
},
body: JSON.stringify({ name, slug, visibility: visibility.value }),
});
const data = await response.json();
if (!response.ok) {
throw new Error(data.error || "Failed to create community");
}
window.location.href = `/${slug}/canvas`;
} catch (err) {
errorMessage.textContent = err.message;
errorMessage.style.display = "block";
submitBtn.disabled = false;
submitBtn.textContent = "Create Space";
}
}
form.addEventListener("submit", (e) => {
e.preventDefault();
if (!isAuthenticated()) {
requireAuth(() => submitCreateCommunity());
return;
}
submitCreateCommunity();
});
</script>
</body>
</html>

View File

@ -52,75 +52,47 @@
margin-bottom: 3rem; margin-bottom: 3rem;
} }
.create-form { .cta-buttons {
display: flex; display: flex;
flex-direction: column;
gap: 1rem; gap: 1rem;
background: rgba(255, 255, 255, 0.05); justify-content: center;
padding: 2rem; flex-wrap: wrap;
border-radius: 16px;
border: 1px solid rgba(255, 255, 255, 0.1);
} }
.form-group { .cta-primary {
display: flex; display: inline-block;
flex-direction: column; padding: 14px 32px;
gap: 0.5rem;
text-align: left;
}
label {
font-size: 0.875rem;
color: #94a3b8;
}
input {
padding: 12px 16px;
border-radius: 8px; border-radius: 8px;
border: 1px solid rgba(255, 255, 255, 0.2);
background: rgba(255, 255, 255, 0.05);
color: white;
font-size: 1rem;
}
input:focus {
outline: none;
border-color: #14b8a6;
}
input::placeholder {
color: #64748b;
}
.slug-preview {
font-size: 0.875rem;
color: #64748b;
margin-top: 0.25rem;
}
.slug-preview span {
color: #14b8a6;
}
button {
padding: 14px 28px;
border-radius: 8px;
border: none;
background: linear-gradient(135deg, #14b8a6, #0d9488); background: linear-gradient(135deg, #14b8a6, #0d9488);
color: white; color: white;
font-size: 1rem; font-size: 1rem;
font-weight: 600; font-weight: 600;
cursor: pointer; text-decoration: none;
transition: transform 0.2s, box-shadow 0.2s; transition: transform 0.2s, box-shadow 0.2s;
} }
button:hover { .cta-primary:hover {
transform: translateY(-2px); transform: translateY(-2px);
box-shadow: 0 8px 20px rgba(20, 184, 166, 0.3); box-shadow: 0 8px 20px rgba(20, 184, 166, 0.3);
} }
button:active { .cta-secondary {
transform: translateY(0); display: inline-block;
padding: 14px 32px;
border-radius: 8px;
background: rgba(255, 255, 255, 0.05);
border: 1px solid rgba(255, 255, 255, 0.2);
color: #94a3b8;
font-size: 1rem;
font-weight: 600;
text-decoration: none;
transition: transform 0.2s, border-color 0.2s, color 0.2s;
}
.cta-secondary:hover {
transform: translateY(-2px);
border-color: rgba(255, 255, 255, 0.4);
color: white;
} }
.features { .features {
@ -149,17 +121,6 @@
color: #64748b; color: #64748b;
} }
.error {
color: #ef4444;
font-size: 0.875rem;
margin-top: 0.5rem;
}
.success {
color: #22c55e;
font-size: 0.875rem;
}
/* EncryptID & Ecosystem Sections */ /* EncryptID & Ecosystem Sections */
.section { .section {
@ -354,30 +315,10 @@
<h1>rSpace</h1> <h1>rSpace</h1>
<p class="tagline">Collaborative community spaces powered by FolkJS</p> <p class="tagline">Collaborative community spaces powered by FolkJS</p>
<form class="create-form" id="create-form"> <div class="cta-buttons">
<div class="form-group"> <a href="/create-space" class="cta-primary">Create a Space</a>
<label for="community-name">Community Name</label> <a href="/demo/canvas" class="cta-secondary">Try the Demo</a>
<input
type="text"
id="community-name"
placeholder="e.g. MycoFi Commons"
required
/>
</div> </div>
<div class="form-group">
<label for="community-slug">Community Slug</label>
<input
type="text"
id="community-slug"
placeholder="e.g. mycofi"
pattern="[a-z0-9-]+"
required
/>
<p class="slug-preview">Your space will be at: <span id="slug-preview">___.rspace.online</span></p>
</div>
<button type="submit">Create Community Space</button>
<p class="error" id="error-message" style="display: none;"></p>
</form>
<div class="features"> <div class="features">
<div class="feature"> <div class="feature">
@ -580,94 +521,14 @@
import { RStackIdentity } from "@shared/components/rstack-identity"; import { RStackIdentity } from "@shared/components/rstack-identity";
import { RStackAppSwitcher } from "@shared/components/rstack-app-switcher"; import { RStackAppSwitcher } from "@shared/components/rstack-app-switcher";
import { RStackSpaceSwitcher } from "@shared/components/rstack-space-switcher"; import { RStackSpaceSwitcher } from "@shared/components/rstack-space-switcher";
import { requireAuth, isAuthenticated, getAccessToken } from "@shared/components/rstack-identity";
// Register shell header components
RStackIdentity.define(); RStackIdentity.define();
RStackAppSwitcher.define(); RStackAppSwitcher.define();
RStackSpaceSwitcher.define(); RStackSpaceSwitcher.define();
// Load module list for app switcher
fetch("/api/modules").then(r => r.json()).then(data => { fetch("/api/modules").then(r => r.json()).then(data => {
document.querySelector("rstack-app-switcher")?.setModules(data.modules || []); document.querySelector("rstack-app-switcher")?.setModules(data.modules || []);
}).catch(() => {}); }).catch(() => {});
const nameInput = document.getElementById("community-name");
const slugInput = document.getElementById("community-slug");
const slugPreview = document.getElementById("slug-preview");
const form = document.getElementById("create-form");
const errorMessage = document.getElementById("error-message");
// Auto-generate slug from name
nameInput.addEventListener("input", () => {
const slug = nameInput.value
.toLowerCase()
.replace(/[^a-z0-9]+/g, "-")
.replace(/^-|-$/g, "");
slugInput.value = slug;
slugPreview.textContent = slug ? `${slug}.rspace.online` : "___.rspace.online";
});
slugInput.addEventListener("input", () => {
const slug = slugInput.value.toLowerCase().replace(/[^a-z0-9-]/g, "");
slugInput.value = slug;
slugPreview.textContent = slug ? `${slug}.rspace.online` : "___.rspace.online";
});
async function submitCreateCommunity() {
errorMessage.style.display = "none";
const name = nameInput.value.trim();
const slug = slugInput.value.trim();
if (!name || !slug) {
errorMessage.textContent = "Please fill in all fields";
errorMessage.style.display = "block";
return;
}
const token = getAccessToken();
if (!token) {
errorMessage.textContent = "Authentication token missing. Please sign in again.";
errorMessage.style.display = "block";
return;
}
try {
const response = await fetch("/api/communities", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`,
},
body: JSON.stringify({ name, slug }),
});
const data = await response.json();
if (!response.ok) {
throw new Error(data.error || "Failed to create community");
}
// Redirect to the new community space
window.location.href = data.url;
} catch (err) {
errorMessage.textContent = err.message;
errorMessage.style.display = "block";
}
}
form.addEventListener("submit", (e) => {
e.preventDefault();
// If not authenticated, show auth modal; after success, re-submit
if (!isAuthenticated()) {
requireAuth(() => submitCreateCommunity());
return;
}
submitCreateCommunity();
});
</script> </script>
</body> </body>
</html> </html>