mirror of
https://github.com/thiloho/archtika.git
synced 2025-11-22 10:51:36 +01:00
Remove NGINX website directories from API and fix some minor issues
This commit is contained in:
@@ -4,37 +4,24 @@ import { apiRequest } from "$lib/server/utils";
|
||||
import type { Settings, Header, Footer } from "$lib/db-schema";
|
||||
|
||||
export const load: PageServerLoad = async ({ params, fetch }) => {
|
||||
const globalSettings: Settings = (
|
||||
await apiRequest(
|
||||
fetch,
|
||||
`${API_BASE_PREFIX}/settings?website_id=eq.${params.websiteId}`,
|
||||
"GET",
|
||||
{
|
||||
headers: {
|
||||
Accept: "application/vnd.pgrst.object+json"
|
||||
},
|
||||
returnData: true
|
||||
}
|
||||
)
|
||||
).data;
|
||||
|
||||
const header: Header = (
|
||||
await apiRequest(fetch, `${API_BASE_PREFIX}/header?website_id=eq.${params.websiteId}`, "GET", {
|
||||
headers: {
|
||||
Accept: "application/vnd.pgrst.object+json"
|
||||
},
|
||||
const [globalSettingsResponse, headerResponse, footerResponse] = await Promise.all([
|
||||
apiRequest(fetch, `${API_BASE_PREFIX}/settings?website_id=eq.${params.websiteId}`, "GET", {
|
||||
headers: { Accept: "application/vnd.pgrst.object+json" },
|
||||
returnData: true
|
||||
}),
|
||||
apiRequest(fetch, `${API_BASE_PREFIX}/header?website_id=eq.${params.websiteId}`, "GET", {
|
||||
headers: { Accept: "application/vnd.pgrst.object+json" },
|
||||
returnData: true
|
||||
}),
|
||||
apiRequest(fetch, `${API_BASE_PREFIX}/footer?website_id=eq.${params.websiteId}`, "GET", {
|
||||
headers: { Accept: "application/vnd.pgrst.object+json" },
|
||||
returnData: true
|
||||
})
|
||||
).data;
|
||||
]);
|
||||
|
||||
const footer: Footer = (
|
||||
await apiRequest(fetch, `${API_BASE_PREFIX}/footer?website_id=eq.${params.websiteId}`, "GET", {
|
||||
headers: {
|
||||
Accept: "application/vnd.pgrst.object+json"
|
||||
},
|
||||
returnData: true
|
||||
})
|
||||
).data;
|
||||
const globalSettings: Settings = globalSettingsResponse.data;
|
||||
const header: Header = headerResponse.data;
|
||||
const footer: Footer = footerResponse.data;
|
||||
|
||||
return {
|
||||
globalSettings,
|
||||
|
||||
@@ -44,14 +44,16 @@
|
||||
<input type="number" name="article-weight" value={data.article.article_weight} min="0" />
|
||||
</label>
|
||||
|
||||
<label>
|
||||
Category:
|
||||
<select name="category">
|
||||
{#each data.categories as { id, category_name }}
|
||||
<option value={id} selected={id === data.article.category}>{category_name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</label>
|
||||
{#if data.categories.length > 0}
|
||||
<label>
|
||||
Category:
|
||||
<select name="category">
|
||||
{#each data.categories as { id, category_name }}
|
||||
<option value={id} selected={id === data.article.category}>{category_name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</label>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
<label>
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import type { Actions, PageServerLoad } from "./$types";
|
||||
import { API_BASE_PREFIX, apiRequest } from "$lib/server/utils";
|
||||
import { rm } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import type { LegalInformation } from "$lib/db-schema";
|
||||
|
||||
export const load: PageServerLoad = async ({ parent, fetch, params }) => {
|
||||
@@ -58,11 +56,6 @@ export const actions: Actions = {
|
||||
return deleteLegalInformation;
|
||||
}
|
||||
|
||||
await rm(
|
||||
join("/", "var", "www", "archtika-websites", params.websiteId, "legal-information.html"),
|
||||
{ force: true }
|
||||
);
|
||||
|
||||
return deleteLegalInformation;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@ import BlogIndex from "$lib/templates/blog/BlogIndex.svelte";
|
||||
import DocsArticle from "$lib/templates/docs/DocsArticle.svelte";
|
||||
import DocsIndex from "$lib/templates/docs/DocsIndex.svelte";
|
||||
import { type WebsiteOverview, hexToHSL, slugify } from "$lib/utils";
|
||||
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
||||
import { mkdir, readFile, rename, writeFile, chmod, readdir } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { render } from "svelte/server";
|
||||
import type { Actions, PageServerLoad } from "./$types";
|
||||
@@ -290,5 +290,20 @@ const generateStaticFiles = async (websiteData: WebsiteOverview, isPreview = tru
|
||||
await writeFile(join(uploadDir, "common.css"), commonStyles);
|
||||
await writeFile(join(uploadDir, "scoped.css"), specificStyles);
|
||||
|
||||
await setPermissions(isPreview ? join(uploadDir, "../") : uploadDir);
|
||||
|
||||
return { websitePreviewUrl, websiteProdUrl };
|
||||
};
|
||||
|
||||
const setPermissions = async (dir: string) => {
|
||||
await chmod(dir, 0o777);
|
||||
const entries = await readdir(dir, { withFileTypes: true });
|
||||
for (const entry of entries) {
|
||||
const fullPath = join(dir, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
await setPermissions(fullPath);
|
||||
} else {
|
||||
await chmod(fullPath, 0o777);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user