diff --git a/go.work b/go.work new file mode 100644 index 0000000..d6397df --- /dev/null +++ b/go.work @@ -0,0 +1,3 @@ +go 1.22.0 + +use ./server diff --git a/go.work.sum b/go.work.sum new file mode 100644 index 0000000..2c1030c --- /dev/null +++ b/go.work.sum @@ -0,0 +1,18 @@ +github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= +github.com/klauspost/cpuid/v2 v2.2.3/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= +github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= +golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= +lukechampine.com/uint128 v1.3.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= +modernc.org/cc/v3 v3.41.0/go.mod h1:Ni4zjJYJ04CDOhG7dn640WGfwBzfE0ecX8TyMB0Fv0Y= +modernc.org/ccgo/v3 v3.16.15/go.mod h1:yT7B+/E2m43tmMOT51GMoM98/MtHIcQQSleGnddkUNI= +modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM= +modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= +modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0= +modernc.org/tcl v1.15.2/go.mod h1:3+k/ZaEbKrC8ePv8zJWPtBSW0V7Gg9g8rkmhI1Kfs3c= +modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= +modernc.org/z v1.7.3/go.mod h1:Ipv4tsdxZRbQyLq9Q1M6gdbkxYzdlrciF2Hi/lS7nWE= diff --git a/auth/auth.go b/server/auth/auth.go similarity index 100% rename from auth/auth.go rename to server/auth/auth.go diff --git a/auth/login_get.go b/server/auth/login_get.go similarity index 100% rename from auth/login_get.go rename to server/auth/login_get.go diff --git a/auth/login_post.go b/server/auth/login_post.go similarity index 100% rename from auth/login_post.go rename to server/auth/login_post.go diff --git a/auth/logout.go b/server/auth/logout.go similarity index 100% rename from auth/logout.go rename to server/auth/logout.go diff --git a/auth/redirect_with_error.go b/server/auth/redirect_with_error.go similarity index 100% rename from auth/redirect_with_error.go rename to server/auth/redirect_with_error.go diff --git a/auth/register.go b/server/auth/register.go similarity index 100% rename from auth/register.go rename to server/auth/register.go diff --git a/context/context.go b/server/context/context.go similarity index 100% rename from context/context.go rename to server/context/context.go diff --git a/context/foreign_wishlist.go b/server/context/foreign_wishlist.go similarity index 100% rename from context/foreign_wishlist.go rename to server/context/foreign_wishlist.go diff --git a/context/group_page.go b/server/context/group_page.go similarity index 100% rename from context/group_page.go rename to server/context/group_page.go diff --git a/context/home.go b/server/context/home.go similarity index 100% rename from context/home.go rename to server/context/home.go diff --git a/context/todo_update.go b/server/context/todo_update.go similarity index 100% rename from context/todo_update.go rename to server/context/todo_update.go diff --git a/db/db.go b/server/db/db.go similarity index 100% rename from db/db.go rename to server/db/db.go diff --git a/db/gen_init_sql.go b/server/db/gen_init_sql.go similarity index 100% rename from db/gen_init_sql.go rename to server/db/gen_init_sql.go diff --git a/db/group.go b/server/db/group.go similarity index 100% rename from db/group.go rename to server/db/group.go diff --git a/db/init.sql b/server/db/init.sql similarity index 100% rename from db/init.sql rename to server/db/init.sql diff --git a/server/db/init_sql.go b/server/db/init_sql.go new file mode 100644 index 0000000..7c4e1f5 --- /dev/null +++ b/server/db/init_sql.go @@ -0,0 +1,39 @@ +// Code generated DO NOT EDIT. +package db + +const InitQuery = `BEGIN TRANSACTION; +CREATE TABLE IF NOT EXISTS "user" ( + "id" INTEGER NOT NULL UNIQUE, + "name" TEXT NOT NULL UNIQUE, + "reference" TEXT NOT NULL UNIQUE, + "motto" TEXT NOT NULL, + "password_hash" TEXT NOT NULL, + PRIMARY KEY("id" AUTOINCREMENT) +); +CREATE TABLE IF NOT EXISTS "gift" ( + "id" INTEGER NOT NULL UNIQUE, + "name" TEXT NOT NULL, + "recipient_id" INTEGER NOT NULL, + "claimant_id" INTEGER, + "creator_id" INTEGER NOT NULL, + "sent" INTEGER NOT NULL DEFAULT 0, + PRIMARY KEY("id" AUTOINCREMENT), + FOREIGN KEY("recipient_id") REFERENCES "user"("id"), + FOREIGN KEY("creator_id") REFERENCES "user"("id"), + FOREIGN KEY("claimant_id") REFERENCES "user"("id") +); +CREATE TABLE IF NOT EXISTS "group" ( + "id" INTEGER NOT NULL UNIQUE, + "name" TEXT NOT NULL UNIQUE, + "reference" TEXT NOT NULL UNIQUE, + PRIMARY KEY("id" AUTOINCREMENT) +); +CREATE TABLE IF NOT EXISTS "group_member" ( + "group_id" INTEGER NOT NULL, + "user_id" INTEGER NOT NULL, + UNIQUE("user_id","group_id"), + FOREIGN KEY("group_id") REFERENCES "group"("id"), + FOREIGN KEY("user_id") REFERENCES "user"("id") +); +COMMIT; +` diff --git a/db/user.go b/server/db/user.go similarity index 100% rename from db/user.go rename to server/db/user.go diff --git a/env/env.go b/server/env/env.go similarity index 100% rename from env/env.go rename to server/env/env.go diff --git a/error/page.go b/server/error/page.go similarity index 100% rename from error/page.go rename to server/error/page.go diff --git a/go.mod b/server/go.mod similarity index 100% rename from go.mod rename to server/go.mod diff --git a/go.sum b/server/go.sum similarity index 100% rename from go.sum rename to server/go.sum diff --git a/hashpword/main.go b/server/hashpword/main.go similarity index 100% rename from hashpword/main.go rename to server/hashpword/main.go diff --git a/main.go b/server/main.go similarity index 100% rename from main.go rename to server/main.go diff --git a/session/session.go b/server/session/session.go similarity index 100% rename from session/session.go rename to server/session/session.go diff --git a/templates/base.gotmpl b/server/templates/base.gotmpl similarity index 100% rename from templates/base.gotmpl rename to server/templates/base.gotmpl diff --git a/templates/error_page.gotmpl b/server/templates/error_page.gotmpl similarity index 100% rename from templates/error_page.gotmpl rename to server/templates/error_page.gotmpl diff --git a/templates/foreign_wishlist.gotmpl b/server/templates/foreign_wishlist.gotmpl similarity index 100% rename from templates/foreign_wishlist.gotmpl rename to server/templates/foreign_wishlist.gotmpl diff --git a/templates/group_page.gotmpl b/server/templates/group_page.gotmpl similarity index 100% rename from templates/group_page.gotmpl rename to server/templates/group_page.gotmpl diff --git a/templates/home.gotmpl b/server/templates/home.gotmpl similarity index 100% rename from templates/home.gotmpl rename to server/templates/home.gotmpl diff --git a/templates/login.gotmpl b/server/templates/login.gotmpl similarity index 100% rename from templates/login.gotmpl rename to server/templates/login.gotmpl diff --git a/templates/public_foreign_wishlist.gotmpl b/server/templates/public_foreign_wishlist.gotmpl similarity index 100% rename from templates/public_foreign_wishlist.gotmpl rename to server/templates/public_foreign_wishlist.gotmpl diff --git a/templates/public_group_page.gotmpl b/server/templates/public_group_page.gotmpl similarity index 100% rename from templates/public_group_page.gotmpl rename to server/templates/public_group_page.gotmpl diff --git a/templates/register.gotmpl b/server/templates/register.gotmpl similarity index 100% rename from templates/register.gotmpl rename to server/templates/register.gotmpl diff --git a/templates/templates.go b/server/templates/templates.go similarity index 100% rename from templates/templates.go rename to server/templates/templates.go