-
Notifications
You must be signed in to change notification settings - Fork 7
feat: default landing page + ACL at server root (#276) #303
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
Changes from all commits
dcf8a91
020aff9
77d0d80
0fe57af
f6b16fa
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,70 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <title>{{title}}</title> | ||
| <meta name="description" content="A personal data server powered by JSS"> | ||
| <style> | ||
| * { margin: 0; padding: 0; box-sizing: border-box; } | ||
| body { | ||
| font-family: Georgia, 'Times New Roman', serif; | ||
| background: #fafaf8; | ||
| color: #2c2c2c; | ||
| line-height: 1.7; | ||
| min-height: 100vh; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| padding: 2rem; | ||
| } | ||
| .container { max-width: 560px; width: 100%; } | ||
| h1 { font-size: 2.2rem; font-weight: 400; margin-bottom: 0.25rem; } | ||
| .subtitle { color: #666; font-size: 1.05rem; margin-bottom: 2rem; padding-bottom: 1.5rem; border-bottom: 1px solid #ddd; } | ||
| p { margin-bottom: 1.25rem; } | ||
| .actions { display: flex; gap: 0.75rem; margin: 1.5rem 0 2rem; flex-wrap: wrap; } | ||
| .btn { | ||
| display: inline-block; | ||
| padding: 0.6rem 1.2rem; | ||
| border-radius: 4px; | ||
| text-decoration: none; | ||
| font-family: Georgia, serif; | ||
| font-size: 0.95rem; | ||
| border: 1px solid transparent; | ||
| cursor: pointer; | ||
| transition: all 0.1s; | ||
| } | ||
| .btn-primary { background: #7c3aed; color: #fff; } | ||
| .btn-primary:hover { background: #6025c0; } | ||
| .btn-secondary { background: #fff; color: #2c2c2c; border-color: #ccc; } | ||
| .btn-secondary:hover { background: #f0efeb; } | ||
| .info { background: #f5f4f0; border-radius: 4px; padding: 1rem; font-size: 0.85rem; color: #666; margin-top: 1.5rem; } | ||
| .info .row { display: flex; justify-content: space-between; padding: 0.2rem 0; } | ||
| .info .label { color: #999; } | ||
| .info code { font-family: 'SFMono-Regular', Consolas, monospace; font-size: 0.9em; color: #555; } | ||
| footer { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid #ddd; color: #999; font-size: 0.8rem; text-align: center; } | ||
| footer a { color: #888; } | ||
| .features { font-size: 0.85rem; color: #666; margin-top: 0.5rem; } | ||
| .features span { display: inline-block; background: #eee; padding: 0.15rem 0.5rem; border-radius: 3px; margin-right: 0.3rem; margin-bottom: 0.3rem; font-family: 'SFMono-Regular', Consolas, monospace; font-size: 0.8rem; } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <div class="container"> | ||
| <h1>{{heading}}</h1> | ||
| <div class="subtitle">{{subtitle}}</div> | ||
| <p>{{description}}</p> | ||
|
|
||
| {{actions}} | ||
|
|
||
| <div class="info"> | ||
| <div class="row"><span class="label">Version</span><code>{{version}}</code></div> | ||
| <div class="row"><span class="label">Mode</span><code>{{mode}}</code></div> | ||
| <div class="features">{{features}}</div> | ||
| </div> | ||
|
|
||
| <footer> | ||
| Powered by <a href="https://jss.live">JSS</a> | ||
| </footer> | ||
| </div> | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,151 @@ | ||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||
| * Server-root landing page. | ||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||
| * Renders src/ui/server-root.html with runtime values, and seeds | ||||||||||||||||||||||||||||||||||
| * DATA_ROOT/index.html + DATA_ROOT/.acl on first start (skip-if-exists, | ||||||||||||||||||||||||||||||||||
| * so operator customisation is preserved). | ||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||
| * See issue #276. | ||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| import { readFileSync } from 'fs'; | ||||||||||||||||||||||||||||||||||
| import { fileURLToPath } from 'url'; | ||||||||||||||||||||||||||||||||||
| import { dirname, join } from 'path'; | ||||||||||||||||||||||||||||||||||
| import * as storage from '../storage/filesystem.js'; | ||||||||||||||||||||||||||||||||||
| import { generatePublicReadAcl, serializeAcl } from '../wac/parser.js'; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| const __dirname = dirname(fileURLToPath(import.meta.url)); | ||||||||||||||||||||||||||||||||||
| const TEMPLATE_PATH = join(__dirname, 'server-root.html'); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||
| * Collect the list of enabled features for display on the landing page. | ||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||
| function listFeatures(options = {}) { | ||||||||||||||||||||||||||||||||||
| const f = []; | ||||||||||||||||||||||||||||||||||
| if (options.idp) f.push('idp'); | ||||||||||||||||||||||||||||||||||
| if (options.nostr) f.push('nostr'); | ||||||||||||||||||||||||||||||||||
| if (options.webrtc) f.push('webrtc'); | ||||||||||||||||||||||||||||||||||
| if (options.activitypub) f.push('activitypub'); | ||||||||||||||||||||||||||||||||||
| if (options.git) f.push('git'); | ||||||||||||||||||||||||||||||||||
| if (options.pay) f.push('payments'); | ||||||||||||||||||||||||||||||||||
| if (options.notifications) f.push('notifications'); | ||||||||||||||||||||||||||||||||||
| if (options.mashlib) f.push('mashlib'); | ||||||||||||||||||||||||||||||||||
| if (options.mongo) f.push('mongo'); | ||||||||||||||||||||||||||||||||||
| if (options.tunnel) f.push('tunnel'); | ||||||||||||||||||||||||||||||||||
| if (options.terminal) f.push('terminal'); | ||||||||||||||||||||||||||||||||||
| return f; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||
| * Build an HTML snippet of action buttons based on server mode. | ||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||
| function renderActions({ singleUser, idp }) { | ||||||||||||||||||||||||||||||||||
| const buttons = []; | ||||||||||||||||||||||||||||||||||
| if (!singleUser && idp) { | ||||||||||||||||||||||||||||||||||
| buttons.push('<a href="/idp/register" class="btn btn-primary">Create a pod</a>'); | ||||||||||||||||||||||||||||||||||
| buttons.push('<a href="/idp" class="btn btn-secondary">Sign in</a>'); | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+42
to
+46
|
||||||||||||||||||||||||||||||||||
| } else if (singleUser && idp) { | ||||||||||||||||||||||||||||||||||
| buttons.push('<a href="/idp" class="btn btn-primary">Sign in</a>'); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| buttons.push('<a href="https://javascriptsolidserver.github.io/docs/" class="btn btn-secondary">Docs</a>'); | ||||||||||||||||||||||||||||||||||
| return `<div class="actions">${buttons.join('\n ')}</div>`; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||
| * Render the landing page as an HTML string. | ||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||
| * @param {object} ctx | ||||||||||||||||||||||||||||||||||
| * @param {string} ctx.version - JSS version | ||||||||||||||||||||||||||||||||||
| * @param {boolean} [ctx.singleUser] | ||||||||||||||||||||||||||||||||||
| * @param {boolean} [ctx.idp] | ||||||||||||||||||||||||||||||||||
| * @param {string} [ctx.singleUserName] | ||||||||||||||||||||||||||||||||||
| * @param {object} [ctx.enabled] - Map of feature flags | ||||||||||||||||||||||||||||||||||
| * @returns {string} HTML | ||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||
| export function renderServerRoot(ctx = {}) { | ||||||||||||||||||||||||||||||||||
| const { version = 'unknown', singleUser = false, idp = false, singleUserName, enabled = {} } = ctx; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| const tpl = readFileSync(TEMPLATE_PATH, 'utf8'); | ||||||||||||||||||||||||||||||||||
| const mode = singleUser ? 'single-user' : 'multi-user'; | ||||||||||||||||||||||||||||||||||
| const features = listFeatures(enabled) | ||||||||||||||||||||||||||||||||||
| .map(f => `<span>${f}</span>`) | ||||||||||||||||||||||||||||||||||
| .join(' '); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| const heading = 'JSS'; | ||||||||||||||||||||||||||||||||||
| const subtitle = singleUser | ||||||||||||||||||||||||||||||||||
| ? `Personal pod${singleUserName && singleUserName !== '/' ? ` for ${escape(singleUserName)}` : ''}` | ||||||||||||||||||||||||||||||||||
| : 'A personal data server'; | ||||||||||||||||||||||||||||||||||
| const description = singleUser | ||||||||||||||||||||||||||||||||||
| ? 'This server hosts a personal data pod. Apps come to the data rather than the other way around.' | ||||||||||||||||||||||||||||||||||
| : 'This server hosts personal data pods on the web. Each pod is a space you own, with your own identity and access control.'; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| return tpl | ||||||||||||||||||||||||||||||||||
| .replace(/{{title}}/g, heading) | ||||||||||||||||||||||||||||||||||
| .replace(/{{heading}}/g, heading) | ||||||||||||||||||||||||||||||||||
| .replace(/{{subtitle}}/g, subtitle) | ||||||||||||||||||||||||||||||||||
| .replace(/{{description}}/g, description) | ||||||||||||||||||||||||||||||||||
| .replace(/{{actions}}/g, renderActions({ singleUser, idp })) | ||||||||||||||||||||||||||||||||||
| .replace(/{{version}}/g, escape(version)) | ||||||||||||||||||||||||||||||||||
| .replace(/{{mode}}/g, mode) | ||||||||||||||||||||||||||||||||||
| .replace(/{{features}}/g, features); | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+83
to
+90
|
||||||||||||||||||||||||||||||||||
| .replace(/{{title}}/g, heading) | |
| .replace(/{{heading}}/g, heading) | |
| .replace(/{{subtitle}}/g, subtitle) | |
| .replace(/{{description}}/g, description) | |
| .replace(/{{actions}}/g, renderActions({ singleUser, idp })) | |
| .replace(/{{version}}/g, escape(version)) | |
| .replace(/{{mode}}/g, mode) | |
| .replace(/{{features}}/g, features); | |
| .replace(/{{title}}/g, () => heading) | |
| .replace(/{{heading}}/g, () => heading) | |
| .replace(/{{subtitle}}/g, () => subtitle) | |
| .replace(/{{description}}/g, () => description) | |
| .replace(/{{actions}}/g, () => renderActions({ singleUser, idp })) | |
| .replace(/{{version}}/g, () => escape(version)) | |
| .replace(/{{mode}}/g, () => mode) | |
| .replace(/{{features}}/g, () => features); |
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.
The landing page feature list omits the terminal feature flag even though the server supports
options.terminal(and other features are listed). This means the UI can incorrectly report enabled features. Add aterminalentry (and any other intended flags) inlistFeatures()so the landing page accurately reflects the configured server capabilities.