mirror of
https://github.com/polaroi8d/cactoide.git
synced 2026-03-22 06:05:28 +00:00
feat: add analytics to website and small improvements
This commit is contained in:
@@ -1,7 +1,14 @@
|
|||||||
# Docker Configuration
|
# Postgres configuration
|
||||||
POSTGRES_DB=cactoied_database
|
POSTGRES_DB=cactoied_database
|
||||||
POSTGRES_USER=cactoide
|
POSTGRES_USER=cactoide
|
||||||
POSTGRES_PASSWORD=cactoide_password
|
POSTGRES_PASSWORD=cactoide_password
|
||||||
|
POSTGRES_PORT=5432
|
||||||
|
|
||||||
# Development Settings
|
|
||||||
DATABASE_URL="postgres://cactoide:cactoide_password@localhost:5432/cactoied_database"
|
DATABASE_URL="postgres://cactoide:cactoide_password@localhost:5432/cactoied_database"
|
||||||
|
|
||||||
|
# Application configuration
|
||||||
|
APP_VERSION=latest
|
||||||
|
ANALYTICS=true
|
||||||
|
PORT=3000
|
||||||
|
HOSTNAME=0.0.0.0
|
||||||
|
NODE_ENV=production
|
||||||
1
.github/workflows/build-and-push.yml
vendored
1
.github/workflows/build-and-push.yml
vendored
@@ -3,6 +3,7 @@ name: build & push the images
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
tags: ['*']
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: ghcr.io
|
REGISTRY: ghcr.io
|
||||||
|
|||||||
18
README.md
18
README.md
@@ -25,15 +25,7 @@ A mobile-first event RSVP platform that lets you create events, share unique URL
|
|||||||
- **🛡️ Smart Limits** - Choose between unlimited RSVPs or set a limited capacity. Perfect for any event size.
|
- **🛡️ Smart Limits** - Choose between unlimited RSVPs or set a limited capacity. Perfect for any event size.
|
||||||
- **✨ Effortless Simplicity** - Designed to be instantly clear and easy. No learning curve — just open, create, and go.
|
- **✨ Effortless Simplicity** - Designed to be instantly clear and easy. No learning curve — just open, create, and go.
|
||||||
|
|
||||||
### 🏗️ Technology
|
### Quick Start
|
||||||
|
|
||||||
- **SvelteKit** - Full-stack web framework
|
|
||||||
- **Tailwind CSS** - Utility-first CSS framework
|
|
||||||
- **TypeScript** - Type-safe development
|
|
||||||
- **PostgreSQL** - Robust relational database
|
|
||||||
- **Drizzle ORM** - Type-safe database queries
|
|
||||||
|
|
||||||
### 🚀 Quick Start
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/polaroi8d/cactoide/
|
git clone https://github.com/polaroi8d/cactoide/
|
||||||
@@ -44,13 +36,13 @@ make db-only
|
|||||||
npm run dev -- --open
|
npm run dev -- --open
|
||||||
```
|
```
|
||||||
|
|
||||||
Your app will be available at `http://localhost:5173`
|
Your app will be available at `http://localhost:5173`. You can use the Makefile commands to run the application or the database, eg.: `make db-only`.
|
||||||
|
|
||||||
### 🚀 Self-Host
|
### Self-Host
|
||||||
|
|
||||||
WIP
|
Use the [`docker-compose.yml`](docker-compose.yml) file to setup the application with the database. You can define all ENV variables in the [`.env`](.env.example) file from the `.env.example`.
|
||||||
|
|
||||||
### 📄 License
|
### License
|
||||||
|
|
||||||
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
|
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
|
||||||
|
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
version: '3.8'
|
|
||||||
|
|
||||||
services:
|
|
||||||
# Database
|
|
||||||
postgres:
|
|
||||||
image: postgres:15-alpine
|
|
||||||
container_name: cactoide-db-prod
|
|
||||||
environment:
|
|
||||||
POSTGRES_DB: ${POSTGRES_DB:-cactoied_database}
|
|
||||||
POSTGRES_USER: ${POSTGRES_USER:-cactoide}
|
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-cactoide_password}
|
|
||||||
ports:
|
|
||||||
- '5432:5432'
|
|
||||||
volumes:
|
|
||||||
- postgres_data_prod:/var/lib/postgresql/data
|
|
||||||
- ./database/init.sql:/docker-entrypoint-initdb.d/init.sql
|
|
||||||
healthcheck:
|
|
||||||
test:
|
|
||||||
[
|
|
||||||
'CMD-SHELL',
|
|
||||||
'pg_isready -U ${POSTGRES_USER:-cactoide} -d ${POSTGRES_DB:-cactoied_database}'
|
|
||||||
]
|
|
||||||
interval: 10s
|
|
||||||
timeout: 5s
|
|
||||||
retries: 5
|
|
||||||
networks:
|
|
||||||
- cactoide-network-prod
|
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
# Application
|
|
||||||
app:
|
|
||||||
image: ghcr.io/polaroi8d/cactoide:latest
|
|
||||||
container_name: cactoide-app-prod
|
|
||||||
ports:
|
|
||||||
- '3000:3000'
|
|
||||||
environment:
|
|
||||||
DATABASE_URL: postgres://${POSTGRES_USER:-cactoide}:${POSTGRES_PASSWORD:-cactoide_password}@postgres:5432/${POSTGRES_DB:-cactoied_database}
|
|
||||||
NODE_ENV: production
|
|
||||||
PORT: 3000
|
|
||||||
HOSTNAME: 0.0.0.0
|
|
||||||
depends_on:
|
|
||||||
postgres:
|
|
||||||
condition: service_healthy
|
|
||||||
networks:
|
|
||||||
- cactoide-network-prod
|
|
||||||
restart: unless-stopped
|
|
||||||
healthcheck:
|
|
||||||
test: ['CMD', 'wget', '--no-verbose', '--tries=1', '--spider', 'http://localhost:3000/']
|
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 3
|
|
||||||
start_period: 40s
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
postgres_data_prod:
|
|
||||||
|
|
||||||
networks:
|
|
||||||
cactoide-network-prod:
|
|
||||||
driver: bridge
|
|
||||||
@@ -1,38 +1,42 @@
|
|||||||
version: '3.8'
|
version: '3.8'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# PostgreSQL Database
|
# Database
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:15-alpine
|
image: postgres:15-alpine
|
||||||
container_name: cactoide-db
|
container_name: cactoide-db
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_DB: cactoied_database
|
POSTGRES_DB: ${POSTGRES_DB:-cactoied_database}
|
||||||
POSTGRES_USER: cactoide
|
POSTGRES_USER: ${POSTGRES_USER:-cactoide}
|
||||||
POSTGRES_PASSWORD: cactoide_password
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-cactoide_password}
|
||||||
ports:
|
ports:
|
||||||
- '5432:5432'
|
- '${POSTGRES_PORT:-5432}:5432'
|
||||||
volumes:
|
volumes:
|
||||||
- postgres_data:/var/lib/postgresql/data
|
- postgres_data:/var/lib/postgresql/data
|
||||||
- ./database/init.sql:/docker-entrypoint-initdb.d/init.sql
|
- ./database/init.sql:/docker-entrypoint-initdb.d/init.sql
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ['CMD-SHELL', 'pg_isready -U cactoide -d cactoied_database']
|
test:
|
||||||
|
[
|
||||||
|
'CMD-SHELL',
|
||||||
|
'pg_isready -U ${POSTGRES_USER:-cactoide} -d ${POSTGRES_DB:-cactoied_database}'
|
||||||
|
]
|
||||||
interval: 10s
|
interval: 10s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
networks:
|
networks:
|
||||||
- cactoide-network
|
- cactoide-network
|
||||||
|
|
||||||
# SvelteKit Application
|
# Application
|
||||||
app:
|
app:
|
||||||
build:
|
image: ghcr.io/polaroi8d/cactoide/cactoide:${APP_VERSION:-latest}
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
container_name: cactoide-app
|
container_name: cactoide-app
|
||||||
ports:
|
ports:
|
||||||
- '3000:3000'
|
- '${PORT:-3000}:3000'
|
||||||
environment:
|
environment:
|
||||||
DATABASE_URL: postgres://cactoide:cactoide_password@postgres:5432/cactoied_database
|
DATABASE_URL: postgres://${POSTGRES_USER:-cactoide}:${POSTGRES_PASSWORD:-cactoide_password}@postgres:${POSTGRES_PORT:-5432}/${POSTGRES_DB:-cactoied_database}
|
||||||
NODE_ENV: production
|
NODE_ENV: ${NODE_ENV:-dev}
|
||||||
|
PORT: 3000
|
||||||
|
HOSTNAME: ${HOSTNAME:-0.0.0.0}
|
||||||
depends_on:
|
depends_on:
|
||||||
postgres:
|
postgres:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
# Production Environment Variables
|
|
||||||
# Copy this file to .env.prod and update the values
|
|
||||||
|
|
||||||
# Database Configuration
|
|
||||||
POSTGRES_DB=cactoide_production
|
|
||||||
POSTGRES_USER=cactoide_prod
|
|
||||||
POSTGRES_PASSWORD=your_secure_password_here
|
|
||||||
|
|
||||||
# App Configuration
|
|
||||||
NODE_ENV=production
|
|
||||||
PORT=3000
|
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
||||||
%sveltekit.head%
|
%sveltekit.head% %ANALYTICS_SCRIPT%
|
||||||
</head>
|
</head>
|
||||||
<body data-sveltekit-preload-data="hover">
|
<body data-sveltekit-preload-data="hover">
|
||||||
<div style="display: contents">%sveltekit.body%</div>
|
<div style="display: contents">%sveltekit.body%</div>
|
||||||
|
|||||||
27
src/hooks.server.ts
Normal file
27
src/hooks.server.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import { env } from '$env/dynamic/private';
|
||||||
|
|
||||||
|
export const handle = async ({ event, resolve }) => {
|
||||||
|
// Check if analytics is enabled
|
||||||
|
const analyticsEnabled = env.ANALYTICS === 'true';
|
||||||
|
|
||||||
|
// Define the analytics script HTML
|
||||||
|
const analyticsScript = analyticsEnabled
|
||||||
|
? '<script defer src="https://analytics.dalev.hu/script.js" data-website-id="7425d098-e340-4464-bd03-c2e47b004cd9"></script>'
|
||||||
|
: '';
|
||||||
|
|
||||||
|
// Replace the placeholder with the actual script or empty string
|
||||||
|
const response = await resolve(event);
|
||||||
|
|
||||||
|
if (response.headers.get('content-type')?.includes('text/html')) {
|
||||||
|
const html = await response.text();
|
||||||
|
const modifiedHtml = html.replace('%ANALYTICS_SCRIPT%', analyticsScript);
|
||||||
|
|
||||||
|
return new Response(modifiedHtml, {
|
||||||
|
headers: response.headers,
|
||||||
|
status: response.status,
|
||||||
|
statusText: response.statusText
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user