From 8d92bdf7da95e1085485c0e60b9dac19c246e235 Mon Sep 17 00:00:00 2001 From: Alexander Kavon Date: Tue, 23 Jan 2024 06:33:20 -0500 Subject: move ui templates into src, update conf to handle other paths, export User Insert Hooks --- src/conf/conf.go | 14 ++++++++------ src/db/db.go | 1 - src/ui/pages/post/create.tmpl.html | 20 ++++++++++++++++++++ src/ui/pages/post/get.tmpl.html | 26 ++++++++++++++++++++++++++ src/ui/pages/user/create.tmpl.html | 16 ++++++++++++++++ src/ui/pages/user/login.tmpl.html | 16 ++++++++++++++++ src/ui/pages/user/me.tmpl.html | 5 +++++ src/ui/templates/base.tmpl.html | 14 ++++++++++++++ src/ui/templates/comments.tmpl.html | 16 ++++++++++++++++ src/ui/templates/messages.tmpl.html | 9 +++++++++ src/user/hooks.go | 2 +- src/user/routes.go | 5 ++++- ui/pages/post/create.tmpl.html | 20 -------------------- ui/pages/post/get.tmpl.html | 26 -------------------------- ui/pages/user/create.tmpl.html | 16 ---------------- ui/pages/user/login.tmpl.html | 16 ---------------- ui/pages/user/me.tmpl.html | 5 ----- ui/templates/base.tmpl.html | 14 -------------- ui/templates/comments.tmpl.html | 16 ---------------- ui/templates/messages.tmpl.html | 9 --------- 20 files changed, 135 insertions(+), 131 deletions(-) create mode 100644 src/ui/pages/post/create.tmpl.html create mode 100644 src/ui/pages/post/get.tmpl.html create mode 100644 src/ui/pages/user/create.tmpl.html create mode 100644 src/ui/pages/user/login.tmpl.html create mode 100644 src/ui/pages/user/me.tmpl.html create mode 100644 src/ui/templates/base.tmpl.html create mode 100644 src/ui/templates/comments.tmpl.html create mode 100644 src/ui/templates/messages.tmpl.html delete mode 100644 ui/pages/post/create.tmpl.html delete mode 100644 ui/pages/post/get.tmpl.html delete mode 100644 ui/pages/user/create.tmpl.html delete mode 100644 ui/pages/user/login.tmpl.html delete mode 100644 ui/pages/user/me.tmpl.html delete mode 100644 ui/templates/base.tmpl.html delete mode 100644 ui/templates/comments.tmpl.html delete mode 100644 ui/templates/messages.tmpl.html diff --git a/src/conf/conf.go b/src/conf/conf.go index 62ffb57..a0852dc 100644 --- a/src/conf/conf.go +++ b/src/conf/conf.go @@ -4,6 +4,7 @@ import ( "fmt" "log" "os" + "path/filepath" "github.com/BurntSushi/toml" ) @@ -39,15 +40,16 @@ func NewConf() *Conf { if err != nil { log.Fatal(err) } - filepath := os.Getenv("NEWSSTAND_CONFIG_PATH") - if filepath == "" { - filepath = cwd + "/.newsstandrc.toml" + configpath := os.Getenv("NEWSSTAND_CONFIG_PATH") + if configpath == "" { + configpath = "./.newsstandrc.toml" } - log.Printf("Config file path: %s", filepath) + confpath := filepath.Clean(filepath.Join(cwd, configpath)) + log.Printf("Config file path: %s", confpath) c := Conf{ cwd, - filepath, + confpath, Db{ Hostname: "localhost", }, @@ -55,7 +57,7 @@ func NewConf() *Conf { UiPath: cwd + "/ui", }, } - _, err = toml.DecodeFile(filepath, &c) + _, err = toml.DecodeFile(confpath, &c) if err != nil { log.Fatalln(err) } diff --git a/src/db/db.go b/src/db/db.go index 198b2be..1a5b9ab 100644 --- a/src/db/db.go +++ b/src/db/db.go @@ -28,7 +28,6 @@ func NewDb(config *conf.Conf) *Db { } log.Println("Database connection pool created.", testquery) return &Db{pool} - } func (d *Db) Conn() *pgxpool.Pool { diff --git a/src/ui/pages/post/create.tmpl.html b/src/ui/pages/post/create.tmpl.html new file mode 100644 index 0000000..385ed22 --- /dev/null +++ b/src/ui/pages/post/create.tmpl.html @@ -0,0 +1,20 @@ +{{define "title"}}Create Post{{end}} + +{{define "main"}} +

Whatcha Got?

+
+ + +