diff --git a/nix/dev-vm.nix b/nix/dev-vm.nix index bbb3ceb..4e8d313 100644 --- a/nix/dev-vm.nix +++ b/nix/dev-vm.nix @@ -26,6 +26,7 @@ graphics = false; memorySize = 2048; cores = 2; + diskSize = 10240; sharedDirectories = { websites = { source = "/var/www/archtika-websites"; diff --git a/rest-api/db/migrations/20240719071602_main_tables.sql b/rest-api/db/migrations/20240719071602_main_tables.sql index 532564f..cca5554 100644 --- a/rest-api/db/migrations/20240719071602_main_tables.sql +++ b/rest-api/db/migrations/20240719071602_main_tables.sql @@ -74,6 +74,7 @@ CREATE TABLE internal.header ( CREATE TABLE internal.home ( website_id UUID PRIMARY KEY REFERENCES internal.website (id) ON DELETE CASCADE, main_content TEXT NOT NULL CHECK (TRIM(main_content) != ''), + meta_description VARCHAR(250) CHECK (TRIM(meta_description) != ''), last_modified_at TIMESTAMPTZ NOT NULL DEFAULT CLOCK_TIMESTAMP(), last_modified_by UUID REFERENCES internal.user (id) ON DELETE SET NULL ); diff --git a/rest-api/db/migrations/20240720132802_exposed_views_functions.sql b/rest-api/db/migrations/20240720132802_exposed_views_functions.sql index 1ce0252..48aaf39 100644 --- a/rest-api/db/migrations/20240720132802_exposed_views_functions.sql +++ b/rest-api/db/migrations/20240720132802_exposed_views_functions.sql @@ -129,7 +129,7 @@ GRANT SELECT, UPDATE (logo_type, logo_text, logo_image) ON internal.header TO au GRANT SELECT, UPDATE ON api.header TO authenticated_user; -GRANT SELECT, UPDATE (main_content) ON internal.home TO authenticated_user; +GRANT SELECT, UPDATE (main_content, meta_description) ON internal.home TO authenticated_user; GRANT SELECT, UPDATE ON api.home TO authenticated_user; diff --git a/rest-api/db/migrations/20240724191017_row_level_security.sql b/rest-api/db/migrations/20240724191017_row_level_security.sql index ae41e55..5acc1a9 100644 --- a/rest-api/db/migrations/20240724191017_row_level_security.sql +++ b/rest-api/db/migrations/20240724191017_row_level_security.sql @@ -75,7 +75,7 @@ CREATE POLICY view_websites ON internal.website CREATE POLICY update_website ON internal.website FOR UPDATE - USING (internal.user_has_website_access (id, 20)); + USING (internal.user_has_website_access (id, 30)); CREATE POLICY delete_website ON internal.website FOR DELETE diff --git a/rest-api/db/migrations/20240911070907_change_log.sql b/rest-api/db/migrations/20240911070907_change_log.sql index 1011bce..cc61118 100644 --- a/rest-api/db/migrations/20240911070907_change_log.sql +++ b/rest-api/db/migrations/20240911070907_change_log.sql @@ -13,6 +13,23 @@ CREATE TABLE internal.change_log ( new_value HSTORE ); +CREATE VIEW api.change_log WITH ( security_invoker = ON +) AS +SELECT + * +FROM + internal.change_log; + +GRANT SELECT ON internal.change_log TO authenticated_user; + +GRANT SELECT ON api.change_log TO authenticated_user; + +ALTER TABLE internal.change_log ENABLE ROW LEVEL SECURITY; + +CREATE POLICY view_change_log ON internal.change_log + FOR SELECT + USING (internal.user_has_website_access (website_id, 10)); + CREATE FUNCTION internal.track_changes () RETURNS TRIGGER AS $$ @@ -109,17 +126,6 @@ CREATE TRIGGER collab_track_changes FOR EACH ROW EXECUTE FUNCTION internal.track_changes (); -CREATE VIEW api.change_log WITH ( security_invoker = ON -) AS -SELECT - * -FROM - internal.change_log; - -GRANT SELECT ON internal.change_log TO authenticated_user; - -GRANT SELECT ON api.change_log TO authenticated_user; - -- migrate:down DROP TRIGGER website_track_changes ON internal.website; diff --git a/web-app/src/lib/db-schema.ts b/web-app/src/lib/db-schema.ts index 33ae85a..4b67699 100644 --- a/web-app/src/lib/db-schema.ts +++ b/web-app/src/lib/db-schema.ts @@ -299,18 +299,26 @@ const header = { export interface Home { website_id: string; main_content: string; + meta_description: string | null; last_modified_at: Date; last_modified_by: string | null; } export interface HomeInput { website_id: string; main_content: string; + meta_description?: string | null; last_modified_at?: Date; last_modified_by?: string | null; } const home = { tableName: "home", - columns: ["website_id", "main_content", "last_modified_at", "last_modified_by"], + columns: [ + "website_id", + "main_content", + "meta_description", + "last_modified_at", + "last_modified_by" + ], requiredForInsert: ["website_id", "main_content"], primaryKey: "website_id", foreignKeys: { diff --git a/web-app/src/lib/templates/blog/BlogArticle.svelte b/web-app/src/lib/templates/blog/BlogArticle.svelte index 4a119f5..a2f334b 100644 --- a/web-app/src/lib/templates/blog/BlogArticle.svelte +++ b/web-app/src/lib/templates/blog/BlogArticle.svelte @@ -8,8 +8,10 @@ const { websiteOverview, article, - apiUrl - }: { websiteOverview: WebsiteOverview; article: Article; apiUrl: string } = $props(); + apiUrl, + websiteUrl + }: { websiteOverview: WebsiteOverview; article: Article; apiUrl: string; websiteUrl: string } = + $props();