diff --git a/README.md b/README.md index 2d62f1c0..9ed8982c 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,11 @@ A super fast forum software written in Go. The initial code-base was forked from one of my side projects, and converted from the web framework it was using. +# Features +Basic Forum Functionality + +Custom Pages + # Dependencies @@ -23,6 +28,8 @@ go install golang.org/x/crypto/bcrypt Tweak the config.go file and put your database details in there. +Set the password column of your user account in the database to what you want your password to be. The system will encrypt your password when you login for the first time. + # Run the program @@ -38,8 +45,6 @@ Oh my, you caught me right at the start of this project. There's nothing to see More moderation features. -Fix the login system. It broke during the switch in frameworks. - Fix the bug where errors are sent off in raw HTML rather than formatted HTML. Add an alert system. @@ -51,3 +56,7 @@ Add a complex permissions system. Add a settings system. Add a plugin system. + +Revamp the system for serving static files to make it much faster. + +Tweak the CSS to make it responsive. diff --git a/src/config.go b/src/config.go index e9c0d2b7..f26a4cde 100644 --- a/src/config.go +++ b/src/config.go @@ -1,6 +1,8 @@ package main // Database details +var dbhost = "127.0.0.1" var dbuser = "root" var dbpassword = "password" var dbname = "grosolo" +var dbport = "3306" // You probably won't need to change this diff --git a/src/main.go b/src/main.go index d3bb8eb3..f605ad71 100644 --- a/src/main.go +++ b/src/main.go @@ -35,7 +35,7 @@ func init_database(err error) { if(dbpassword != ""){ dbpassword = ":" + dbpassword } - db, err = sql.Open("mysql",dbuser + dbpassword + "@tcp(127.0.0.1:3306)/" + dbname) + db, err = sql.Open("mysql",dbuser + dbpassword + "@tcp(" + dbhost + ":" + dbport + ")/" + dbname) if err != nil { log.Fatal(err) } @@ -51,7 +51,6 @@ func init_database(err error) { if err != nil { log.Fatal(err) } - _ = get_session_stmt // Bug fix, compiler isn't recognising this despite it being used, probably because it's hidden behind if statements log.Print("Preparing create_topic statement.") create_topic_stmt, err = db.Prepare("INSERT INTO topics(title,createdAt,lastReplyAt,createdBy) VALUES(?,?,0,?)") @@ -150,7 +149,7 @@ func main(){ http.HandleFunc("/topic/edit/submit/", route_edit_topic) //POST // Custom Pages - http.HandleFunc("/pages/:name/", route_custom_page) + http.HandleFunc("/pages/", route_custom_page) // Accounts http.HandleFunc("/accounts/login/", route_login) diff --git a/src/pages/test.html b/src/pages/test.html index 6c70bcfe..0a901256 100644 --- a/src/pages/test.html +++ b/src/pages/test.html @@ -1 +1 @@ - \ No newline at end of file +Testing \ No newline at end of file diff --git a/src/routes.go b/src/routes.go index 5618c346..a9aceb64 100644 --- a/src/routes.go +++ b/src/routes.go @@ -27,7 +27,7 @@ func route_overview(w http.ResponseWriter, r *http.Request){ func route_custom_page(w http.ResponseWriter, r *http.Request){ user := SessionCheck(w,r) - name := r.URL.Path[len("/edit/"):] + name := r.URL.Path[len("/pages/"):] val, ok := custom_pages[name]; if ok { @@ -594,16 +594,17 @@ func route_login_submit(w http.ResponseWriter, r *http.Request) { return } - _, err = update_session_stmt.Exec(session, user.ID) + _, err = update_session_stmt.Exec(session, uid) if err != nil { InternalError(err,w,r,user) return } log.Print("Successful Login") - cookie := http.Cookie{"uid",strconv.Itoa(uid),"/","",time.Now(),"",0,true,false,"",[]string{}} + log.Print("Session: " + session) + cookie := http.Cookie{Name: "uid",Value: strconv.Itoa(uid),Path: "/",MaxAge: year} http.SetCookie(w,&cookie) - cookie = http.Cookie{"session",session,"/","",time.Now(),"",0,true,false,"",[]string{}} + cookie = http.Cookie{Name: "session",Value: session,Path: "/",MaxAge: year} http.SetCookie(w,&cookie) http.Redirect(w,r, "/", http.StatusSeeOther) } @@ -697,9 +698,9 @@ func route_register_submit(w http.ResponseWriter, r *http.Request) { return } - cookie := http.Cookie{"uid",strconv.FormatInt(lastId, 10),"/","",time.Now(),"",0,true,false,"",[]string{}} + cookie := http.Cookie{Name: "uid",Value: strconv.FormatInt(lastId, 10),Path: "/",MaxAge: year} http.SetCookie(w,&cookie) - cookie = http.Cookie{"session",session,"/","",time.Now(),"",0,true,false,"",[]string{}} + cookie = http.Cookie{Name: "session",Value: session,Path: "/",MaxAge: year} http.SetCookie(w,&cookie) http.Redirect(w,r, "/", http.StatusSeeOther) }