diff --git a/src/routes/api/edit/+server.ts b/src/routes/api/edit/+server.ts
index 053fac1..dc82fc2 100644
--- a/src/routes/api/edit/+server.ts
+++ b/src/routes/api/edit/+server.ts
@@ -7,7 +7,6 @@ import { error } from '@sveltejs/kit';
// header: use for bearer token for now
// recipe json in body
export const POST: RequestHandler = async ({request}) => {
- console.log("AT EDIT API")
let message = await request.json()
const recipe_json = message.recipe
const bearer_token = message.headers.bearer
diff --git a/src/routes/api/img/add/+server.ts b/src/routes/api/img/add/+server.ts
index 266b499..d3d00ad 100644
--- a/src/routes/api/img/add/+server.ts
+++ b/src/routes/api/img/add/+server.ts
@@ -21,18 +21,21 @@ export const POST = (async ({ request }) => {
await sharp(full_res)
.toFormat('webp')
.toFile(path.join(IMAGE_DIR,
+ "rezepte",
"full",
data.name + ".webp"))
await sharp(full_res)
.resize({ width: 800})
.toFormat('webp')
.toFile(path.join(IMAGE_DIR,
+ "rezepte",
"thumb",
data.name + ".webp"))
await sharp(full_res)
.resize({ width: 20})
.toFormat('webp')
.toFile(path.join(IMAGE_DIR,
+ "rezepte",
"placeholder",
data.name + ".webp"))
return new Response(JSON.stringify({msg: "Added image successfully"}),{
diff --git a/src/routes/api/img/delete/+server.ts b/src/routes/api/img/delete/+server.ts
index a5f7c98..1eda0d9 100644
--- a/src/routes/api/img/delete/+server.ts
+++ b/src/routes/api/img/delete/+server.ts
@@ -9,7 +9,7 @@ export const POST = (async ({ request }) => {
const data = await request.json();
if(data.bearer === BEARER_TOKEN){
[ "full", "thumb", "placeholder"].forEach((folder) => {
- unlink(path.join(IMAGE_DIR, folder, data.name + ".webp"), (e) => {
+ unlink(path.join(IMAGE_DIR, "rezepte", folder, data.name + ".webp"), (e) => {
if(e) throw error(500, "could not delete: " + folder + "/" + data.name + ".webp")
})
})
diff --git a/src/routes/api/img/mv/+server.ts b/src/routes/api/img/mv/+server.ts
index aaacd49..4ea879a 100644
--- a/src/routes/api/img/mv/+server.ts
+++ b/src/routes/api/img/mv/+server.ts
@@ -9,8 +9,10 @@ export const POST = (async ({ request }) => {
const data = await request.json();
if(data.bearer === BEARER_TOKEN){
[ "full", "thumb", "placeholder"].forEach((folder) => {
- rename(path.join(IMAGE_DIR, folder, data.old_name + ".webp"), path.join(IMAGE_DIR, folder, data.new_name + ".webp"), (e) => {
- if(e) throw error(500, "could not mv: " + folder + "/" + data.old_name + ".webp")
+ const old_path = path.join(IMAGE_DIR, "rezepte", folder, data.old_name + ".webp")
+ rename(old_path, path.join(IMAGE_DIR, "rezepte", folder, data.new_name + ".webp"), (e) => {
+ console.log(e)
+ if(e) throw error(500, "could not mv: " + old_path)
})
});
return new Response(JSON.stringify({msg: "Deleted image successfully"}),{
diff --git a/src/routes/rezepte/edit/[name]/+page.svelte b/src/routes/rezepte/edit/[name]/+page.svelte
index 68ef032..367d633 100644
--- a/src/routes/rezepte/edit/[name]/+page.svelte
+++ b/src/routes/rezepte/edit/[name]/+page.svelte
@@ -99,17 +99,18 @@
method: 'POST',
body: JSON.stringify({
name: old_short_name,
+ bearer: password,}),
headers : {
'content-type': 'application/json',
bearer: password
}
})
- })
if(!res_img.ok){
const item = await res_img.json();
alert(item.message)
return
}
+ return
const res = await fetch('/api/delete', {
method: 'POST',
body: JSON.stringify({
@@ -142,16 +143,16 @@
method: 'POST',
body: JSON.stringify({
name: old_short_name,
+ bearer: password,
+ }),
headers : {
'content-type': 'application/json',
bearer: password
}
- })
})
if(!res_img.ok){
const item = await res_img.json();
alert(item.message)
- return
}
}
async function upload_img(){
@@ -172,7 +173,6 @@
if(!res.ok){
const item = await res_img.json();
alert(item.message)
- return
}
}
delete_img()
@@ -180,11 +180,19 @@
}
// case new short_name:
else if(short_name != old_short_name){
+ console.log("MOVING")
+ console.log("PASSWORD:", password)
const res_img = await fetch('/api/img/mv', {
method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ Accept: 'application/json',
+ bearer: password,
+ },
body: JSON.stringify({
old_name: old_short_name,
- new_name: short_name
+ new_name: short_name,
+ bearer: password,
})
})
if(!res_img.ok){
@@ -219,7 +227,8 @@
})
if(res.ok){
const url = location.href.split('/');
- url.splice(url.length -2, 1);
+ url.splice(url.length -2, 2);
+ url.push(short_name);
location.assign(url.join('/'))
}
else{
diff --git a/src/routes/rezepte/edit/[name]/.jukit/.jukit_info.json b/src/routes/rezepte/edit/[name]/.jukit/.jukit_info.json
deleted file mode 100644
index 92c7342..0000000
--- a/src/routes/rezepte/edit/[name]/.jukit/.jukit_info.json
+++ /dev/null
@@ -1 +0,0 @@
-{"terminal": "nvimterm"}
\ No newline at end of file
diff --git a/src/routes/test/+page.svelte b/src/routes/test/+page.svelte
deleted file mode 100644
index ed2b092..0000000
--- a/src/routes/test/+page.svelte
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-