diff --git a/Dockerfile b/Dockerfile index 76d8bd6..674d4d4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,12 @@ FROM node:lts AS runtime WORKDIR /app +VOLUME [ "/data" ] + COPY . . ENV DATABASE_URL=postgresql://memento:test@localhost:5432/memento +ENV UPLOAD_DIR=/data/images RUN npm install RUN npx drizzle-kit push diff --git a/src/db/schema.ts b/src/db/schema.ts index 378a032..d059b7c 100644 --- a/src/db/schema.ts +++ b/src/db/schema.ts @@ -2,7 +2,7 @@ import { integer, pgTable, varchar, date, json } from "drizzle-orm/pg-core"; export const entryTable = pgTable("entries", { id: integer().primaryKey().generatedAlwaysAsIdentity(), - data: date().defaultNow(), + date: varchar().notNull(), location: json(), content: json(), }); diff --git a/src/pages/index.astro b/src/pages/index.astro index fa5733c..44c913a 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -8,7 +8,6 @@ import "../styles/global.css" const quill = new Quill('#editor', { modules: { toolbar: [ - // [{ header: [1, 2, false] }], ['bold', 'italic', 'underline'], ['image'], ], diff --git a/src/utils/quill.ts b/src/utils/quill.ts new file mode 100644 index 0000000..6d746bf --- /dev/null +++ b/src/utils/quill.ts @@ -0,0 +1,38 @@ +import { db } from "./db"; +import type { Delta } from "quill"; + +export interface Entry { + date: string, + location: { lat: number, long: number } | null, + content: Delta +} + +// ty https://stackoverflow.com/questions/35940290 +function dataURLtoFile(dataurl: string, filename: string) { + var arr = dataurl.split(','), + mime = arr[0].match(/:(.*?);/)[1], + bstr = atob(arr[arr.length - 1]), + n = bstr.length, + u8arr = new Uint8Array(n); + while(n--){ + u8arr[n] = bstr.charCodeAt(n); + } + return new File([u8arr], filename, {type:mime}); +} + + +async function uploadImages(delta: Delta) { + let newDelta = delta + + for (const value in newDelta.ops) { + + } + + const data = new FormData() + data.append('image', dataURLtoFile('image.jpg', 'a')) + +} + +export async function uploadDelta(entry: Entry) { + +} \ No newline at end of file