History: URL + ID columns at end, custom_slug in /api/public (#44)
This commit is contained in:
@@ -487,6 +487,7 @@ func (a *apiServer) handleListPublic(w http.ResponseWriter, r *http.Request) {
|
|||||||
items = append(items, map[string]any{
|
items = append(items, map[string]any{
|
||||||
"id": row.ID, "title": title, "language": lang,
|
"id": row.ID, "title": title, "language": lang,
|
||||||
"created_at": row.CreatedAt, "view_count": row.ViewCount, "size": row.Size,
|
"created_at": row.CreatedAt, "view_count": row.ViewCount, "size": row.Size,
|
||||||
|
"custom_slug": nullStrPtr(row.CustomSlug),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
writeJSON(w, 200, map[string]any{"total": total, "limit": limit, "offset": offset, "items": items})
|
writeJSON(w, 200, map[string]any{"total": total, "limit": limit, "offset": offset, "items": items})
|
||||||
|
|||||||
@@ -296,3 +296,6 @@ td a.slug:hover { color: var(--accent); }
|
|||||||
/* paste name under slug pill in Paste column (#43) */
|
/* paste name under slug pill in Paste column (#43) */
|
||||||
.paste-sub { font-size: 19.8px; color: var(--muted-fg); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
.paste-sub { font-size: 19.8px; color: var(--muted-fg); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||||
.paste-sub.dim { color: var(--muted); }
|
.paste-sub.dim { color: var(--muted); }
|
||||||
|
td .url-link { font-size: 19.8px; }
|
||||||
|
td .id-link { color: var(--muted-fg); text-decoration: none; font-family: var(--font-mono); font-size: 19.8px; }
|
||||||
|
td .id-link:hover { color: var(--accent); }
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
<div class="search"><input id="filter" placeholder="Search…"><span class="search-spinner" id="search-spinner"></span></div>
|
<div class="search"><input id="filter" placeholder="Search…"><span class="search-spinner" id="search-spinner"></span></div>
|
||||||
<div class="float">
|
<div class="float">
|
||||||
<table>
|
<table>
|
||||||
<colgroup><col style="width:300px"><col style="width:156px"><col style="width:138px"><col style="width:111px"><col style="width:165px"></colgroup>
|
<colgroup><col style="width:260px"><col style="width:140px"><col style="width:120px"><col style="width:96px"><col style="width:140px"><col style="width:190px"><col style="width:100px"></colgroup>
|
||||||
<thead><tr><th>Paste</th><th>Language</th><th>Size</th><th>Views</th><th>Created</th></tr></thead>
|
<thead><tr><th>Paste</th><th>Language</th><th>Size</th><th>Views</th><th>Created</th><th>URL</th><th>ID</th></tr></thead>
|
||||||
<tbody id="rows"></tbody>
|
<tbody id="rows"></tbody>
|
||||||
</table>
|
</table>
|
||||||
<div class="empty" id="empty" style="display:none">No pastes yet. Create the first one.</div>
|
<div class="empty" id="empty" style="display:none">No pastes yet. Create the first one.</div>
|
||||||
@@ -71,7 +71,9 @@ async function load() {
|
|||||||
`<tr class="row" data-href="/${esc(it.id)}"><td><a class="slug" href="/${esc(it.id)}">${esc(it.id)}</a>` +
|
`<tr class="row" data-href="/${esc(it.id)}"><td><a class="slug" href="/${esc(it.id)}">${esc(it.id)}</a>` +
|
||||||
(it.title ? `<div class="paste-sub">${esc(it.title)}</div>` : `<div class="paste-sub dim">none</div>`) + `</td>` +
|
(it.title ? `<div class="paste-sub">${esc(it.title)}</div>` : `<div class="paste-sub dim">none</div>`) + `</td>` +
|
||||||
`<td><span class="badge">${esc(it.language || 'text')}</span></td>` +
|
`<td><span class="badge">${esc(it.language || 'text')}</span></td>` +
|
||||||
`<td class="dim">${fmtSize(it.size)}</td><td class="dim">${it.view_count}</td><td class="dim">${ago(it.created_at)}</td></tr>`
|
`<td class="dim">${fmtSize(it.size)}</td><td class="dim">${it.view_count}</td><td class="dim">${ago(it.created_at)}</td>` +
|
||||||
|
(it.custom_slug ? `<td><a class="slug url-link" href="/${esc(it.custom_slug)}">/${esc(it.custom_slug)}</a></td>` : `<td class="dim">none</td>`) +
|
||||||
|
`<td class="dim"><a class="id-link" href="/${esc(it.id)}">${esc(it.id)}</a></td></tr>`
|
||||||
).join('');
|
).join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user