draftlink 0.1.0 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/ui.ts +9 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# draftlink
|
|
2
2
|
|
|
3
|
-
<
|
|
3
|
+
<div align="center"><img src="https://raw.githubusercontent.com/lm-sousa/draftlink/master/assets/banner.png" alt="DraftLink — from idea to impact" width="720"></div>
|
|
4
4
|
|
|
5
5
|
Publish HTML drafts from agents; searchable, shareable, status-tracked.
|
|
6
6
|
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -238,7 +238,7 @@ export default {
|
|
|
238
238
|
});
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
-
return html(draftShellPage({ access, versions, versionId }), 200, { "X-Robots-Tag": "noindex" });
|
|
241
|
+
return html(draftShellPage({ access, versions, versionId, base: origin }), 200, { "X-Robots-Tag": "noindex" });
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
if (path === "/login" && req.method === "GET") {
|
package/src/ui.ts
CHANGED
|
@@ -106,12 +106,17 @@ function themeButton(): string {
|
|
|
106
106
|
return `<button id="themeToggle" onclick="dlToggleTheme()" aria-label="Toggle dark mode" class="rounded-md border border-zinc-300 dark:border-zinc-600 px-2 py-1 text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800">◐</button>`;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
export function layout(opts: { title: string; body: string; user?: { login: string; admin?: boolean; pending?: number } | null; base: string; bare?: boolean }): string {
|
|
109
|
+
export function layout(opts: { title: string; body: string; user?: { login: string; admin?: boolean; pending?: number } | null; base: string; bare?: boolean; description?: string; ogUrl?: string }): string {
|
|
110
110
|
const head = `<meta charset="utf-8">
|
|
111
111
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
112
112
|
<title>${esc(opts.title)}</title>
|
|
113
113
|
<link rel="icon" type="image/png" href="/favicon.png">
|
|
114
114
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
|
|
115
|
+
${opts.description ? `<meta property="og:title" content="${esc(opts.title)}">
|
|
116
|
+
<meta property="og:description" content="${esc(opts.description)}">
|
|
117
|
+
<meta property="og:image" content="${esc(opts.base)}/banner.png">
|
|
118
|
+
<meta property="og:url" content="${esc(opts.ogUrl ?? opts.base)}">
|
|
119
|
+
<meta name="twitter:card" content="summary_large_image">` : ""}
|
|
115
120
|
<script src="https://cdn.tailwindcss.com"></script>
|
|
116
121
|
<script>tailwind.config = { darkMode: 'class' }</script>
|
|
117
122
|
${THEME_SCRIPT}
|
|
@@ -171,6 +176,7 @@ export function loginPage(base: string, opts: { configured: boolean; error?: str
|
|
|
171
176
|
return layout({
|
|
172
177
|
base,
|
|
173
178
|
title: "draftlink — sign in",
|
|
179
|
+
description: "Publish HTML drafts from coding agents; searchable, shareable, status-tracked.",
|
|
174
180
|
body: `
|
|
175
181
|
<div class="max-w-sm mx-auto mt-24 text-center">
|
|
176
182
|
<img src="/banner.png" alt="DraftLink — from idea to impact" class="mb-6 w-full rounded-xl shadow-md">
|
|
@@ -508,7 +514,7 @@ const SHELL_SCRIPT = `<script>
|
|
|
508
514
|
})();
|
|
509
515
|
</script>`;
|
|
510
516
|
|
|
511
|
-
export function draftShellPage(opts: ShellOptions): string {
|
|
517
|
+
export function draftShellPage(opts: ShellOptions & { base: string }): string {
|
|
512
518
|
const d = opts.access.draft;
|
|
513
519
|
const embedUrl = `/d/${esc(d.id)}?embed=1${opts.versionId ? `&v=${opts.versionId}` : ""}`;
|
|
514
520
|
const body = `
|
|
@@ -516,7 +522,7 @@ ${draftShellHeader(opts)}
|
|
|
516
522
|
${draftShellBanner(opts)}
|
|
517
523
|
<iframe id="dl-frame" src="${embedUrl}" sandbox="allow-scripts allow-popups" title="${esc(d.title)}" class="block w-full border-0" style="height:100vh"></iframe>
|
|
518
524
|
${SHELL_SCRIPT}`;
|
|
519
|
-
return layout({ base:
|
|
525
|
+
return layout({ base: opts.base, title: d.title, bare: true, body, ogUrl: `${opts.base}/d/${d.id}` });
|
|
520
526
|
}
|
|
521
527
|
|
|
522
528
|
export function editPage(base: string, user: { login: string }, d: DraftRow & { body: string }): string {
|