diff --git a/db.go b/db.go deleted file mode 100644 index 1e3d21a..0000000 --- a/db.go +++ /dev/null @@ -1,35 +0,0 @@ -package main - -import ( - // External - "github.com/jmoiron/sqlx" - _ "github.com/lib/pq" - - // Standard - "fmt" -) - -var ( - dbConn string - db *sqlx.DB -) - -func dbInit() (err error) { // {{{ - dbConn = fmt.Sprintf( - "host=%s port=%d user=%s password=%s dbname=%s sslmode=disable", - config.Database.Host, - config.Database.Port, - config.Database.Username, - config.Database.Password, - config.Database.Name, - ) - - logger.Info("db", "op", "connect", "host", config.Database.Host, "port", config.Database.Port) - - if db, err = sqlx.Connect("postgres", dbConn); err != nil { - return - } - return -} // }}} - -// vim: foldmethod=marker diff --git a/main.go b/main.go index 7d4e1e3..d2c95d1 100644 --- a/main.go +++ b/main.go @@ -172,6 +172,7 @@ func userPassword(w http.ResponseWriter, r *http.Request) { // {{{ */ func nodeTree(w http.ResponseWriter, r *http.Request, sess *session.T) { // {{{ + logger.Info("webserver", "request", "/node/tree") var err error req := struct{ StartNodeID int }{} @@ -192,8 +193,8 @@ func nodeTree(w http.ResponseWriter, r *http.Request, sess *session.T) { // {{{ }) } // }}} func nodeRetrieve(w http.ResponseWriter, r *http.Request, sess *session.T) { // {{{ - var err error logger.Info("webserver", "request", "/node/retrieve") + var err error req := struct{ ID int }{} if err = parseRequest(r, &req); err != nil { diff --git a/node.go b/node.go index 2ebf876..aacdc82 100644 --- a/node.go +++ b/node.go @@ -79,6 +79,9 @@ func NodeTree(userID, startNodeID int) (nodes []Node, err error) {// {{{ for rows.Next() { node := Node{} node.Complete = false + node.Crumbs = []Node{} + node.Children = []Node{} + node.Files = []File{} if err = rows.StructScan(&node); err != nil { return } @@ -385,7 +388,7 @@ func SearchNodes(userID int, search string) (nodes []Node, err error) {// {{{ updated FROM node WHERE - user_id = $1 + user_id = $1 AND crypto_key_id IS NULL AND ( content ~* $2 OR diff --git a/static/js/app.mjs b/static/js/app.mjs index 740f475..0176d1a 100644 --- a/static/js/app.mjs +++ b/static/js/app.mjs @@ -25,7 +25,7 @@ class App extends Component { this.startNode = null - //this.setStartNode() + this.setStartNode() }//}}} render() {//{{{ let app_el = document.getElementById('app') diff --git a/static/js/session.mjs b/static/js/session.mjs index a5dcc06..65a90c4 100644 --- a/static/js/session.mjs +++ b/static/js/session.mjs @@ -1,10 +1,10 @@ export class Session { - constructor(app) { + constructor(app) {//{{{ this.app = app this.UUID = '' this.initialized = false this.UserID = 0 - } + }//}}} initialize() {//{{{ // Retrieving the stored session UUID, if any. @@ -29,7 +29,7 @@ export class Session { if (res.Error === undefined) { // Session exists on server. // Not necessarily authenticated. - this.UserID = res.UserID // could be 0 + this.UserID = res.Session.UserID // could be 0 this.initialized = true this.app.forceUpdate() } else { @@ -58,7 +58,7 @@ export class Session { }) .then(res => { if (res.Authenticated) { - this.UserID = res.Session.UserID + this.UserID = res.UserID this.app.forceUpdate() } else { this.app.login.current.authentication_failed.value = true