mirror of
https://github.com/narrrl/narl-workspace.git
synced 2026-11-13 17:57:04 +01:00
files: a file belongs to a node, and a document holds its own
An upload while writing is now a file node of the document, through
POST /nodes/{id}/files, instead of a loose row of media that only the media
browser listed. It moves, seals, goes to the trash and comes back with the
document. Migration 0029 gives every embedded upload that had no node a
place under the document that embeds it (a living one before a trashed
one), keeping its media id, so no body changes; the sealed-folder triggers
now ask a document's folder for the files under it.
- nodes: `holds` and `place_for` say what may go where; a document holds
files and nothing else, in moves, uploads and restores from the trash.
A loaded document carries its files and whether its folder seals them.
- seal: a document moving into a sealed folder seals its files first.
- media: POST /media, GET /media and DELETE /media/{id} are gone, and with
them MediaBrowser and :media.
- import: `plan/` beside `plan.md` comes back as the document's files, the
shape export writes; an older export's media/ goes to the first document
that embeds each file.
- sftp: a document's files are `<slug>/` beside its `.md`, listed once it
has any, holding files only, moving with the `.md`.
- web: paste, drop and :upload while reading go to the document; the info
sheet has a files section (Enter opens, i embeds, y copies how); the list
shows +N on a document, za folds its files open, p drops marked files in.
This commit is contained in:
1 parent
2233fa41a6
commit
d8e72c688d
29 files changed
+869
-490
No files matched your search
+5
-24
@@ -57,6 +57,8 @@ export interface WorkspaceNode extends NodeSummary {
|
||||
cards: AgendaCard[]
|
||||
/** Where each `[[title]]` in the body leads, as an /n/ path; a title that leads nowhere is missing. */
|
||||
wikilinks: Record<string, string>
|
||||
/** A document's own files, oldest first: what was pasted into it, and what was put beside it. */
|
||||
files: NodeSummary[]
|
||||
}
|
||||
|
||||
/** A document that links to the one asked about, and the line it does it on. */
|
||||
@@ -256,20 +258,6 @@ export interface Board {
|
||||
lists: BoardList[]
|
||||
}
|
||||
|
||||
export interface MediaFile {
|
||||
id: string
|
||||
filename: string
|
||||
mime: string
|
||||
size: number
|
||||
created_at: number
|
||||
url: string
|
||||
encrypted: boolean
|
||||
/** Every document that embeds this file — a file may be used by several. */
|
||||
node_ids: number[]
|
||||
/** The file node it is, when it sits in the tree; deleted from there. */
|
||||
file_node: number | null
|
||||
}
|
||||
|
||||
/** One thing a certificate, key or keystore file holds, as `/inspect` describes it. */
|
||||
export type CertItem =
|
||||
| {
|
||||
@@ -627,21 +615,14 @@ export const api = {
|
||||
moveCard: (id: number, list_id: number, position?: number) =>
|
||||
request<Moved>(`/cards/${id}/move`, { method: 'POST', body: body({ list_id, position }) }),
|
||||
|
||||
listMedia: () => pages((limit, offset) => request<MediaFile[]>(`/media?limit=${limit}&offset=${offset}`)),
|
||||
|
||||
/**
|
||||
* Upload files into a space or folder as file nodes. XHR rather than fetch,
|
||||
* because a gigabyte going up needs to say how far along it is.
|
||||
* Upload files into a space or folder, or to a document as its own files.
|
||||
* XHR rather than fetch, because a gigabyte going up needs to say how far
|
||||
* along it is.
|
||||
*/
|
||||
putFiles: (parentId: number, files: File[], encrypt: boolean, progress?: (fraction: number) => void) =>
|
||||
send<WorkspaceNode[]>(`/api/nodes/${parentId}/files${encrypt ? '?encrypt=true' : ''}`, files, progress),
|
||||
|
||||
/** Files to embed in a document, with the same progress as `putFiles`. */
|
||||
upload: (files: File[], progress?: (fraction: number) => void) =>
|
||||
send<MediaFile[]>('/api/media', files, progress),
|
||||
|
||||
deleteMedia: (id: string) => request<{ ok: true }>(`/media/${id}`, { method: 'DELETE' }),
|
||||
|
||||
vaultStatus: () => request<VaultStatus>('/vault'),
|
||||
|
||||
setupVault: (password: string) =>
|
||||
|
||||
Reference in new issue
Block a user