From 716096eed05575c9bc5f2263d4326bf199313c78 Mon Sep 17 00:00:00 2001 From: Darek Adamkiewicz Date: Sat, 20 Jul 2024 16:22:20 +0200 Subject: [PATCH 1/5] initial commit, use of '@sveltekit-i18n/base', '@sveltekit-i18n/parser-icu' for i18n, see: ' .env.example.en', '.env.example.en' --- .env.example.en | 18 + .env.example.pl | 18 + .gitignore | 1 + package.json | 2 + src/hooks.server.js | 1 + src/lib/components/EditorControls.svelte | 338 +++++++------- src/lib/components/EditorToolbar.svelte | 8 +- src/lib/components/Footer.svelte | 44 +- src/lib/components/ImageEditor.svelte | 305 ++++++------ src/lib/components/PlainTextEditor.svelte | 153 +++--- src/lib/components/Post.svelte | 62 +-- src/lib/components/PostTeaser.svelte | 157 ++++--- src/lib/components/RecipientsSelector.svelte | 413 ++++++++-------- src/lib/components/Testimonial.svelte | 1 + src/lib/components/WebsiteNav.svelte | 328 ++++++------- src/lib/constants.js | 9 +- src/lib/en/common.json | 65 +++ src/lib/lang.json | 4 + src/lib/pl/common.json | 65 +++ src/lib/translations.js | 38 ++ src/routes/+error.svelte | 20 +- src/routes/+layout.js | 14 + src/routes/+layout.server.js | 31 ++ src/routes/+page.server.js | 1 + src/routes/+page.svelte | 467 ++++++++++--------- src/routes/friends/+page.svelte | 41 +- src/routes/friends/[id]/+page.svelte | 140 +++--- src/routes/friends/new/+page.svelte | 88 ++-- src/routes/login/+page.svelte | 47 +- src/routes/logout/+page.svelte | 30 +- src/routes/posts/[slug]/+page.svelte | 6 +- src/routes/posts/new/+page.svelte | 98 ++-- 32 files changed, 1670 insertions(+), 1343 deletions(-) create mode 100644 .env.example.en create mode 100644 .env.example.pl create mode 100644 src/lib/en/common.json create mode 100644 src/lib/lang.json create mode 100644 src/lib/pl/common.json create mode 100644 src/lib/translations.js create mode 100644 src/routes/+layout.js create mode 100644 src/routes/+layout.server.js diff --git a/.env.example.en b/.env.example.en new file mode 100644 index 0000000..a939838 --- /dev/null +++ b/.env.example.en @@ -0,0 +1,18 @@ +# Example .env file for local development +# For production, environment variables are set on the production server + +# SvelteKit settings +ORIGIN=http://localhost:5173 + +# PostOwl settings +DB_PATH="./data/db.sqlite3" +ADMIN_PASSWORD="your-secret-password" +ADMIN_NAME="Your Name" +ADMIN_EMAIL="you@your-domain.com" +INITIAL_MESSAGE="Welcome to my PostOwl website!" + +# SMTP settings for dev if using mailpit - see README for instructions +SMTP_SERVER="localhost" +SMTP_PORT="1025" +SMTP_USERNAME="postmaster@localhost" # can be whatever you want in dev +SMTP_PASSWORD="password" # can be whatever you want in dev diff --git a/.env.example.pl b/.env.example.pl new file mode 100644 index 0000000..3a67e94 --- /dev/null +++ b/.env.example.pl @@ -0,0 +1,18 @@ +# Example .env file for local development +# For production, environment variables are set on the production server + +# SvelteKit settings +ORIGIN=http://localhost:5173 + +# PostOwl settings +DB_PATH="./data/db.sqlite3" +ADMIN_PASSWORD="your-secret-password" +ADMIN_NAME="Twoja Nazwa" +ADMIN_EMAIL="you@your-domain.com" +INITIAL_MESSAGE="Witamy na mojej stronie PostOwl!" + +# SMTP settings for dev if using mailpit - see README for instructions +SMTP_SERVER="localhost" +SMTP_PORT="1025" +SMTP_USERNAME="postmaster@localhost" # can be whatever you want in dev +SMTP_PASSWORD="password" # can be whatever you want in dev diff --git a/.gitignore b/.gitignore index 8b714f2..5ef8046 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ .DS_Store .env* !.env.example +!.env.example.* !.env.production.example *.sqlite3* .tool-versions diff --git a/package.json b/package.json index 48f5d7b..ffef987 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,8 @@ "@sveltejs/adapter-auto": "^3.1.1", "@sveltejs/kit": "^2.5.3", "@sveltejs/vite-plugin-svelte": "^3.0.2", + "@sveltekit-i18n/base": "^1.3.7", + "@sveltekit-i18n/parser-icu": "^1.0.8", "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-svelte": "^2.35.1", diff --git a/src/hooks.server.js b/src/hooks.server.js index e6bccd3..cd07af0 100644 --- a/src/hooks.server.js +++ b/src/hooks.server.js @@ -4,6 +4,7 @@ export async function handle({ event, resolve }) { // ATTENTION: Never expose anything to event.locals that shouldn't be seen by the client // We mix in ...local to data objects on server routes event.locals.currentUser = await getCurrentUser(event.cookies.get('sessionid')); + console.log(`src/hooks.server.js: ${event.locals.currentUser?.name}`); event.locals.bio = await getBio(); event.locals.counts = await getCounts(); event.locals.origin = event.url.origin; diff --git a/src/lib/components/EditorControls.svelte b/src/lib/components/EditorControls.svelte index c1a35e3..19d61c2 100644 --- a/src/lib/components/EditorControls.svelte +++ b/src/lib/components/EditorControls.svelte @@ -1,184 +1,186 @@
-
-
-
- - {#if editorState} -
- - - - - - - - - -