From e2a6c9232296ab3ca4cbbc85cc7e2fa77fadff19 Mon Sep 17 00:00:00 2001 From: aleidk Date: Wed, 5 Feb 2025 19:09:17 -0300 Subject: [PATCH 1/2] chore: add example .env --- .env.example | 5 +++++ docker/Dockerfile | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..84874d5 --- /dev/null +++ b/.env.example @@ -0,0 +1,5 @@ +POSTGRES_DB=index +POSTGRES_USER=index +POSTGRES_PASSWORD= + +DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}?sslmode=disable" diff --git a/docker/Dockerfile b/docker/Dockerfile index b5af08e..d9229e9 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -2,7 +2,6 @@ FROM ghcr.io/linuxcontainers/debian-slim:latest COPY --from=ghcr.io/amacneil/dbmate /usr/local/bin/dbmate /usr/local/bin/dbmate COPY --from=lovasoa/sqlpage:latest /usr/local/bin/sqlpage /usr/local/bin/sqlpage -COPY --from=lovasoa/sqlpage:latest /lib/libgcc_s.so.1 /lib/libgcc_s.so.1 WORKDIR /app From 29065c72c8e5a76367e23ae144169d8cf6a04b58 Mon Sep 17 00:00:00 2001 From: aleidk Date: Wed, 5 Feb 2025 19:56:47 -0300 Subject: [PATCH 2/2] feat: add sources form and table --- .env.example | 2 ++ .justfile | 2 ++ docker/docker-compose.yaml | 5 ++++ src/app/index.sql | 1 + src/app/sources/index.sql | 47 ++++++++++++++++++++++++++++++++++++++ src/index.sql | 6 ----- src/shared/shell.json | 21 +++++++++++++++++ 7 files changed, 78 insertions(+), 6 deletions(-) create mode 100644 src/app/index.sql create mode 100644 src/app/sources/index.sql delete mode 100644 src/index.sql create mode 100644 src/shared/shell.json diff --git a/.env.example b/.env.example index 84874d5..eae5060 100644 --- a/.env.example +++ b/.env.example @@ -3,3 +3,5 @@ POSTGRES_USER=index POSTGRES_PASSWORD= DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}?sslmode=disable" + +SQLPAGE_WEB_ROOT=app diff --git a/.justfile b/.justfile index 04b421f..9686466 100644 --- a/.justfile +++ b/.justfile @@ -11,3 +11,5 @@ dev: docker compose up --watch dbmate +ARGS: (compose-exec "index dbmate" ARGS) + +migrate: (dbmate "migrate") diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 799130e..efb80cc 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -17,3 +17,8 @@ services: db: image: postgres:17 env_file: ../.env + volumes: + - db_data:/var/lib/postgresql/data + +volumes: + db_data: diff --git a/src/app/index.sql b/src/app/index.sql new file mode 100644 index 0000000..0d98893 --- /dev/null +++ b/src/app/index.sql @@ -0,0 +1 @@ +SELECT 'dynamic' AS component, sqlpage.read_file_as_text('../shared/shell.json') AS properties; diff --git a/src/app/sources/index.sql b/src/app/sources/index.sql new file mode 100644 index 0000000..2c65a84 --- /dev/null +++ b/src/app/sources/index.sql @@ -0,0 +1,47 @@ +SELECT + 'dynamic' AS component, + sqlpage.read_file_as_text('../shared/shell.json') AS properties; + +-- ╭─────────────────────────────────────────────────────────╮ +-- │ Form │ +-- ╰─────────────────────────────────────────────────────────╯ +SELECT + 'form' AS component, + 'sources/create.sql' AS ACTION, + 'Save' AS validate, + 'Sources' AS title; + +SELECT + 'name' AS name, + 'Name' AS label, + 8 AS width, + TRUE AS required; + +SELECT + 'uid' AS name, + 'Identifier' AS label, + 4 AS width, + 5 AS maxlength, + 1 AS minlength, + TRUE AS required; + +SELECT + 'uri' AS name, + 'URI' AS label, + TRUE AS required; + +INSERT INTO + public.sources(name, uid, uri) +VALUES + (:name, :uid, :uri); + +-- ╭─────────────────────────────────────────────────────────╮ +-- │ Table list │ +-- ╰─────────────────────────────────────────────────────────╯ +SELECT + 'table' AS component; + +SELECT + * +FROM + public.sources; diff --git a/src/index.sql b/src/index.sql deleted file mode 100644 index 3886b29..0000000 --- a/src/index.sql +++ /dev/null @@ -1,6 +0,0 @@ -SELECT 'list' AS component, - 'Popular websites TESTOOO' AS title; - -SELECT 'Hello' AS title, - 'world' AS description, - 'https://wikipedia.org' AS link; diff --git a/src/shared/shell.json b/src/shared/shell.json new file mode 100644 index 0000000..27da355 --- /dev/null +++ b/src/shared/shell.json @@ -0,0 +1,21 @@ +{ + "component": "shell", + "title": "Index", + "link": "/", + "layout": "boxed", + "theme": "dark", + "menu_item": [ + { "link": "index.sql", "title": "Home" }, + { + "title": "Dependencies", + "icon": "brand-stackshare", + "submenu": [ + { + "link": "/sources/index.sql", + "title": "Sources", + "icon": "external-link" + } + ] + } + ] +}