aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Kavon <me+git@alexkavon.com>2024-01-23 06:33:20 -0500
committerAlexander Kavon <me+git@alexkavon.com>2024-01-23 06:33:20 -0500
commit8d92bdf7da95e1085485c0e60b9dac19c246e235 (patch)
tree5c346f8bdb10b3b8084a3b9e95c727f7fa3914be
parent8510c36ded85740885e67b59ee2ec2360986c0a9 (diff)
move ui templates into src, update conf to handle other paths, export User Insert Hooks
-rw-r--r--src/conf/conf.go14
-rw-r--r--src/db/db.go1
-rw-r--r--src/ui/pages/post/create.tmpl.html (renamed from ui/pages/post/create.tmpl.html)0
-rw-r--r--src/ui/pages/post/get.tmpl.html (renamed from ui/pages/post/get.tmpl.html)0
-rw-r--r--src/ui/pages/user/create.tmpl.html (renamed from ui/pages/user/create.tmpl.html)0
-rw-r--r--src/ui/pages/user/login.tmpl.html (renamed from ui/pages/user/login.tmpl.html)0
-rw-r--r--src/ui/pages/user/me.tmpl.html (renamed from ui/pages/user/me.tmpl.html)0
-rw-r--r--src/ui/templates/base.tmpl.html (renamed from ui/templates/base.tmpl.html)0
-rw-r--r--src/ui/templates/comments.tmpl.html (renamed from ui/templates/comments.tmpl.html)0
-rw-r--r--src/ui/templates/messages.tmpl.html (renamed from ui/templates/messages.tmpl.html)0
-rw-r--r--src/user/hooks.go2
-rw-r--r--src/user/routes.go5
12 files changed, 13 insertions, 9 deletions
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/ui/pages/post/create.tmpl.html b/src/ui/pages/post/create.tmpl.html
index 385ed22..385ed22 100644
--- a/ui/pages/post/create.tmpl.html
+++ b/src/ui/pages/post/create.tmpl.html
diff --git a/ui/pages/post/get.tmpl.html b/src/ui/pages/post/get.tmpl.html
index b32bd1c..b32bd1c 100644
--- a/ui/pages/post/get.tmpl.html
+++ b/src/ui/pages/post/get.tmpl.html
diff --git a/ui/pages/user/create.tmpl.html b/src/ui/pages/user/create.tmpl.html
index 135b7bc..135b7bc 100644
--- a/ui/pages/user/create.tmpl.html
+++ b/src/ui/pages/user/create.tmpl.html
diff --git a/ui/pages/user/login.tmpl.html b/src/ui/pages/user/login.tmpl.html
index e091322..e091322 100644
--- a/ui/pages/user/login.tmpl.html
+++ b/src/ui/pages/user/login.tmpl.html
diff --git a/ui/pages/user/me.tmpl.html b/src/ui/pages/user/me.tmpl.html
index be66beb..be66beb 100644
--- a/ui/pages/user/me.tmpl.html
+++ b/src/ui/pages/user/me.tmpl.html
diff --git a/ui/templates/base.tmpl.html b/src/ui/templates/base.tmpl.html
index a080925..a080925 100644
--- a/ui/templates/base.tmpl.html
+++ b/src/ui/templates/base.tmpl.html
diff --git a/ui/templates/comments.tmpl.html b/src/ui/templates/comments.tmpl.html
index b069bbd..b069bbd 100644
--- a/ui/templates/comments.tmpl.html
+++ b/src/ui/templates/comments.tmpl.html
diff --git a/ui/templates/messages.tmpl.html b/src/ui/templates/messages.tmpl.html
index dd5bfb1..dd5bfb1 100644
--- a/ui/templates/messages.tmpl.html
+++ b/src/ui/templates/messages.tmpl.html
diff --git a/src/user/hooks.go b/src/user/hooks.go
index 61e24bc..c7b7632 100644
--- a/src/user/hooks.go
+++ b/src/user/hooks.go
@@ -8,7 +8,7 @@ import (
"gitlab.com/alexkavon/newsstand/src/models"
)
-func init() {
+func InitHooks() {
models.AddUserHook(boil.BeforeInsertHook, validateNew)
// should always be last
models.AddUserHook(boil.BeforeInsertHook, hashSecretBeforeInsert)
diff --git a/src/user/routes.go b/src/user/routes.go
index 862545a..eaf4582 100644
--- a/src/user/routes.go
+++ b/src/user/routes.go
@@ -10,6 +10,10 @@ import (
"gitlab.com/alexkavon/newsstand/src/sessions"
)
+func init() {
+ InitHooks()
+}
+
var Routes = server.Routes{
server.Route{
Name: "Create",
@@ -73,7 +77,6 @@ func Store(s *server.Server) http.HandlerFunc {
if err != nil {
log.Fatal("Insert Error", err)
}
- // Send email validation
// Create cookie session
sessions.NewSession(w, sessions.SessionValues{"uid": user.ID, "username": user.Username})
// Redirect to user profile